* register operators like other classes
authorCampbell Barton <ideasman42@gmail.com>
Thu, 24 Dec 2009 19:50:43 +0000 (19:50 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 24 Dec 2009 19:50:43 +0000 (19:50 +0000)
* operators now return sets (converted into flags)
* can't remove bpy_operator_wrap.c since macro's still use the custom register funcs

41 files changed:
release/scripts/io/export_3ds.py
release/scripts/io/export_fbx.py
release/scripts/io/export_mdd.py
release/scripts/io/export_obj.py
release/scripts/io/export_ply.py
release/scripts/io/export_x3d.py
release/scripts/io/import_anim_bvh.py
release/scripts/io/import_scene_3ds.py
release/scripts/io/import_scene_obj.py
release/scripts/io/netrender/operators.py
release/scripts/io/netrender/utils.py
release/scripts/modules/bpy/ops.py
release/scripts/modules/rna_info.py
release/scripts/modules/rna_prop_ui.py
release/scripts/op/add_armature_human.py
release/scripts/op/add_mesh_torus.py
release/scripts/op/console_python.py
release/scripts/op/console_shell.py
release/scripts/op/mesh.py
release/scripts/op/mesh_skin.py
release/scripts/op/object.py
release/scripts/op/presets.py
release/scripts/op/screen_play_rendered_anim.py
release/scripts/op/uvcalc_follow_active.py
release/scripts/op/uvcalc_smart_project.py
release/scripts/op/vertexpaint_dirt.py
release/scripts/op/wm.py
release/scripts/templates/operator.py
release/scripts/templates/operator_simple.py
release/scripts/ui/properties_data_armature_rigify.py
release/scripts/ui/space_console.py
release/scripts/ui/space_info.py
release/scripts/ui/space_userpref.py
source/blender/editors/animation/keyframes_edit.c
source/blender/editors/include/ED_keyframes_edit.h
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/makesrna/intern/rna_wm.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_operator_wrap.c
source/blender/python/intern/bpy_rna.c
source/blender/windowmanager/intern/wm_operators.c

index edbb80b0272bb4e2f7e68816e2037dfe8ed8751a..a60aeeb3cb2092cb79061c48465e2190cf930c61 100644 (file)
@@ -1126,7 +1126,7 @@ class Export3DS(bpy.types.Operator):
 
     def execute(self, context):
         save_3ds(self.properties.path, context)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -1136,7 +1136,7 @@ class Export3DS(bpy.types.Operator):
     def poll(self, context): # Poll isnt working yet
         return context.active_object != None
 
-bpy.ops.add(Export3DS)
+bpy.types.register(Export3DS)
 
 # Add to a menu
 import dynamic_menu
index ba2741a7e7e4efd563910cb0e8361b1ce009aeda..401f645536f610b31ff23bea0eb0b3ad72bb9479 100644 (file)
@@ -3426,7 +3426,7 @@ class ExportFBX(bpy.types.Operator):
               self.properties.BATCH_FILE_PREFIX,
               self.properties.BATCH_OWN_DIR)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -3434,7 +3434,7 @@ class ExportFBX(bpy.types.Operator):
         return ('RUNNING_MODAL',)
 
 
-bpy.ops.add(ExportFBX)
+bpy.types.register(ExportFBX)
 
 # if __name__ == "__main__":
 #      bpy.ops.EXPORT_OT_ply(filename="/tmp/test.ply")
index cfd73b1979ed0b4fd748b294048318b24dadc0c2..22e76ae242767813fa895d3d46b4b71beed8cc1f 100644 (file)
@@ -173,14 +173,14 @@ class ExportMDD(bpy.types.Operator):
             raise Exception("filename not set")
         write(self.properties.path, context.scene, context.active_object,
             self.properties.start_frame, self.properties.end_frame, self.properties.fps)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
         wm.add_fileselect(self)
         return ('RUNNING_MODAL',)
 
-bpy.ops.add(ExportMDD)
+bpy.types.register(ExportMDD)
 
 # Add to a menu
 import dynamic_menu
index d6026d10ba9c02f95bb1d18ba8f4b13142dc5046..9d9b0e88732cb624ff1ed1449a537e7d96cb53c7 100644 (file)
@@ -980,7 +980,7 @@ class ExportOBJ(bpy.types.Operator):
                   EXPORT_SEL_ONLY=self.properties.use_selection,
                   EXPORT_ALL_SCENES=self.properties.use_all_scenes)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -991,7 +991,7 @@ class ExportOBJ(bpy.types.Operator):
 
 
 
-bpy.ops.add(ExportOBJ)
+bpy.types.register(ExportOBJ)
 
 import dynamic_menu
 
index 858e22952b808dc875ba5827ab2046740dec86b5..301fb4c5fe8a4d4cb79534e31241555d61308250 100644 (file)
@@ -297,7 +297,7 @@ class ExportPLY(bpy.types.Operator):
             EXPORT_COLORS=self.properties.use_colors,
         )
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -316,7 +316,7 @@ class ExportPLY(bpy.types.Operator):
         row.prop(props, "use_colors")
 
 
-bpy.ops.add(ExportPLY)
+bpy.types.register(ExportPLY)
 
 import dynamic_menu
 
index 6cfe0f4562623a41851d96e4012e1ecfce238650..95ddb21b21dae22621af864898c8616fb9654dfb 100644 (file)
@@ -1233,14 +1233,14 @@ class ExportX3D(bpy.types.Operator):
 
     def execute(self, context):
         x3d_export(self.properties.path, context, self.properties.apply_modifiers, self.properties.triangulate, self.properties.compress)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
         wm.add_fileselect(self)
         return ('RUNNING_MODAL',)
 
-bpy.ops.add(ExportX3D)
+bpy.types.register(ExportX3D)
 
 import dynamic_menu
 
index 30ff99c1fe88400dc7b9f5c871036f41a3221fc4..0ea8dbe5356257b9c3c8047e853437b759b183b8 100644 (file)
@@ -887,7 +887,7 @@ class BvhImporter(bpy.types.Operator):
 
         read_bvh(context, self.properties.path)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -895,7 +895,7 @@ class BvhImporter(bpy.types.Operator):
         return ('RUNNING_MODAL',)
 
 
-bpy.ops.add(BvhImporter)
+bpy.types.register(BvhImporter)
 
 
 import dynamic_menu
index 4744c5df01a769093be954b99303d1b16ca46091..d11b242b7646fedf39140f7bf4e6d9bcaaae7596 100644 (file)
@@ -1159,14 +1159,14 @@ class IMPORT_OT_autodesk_3ds(bpy.types.Operator):
 
     def execute(self, context):
         load_3ds(self.properties.path, context, 0.0, False, False)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
         wm.add_fileselect(self)
         return ('RUNNING_MODAL',)
 
-bpy.ops.add(IMPORT_OT_autodesk_3ds)
+bpy.types.register(IMPORT_OT_autodesk_3ds)
 
 import dynamic_menu
 menu_func = lambda self, context: self.layout.operator(IMPORT_OT_autodesk_3ds.bl_idname, text="3D Studio (.3ds)...")
index cbd2b831e55bfce7002ccdbf59f15f8e0376b412..e4a218fce4dd808a80e0f56bc9b4ab92390531fc 100644 (file)
@@ -1616,7 +1616,7 @@ class IMPORT_OT_obj(bpy.types.Operator):
                  self.properties.IMAGE_SEARCH,
                  self.properties.POLYGROUPS)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -1624,7 +1624,7 @@ class IMPORT_OT_obj(bpy.types.Operator):
         return ('RUNNING_MODAL',)
 
 
-bpy.ops.add(IMPORT_OT_obj)
+bpy.types.register(IMPORT_OT_obj)
 
 
 import dynamic_menu
index ec229fbb47164ac597907a73d438b18692ed96b1..7f36087a30ca4dea59045132ec77849f2fe2a219 100644 (file)
@@ -79,7 +79,7 @@ class RENDER_OT_netslave_bake(bpy.types.Operator):
                
                #bpy.ops.wm.save_mainfile(path = path + os.sep + root + "_baked.blend")
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -106,7 +106,7 @@ class RENDER_OT_netclientanim(bpy.types.Operator):
                
                bpy.ops.screen.render('INVOKE_AREA', animation=True)
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -136,7 +136,7 @@ class RENDER_OT_netclientsend(bpy.types.Operator):
                        self.report('ERROR', str(err))
                
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -176,7 +176,7 @@ class RENDER_OT_netclientstatus(bpy.types.Operator):
                                
                                job.name = j.name
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -206,7 +206,7 @@ class RENDER_OT_netclientblacklistslave(bpy.types.Operator):
                        netsettings.slaves.remove(netsettings.active_slave_index)
                        netsettings.active_slave_index = -1
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -236,7 +236,7 @@ class RENDER_OT_netclientwhitelistslave(bpy.types.Operator):
                        netsettings.slaves_blacklist.remove(netsettings.active_blacklisted_slave_index)
                        netsettings.active_blacklisted_slave_index = -1
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -282,7 +282,7 @@ class RENDER_OT_netclientslaves(bpy.types.Operator):
                                        slave = netsettings.slaves[-1]
                                        slave.name = s.name
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -311,7 +311,7 @@ class RENDER_OT_netclientcancel(bpy.types.Operator):
 
                        netsettings.jobs.remove(netsettings.active_job_index)
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -338,7 +338,7 @@ class RENDER_OT_netclientcancelall(bpy.types.Operator):
                        while(len(netsettings.jobs) > 0):
                                netsettings.jobs.remove(0)
 
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -383,7 +383,7 @@ class netclientdownload(bpy.types.Operator):
                        
                        conn.close()
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
@@ -406,7 +406,7 @@ class netclientscan(bpy.types.Operator):
                        netsettings.server_address = address
                        netsettings.server_port = port
                
-               return ('FINISHED',)
+               return {'FINISHED'}
 
        def invoke(self, context, event):
                return self.execute(context)
@@ -432,7 +432,7 @@ class netclientweb(bpy.types.Operator):
                        
                        webbrowser.open("http://%s:%i" % (netsettings.server_address, netsettings.server_port))
                
-               return ('FINISHED',)
+               return {'FINISHED'}
        
        def invoke(self, context, event):
                return self.execute(context)
index 3da15a33b65320c1a082be7c6b66be985bcb3698..2d22dfb7320d4ae38e804295399cbb8513831474 100644 (file)
@@ -62,7 +62,7 @@ def rnaType(rna_type):
        return rna_type
 
 def rnaOperator(rna_op):
-       if bpy: bpy.ops.add(rna_op)
+       if bpy: bpy.types.register(rna_op)
        return rna_op
 
 def reporting(report, message, errorType = None):
index 93c0d719580617b1df091c10713391b77c1b02d6..268189b2db49b1bd80bccd83a5ca3ee997235d9c 100644 (file)
@@ -21,7 +21,7 @@
 # for slightly faster access
 from _bpy import ops as ops_module
 
-op_add = ops_module.add
+op_add = ops_module.add
 op_remove = ops_module.remove
 op_add_macro = ops_module.add_macro
 op_dir = ops_module.dir
index 1de750a4ff21b4ddbd0cdb906110941f5e3b01b0..84171335c64bd002a3a360c0c25e77101b49e7bd 100644 (file)
@@ -121,12 +121,18 @@ class InfoFunctionRNA:
         # self.name = rna_func.name # functions have no name!
         self.description = rna_func.description.strip()
 
-        self.args = [] # todo
-        self.return_value = None # todo
+        self.args = []
+        self.return_value = None
 
     def build(self):
         rna_prop = self.bl_prop
-        pass
+        
+        for rna_id, rna_prop in rna_type.parameters.items():
+            prop = GetInfoPropertyRNA(rna_prop, parent_id)
+            if rna_prop.use_return:
+                self.return_value = prop
+            else:
+                self.args.append(prop)
 
     def __repr__(self):
         txt = ''
index 0aa62bb596048d2bd5497c5138500846e590c199..aac6431768dbda45299c1c4835edb7936e081379 100644 (file)
@@ -196,7 +196,7 @@ class WM_OT_properties_edit(bpy.types.Operator):
 
         prop_ui['description'] = self.properties.description
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
 
@@ -242,7 +242,7 @@ class WM_OT_properties_add(bpy.types.Operator):
         property = unique_name(item.keys())
 
         item[property] = 1.0
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_properties_remove(bpy.types.Operator):
@@ -256,4 +256,4 @@ class WM_OT_properties_remove(bpy.types.Operator):
     def execute(self, context):
         item = eval("context.%s" % self.properties.path)
         del item[self.properties.property]
-        return ('FINISHED',)
+        return {'FINISHED'}
index 264f290f271c5a340cebe5aed2b78fa2f381e366..8696312eae04d2a73520481c9031085b29fd4b8d 100644 (file)
@@ -607,10 +607,10 @@ class AddHuman(bpy.types.Operator):
         bones.remove(bones[0])
         metarig_template()
         bpy.ops.object.mode_set(mode=mode_orig)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 # Register the operator
-bpy.ops.add(AddHuman)
+bpy.types.register(AddHuman)
 
 # Add to a menu
 import dynamic_menu
index 7e3b28b628e2c97628d80fac32729732e94c38b3..685f1cae8a4be177aa2ca14194782e99aae83b7d 100644 (file)
@@ -122,10 +122,10 @@ class AddTorus(bpy.types.Operator):
 
         ob_new.location = tuple(context.scene.cursor_location)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 # Register the operator
-bpy.ops.add(AddTorus)
+bpy.types.register(AddTorus)
 
 # Add to a menu
 import dynamic_menu
index 7f1d35ede209949ec5eadf1c3efe6f7f643836b0..383eb3c12d3838c106dc90deb54ca2535dd66b59 100644 (file)
@@ -79,10 +79,10 @@ def execute(context):
     try:
         line = sc.history[-1].line
     except:
-        return ('CANCELLED',)
+        return {'CANCELLED'}
 
     if sc.console_type != 'PYTHON':
-        return ('CANCELLED',)
+        return {'CANCELLED'}
 
     console, stdout, stderr = get_console(hash(context.region))
 
@@ -136,7 +136,7 @@ def execute(context):
     if output_err:
         add_scrollback(output_err, 'ERROR')
 
-    return ('FINISHED',)
+    return {'FINISHED'}
 
 
 def autocomplete(context):
@@ -150,10 +150,10 @@ def autocomplete(context):
     line = current_line.line
 
     if not console:
-        return ('CANCELLED',)
+        return {'CANCELLED'}
 
     if sc.console_type != 'PYTHON':
-        return ('CANCELLED',)
+        return {'CANCELLED'}
 
     # This function isnt aware of the text editor or being an operator
     # just does the autocomp then copy its results back
@@ -172,7 +172,7 @@ def autocomplete(context):
 
     context.area.tag_redraw()
 
-    return ('FINISHED',)
+    return {'FINISHED'}
 
 
 def banner(context):
@@ -195,4 +195,4 @@ def banner(context):
     console = get_console(hash(context.region))[0]
     console.locals["C"] = bpy.context
 
-    return ('FINISHED',)
+    return {'FINISHED'}
index bdb4a746d95e1bbe73e2c833bb22b8eecc9cde45..4dc211143671225dd255209f53672b930cd61458 100644 (file)
@@ -49,7 +49,7 @@ def execute(context):
     try:
         line = sc.history[-1].line
     except:
-        return ('CANCELLED',)
+        return {'CANCELLED'}
 
     bpy.ops.console.scrollback_append(text=sc.prompt + line, type='INPUT')
 
@@ -60,13 +60,13 @@ def execute(context):
         remove_duplicates=True)
 
     sc.prompt = os.getcwd() + PROMPT
-    return ('FINISHED',)
+    return {'FINISHED'}
 
 
 def autocomplete(context):
     # sc = context.space_data
     # TODO
-    return ('CANCELLED',)
+    return {'CANCELLED'}
 
 
 def banner(context):
@@ -75,4 +75,4 @@ def banner(context):
     shell_run("bash --version")
     sc.prompt = os.getcwd() + PROMPT
 
-    return ('FINISHED',)
+    return {'FINISHED'}
index 1de06963c7a2b5a4ff30e6cc5b1aabc69a14f50e..a8f50f281783c99df1a009d0b0ad0e43a40ddcff 100644 (file)
@@ -65,11 +65,11 @@ class MeshSelectInteriorFaces(bpy.types.Operator):
 
     def execute(self, context):
         main(context)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 # Register the operator
-bpy.ops.add(MeshSelectInteriorFaces)
+bpy.types.register(MeshSelectInteriorFaces)
 
 if __name__ == "__main__":
     bpy.ops.mesh.faces_select_interior()
index a78da39c5d43e997fb26a4794acc4309de15cc27..251cfb32b9354e52bdf519b7c5e62f900c3b726d 100644 (file)
@@ -643,11 +643,11 @@ class MESH_OT_skin(bpy.types.Operator):
 
     def execute(self, context):
         main(context)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 # Register the operator
-bpy.ops.add(MESH_OT_skin)
+bpy.types.register(MESH_OT_skin)
 
 # Add to a menu
 import dynamic_menu
index 228d8566f77277892f146c8114134b1410191dc9..1b421cac98cffd57b3eebe840d9fc588683732f0 100644 (file)
@@ -57,7 +57,7 @@ class SelectPattern(bpy.types.Operator):
             elif not self.properties.extend:
                 item.selected = False
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -97,7 +97,7 @@ class SubdivisionSet(bpy.types.Operator):
         relative = self.properties.relative
 
         if relative and level == 0:
-            return ('CANCELLED',) # nothing to do
+            return {'CANCELLED'} # nothing to do
 
         def set_object_subd(obj):
             for mod in obj.modifiers:
@@ -132,7 +132,7 @@ class SubdivisionSet(bpy.types.Operator):
         for obj in context.selected_editable_objects:
             set_object_subd(obj)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class Retopo(bpy.types.Operator):
@@ -146,9 +146,9 @@ class Retopo(bpy.types.Operator):
     def execute(self, context):
         import retopo
         retopo.main()
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
-bpy.ops.add(SelectPattern)
-bpy.ops.add(SubdivisionSet)
-bpy.ops.add(Retopo)
+bpy.types.register(SelectPattern)
+bpy.types.register(SubdivisionSet)
+bpy.types.register(Retopo)
index 0f6d5e11b5c02fbdb3a9d1f2e8005a0a8de418b2..af338c9364d7fdd365f841338e7fd9b95763523a 100644 (file)
@@ -40,7 +40,7 @@ class AddPresetBase(bpy.types.Operator):
     def execute(self, context):
 
         if not self.properties.name:
-            return ('FINISHED',)
+            return {'FINISHED'}
 
         filename = self._as_filename(self.properties.name) + ".py"
 
@@ -53,7 +53,7 @@ class AddPresetBase(bpy.types.Operator):
 
         file_preset.close()
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -125,6 +125,6 @@ class AddPresetCloth(AddPresetBase):
 
     preset_subdir = "cloth"
 
-bpy.ops.add(AddPresetRender)
-bpy.ops.add(AddPresetSSS)
-bpy.ops.add(AddPresetCloth)
+bpy.types.register(AddPresetRender)
+bpy.types.register(AddPresetSSS)
+bpy.types.register(AddPresetCloth)
index a1401304c08e40738672977290a43f770fcbccbe..40173879787808ce56441e8cd06d0a8fa733a51c 100644 (file)
@@ -146,4 +146,4 @@ class PlayRenderedAnim(bpy.types.Operator):
 
         return('FINISHED',)
 
-bpy.ops.add(PlayRenderedAnim)
+bpy.types.register(PlayRenderedAnim)
index f2dcaec4728aff8a6ff8ebb2cbc9b71f95e82e7c..8ab5b8ec454377467df51de39fa618d9106c5160 100644 (file)
@@ -257,9 +257,9 @@ class FollowActiveQuads(bpy.types.Operator):
 
     def execute(self, context):
         main(context, self)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
-bpy.ops.add(FollowActiveQuads)
+bpy.types.register(FollowActiveQuads)
 
 # Add to a menu
 import dynamic_menu
index f3c8f7ed7ddbc5fe8520ba992161c042632c29ac..25840e04cf8a5e8fe5b77a6282fa80370e5ff218 100644 (file)
@@ -1130,9 +1130,9 @@ class SmartProject(bpy.types.Operator):
 
     def execute(self, context):
         main(context, self.properties.island_margin, self.properties.angle_limit)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
-bpy.ops.add(SmartProject)
+bpy.types.register(SmartProject)
 
 # Add to a menu
 import dynamic_menu
index a521c24e06cea371e7e7a4f3d50338b362ff818e..f029541dbca90a5f4894d62591d1af5b5428ef53 100644 (file)
@@ -175,7 +175,7 @@ class VertexPaintDirt(bpy.types.Operator):
 
         return('FINISHED',)
 
-bpy.ops.add(VertexPaintDirt)
+bpy.types.register(VertexPaintDirt)
 
 if __name__ == "__main__":
     bpy.ops.mesh.vertex_paint_dirt()
index 45a9e91d2c65ac06bdf5191b6bdca2fc28b79e17..58cc274393232348def50354e46a6cca30788175 100644 (file)
@@ -34,7 +34,7 @@ class MESH_OT_delete_edgeloop(bpy.types.Operator):
         bpy.ops.mesh.select_more()
         bpy.ops.mesh.remove_doubles()
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 rna_path_prop = StringProperty(name="Context Attributes",
         description="rna context string", maxlen=1024, default="")
@@ -60,9 +60,9 @@ def context_path_validate(context, path):
 
 def execute_context_assign(self, context):
     if context_path_validate(context, self.properties.path) is Ellipsis:
-        return ('PASS_THROUGH',)
+        return {'PASS_THROUGH'}
     exec("context.%s=self.properties.value" % self.properties.path)
-    return ('FINISHED',)
+    return {'FINISHED'}
 
 
 class WM_OT_context_set_boolean(bpy.types.Operator):
@@ -143,9 +143,9 @@ class WM_OT_context_set_value(bpy.types.Operator):
 
     def execute(self, context):
         if context_path_validate(context, self.properties.path) is Ellipsis:
-            return ('PASS_THROUGH',)
+            return {'PASS_THROUGH'}
         exec("context.%s=%s" % (self.properties.path, self.properties.value))
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_context_toggle(bpy.types.Operator):
@@ -159,12 +159,12 @@ class WM_OT_context_toggle(bpy.types.Operator):
     def execute(self, context):
 
         if context_path_validate(context, self.properties.path) is Ellipsis:
-            return ('PASS_THROUGH',)
+            return {'PASS_THROUGH'}
 
         exec("context.%s=not (context.%s)" %
             (self.properties.path, self.properties.path))
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_context_toggle_enum(bpy.types.Operator):
@@ -183,14 +183,14 @@ class WM_OT_context_toggle_enum(bpy.types.Operator):
     def execute(self, context):
 
         if context_path_validate(context, self.properties.path) is Ellipsis:
-            return ('PASS_THROUGH',)
+            return {'PASS_THROUGH'}
 
         exec("context.%s = ['%s', '%s'][context.%s!='%s']" % \
             (self.properties.path, self.properties.value_1,\
              self.properties.value_2, self.properties.path,
              self.properties.value_2))
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_context_cycle_int(bpy.types.Operator):
@@ -207,7 +207,7 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
 
         value = context_path_validate(context, self.properties.path)
         if value is Ellipsis:
-            return ('PASS_THROUGH',)
+            return {'PASS_THROUGH'}
 
         self.properties.value = value
         if self.properties.reverse:
@@ -224,7 +224,7 @@ class WM_OT_context_cycle_int(bpy.types.Operator):
                 self.properties.value = - (1 << 32)
             execute_context_assign(self, context)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_context_cycle_enum(bpy.types.Operator):
@@ -240,7 +240,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
 
         value = context_path_validate(context, self.properties.path)
         if value is Ellipsis:
-            return ('PASS_THROUGH',)
+            return {'PASS_THROUGH'}
 
         orig_value = value
 
@@ -276,7 +276,7 @@ class WM_OT_context_cycle_enum(bpy.types.Operator):
 
         # set the new value
         exec("context.%s=advance_enum" % self.properties.path)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 doc_id = StringProperty(name="Doc ID",
         description="", maxlen=1024, default="", hidden=True)
@@ -318,12 +318,12 @@ class WM_OT_doc_view(bpy.types.Operator):
                         (self._prefix, class_name_full, class_prop)
 
         else:
-            return ('PASS_THROUGH',)
+            return {'PASS_THROUGH'}
 
         import webbrowser
         webbrowser.open(url)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_doc_edit(bpy.types.Operator):
@@ -388,7 +388,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
 
         self._send_xmlrpc(upload)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -403,29 +403,29 @@ class WM_OT_reload_scripts(bpy.types.Operator):
     def execute(self, context):
         MOD = type(bpy)
         bpy.load_scripts(True)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
-bpy.ops.add(MESH_OT_delete_edgeloop)
+bpy.types.register(MESH_OT_delete_edgeloop)
 
-bpy.ops.add(WM_OT_context_set_boolean)
-bpy.ops.add(WM_OT_context_set_int)
-bpy.ops.add(WM_OT_context_set_float)
-bpy.ops.add(WM_OT_context_set_string)
-bpy.ops.add(WM_OT_context_set_enum)
-bpy.ops.add(WM_OT_context_set_value)
-bpy.ops.add(WM_OT_context_toggle)
-bpy.ops.add(WM_OT_context_toggle_enum)
-bpy.ops.add(WM_OT_context_cycle_enum)
-bpy.ops.add(WM_OT_context_cycle_int)
+bpy.types.register(WM_OT_context_set_boolean)
+bpy.types.register(WM_OT_context_set_int)
+bpy.types.register(WM_OT_context_set_float)
+bpy.types.register(WM_OT_context_set_string)
+bpy.types.register(WM_OT_context_set_enum)
+bpy.types.register(WM_OT_context_set_value)
+bpy.types.register(WM_OT_context_toggle)
+bpy.types.register(WM_OT_context_toggle_enum)
+bpy.types.register(WM_OT_context_cycle_enum)
+bpy.types.register(WM_OT_context_cycle_int)
 
-bpy.ops.add(WM_OT_doc_view)
-bpy.ops.add(WM_OT_doc_edit)
+bpy.types.register(WM_OT_doc_view)
+bpy.types.register(WM_OT_doc_edit)
 
-bpy.ops.add(WM_OT_reload_scripts)
+bpy.types.register(WM_OT_reload_scripts)
 
 # experemental!
 import rna_prop_ui
-bpy.ops.add(rna_prop_ui.WM_OT_properties_edit)
-bpy.ops.add(rna_prop_ui.WM_OT_properties_add)
-bpy.ops.add(rna_prop_ui.WM_OT_properties_remove)
+bpy.types.register(rna_prop_ui.WM_OT_properties_edit)
+bpy.types.register(rna_prop_ui.WM_OT_properties_add)
+bpy.types.register(rna_prop_ui.WM_OT_properties_remove)
index 72a6ae53f5f398210613649b05c09ba3b764190b..c6fb887b091253714f2a77aa06c20f8c74fe3159 100644 (file)
@@ -30,7 +30,7 @@ class ExportSomeData(bpy.types.Operator):
 
         write_some_data(self.properties.path, context, self.properties.use_setting)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -46,7 +46,7 @@ class ExportSomeData(bpy.types.Operator):
             return self.execute(context)
 
 
-bpy.ops.add(ExportSomeData)
+bpy.types.register(ExportSomeData)
 
 # Only needed if you want to add into a dynamic menu
 import dynamic_menu
index 030ed85f01f23439694db0fd2a4f1d2da37960b4..c62d3720d96ae261d4ab0b8f43924ad81f2d14a8 100644 (file)
@@ -13,9 +13,9 @@ class SimpleOperator(bpy.types.Operator):
 
     def execute(self, context):
         main(context)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
-bpy.ops.add(SimpleOperator)
+bpy.types.register(SimpleOperator)
 
 if __name__ == "__main__":
     bpy.ops.object.simple_operator()
index 9d04afe22b5509665a8a3a99437d4619e1f68d86..12f1b0ed5e52d3496305487bb4d9c36e95149746 100644 (file)
@@ -138,7 +138,7 @@ class Reload(bpy.types.Operator):
 
     def execute(self, context):
         DATA_PT_template.templates[:] = metarig_templates()
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 def rigify_report_exception(operator, exception):
@@ -180,7 +180,7 @@ class Generate(bpy.types.Operator):
         except rigify.RigifyError as rig_exception:
             rigify_report_exception(self, rig_exception)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class Validate(bpy.types.Operator):
@@ -196,7 +196,7 @@ class Validate(bpy.types.Operator):
             rigify.validate_rig(context, context.object)
         except rigify.RigifyError as rig_exception:
             rigify_report_exception(self, rig_exception)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class Sample(bpy.types.Operator):
@@ -219,7 +219,7 @@ class Sample(bpy.types.Operator):
                 if obj_gen:
                     obj_gen.location.x = i * 1.0
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class Graph(bpy.types.Operator):
@@ -244,7 +244,7 @@ class Graph(bpy.types.Operator):
             os.system("dot -Tpng %s > %s; gnome-open %s &" % (path_dot, path_png, path_png))
             #os.system("python /b/xdot.py '%s' &" % path_dot)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class AsScript(bpy.types.Operator):
@@ -267,7 +267,7 @@ class AsScript(bpy.types.Operator):
         file.write(code)
         file.close()
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         import os
@@ -294,7 +294,7 @@ class ActiveAssign(bpy.types.Operator):
         pose_templates = scene.pose_templates
         template_name = DATA_PT_template.templates[pose_templates.active_template_index]
         context.active_pose_bone["type"] = template_name
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class ActiveClear(bpy.types.Operator):
@@ -310,7 +310,7 @@ class ActiveClear(bpy.types.Operator):
     def execute(self, context):
         scene = context.scene
         del context.active_pose_bone["type"]
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 import space_info
@@ -336,15 +336,15 @@ bpy.types.register(DATA_PT_template)
 bpy.types.register(PoseTemplateSettings)
 bpy.types.register(PoseTemplate)
 
-bpy.ops.add(Reload)
-bpy.ops.add(Generate)
-bpy.ops.add(Validate)
-bpy.ops.add(Sample)
-bpy.ops.add(Graph)
-bpy.ops.add(AsScript)
+bpy.types.register(Reload)
+bpy.types.register(Generate)
+bpy.types.register(Validate)
+bpy.types.register(Sample)
+bpy.types.register(Graph)
+bpy.types.register(AsScript)
 
-bpy.ops.add(ActiveAssign)
-bpy.ops.add(ActiveClear)
+bpy.types.register(ActiveAssign)
+bpy.types.register(ActiveClear)
 
 
 bpy.types.register(INFO_MT_armature_metarig_add)
index 5e086435ddde15f4503e521cc85a7a0f9be04fab..3e593246e2c1297c9452833fbfebf399768998fa 100644 (file)
@@ -131,7 +131,7 @@ class ConsoleExec(bpy.types.Operator):
             return execute(context)
         else:
             print("Error: bpy.ops.console.execute_" + sc.language + " - not found")
-            return ('FINISHED',)
+            return {'FINISHED'}
 
 
 class ConsoleAutocomplete(bpy.types.Operator):
@@ -153,11 +153,13 @@ class ConsoleAutocomplete(bpy.types.Operator):
             return autocomplete(context)
         else:
             print("Error: bpy.ops.console.autocomplete_" + sc.language + " - not found")
-            return ('FINISHED',)
+            return {'FINISHED'}
 
 
 class ConsoleBanner(bpy.types.Operator):
+    '''Print a message whem the terminal initializes'''
     bl_idname = "console.banner"
+    bl_label = "Console Banner"
 
     def execute(self, context):
         sc = context.space_data
@@ -173,12 +175,13 @@ class ConsoleBanner(bpy.types.Operator):
             return banner(context)
         else:
             print("Error: bpy.ops.console.banner_" + sc.language + " - not found")
-            return ('FINISHED',)
+            return {'FINISHED'}
 
 
 class ConsoleLanguage(bpy.types.Operator):
     '''Set the current language for this console'''
     bl_idname = "console.language"
+    bl_label = "Console Language"
     language = StringProperty(name="Language", maxlen=32, default="")
 
     def execute(self, context):
@@ -193,7 +196,7 @@ class ConsoleLanguage(bpy.types.Operator):
         bpy.ops.console.history_append(text="", current_character=0,
             remove_duplicates=True)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 bpy.types.register(CONSOLE_HT_header)
@@ -202,9 +205,9 @@ bpy.types.register(CONSOLE_MT_report)
 bpy.types.register(CONSOLE_MT_language)
 
 # Stubs that call the language operators
-bpy.ops.add(ConsoleExec)
-bpy.ops.add(ConsoleAutocomplete)
-bpy.ops.add(ConsoleBanner)
+bpy.types.register(ConsoleExec)
+bpy.types.register(ConsoleAutocomplete)
+bpy.types.register(ConsoleBanner)
 
 # Set the language and call the banner
-bpy.ops.add(ConsoleLanguage)
+bpy.types.register(ConsoleLanguage)
index 56509a6e09973822060188aa46f4d0b6e60618e1..1f7ba15de6116a22ede40a8aa4586c299e6a85c4 100644 (file)
@@ -308,7 +308,7 @@ class HelpOperator(bpy.types.Operator):
     def execute(self, context):
         import webbrowser
         webbrowser.open(self._url)
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class HELP_OT_manual(HelpOperator):
@@ -391,14 +391,14 @@ class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
         textblock.write('\n'.join(op_strings))
         textblock.name = "OperatorList.txt"
         print("See OperatorList.txt textblock")
-        return ('FINISHED',)
-
-bpy.ops.add(HELP_OT_manual)
-bpy.ops.add(HELP_OT_release_logs)
-bpy.ops.add(HELP_OT_blender_website)
-bpy.ops.add(HELP_OT_blender_eshop)
-bpy.ops.add(HELP_OT_developer_community)
-bpy.ops.add(HELP_OT_user_community)
-bpy.ops.add(HELP_OT_report_bug)
-bpy.ops.add(HELP_OT_python_api)
-bpy.ops.add(HELP_OT_operator_cheat_sheet)
+        return {'FINISHED'}
+
+bpy.types.register(HELP_OT_manual)
+bpy.types.register(HELP_OT_release_logs)
+bpy.types.register(HELP_OT_blender_website)
+bpy.types.register(HELP_OT_blender_eshop)
+bpy.types.register(HELP_OT_developer_community)
+bpy.types.register(HELP_OT_user_community)
+bpy.types.register(HELP_OT_report_bug)
+bpy.types.register(HELP_OT_python_api)
+bpy.types.register(HELP_OT_operator_cheat_sheet)
index 81f61b3c78c49c5e3d1b306e2962e51dcca3f3a6..08efb92f00ef270a6b439089f98bd6ffb63c06c9 100644 (file)
@@ -1646,7 +1646,7 @@ class WM_OT_keyconfig_test(bpy.types.Operator):
         if self.testConfig(kc):
             print("CONFLICT")
        
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 def _string_value(value):
     result = ""
@@ -1736,7 +1736,7 @@ class WM_OT_keyconfig_export(bpy.types.Operator):
 
         f.close()
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
     def invoke(self, context, event):
         wm = context.manager
@@ -1753,7 +1753,7 @@ class WM_OT_keymap_edit(bpy.types.Operator):
         wm = context.manager
         km = context.keymap
         km.copy_to_user()
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_keymap_restore(bpy.types.Operator):
@@ -1773,7 +1773,7 @@ class WM_OT_keymap_restore(bpy.types.Operator):
             km = context.keymap
             km.restore_to_default()
 
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 class WM_OT_keyitem_restore(bpy.types.Operator):
     "Restore key map item."
@@ -1792,7 +1792,7 @@ class WM_OT_keyitem_restore(bpy.types.Operator):
 
         km.restore_item_to_default(kmi)
 
-        return ('FINISHED',)
+        return {'FINISHED'}
     
 class WM_OT_keyitem_add(bpy.types.Operator):
     "Add key map item."
@@ -1806,7 +1806,7 @@ class WM_OT_keyitem_add(bpy.types.Operator):
             km.add_modal_item("", 'A', 'PRESS') # kmi
         else:
             km.add_item("", 'A', 'PRESS') # kmi
-        return ('FINISHED',)
+        return {'FINISHED'}
 
 
 class WM_OT_keyitem_remove(bpy.types.Operator):
@@ -1819,12 +1819,12 @@ class WM_OT_keyitem_remove(bpy.types.Operator):
         kmi = context.keyitem
         km = context.keymap
         km.remove_item(kmi)
-        return ('FINISHED',)
-
-bpy.ops.add(WM_OT_keyconfig_export)
-bpy.ops.add(WM_OT_keyconfig_test)
-bpy.ops.add(WM_OT_keymap_edit)
-bpy.ops.add(WM_OT_keymap_restore)
-bpy.ops.add(WM_OT_keyitem_add)
-bpy.ops.add(WM_OT_keyitem_remove)
-bpy.ops.add(WM_OT_keyitem_restore)
+        return {'FINISHED'}
+
+bpy.types.register(WM_OT_keyconfig_export)
+bpy.types.register(WM_OT_keyconfig_test)
+bpy.types.register(WM_OT_keymap_edit)
+bpy.types.register(WM_OT_keymap_restore)
+bpy.types.register(WM_OT_keyitem_add)
+bpy.types.register(WM_OT_keyitem_remove)
+bpy.types.register(WM_OT_keyitem_restore)
index 9476aa479a75e5221853bae4eb8121009b44ad01..413f01590edb5b4721fbac22693a4d6c80201d73 100644 (file)
@@ -562,7 +562,7 @@ short bezt_to_cfraelem(BeztEditData *bed, BezTriple *bezt)
 /* used to remap times from one range to another
  * requires:  bed->data = BeztEditCD_Remap     
  */
-short bezt_remap_times(BeztEditData *bed, BezTriple *bezt)
+void bezt_remap_times(BeztEditData *bed, BezTriple *bezt)
 {
        BeztEditCD_Remap *rmap= (BeztEditCD_Remap*)bed->data;
        const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin);
index 26290d8771c950a366f67346dfd9fc2c3a445c4d..9e29d747d4a767cfeb98f58497cf9e40f1f52305 100644 (file)
@@ -154,7 +154,7 @@ short bezt_to_cfraelem(BeztEditData *bed, struct BezTriple *bezt);
 /* used to remap times from one range to another
  * requires:  bed->custom = BeztEditCD_Remap   
  */
-short bezt_remap_times(BeztEditData *bed, struct BezTriple *bezt);
+void bezt_remap_times(BeztEditData *bed, struct BezTriple *bezt);
 
 /* ************************************************ */
 /* Destructive Editing API (keyframes_general.c) */
index bfb7d1390742e2a7e174d1de70eca4ed400a11a4..f174e96120c3aea490513cd26e3bf1a0e3f2c33e 100644 (file)
@@ -2102,7 +2102,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op)
        
        Sequence *seq, *seqm, *next;
        
-       int tot, channel_max= 1;
+       int channel_max= 1;
 
        if(ed==NULL)
                return OPERATOR_CANCELLED;
@@ -2241,10 +2241,10 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
 /* view_all operator */
 static int sequencer_view_all_exec(bContext *C, wmOperator *op)
 {
-       Scene *scene= CTX_data_scene(C);
+       //Scene *scene= CTX_data_scene(C);
        bScreen *sc= CTX_wm_screen(C);
        ScrArea *area= CTX_wm_area(C);
-       ARegion *ar= CTX_wm_region(C);
+       //ARegion *ar= CTX_wm_region(C);
        View2D *v2d= UI_view2d_fromcontext(C);
 
        v2d->cur= v2d->tot;
@@ -2275,11 +2275,11 @@ void SEQUENCER_OT_view_all(wmOperatorType *ot)
 static int sequencer_view_all_preview_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
-       bScreen *sc= CTX_wm_screen(C);
+       //bScreen *sc= CTX_wm_screen(C);
        ScrArea *area= CTX_wm_area(C);
        ARegion *ar= CTX_wm_region(C);
        SpaceSeq *sseq= area->spacedata.first;
-       View2D *v2d= UI_view2d_fromcontext(C);
+       //View2D *v2d= UI_view2d_fromcontext(C);
 
 
        /* Like zooming on an image view */
@@ -2735,7 +2735,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
        Editing *ed= seq_give_editing(scene, FALSE);
-       Sequence *seq, *seq_act;
+       Sequence *seq;
 
        if(ed==NULL)
                return OPERATOR_CANCELLED;
index fdad021291a83ecf6916ab3517045f2a95575757..51cd9d5d3acc87507a38c5b843cf09297949bfbb 100644 (file)
@@ -605,39 +605,6 @@ static void rna_Operator_unregister(const bContext *C, StructRNA *type)
                WM_main_add_notifier(NC_SCREEN|NA_EDITED, NULL);
 }
 
-void operator_wrapper(wmOperatorType *ot, void *userdata)
-{
-       /* take care not to overwrite anything set in
-        * WM_operatortype_append_ptr before opfunc() is called */
-       StructRNA *srna = ot->srna;
-       *ot= *((wmOperatorType *)userdata);
-       ot->srna= srna; /* restore */
-
-       RNA_struct_blender_type_set(ot->ext.srna, ot);
-}
-
-#if 0
-static int PYTHON_OT_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       return PYTHON_OT_generic(PYOP_INVOKE, C, op->type, op, event, NULL);
-}
-
-static int PYTHON_OT_execute(bContext *C, wmOperator *op)
-{
-       return PYTHON_OT_generic(PYOP_EXEC, C, op->type, op, NULL, NULL);
-}
-
-static int PYTHON_OT_poll(bContext *C, wmOperatorType *ot)
-{
-       return PYTHON_OT_generic(PYOP_POLL, C, ot, NULL, NULL, NULL);
-}
-
-static void PYTHON_OT_draw(bContext *C, wmOperator *op, uiLayout *layout)
-{
-       PYTHON_OT_generic(PYOP_DRAW, C, op->type, op, NULL, layout);
-}
-#endif
-
 static int operator_poll(bContext *C, wmOperatorType *ot)
 {
        PointerRNA ptr;
@@ -708,7 +675,11 @@ static int operator_invoke(bContext *C, wmOperator *op, wmEvent *event)
        return result;
 }
 
+
+void operator_wrapper(wmOperatorType *ot, void *userdata);
+
 static char _operator_idname[OP_MAX_TYPENAME];
+static char _operator_name[OP_MAX_TYPENAME];
 static char _operator_descr[1024];
 static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free)
 {
@@ -720,6 +691,7 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
        /* setup dummy operator & operator type to store static properties in */
        dummyop.type= &dummyot;
        dummyot.idname= _operator_idname; /* only assigne the pointer, string is NULL'd */
+       dummyot.name= _operator_name; /* only assigne the pointer, string is NULL'd */
        dummyot.description= _operator_descr; /* only assigne the pointer, string is NULL'd */
        RNA_pointer_create(NULL, &RNA_Operator, &dummyop, &dummyotr);
 
@@ -729,12 +701,19 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
 
        {       /* convert foo.bar to FOO_OT_bar
                 * allocate the description and the idname in 1 go */
-               int idlen = strlen(_operator_idname);
-               int desclen = strlen(_operator_descr);
-               dummyot.idname= MEM_callocN(sizeof(char) * (idlen + desclen + 2 + 3), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */
-               WM_operator_bl_idname(dummyot.idname, _operator_idname); /* convert the idname from python */
-               dummyot.description = dummyot.idname + (idlen + 4);
-               strcpy(dummyot.description, _operator_descr);
+               int idlen = strlen(_operator_idname) + 4;
+               int namelen = strlen(_operator_name) + 1;
+               int desclen = strlen(_operator_descr) + 1;
+               char *ch, *ch_arr;
+               ch_arr= ch= MEM_callocN(sizeof(char) * (idlen + namelen + desclen), "_operator_idname"); /* 2 terminators and 3 to convert a.b -> A_OT_b */
+               WM_operator_bl_idname(ch, _operator_idname); /* convert the idname from python */
+               dummyot.idname= ch;
+               ch += idlen;
+               strcpy(ch, _operator_name);
+               dummyot.name = ch;
+               ch += namelen;
+               strcpy(ch, _operator_descr);
+               dummyot.description = ch;
        }
 
        if(strlen(identifier) >= sizeof(dummyop.idname)) {
@@ -806,7 +785,7 @@ static void rna_def_operator(BlenderRNA *brna)
        RNA_def_property_flag(prop, PROP_REGISTER);
 
        prop= RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE);
-       RNA_def_property_string_sdna(prop, NULL, "type->description");
+       RNA_def_property_string_sdna(prop, NULL, "type->name");
        RNA_def_property_string_maxlength(prop, 1024); /* else it uses the pointer size! */
        RNA_def_property_flag(prop, PROP_REGISTER);
 
index 7ccbe1c16a468b204c074573be39682e3f5e7d51..101f3619da4fb8e9575aee36ce89b2c5950c451d 100644 (file)
@@ -244,7 +244,7 @@ PyObject *BPY_operator_module( void )
        static PyMethodDef pyop_as_string_meth ={"as_string", (PyCFunction) pyop_as_string, METH_VARARGS, NULL};
        static PyMethodDef pyop_dir_meth =              {"dir", (PyCFunction) pyop_dir, METH_NOARGS, NULL};
        static PyMethodDef pyop_getrna_meth =   {"get_rna", (PyCFunction) pyop_getrna, METH_O, NULL};
-       static PyMethodDef pyop_add_meth =              {"add", (PyCFunction) PYOP_wrap_add, METH_O, NULL};
+//     static PyMethodDef pyop_add_meth =              {"add", (PyCFunction) PYOP_wrap_add, METH_O, NULL};
        static PyMethodDef pyop_add_macro_meth ={"add_macro", (PyCFunction) PYOP_wrap_add_macro, METH_O, NULL};
        static PyMethodDef pyop_macro_def_meth ={"macro_define", (PyCFunction) PYOP_wrap_macro_define, METH_VARARGS, NULL};
        static PyMethodDef pyop_remove_meth =   {"remove", (PyCFunction) PYOP_wrap_remove, METH_O, NULL};
@@ -256,7 +256,7 @@ PyObject *BPY_operator_module( void )
        PyModule_AddObject( submodule, "as_string",PyCFunction_New(&pyop_as_string_meth,NULL) );
        PyModule_AddObject( submodule, "dir",           PyCFunction_New(&pyop_dir_meth,         NULL) );
        PyModule_AddObject( submodule, "get_rna",       PyCFunction_New(&pyop_getrna_meth,      NULL) );
-       PyModule_AddObject( submodule, "add",           PyCFunction_New(&pyop_add_meth,         NULL) );
+//     PyModule_AddObject( submodule, "add",           PyCFunction_New(&pyop_add_meth,         NULL) );
        PyModule_AddObject( submodule, "add_macro",     PyCFunction_New(&pyop_add_macro_meth,           NULL) );
        PyModule_AddObject( submodule, "macro_define",PyCFunction_New(&pyop_macro_def_meth,             NULL) );
        PyModule_AddObject( submodule, "remove",        PyCFunction_New(&pyop_remove_meth,      NULL) );
index cd5b07565312227875fe63a1f7fe8c0f8cbe3ea5..3bd18d98563c532b63d84eac058a5206293b2329 100644 (file)
@@ -105,7 +105,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
 
        py_class_instance = PyObject_Call(py_class, args, NULL);
        Py_DECREF(args);
-       
+
        if (py_class_instance==NULL) { /* Initializing the class worked, now run its invoke function */
                PyErr_Print();
                PyErr_Clear();
@@ -128,7 +128,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
                else if (mode==PYOP_EXEC) {
                        item= PyObject_GetAttrString(py_class, "execute");
                        args = PyTuple_New(2);
-                       
+
                        PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context));
                }
                else if (mode==PYOP_POLL) {
@@ -173,7 +173,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
                Py_DECREF(args);
                Py_DECREF(item);
        }
-       
+
        if (ret == NULL) { /* covers py_class_instance failing too */
                if(op)
                        BPy_errors_to_report(op->reports);
@@ -202,7 +202,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
                 * If we ever want to do this and use the props again,
                 * it can be done with - pyrna_pydict_to_props(op->ptr, kw, "")
                 */
-               
+
                Py_DECREF(ret);
        }
 
@@ -215,7 +215,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperatorType *ot, wmOperat
                BPY_flag_def *flag_def = pyop_ret_flags;
 
                strcpy(flag_str, "");
-               
+
                while(flag_def->name) {
                        if (ret_flag & flag_def->flag) {
                                if(flag_str[1])
@@ -260,6 +260,49 @@ static void PYTHON_OT_draw(bContext *C, wmOperator *op, uiLayout *layout)
        PYTHON_OT_generic(PYOP_DRAW, C, op->type, op, NULL, layout);
 }
 
+
+
+void operator_wrapper(wmOperatorType *ot, void *userdata)
+{
+       /* take care not to overwrite anything set in
+        * WM_operatortype_append_ptr before opfunc() is called */
+       StructRNA *srna = ot->srna;
+       *ot= *((wmOperatorType *)userdata);
+       ot->srna= srna; /* restore */
+
+       RNA_struct_blender_type_set(ot->ext.srna, ot);
+
+
+       /* Can't use this because it returns a dict proxy
+        *
+        * item= PyObject_GetAttrString(py_class, "__dict__");
+        */
+       {
+               PyObject *py_class = ot->ext.data;
+               PyObject *item= ((PyTypeObject*)py_class)->tp_dict;
+               if(item) {
+                       /* only call this so pyrna_deferred_register_props gives a useful error
+                        * WM_operatortype_append_ptr will call RNA_def_struct_identifier
+                        * later */
+                       RNA_def_struct_identifier(ot->srna, ot->idname);
+
+                       if(pyrna_deferred_register_props(ot->srna, item)!=0) {
+                               /* failed to register operator props */
+                               PyErr_Print();
+                               PyErr_Clear();
+
+                       }
+               }
+               else {
+                       PyErr_Clear();
+               }
+       }
+}
+
+
+
+
+
 void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
 {
        PyObject *py_class = (PyObject *)userdata;
@@ -283,8 +326,8 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
        item= PyObject_GetAttrString(py_class, PYOP_ATTR_DESCRIPTION);
        ot->description= (item && PyUnicode_Check(item)) ? _PyUnicode_AsString(item):"undocumented python operator";
        Py_XDECREF(item);
-       
-       /* api callbacks, detailed checks dont on adding */ 
+
+       /* api callbacks, detailed checks dont on adding */
        if (PyObject_HasAttrString(py_class, "invoke"))
                ot->invoke= PYTHON_OT_invoke;
        //else
@@ -296,9 +339,9 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata)
                ot->pyop_poll= PYTHON_OT_poll;
        if (PyObject_HasAttrString(py_class, "draw"))
                ot->ui= PYTHON_OT_draw;
-       
+
        ot->pyop_data= userdata;
-       
+
        /* flags */
        ot->flag= 0;
 
@@ -419,11 +462,11 @@ void PYTHON_OT_MACRO_wrapper(wmOperatorType *ot, void *userdata)
 
 /* pyOperators - Operators defined IN Python */
 PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class)
-{      
+{
        PyObject *base_class, *item;
        wmOperatorType *ot;
-       
-       
+
+
        char *idname= NULL;
        char idname_bl[OP_MAX_TYPENAME]; /* converted to blender syntax */
 
@@ -466,7 +509,7 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class)
        Py_DECREF(item);
        /* end annoying conversion! */
 
-       
+
        /* remove if it already exists */
        if ((ot=WM_operatortype_exists(idname))) {
                if(ot->pyop_data) {
@@ -474,7 +517,7 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class)
                }
                WM_operatortype_remove(idname);
        }
-       
+
        Py_INCREF(py_class);
        WM_operatortype_append_ptr(PYTHON_OT_wrapper, py_class);
 
index d0cc3e95097773d427d560f6dd4bae9cbbbae766..8eda19d8198a7a723fd1d49a68e0ed0c56b54550 100644 (file)
@@ -3912,7 +3912,18 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
                                }
                        }
 
+#if 0
+                       if(strcmp(identifier, "bl_label") == 0) {
+                               item= PyObject_GetAttrString(py_class, "__doc__");
 
+                               if(item) {
+                                       Py_DECREF(item); /* no need to keep a ref, the class owns it */
+
+                                       if(pyrna_py_to_prop(dummyptr, prop, NULL, item, "validating class error:") != 0)
+                                               return -1;
+                               }
+                       }
+#endif
                        if (item == NULL && (((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL))) {
                                PyErr_Format( PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, identifier);
                                return -1;
@@ -4092,6 +4103,7 @@ void pyrna_free_types(void)
                }
        }
        RNA_PROP_END;
+
 }
 
 /* Note! MemLeak XXX
index 4ad067e874362c74707b488e515300e62feb9c83..6d008d5cbb341844946c65493945870ee9d05357 100644 (file)
@@ -2655,9 +2655,13 @@ void wm_operatortype_free(void)
 {
        wmOperatorType *ot;
        
-       for(ot= global_ops.first; ot; ot= ot->next)
+       for(ot= global_ops.first; ot; ot= ot->next) {
                if(ot->macro.first)
                        wm_operatortype_free_macro(ot);
+
+               if(ot->ext.srna) /* python operator, allocs own string */
+                       MEM_freeN(ot->idname);
+       }
        
        BLI_freelistN(&global_ops);
 }