diff options
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 63 |
2 files changed, 33 insertions, 40 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 4e60fb413db..841f8708aa2 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -323,6 +323,16 @@ typedef struct ExtensionRNA { void (*free)(void *data); } ExtensionRNA; +/* fake struct definitions, needed otherwise collections end up owning the C + * structs like 'Object' when defined first */ +#define MainCameras Main +#define MainScenes Main +#define MainArmatures Main +#define MainMaterials Main +#define MainMeshes Main +#define MainLamps Main +#define MainObjects Main + #ifdef __cplusplus } #endif diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 09c92751087..f1fe24418e9 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -52,25 +52,24 @@ #include "DNA_mesh_types.h" #include "DNA_object_types.h" -static Tex *rna_Main_add_texture(Main *bmain, char *name) +Tex *rna_Main_add_texture(Main *bmain, char *name) { return add_texture(name); } /* TODO: remove texture? */ -static Image *rna_Main_add_image(Main *bmain, char *filename) +Image *rna_Main_add_image(Main *bmain, char *filename) { return BKE_add_image_file(filename, 0); } -static Camera *rna_Main_cameras_new(bContext *C, char* name) +Camera *rna_Main_cameras_new(Main *bmain, char* name) { return add_camera(name); } -static void rna_Main_cameras_remove(bContext *C, ReportList *reports, struct Camera *camera) +void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) { - Main *bmain= CTX_data_main(C); if(camera->id.us == 0) free_libblock(&bmain->camera, camera); else @@ -79,23 +78,22 @@ static void rna_Main_cameras_remove(bContext *C, ReportList *reports, struct Cam /* XXX python now has invalid pointer? */ } -static Scene *rna_Main_scenes_new(bContext *C, char* name) +Scene *rna_Main_scenes_new(Main *bmain, char* name) { return add_scene(name); } -static void rna_Main_scenes_remove(bContext *C, ReportList *reports, struct Scene *scene) +void rna_Main_scenes_remove(Main *bmain, ReportList *reports, struct Scene *scene) { - Main *bmain= CTX_data_main(C); free_libblock(&bmain->scene, scene); } -static Object *rna_Main_objects_new(bContext *C, char* name, int type) +Object *rna_Main_objects_new(Main *bmain, char* name, int type) { Object *ob= add_only_object(type, name); ob->id.us--; return ob; } -static void rna_Main_objects_remove(bContext *C, ReportList *reports, struct Object *object) +void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { /* NOTE: the following example shows when this function should _not_ be called @@ -109,20 +107,18 @@ static void rna_Main_objects_remove(bContext *C, ReportList *reports, struct Obj # don't do this since ob is already freed! bpy.data.remove_object(ob) */ - Main *bmain= CTX_data_main(C); if(object->id.us == 0) free_libblock(&bmain->object, object); else BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d.", object->id.name+2, object->id.us); } -static Material *rna_Main_materials_new(bContext *C, char* name) +struct Material *rna_Main_materials_new(Main *bmain, char* name) { return add_material(name); } -static void rna_Main_materials_remove(bContext *C, ReportList *reports, struct Material *material) +void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) { - Main *bmain= CTX_data_main(C); if(material->id.us == 0) free_libblock(&bmain->mat, material); else @@ -131,15 +127,14 @@ static void rna_Main_materials_remove(bContext *C, ReportList *reports, struct M /* XXX python now has invalid pointer? */ } -static Mesh *rna_Main_meshes_new(bContext *C, char* name) +Mesh *rna_Main_meshes_new(Main *bmain, char* name) { Mesh *me= add_mesh(name); me->id.us--; return me; } -static void rna_Main_meshes_remove(bContext *C, ReportList *reports, Mesh *mesh) +void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) { - Main *bmain= CTX_data_main(C); if(mesh->id.us == 0) free_libblock(&bmain->mesh, mesh); else @@ -148,15 +143,14 @@ static void rna_Main_meshes_remove(bContext *C, ReportList *reports, Mesh *mesh) /* XXX python now has invalid pointer? */ } -static Lamp *rna_Main_lamps_new(bContext *C, char* name) +Lamp *rna_Main_lamps_new(Main *bmain, char* name) { Lamp *lamp= add_lamp(name); lamp->id.us--; return lamp; } -static void rna_Main_lamps_remove(bContext *C, ReportList *reports, Lamp *lamp) +void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) { - Main *bmain= CTX_data_main(C); if(lamp->id.us == 0) free_libblock(&bmain->lamp, lamp); else @@ -165,15 +159,14 @@ static void rna_Main_lamps_remove(bContext *C, ReportList *reports, Lamp *lamp) /* XXX python now has invalid pointer? */ } -static bArmature *rna_Main_armatures_new(bContext *C, char* name) +bArmature *rna_Main_armatures_new(Main *bmain, char* name) { bArmature *arm= add_armature(name); arm->id.us--; return arm; } -static void rna_Main_armatures_remove(bContext *C, ReportList *reports, bArmature *arm) +void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) { - Main *bmain= CTX_data_main(C); if(arm->id.us == 0) free_libblock(&bmain->armature, arm); else @@ -212,11 +205,9 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainCameras"); srna= RNA_def_struct(brna, "MainCameras", NULL); -// RNA_def_struct_sdna(srna, "Camera"); RNA_def_struct_ui_text(srna, "Main Cameras", "Collection of cameras."); func= RNA_def_function(srna, "new", "rna_Main_cameras_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new camera to the main database"); parm= RNA_def_string(func, "name", "Camera", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -225,7 +216,7 @@ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_cameras_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a camera from the current blendfile."); parm= RNA_def_pointer(func, "camera", "Camera", "", "Camera to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -239,11 +230,9 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainScenes"); srna= RNA_def_struct(brna, "MainScenes", NULL); -// RNA_def_struct_sdna(srna, "Scene"); RNA_def_struct_ui_text(srna, "Main Scenes", "Collection of scenes."); func= RNA_def_function(srna, "new", "rna_Main_scenes_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new scene to the main database"); parm= RNA_def_string(func, "name", "Scene", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -252,7 +241,7 @@ void RNA_def_main_scenes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_scenes_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "scene", "Scene", "", "Scene to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_ui_description(func, "Remove a scene from the current blendfile."); @@ -271,7 +260,6 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Objects", "Collection of objects."); func= RNA_def_function(srna, "new", "rna_Main_objects_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new object to the main database"); parm= RNA_def_string(func, "name", "Object", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -283,7 +271,7 @@ void RNA_def_main_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_objects_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_ui_description(func, "Remove a object from the current blendfile."); @@ -301,7 +289,6 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Material", "Collection of materials."); func= RNA_def_function(srna, "new", "rna_Main_materials_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new material to the main database"); parm= RNA_def_string(func, "name", "Material", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -310,7 +297,7 @@ void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_materials_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a material from the current blendfile."); parm= RNA_def_pointer(func, "material", "Material", "", "Material to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -331,7 +318,6 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Meshes", "Collection of meshes."); func= RNA_def_function(srna, "new", "rna_Main_meshes_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new mesh to the main database"); parm= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -340,7 +326,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_meshes_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile."); parm= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -357,7 +343,6 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Main Lamps", "Collection of lamps."); func= RNA_def_function(srna, "new", "rna_Main_lamps_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new lamp to the main database"); parm= RNA_def_string(func, "name", "Lamp", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -366,7 +351,7 @@ void RNA_def_main_lamps(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_lamps_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a lamp from the current blendfile."); parm= RNA_def_pointer(func, "lamp", "Lamp", "", "Lamp to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -435,11 +420,9 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_srna(cprop, "MainArmatures"); srna= RNA_def_struct(brna, "MainArmatures", NULL); -// RNA_def_struct_sdna(srna, "Armature"); RNA_def_struct_ui_text(srna, "Main Armatures", "Collection of armatures."); func= RNA_def_function(srna, "new", "rna_Main_armatures_new"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a new armature to the main database"); parm= RNA_def_string(func, "name", "Armature", 0, "", "New name for the datablock."); RNA_def_property_flag(parm, PROP_REQUIRED); @@ -448,7 +431,7 @@ void RNA_def_main_armatures(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_Main_armatures_remove"); - RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a armature from the current blendfile."); parm= RNA_def_pointer(func, "armature", "Armature", "", "Armature to remove."); RNA_def_property_flag(parm, PROP_REQUIRED); |