diff --git a/release/io/export_obj.py b/release/io/export_obj.py index df10c3e9089..4354f9f9bb9 100644 --- a/release/io/export_obj.py +++ b/release/io/export_obj.py @@ -4,10 +4,7 @@ def write_obj(filepath, scene, ob): out = open(filepath, 'w') # create a temporary mesh - mesh = bpy.data.add_mesh("tmpmesh") - - # copy data with modifiers applied - mesh.copy_applied(scene, ob) + mesh = ob.create_render_mesh(scene) # for vert in mesh.verts: # ^ iterating that way doesn't work atm for some reason @@ -25,7 +22,8 @@ def write_obj(filepath, scene, ob): out.write(' {0}'.format(index + 1)) out.write('\n') - # TODO: delete mesh here + # delete mesh gain + bpy.data.remove_mesh(mesh) out.close() @@ -37,13 +35,13 @@ class SCRIPT_OT_export_obj(bpy.types.Operator): # List of operator properties, the attributes will be assigned # to the class instance from the operator settings before calling. __props__ = [ - bpy.props["StringProperty"](attr="filename", name="filename") + bpy.props.StringProperty(attr="filename", name="filename") ] def debug(self, message): print("{0}: {1}".format(self.__class__.__name__, message)) - def exec(self, context): + def execute(self, context): self.debug("exec") self.debug("filename = " + self.filename) @@ -61,9 +59,13 @@ class SCRIPT_OT_export_obj(bpy.types.Operator): def invoke(self, context, event): self.debug("invoke") - context.add_fileselect(self.__operator__) + wm = context.manager + wm.add_fileselect(self.__operator__) return ('RUNNING_MODAL',) def poll(self, context): # poll isnt working yet self.debug("poll") return True + +bpy.ops.add(SCRIPT_OT_export_obj) + diff --git a/release/ui/space_script.py b/release/ui/space_script.py index d2c73adb00f..d35f2d389c8 100644 --- a/release/ui/space_script.py +++ b/release/ui/space_script.py @@ -61,8 +61,8 @@ class SCRIPT_MT_export(bpy.types.Menu): class SCRIPT_OT_reload_scripts(bpy.types.Operator): __label__ = 'Reload Scripts' - def exec(self, context): - print("SCRIPT_OT_reload_scripts: exec") + def execute(self, context): + print("SCRIPT_OT_reload_scripts: execute") # add ../io to sys.path @@ -116,7 +116,7 @@ class SCRIPT_OT_reload_scripts(bpy.types.Operator): def invoke(self, context, event): print("SCRIPT_OT_reload_scripts: invoke") - return self.exec(context) + return self.execute(context) def poll(self, context): pass @@ -129,3 +129,4 @@ if (hasattr(bpy.ops, "SCRIPT_OT_reload_scripts")): bpy.ops.remove(bpy.ops.SCRIPT_OT_reload_scripts) bpy.ops.add(SCRIPT_OT_reload_scripts) + diff --git a/source/Makefile b/source/Makefile index 94446f4d1d5..2df57f58c73 100644 --- a/source/Makefile +++ b/source/Makefile @@ -162,6 +162,7 @@ COMLIB += $(OCGDIR)/blender/makesdna/$(DEBUG_DIR)libdna.a COMLIB += $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a COMLIB += $(NAN_MEMUTIL)/lib/libmemutil.a COMLIB += $(NAN_PNG)/lib/libpng.a +COMLIB += $(OCGDIR)/blender/gen_python/$(DEBUG_DIR)libgen_python.a ifeq ($(WITH_QUICKTIME), true) COMLIB += $(OCGDIR)/blender/blenderqt/$(DEBUG_DIR)libblenderqt.a diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index e88e86ca8db..dd003d103d5 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -2027,39 +2027,3 @@ void em_setup_viewcontext(bContext *C, ViewContext *vc) vc->em= me->edit_mesh; } } - -/* - * This version of copy_mesh doesn't allocate a new mesh, - * instead it copies data between two existing meshes. - * - * XXX not used anywhere... - */ -void copy_mesh_data(Mesh *dest, Mesh *src) -{ - int totvert, totedge, totface; - int has_layer; - - CustomData_free(&dest->vdata, dest->totvert); - CustomData_free(&dest->edata, dest->totedge); - CustomData_free(&dest->fdata, dest->totface); - - memset(&dest->vdata, 0, sizeof(dest->vdata)); - memset(&dest->edata, 0, sizeof(dest->edata)); - memset(&dest->fdata, 0, sizeof(dest->fdata)); - - totvert = dest->totvert = src->totvert; - totedge = dest->totedge = src->totedge; - totface = dest->totface = src->totface; - - CustomData_copy(&src->vdata, &dest->vdata, CD_MASK_MESH, CD_DUPLICATE, totvert); - CustomData_copy(&src->edata, &dest->edata, CD_MASK_MESH, CD_DUPLICATE, totedge); - CustomData_copy(&src->fdata, &dest->fdata, CD_MASK_MESH, CD_DUPLICATE, totface); - - CustomData_has_layer(&dest->vdata, CD_MVERT); - - CustomData_add_layer(&dest->vdata, CD_MVERT, CD_ASSIGN, src->mvert, totvert); - CustomData_add_layer(&dest->edata, CD_MEDGE, CD_ASSIGN, src->medge, totedge); - CustomData_add_layer(&dest->fdata, CD_MFACE, CD_ASSIGN, src->mface, totface); - - mesh_update_customdata_pointers(dest); -} diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 255bee1bf5a..42180e7902f 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -574,8 +574,14 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if(CTX_data_equals(member, "cloth")) { - set_pointer_type(path, result, &RNA_ClothModifier); - return 1; + PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + + if(ptr && ptr->data) { + Object *ob= ptr->data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); + return 1; + } } else if(CTX_data_equals(member, "soft_body")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 01f19b3a0ab..99233cc5020 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -175,31 +175,11 @@ static void script_main_area_draw(const bContext *C, ARegion *ar) /* add handlers, stuff you only do once or on area/region changes */ static void script_header_area_init(wmWindowManager *wm, ARegion *ar) { - /* UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy); */ ED_region_header_init(ar); } static void script_header_area_draw(const bContext *C, ARegion *ar) { - /* float col[3]; */ - - /* /\* clear *\/ */ - /* if(ED_screen_area_active(C)) */ - /* UI_GetThemeColor3fv(TH_HEADER, col); */ - /* else */ - /* UI_GetThemeColor3fv(TH_HEADERDESEL, col); */ - - /* glClearColor(col[0], col[1], col[2], 0.0); */ - /* glClear(GL_COLOR_BUFFER_BIT); */ - - /* /\* set view2d view matrix for scrolling (without scrollers) *\/ */ - /* UI_view2d_view_ortho(C, &ar->v2d); */ - - /* script_header_buttons(C, ar); */ - - /* /\* restore view matrix? *\/ */ - /* UI_view2d_view_restore(C); */ - ED_region_header(C, ar); } diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index f7b069d8227..1907b2cedb4 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -37,6 +37,7 @@ extern "C" { struct bContext; struct ID; struct Main; +struct ReportList; /* Types */ @@ -719,13 +720,13 @@ void RNA_parameter_get_lookup(ParameterList *parms, const char *identifier, void void RNA_parameter_set(ParameterList *parms, PropertyRNA *parm, void *value); void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, void *value); -int RNA_function_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *parms); -int RNA_function_call_lookup(PointerRNA *ptr, const char *identifier, ParameterList *parms); +int RNA_function_call(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms); +int RNA_function_call_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, ParameterList *parms); -int RNA_function_call_direct(PointerRNA *ptr, FunctionRNA *func, const char *format, ...); -int RNA_function_call_direct_lookup(PointerRNA *ptr, const char *identifier, const char *format, ...); -int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args); -int RNA_function_call_direct_va_lookup(PointerRNA *ptr, const char *identifier, const char *format, va_list args); +int RNA_function_call_direct(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...); +int RNA_function_call_direct_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...); +int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args); +int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args); /* ID */ diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h index 11f04273842..dfe072c4b8e 100644 --- a/source/blender/makesrna/RNA_define.h +++ b/source/blender/makesrna/RNA_define.h @@ -147,7 +147,7 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item); void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set); void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *typef); -void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add); +void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add, const char *remove); /* Function */ diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index b527a4f11b3..75f52ededd0 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -161,11 +161,13 @@ typedef struct ParameterIterator { /* Function */ typedef enum FunctionFlag { - FUNC_TYPESTATIC = 1, /* for static functions, FUNC_ STATIC is taken by some windows header it seems */ + FUNC_NO_SELF = 1, /* for static functions */ + FUNC_USE_CONTEXT = 2, + FUNC_USE_REPORTS = 4, /* registering */ - FUNC_REGISTER = 2, - FUNC_REGISTER_OPTIONAL = 2|4, + FUNC_REGISTER = 8, + FUNC_REGISTER_OPTIONAL = 8|16, /* internal flags */ FUNC_BUILTIN = 128, @@ -173,7 +175,7 @@ typedef enum FunctionFlag { FUNC_RUNTIME = 512 } FunctionFlag; -typedef void (*CallFunc)(PointerRNA *ptr, ParameterList *parms); +typedef void (*CallFunc)(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, ParameterList *parms); typedef struct FunctionRNA FunctionRNA; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 2914e488efa..963e4f9aeff 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -25,8 +25,9 @@ # ***** END GPL LICENSE BLOCK ***** FILE(GLOB DEFSRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") +FILE(GLOB APISRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*_api.c") LIST(REMOVE_ITEM DEFSRC rna_access.c rna_define.c makesrna.c) -FILE(GLOB_RECURSE APISRC "../../editors/*/*_api.c") +LIST(REMOVE_ITEM DEFSRC ${APISRC}) STRING(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}") diff --git a/source/blender/makesrna/intern/Makefile b/source/blender/makesrna/intern/Makefile index 78757c4f4b5..03f75f0bea6 100644 --- a/source/blender/makesrna/intern/Makefile +++ b/source/blender/makesrna/intern/Makefile @@ -28,10 +28,11 @@ DIR = $(OCGDIR)/blender/makesrna ALLRNA = $(wildcard rna_*.c) DEFRNA = $(filter-out %rna_define.c, $(filter-out %rna_access.c, $(ALLRNA))) -GENSRCS = $(patsubst rna_%.c, rna_%_gen.c, $(DEFRNA)) +GENRNA = $(filter-out %_api.c, $(DEFRNA)) +GENSRCS = $(patsubst rna_%.c, rna_%_gen.c, $(GENRNA)) GENTARGET = $(patsubst %.c, $(DIR)/$(DEBUG_DIR)%.c, $(GENSRCS)) -MAKESRCS = $(DEFRNA) makesrna.c rna_define.c $(wildcard ../../editors/*/*_api.c) +MAKESRCS = $(DEFRNA) makesrna.c rna_define.c MAKEOBJS = $(patsubst %.c, $(DIR)/$(DEBUG_DIR)%.o, $(notdir $(MAKESRCS))) CSRCS = $(GENSRCS) rna_access.c @@ -94,24 +95,6 @@ clean:: # TODO include right .mk for ldflags -# XXX this is an ugly hack, copying code from nan_compile.mk -# we want the .o's to be in the makesrna/ directory, but the -# .c's are in the editors/*/ directories - -$(DIR)/$(DEBUG_DIR)%_api.o: ../../editors/interface/%_api.c - ifdef NAN_DEPEND - @set -e; $(CC) -M $(CPPFLAGS) $< 2>/dev/null \ - | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \ - > $(DIR)/$(DEBUG_DIR)$*.d; \ - [ -s $(DIR)/$(DEBUG_DIR)$*.d ] || $(RM) $(DIR)/$*.d - endif - ifdef NAN_QUIET - @echo " -- $< -- " - @$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ - else - $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ - endif - # A small note: we do not use the debug version of the alloc lib. That # is done quite intentionally. If there is a bug in that lib, it needs # to be fixed by the module maintainer. diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 0b1c1bff24e..03f0afdb2cc 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -13,17 +13,15 @@ root_build_dir=normpath(env['BF_BUILDDIR']) source_files = env.Glob('*.c') source_files.remove('rna_access.c') -api_runtime_files = env.Glob('*_api.c') -for api_file in api_runtime_files: - source_files.remove(api_file) - generated_files = source_files[:] generated_files.remove('rna_define.c') generated_files.remove('makesrna.c') -generated_files = [filename[:-2] + '_gen.c' for filename in generated_files] -source_files.extend(env.Glob('../../editors/*/*_api.c')) -source_files.extend(env.Glob('rna_api.c')) +api_files = env.Glob('*_api.c') +for api_file in api_files: + generated_files.remove(api_file) + +generated_files = [filename[:-2] + '_gen.c' for filename in generated_files] makesrna_tool = env.Clone() rna = env.Clone() @@ -119,9 +117,8 @@ else: rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe " + build_dir) -api_runtime_files.remove('rna_api.c') obj = ['intern/rna_access.c'] -for generated_file in generated_files + api_runtime_files: +for generated_file in generated_files: obj += ['intern/' + generated_file] Return ('obj') diff --git a/source/blender/makesrna/intern/main_api.c b/source/blender/makesrna/intern/main_api.c deleted file mode 100644 index 5d9e1f5e580..00000000000 --- a/source/blender/makesrna/intern/main_api.c +++ /dev/null @@ -1,26 +0,0 @@ -#include - -#include "BKE_main.h" -#include "BKE_mesh.h" -#include "BKE_library.h" - -#include "BLI_listbase.h" - -#include "DNA_mesh_types.h" - -Mesh *RNA_api_main_add_mesh(Main *main, char *name) -{ - return add_mesh(name); -} - -void RNA_api_main_remove_mesh(Main *main, Mesh *me) -{ - if (BLI_findindex(&main->mesh, me) == -1) { - /* XXX report error */ - return; - } - - /* XXX correct ? */ - if (me->id.us == 1) - free_libblock(&main->mesh, me); -} diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index b3fdd8e4457..a8fe025fd46 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -394,7 +394,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr else if(rna_color_quantize(prop, dp)) fprintf(f, " values[%d]= (%s)(data->%s[%d]*(1.0f/255.0f));\n", i, rna_type_type(prop), dp->dnaname, i); else - fprintf(f, " values[%d]= (%s)%s(data->%s[%d]);\n", i, rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnaname, i); + fprintf(f, " values[%d]= (%s)%s(((%s*)data->%s)[%d]);\n", i, rna_type_type(prop), (dp->booleannegative)? "!": "", dp->dnatype, dp->dnaname, i); } } } @@ -559,7 +559,7 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, " data->%s[%d]= FTOCHAR(values[%d]);\n", dp->dnaname, i, i); } else { - fprintf(f, " data->%s[%d]= %s", dp->dnaname, i, (dp->booleannegative)? "!": ""); + fprintf(f, " ((%s*)data->%s)[%d]= %s", dp->dnatype, dp->dnaname, i, (dp->booleannegative)? "!": ""); rna_clamp_value(f, prop, 1, i); } } @@ -1104,6 +1104,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA FunctionRNA *func; PropertyDefRNA *dparm; char *funcname, *ptrstr; + int first; srna= dsrna->srna; func= dfunc->func; @@ -1113,10 +1114,10 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA funcname= rna_alloc_function_name(srna->identifier, func->identifier, "call"); - fprintf(f, "void %s(PointerRNA *_ptr, ParameterList *_parms)", funcname); + fprintf(f, "void %s(bContext *C, ReportList *reports, PointerRNA *_ptr, ParameterList *_parms)", funcname); fprintf(f, "\n{\n"); - if((func->flag & FUNC_TYPESTATIC)==0) { + if((func->flag & FUNC_NO_SELF)==0) { if(dsrna->dnaname) fprintf(f, "\tstruct %s *_self;\n", dsrna->dnaname); else fprintf(f, "\tstruct %s *_self;\n", srna->identifier); } @@ -1132,7 +1133,7 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA fprintf(f, ";\n"); fprintf(f, "\t\n"); - if((func->flag & FUNC_TYPESTATIC)==0) { + if((func->flag & FUNC_NO_SELF)==0) { if(dsrna->dnaname) fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", dsrna->dnaname); else fprintf(f, "\t_self= (struct %s *)_ptr->data;\n", srna->identifier); } @@ -1164,16 +1165,33 @@ static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA if(func->ret) fprintf(f, "%s= ", func->ret->identifier); fprintf(f, "%s(", dfunc->call); - if((func->flag & FUNC_TYPESTATIC)==0) + first= 1; + + if((func->flag & FUNC_NO_SELF)==0) { fprintf(f, "_self"); + first= 0; + } + + if(func->flag & FUNC_USE_CONTEXT) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "C"); + } + + if(func->flag & FUNC_USE_REPORTS) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "reports"); + } dparm= dfunc->cont.properties.first; for(; dparm; dparm= dparm->next) { if(dparm->prop==func->ret) continue; - if((func->flag & FUNC_TYPESTATIC)==0 || dparm!=dfunc->cont.properties.first) - fprintf(f, ", "); + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "%s", dparm->prop->identifier); } @@ -1356,7 +1374,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, base= srna->base; while (base) { for(func= base->functions.first; func; func= func->cont.next) { - fprintf(f, "%s%s rna_%s_%s;\n", "extern ", "FunctionRNA", base->identifier, func->identifier); + fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", base->identifier, func->identifier); rna_generate_parameter_prototypes(brna, base, func, f); } @@ -1367,7 +1385,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, } for(func= srna->functions.first; func; func= func->cont.next) { - fprintf(f, "%s%s rna_%s_%s;\n", "extern ", "FunctionRNA", srna->identifier, func->identifier); + fprintf(f, "%s%s rna_%s_%s_func;\n", "extern ", "FunctionRNA", srna->identifier, func->identifier); rna_generate_parameter_prototypes(brna, srna, func, f); } @@ -1380,6 +1398,7 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA FunctionRNA *func; PropertyDefRNA *dparm; StructDefRNA *dsrna; + int first; dsrna= rna_find_struct_def(srna); func= dfunc->func; @@ -1402,17 +1421,39 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *brna, StructRNA fprintf(f, "%s(", dfunc->call); - if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname); - else fprintf(f, "struct %s *_self", srna->identifier); + first= 1; + + if((func->flag & FUNC_NO_SELF)==0) { + if(dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname); + else fprintf(f, "struct %s *_self", srna->identifier); + first= 0; + } + + if(func->flag & FUNC_USE_CONTEXT) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "bContext *C"); + } + + if(func->flag & FUNC_USE_REPORTS) { + if(!first) fprintf(f, ", "); + first= 0; + fprintf(f, "ReportList *reports"); + } for(dparm= dfunc->cont.properties.first; dparm; dparm= dparm->next) { - if(dparm->prop==func->ret) ; - else if(dparm->prop->arraylength) - fprintf(f, ", %s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->arraylength); + if(dparm->prop==func->ret) + continue; + + if(!first) fprintf(f, ", "); + first= 0; + + if(dparm->prop->arraylength) + fprintf(f, "%s%s %s[%d]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier, dparm->prop->arraylength); else if(dparm->prop->type == PROP_POINTER) - fprintf(f, ", %s%s *%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); + fprintf(f, "%s%s *%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); else - fprintf(f, ", %s%s %s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); + fprintf(f, "%s%s %s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), dparm->prop->identifier); } fprintf(f, ");\n"); @@ -1628,11 +1669,15 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr } case PROP_COLLECTION: { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; - fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring), rna_function_string(cprop->add)); + fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring)); + if(cprop->add) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->add); + else fprintf(f, "NULL, "); + if(cprop->remove) fprintf(f, "&rna_%s_%s_func, ", srna->identifier, (char*)cprop->remove); + else fprintf(f, "NULL, "); if(cprop->type) fprintf(f, "&RNA_%s\n", (char*)cprop->type); else fprintf(f, "NULL\n"); break; - } + } } fprintf(f, "};\n\n"); @@ -1659,11 +1704,11 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) for(parm= func->cont.properties.first; parm; parm= parm->next) rna_generate_property(f, srna, func->identifier, parm); - fprintf(f, "%s%s rna_%s_%s = {\n", "", "FunctionRNA", srna->identifier, func->identifier); + fprintf(f, "%s%s rna_%s_%s_func = {\n", "", "FunctionRNA", srna->identifier, func->identifier); - if(func->cont.next) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s, ", srna->identifier, ((FunctionRNA*)func->cont.next)->identifier); + if(func->cont.next) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s_func, ", srna->identifier, ((FunctionRNA*)func->cont.next)->identifier); else fprintf(f, "\t{NULL, "); - if(func->cont.prev) fprintf(f, "(FunctionRNA*)&rna_%s_%s,\n", srna->identifier, ((FunctionRNA*)func->cont.prev)->identifier); + if(func->cont.prev) fprintf(f, "(FunctionRNA*)&rna_%s_%s_func,\n", srna->identifier, ((FunctionRNA*)func->cont.prev)->identifier); else fprintf(f, "NULL,\n"); parm= func->cont.properties.first; @@ -1749,11 +1794,11 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) } func= srna->functions.first; - if(func) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s, ", srna->identifier, func->identifier); + if(func) fprintf(f, "\t{(FunctionRNA*)&rna_%s_%s_func, ", srna->identifier, func->identifier); else fprintf(f, "\t{NULL, "); func= srna->functions.last; - if(func) fprintf(f, "(FunctionRNA*)&rna_%s_%s}\n", srna->identifier, func->identifier); + if(func) fprintf(f, "(FunctionRNA*)&rna_%s_%s_func}\n", srna->identifier, func->identifier); else fprintf(f, "NULL}\n"); fprintf(f, "};\n"); @@ -1763,63 +1808,64 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) typedef struct RNAProcessItem { char *filename; + char *api_filename; void (*define)(BlenderRNA *brna); } RNAProcessItem; RNAProcessItem PROCESS_ITEMS[]= { - {"rna_rna.c", RNA_def_rna}, - {"rna_ID.c", RNA_def_ID}, - {"rna_texture.c", RNA_def_texture}, - {"rna_action.c", RNA_def_action}, - {"rna_animation.c", RNA_def_animation}, - {"rna_actuator.c", RNA_def_actuator}, - {"rna_armature.c", RNA_def_armature}, - {"rna_brush.c", RNA_def_brush}, - {"rna_camera.c", RNA_def_camera}, - {"rna_cloth.c", RNA_def_cloth}, - {"rna_color.c", RNA_def_color}, - {"rna_constraint.c", RNA_def_constraint}, - {"rna_context.c", RNA_def_context}, - {"rna_controller.c", RNA_def_controller}, - {"rna_curve.c", RNA_def_curve}, - {"rna_fcurve.c", RNA_def_fcurve}, - {"rna_fluidsim.c", RNA_def_fluidsim}, - {"rna_group.c", RNA_def_group}, - {"rna_image.c", RNA_def_image}, - {"rna_key.c", RNA_def_key}, - {"rna_lamp.c", RNA_def_lamp}, - {"rna_lattice.c", RNA_def_lattice}, - {"rna_main.c", RNA_def_main}, - {"rna_material.c", RNA_def_material}, - {"rna_mesh.c", RNA_def_mesh}, - {"rna_meta.c", RNA_def_meta}, - {"rna_modifier.c", RNA_def_modifier}, - {"rna_nodetree.c", RNA_def_nodetree}, - {"rna_object.c", RNA_def_object}, - {"rna_object_force.c", RNA_def_object_force}, - {"rna_packedfile.c", RNA_def_packedfile}, - {"rna_particle.c", RNA_def_particle}, - {"rna_pose.c", RNA_def_pose}, - {"rna_property.c", RNA_def_gameproperty}, - {"rna_radio.c", RNA_def_radio}, - {"rna_scene.c", RNA_def_scene}, - {"rna_screen.c", RNA_def_screen}, - {"rna_scriptlink.c", RNA_def_scriptlink}, - {"rna_sensor.c", RNA_def_sensor}, - {"rna_sequence.c", RNA_def_sequence}, - {"rna_space.c", RNA_def_space}, - {"rna_text.c", RNA_def_text}, - {"rna_timeline.c", RNA_def_timeline_marker}, - {"rna_sound.c", RNA_def_sound}, - {"rna_ui.c", RNA_def_ui}, - {"rna_userdef.c", RNA_def_userdef}, - {"rna_vfont.c", RNA_def_vfont}, - {"rna_vpaint.c", RNA_def_vpaint}, - {"rna_wm.c", RNA_def_wm}, - {"rna_world.c", RNA_def_world}, + {"rna_rna.c", NULL, RNA_def_rna}, + {"rna_ID.c", NULL, RNA_def_ID}, + {"rna_texture.c", NULL, RNA_def_texture}, + {"rna_action.c", NULL, RNA_def_action}, + {"rna_animation.c", NULL, RNA_def_animation}, + {"rna_actuator.c", NULL, RNA_def_actuator}, + {"rna_armature.c", NULL, RNA_def_armature}, + {"rna_brush.c", NULL, RNA_def_brush}, + {"rna_camera.c", NULL, RNA_def_camera}, + {"rna_cloth.c", NULL, RNA_def_cloth}, + {"rna_color.c", NULL, RNA_def_color}, + {"rna_constraint.c", NULL, RNA_def_constraint}, + {"rna_context.c", NULL, RNA_def_context}, + {"rna_controller.c", NULL, RNA_def_controller}, + {"rna_curve.c", NULL, RNA_def_curve}, + {"rna_fcurve.c", NULL, RNA_def_fcurve}, + {"rna_fluidsim.c", NULL, RNA_def_fluidsim}, + {"rna_group.c", NULL, RNA_def_group}, + {"rna_image.c", NULL, RNA_def_image}, + {"rna_key.c", NULL, RNA_def_key}, + {"rna_lamp.c", NULL, RNA_def_lamp}, + {"rna_lattice.c", NULL, RNA_def_lattice}, + {"rna_main.c", "rna_main_api.c", RNA_def_main}, + {"rna_material.c", NULL, RNA_def_material}, + {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, + {"rna_meta.c", NULL, RNA_def_meta}, + {"rna_modifier.c", NULL, RNA_def_modifier}, + {"rna_nodetree.c", NULL, RNA_def_nodetree}, + {"rna_object.c", "rna_object_api.c", RNA_def_object}, + {"rna_object_force.c", NULL, RNA_def_object_force}, + {"rna_packedfile.c", NULL, RNA_def_packedfile}, + {"rna_particle.c", NULL, RNA_def_particle}, + {"rna_pose.c", NULL, RNA_def_pose}, + {"rna_property.c", NULL, RNA_def_gameproperty}, + {"rna_radio.c", NULL, RNA_def_radio}, + {"rna_scene.c", NULL, RNA_def_scene}, + {"rna_screen.c", NULL, RNA_def_screen}, + {"rna_scriptlink.c", NULL, RNA_def_scriptlink}, + {"rna_sensor.c", NULL, RNA_def_sensor}, + {"rna_sequence.c", NULL, RNA_def_sequence}, + {"rna_space.c", NULL, RNA_def_space}, + {"rna_text.c", NULL, RNA_def_text}, + {"rna_timeline.c", NULL, RNA_def_timeline_marker}, + {"rna_sound.c", NULL, RNA_def_sound}, + {"rna_ui.c", "rna_ui_api.c", RNA_def_ui}, + {"rna_userdef.c", NULL, RNA_def_userdef}, + {"rna_vfont.c", NULL, RNA_def_vfont}, + {"rna_vpaint.c", NULL, RNA_def_vpaint}, + {"rna_wm.c", "rna_wm_api.c", RNA_def_wm}, + {"rna_world.c", NULL, RNA_def_world}, {NULL, NULL}}; -static void rna_generate(BlenderRNA *brna, FILE *f, char *filename) +static void rna_generate(BlenderRNA *brna, FILE *f, char *filename, char *api_filename) { StructDefRNA *ds; PropertyDefRNA *dp; @@ -1837,7 +1883,9 @@ static void rna_generate(BlenderRNA *brna, FILE *f, char *filename) fprintf(f, "#include \"BLI_blenlib.h\"\n\n"); + fprintf(f, "#include \"BKE_context.h\"\n"); fprintf(f, "#include \"BKE_library.h\"\n"); + fprintf(f, "#include \"BKE_report.h\"\n"); fprintf(f, "#include \"BKE_utildefines.h\"\n\n"); fprintf(f, "#include \"RNA_define.h\"\n"); @@ -1846,7 +1894,10 @@ static void rna_generate(BlenderRNA *brna, FILE *f, char *filename) rna_generate_prototypes(brna, f); - fprintf(f, "#include \"%s\"\n\n", filename); + fprintf(f, "#include \"%s\"\n", filename); + if(api_filename) + fprintf(f, "#include \"%s\"\n", api_filename); + fprintf(f, "\n"); fprintf(f, "/* Autogenerated Functions */\n\n"); @@ -2169,7 +2220,7 @@ static int rna_preprocess(char *outfile) status = 1; } else { - rna_generate(brna, file, PROCESS_ITEMS[i].filename); + rna_generate(brna, file, PROCESS_ITEMS[i].filename, PROCESS_ITEMS[i].api_filename); fclose(file); status= (DefRNA.error != 0); diff --git a/source/blender/makesrna/intern/mesh_api.c b/source/blender/makesrna/intern/mesh_api.c deleted file mode 100644 index e9437e29f81..00000000000 --- a/source/blender/makesrna/intern/mesh_api.c +++ /dev/null @@ -1,42 +0,0 @@ -#include - -#include "DNA_mesh_types.h" -#include "DNA_scene_types.h" -#include "DNA_object_types.h" - -#include "BLI_blenlib.h" - -#include "BKE_DerivedMesh.h" -#include "BKE_mesh.h" - - -/* -void RNA_api_mesh_copy(Mesh *me, Mesh *from) -{ - copy_mesh_data(me, from); -} - -void RNA_api_mesh_copy_applied(Mesh *me, Scene *sce, Object *ob) -{ - DerivedMesh *dm= mesh_create_derived_view(sce, ob, CD_MASK_MESH); - DM_to_mesh(dm, me); - dm->release(dm); -} -*/ - -/* copied from init_render_mesh (render code) */ -void RNA_api_mesh_make_rendermesh(Mesh *me, Scene *sce, Object *ob) -{ - CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; - DerivedMesh *dm= mesh_create_derived_render(sce, ob, mask); - - /* XXX report reason */ - if(dm==NULL) return; - - DM_to_mesh(dm, me); - dm->release(dm); -} - -void RNA_api_mesh_transform(Mesh *me, float **mat) -{ -} diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 56eda4eb735..52680e26afe 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -246,12 +246,6 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "lib"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Library", "Library file the datablock is linked from."); - - /* XXX temporary for testing */ - func= RNA_def_function(srna, "rename", "rename_id"); - RNA_def_function_ui_description(func, "Rename this ID datablock."); - prop= RNA_def_string(func, "name", "", 0, "", "New name for the datablock."); - RNA_def_property_flag(prop, PROP_REQUIRED); } static void rna_def_library(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index d015f400e54..cfddb1daf10 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -33,7 +33,9 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BKE_context.h" #include "BKE_idprop.h" +#include "BKE_report.h" #include "BKE_utildefines.h" #include "WM_api.h" @@ -725,7 +727,7 @@ int RNA_property_animated(PointerRNA *ptr, PropertyRNA *prop) return 0; } -void RNA_property_update(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop) +void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop) { prop= rna_ensure_property(prop); @@ -1321,7 +1323,7 @@ int RNA_property_collection_length(PointerRNA *ptr, PropertyRNA *prop) void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr) { IDProperty *idprop; - CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDPropertyTemplate val = {0}; @@ -1347,9 +1349,15 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA MEM_freeN(item); } } +#if 0 else if(cprop->add){ - cprop->add(ptr, r_ptr); + if(!(cprop->add->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ + ParameterList *params= RNA_parameter_list_create(ptr, cprop->add); + RNA_function_call(NULL, NULL, ptr, cprop->add, params); + RNA_parameter_list_free(params); + } } +#endif else printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier); @@ -1369,6 +1377,7 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) { IDProperty *idprop; + //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; if((idprop=rna_idproperty_check(&prop, ptr))) { IDProperty tmp, *array; @@ -1389,6 +1398,15 @@ void RNA_property_collection_remove(PointerRNA *ptr, PropertyRNA *prop, int key) } } else if(prop->flag & PROP_IDPROPERTY); +#if 0 + else if(cprop->remove){ + if(!(cprop->remove->flag & FUNC_USE_CONTEXT)) { /* XXX check for this somewhere else */ + ParameterList *params= RNA_parameter_list_create(ptr, cprop->remove); + RNA_function_call(NULL, NULL, ptr, cprop->remove, params); + RNA_parameter_list_free(params); + } + } +#endif else printf("RNA_property_collection_remove %s.%s: only supported for id properties.\n", ptr->type->identifier, prop->identifier); } @@ -1521,13 +1539,6 @@ void rna_iterator_listbase_end(CollectionPropertyIterator *iter) iter->internal= NULL; } -void *rna_iterator_listbase_add(ListBase *lb, void *item) -{ - BLI_addtail(lb, item); - - return item; -} - void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, IteratorSkipFunc skip) { ArrayIterator *internal; @@ -1585,21 +1596,6 @@ void rna_iterator_array_end(CollectionPropertyIterator *iter) iter->internal= NULL; } -void *rna_iterator_array_add(void *ptr, int itemsize, int length, void *item) -{ - // alloc new block, copy old data - void *newptr= MEM_callocN(length * itemsize + itemsize, "RNA collection add"); - memcpy(newptr, ptr, length * itemsize); - - // copy new item - memcpy(((char*)newptr) + length * itemsize, item, itemsize); - - // free old block - MEM_freeN(ptr); - - return newptr; -} - /* RNA Path - Experiment */ static char *rna_path_token(const char **path, char *fixedbuf, int fixedlen, int bracket) @@ -2550,10 +2546,10 @@ void RNA_parameter_set_lookup(ParameterList *parms, const char *identifier, void RNA_parameter_set(parms, parm, value); } -int RNA_function_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) +int RNA_function_call(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) { if(func->call) { - func->call(ptr, parms); + func->call(C, reports, ptr, parms); return 0; } @@ -2561,33 +2557,33 @@ int RNA_function_call(PointerRNA *ptr, FunctionRNA *func, ParameterList *parms) return -1; } -int RNA_function_call_lookup(PointerRNA *ptr, const char *identifier, ParameterList *parms) +int RNA_function_call_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, const char *identifier, ParameterList *parms) { FunctionRNA *func; func= RNA_struct_find_function(ptr, identifier); if(func) - return RNA_function_call(ptr, func, parms); + return RNA_function_call(C, reports, ptr, func, parms); return -1; } -int RNA_function_call_direct(PointerRNA *ptr, FunctionRNA *func, const char *format, ...) +int RNA_function_call_direct(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, ...) { va_list args; int ret; va_start(args, format); - ret= RNA_function_call_direct_va(ptr, func, format, args); + ret= RNA_function_call_direct_va(C, reports, ptr, func, format, args); va_end(args); return ret; } -int RNA_function_call_direct_lookup(PointerRNA *ptr, const char *identifier, const char *format, ...) +int RNA_function_call_direct_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, ...) { FunctionRNA *func; @@ -2599,7 +2595,7 @@ int RNA_function_call_direct_lookup(PointerRNA *ptr, const char *identifier, con va_start(args, format); - ret= RNA_function_call_direct_va(ptr, func, format, args); + ret= RNA_function_call_direct_va(C, reports, ptr, func, format, args); va_end(args); @@ -2741,7 +2737,7 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop return 0; } -int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args) +int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *ptr, FunctionRNA *func, const char *format, va_list args) { PointerRNA funcptr; ParameterList *parms; @@ -2836,7 +2832,7 @@ int RNA_function_call_direct_va(PointerRNA *ptr, FunctionRNA *func, const char * } if (err==0) - err= RNA_function_call(ptr, func, parms); + err= RNA_function_call(C, reports, ptr, func, parms); /* XXX throw error when more parameters than those needed are passed or leave silent? */ if (err==0 && pret && ofs -#include - -#include "RNA_define.h" -#include "RNA_types.h" - -#include "UI_interface.h" - - -void RNA_api_main(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *prop; - - func= RNA_def_function(srna, "add_mesh", "RNA_api_main_add_mesh"); - RNA_def_function_ui_description(func, "Add a new mesh."); - prop= RNA_def_string(func, "name", "", 0, "", "New name for the datablock."); - RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_pointer(func, "mesh", "Mesh", "", "A new mesh."); - RNA_def_function_return(func, prop); - - func= RNA_def_function(srna, "remove_mesh", "RNA_api_main_remove_mesh"); - RNA_def_function_ui_description(func, "Remove a mesh if it has only one user."); - prop= RNA_def_pointer(func, "mesh", "Mesh", "", "A mesh to remove."); - RNA_def_property_flag(prop, PROP_REQUIRED); -} - -void RNA_api_mesh(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *prop; - - /* - func= RNA_def_function(srna, "copy", "RNA_api_mesh_copy"); - RNA_def_function_ui_description(func, "Copy mesh data."); - prop= RNA_def_pointer(func, "src", "Mesh", "", "A mesh to copy data from."); - RNA_def_property_flag(prop, PROP_REQUIRED);*/ - - func= RNA_def_function(srna, "make_rendermesh", "RNA_api_mesh_make_rendermesh"); - RNA_def_function_ui_description(func, "Copy mesh data from object with all modifiers applied."); - prop= RNA_def_pointer(func, "sce", "Scene", "", "Scene."); - RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_pointer(func, "ob", "Object", "", "Object to copy data from."); - RNA_def_property_flag(prop, PROP_REQUIRED); - - /* - func= RNA_def_function(srna, "add_geom", "RNA_api_mesh_add_geom"); - RNA_def_function_ui_description(func, "Add geometry data to mesh."); - prop= RNA_def_collection(func, "verts", "?", "", "Vertices."); - RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_collection(func, "faces", "?", "", "Faces."); - RNA_def_property_flag(prop, PROP_REQUIRED); - */ -} - -void RNA_api_wm(StructRNA *srna) -{ - FunctionRNA *func; - PropertyRNA *prop; - - func= RNA_def_function(srna, "add_fileselect", "RNA_api_wm_add_fileselect"); - RNA_def_function_ui_description(func, "Show up the file selector."); - prop= RNA_def_pointer(func, "context", "Context", "", "Context."); - RNA_def_property_flag(prop, PROP_REQUIRED); - prop= RNA_def_pointer(func, "op", "Operator", "", "Operator to call."); - RNA_def_property_flag(prop, PROP_REQUIRED); -} - diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 919ae210801..361c1b61303 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -31,6 +31,8 @@ #include "rna_internal.h" #include "BKE_cloth.h" +#include "BKE_modifier.h" + #include "DNA_cloth_types.h" #ifdef RNA_RUNTIME @@ -129,6 +131,22 @@ static void rna_ClothSettings_gravity_set(PointerRNA *ptr, const float *values) sim->gravity[2]= values[2]; } +static char *rna_ClothSettings_path(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + + return BLI_sprintfN("modifiers[%s].settings", md->name); +} + +static char *rna_ClothCollisionSettings_path(PointerRNA *ptr) +{ + Object *ob= (Object*)ptr->id.data; + ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + + return BLI_sprintfN("modifiers[%s].collision_settings", md->name); +} + #else static void rna_def_cloth_sim_settings(BlenderRNA *brna) @@ -139,6 +157,7 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) srna = RNA_def_struct(brna, "ClothSettings", NULL); RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object."); RNA_def_struct_sdna(srna, "ClothSimSettings"); + RNA_def_struct_path_func(srna, "rna_ClothSettings_path"); /* goal */ @@ -297,6 +316,7 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna) srna = RNA_def_struct(brna, "ClothCollisionSettings", NULL); RNA_def_struct_ui_text(srna, "Cloth Collision Settings", "Cloth simulation settings for self collision and collision with other objects."); RNA_def_struct_sdna(srna, "ClothCollSettings"); + RNA_def_struct_path_func(srna, "rna_ClothCollisionSettings_path"); /* general collision */ diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 4b34680c07f..179808ab66d 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -212,7 +212,7 @@ static void rna_def_curvemapping(BlenderRNA *brna) RNA_def_property_float_funcs(prop, NULL, NULL, "rna_CurveMapping_clipmaxy_range"); prop= RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_CurveMapping_curves_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_CurveMapping_curves_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "CurveMap"); RNA_def_property_ui_text(prop, "Curves", ""); diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index de648af14b6..07a50235733 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -102,7 +102,6 @@ void RNA_def_context(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - FunctionRNA *func; srna= RNA_def_struct(brna, "Context", NULL); RNA_def_struct_ui_text(srna, "Context", "Current windowmanager and data context."); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 137230b681b..41a47e279e9 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -605,7 +605,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna) prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "bp", NULL); RNA_def_property_struct_type(prop, "CurvePoint"); - RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Points", "Collection of points for Poly and Nurbs curves."); prop= RNA_def_property(srna, "bezier_points", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 4b6e595e001..d91f538d412 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -604,7 +604,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char * if(DefRNA.preprocess) { RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", "rna_iterator_listbase_end", "rna_builtin_properties_get", 0, 0, 0, 0, 0); } else { #ifdef RNA_RUNTIME @@ -1776,7 +1776,7 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch } } -void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add) +void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *add, const char *remove) { StructRNA *srna= DefRNA.laststruct; @@ -1796,7 +1796,8 @@ void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, con if(length) cprop->length= (PropCollectionLengthFunc)length; if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint; if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring; - if(add) cprop->add= (PropCollectionAddFunc)add; + if(add) cprop->add= (FunctionRNA*)add; + if(remove) cprop->remove= (FunctionRNA*)remove; break; } default: diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c index f284423ef7f..1406ad1ae60 100644 --- a/source/blender/makesrna/intern/rna_group.c +++ b/source/blender/makesrna/intern/rna_group.c @@ -61,7 +61,7 @@ void RNA_def_group(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects."); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, 0, 0); prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layer", 1); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index f38c3aac71d..61cde5a01a3 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -188,29 +188,11 @@ void rna_object_vcollayer_name_set(struct PointerRNA *ptr, const char *value, ch /* API functions */ -void RNA_api_ui_layout(struct StructRNA *srna); +void RNA_api_main(struct StructRNA *srna); void RNA_api_mesh(struct StructRNA *srna); +void RNA_api_object(struct StructRNA *srna); +void RNA_api_ui_layout(struct StructRNA *srna); void RNA_api_wm(struct StructRNA *srna); -void RNA_api_main(StructRNA *srna); - -#ifdef RNA_RUNTIME - -struct wmWindowManager; -struct bContext; -struct wmOperator; -struct Main; -struct Mesh; -struct Scene; -struct Object; - -void RNA_api_wm_add_fileselect(struct wmWindowManager *self, struct bContext *C, struct wmOperator *op); - -struct Mesh *RNA_api_main_add_mesh(struct Main *main, char *name); -void RNA_api_main_remove_mesh(struct Main *main, struct Mesh *me); - -void RNA_api_mesh_make_rendermesh(struct Mesh *me, struct Scene *sce, struct Object *ob); - -#endif /* ID Properties */ @@ -251,9 +233,6 @@ void rna_iterator_listbase_next(struct CollectionPropertyIterator *iter); void *rna_iterator_listbase_get(struct CollectionPropertyIterator *iter); void rna_iterator_listbase_end(struct CollectionPropertyIterator *iter); -/* experimental */ -void *rna_iterator_listbase_add(ListBase *lb, void *item); - typedef struct ArrayIterator { char *ptr; char *endptr; @@ -267,9 +246,6 @@ void *rna_iterator_array_get(struct CollectionPropertyIterator *iter); void *rna_iterator_array_dereference_get(struct CollectionPropertyIterator *iter); void rna_iterator_array_end(struct CollectionPropertyIterator *iter); -/* experimental */ -void *rna_iterator_array_add(void *ptr, int itemsize, int length, void *item); - /* Duplicated code since we can't link in blenlib */ void rna_addtail(struct ListBase *listbase, void *vlink); diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index 0140f2b091e..d93e6f4d7cf 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -78,7 +78,6 @@ typedef PointerRNA (*PropCollectionGetFunc)(struct CollectionPropertyIterator *i typedef int (*PropCollectionLengthFunc)(struct PointerRNA *ptr); typedef PointerRNA (*PropCollectionLookupIntFunc)(struct PointerRNA *ptr, int key); typedef PointerRNA (*PropCollectionLookupStringFunc)(struct PointerRNA *ptr, const char *key); -typedef void (*PropCollectionAddFunc)(PointerRNA *ptr, PointerRNA *ptr_item); /* Container - generic abstracted container of RNA properties */ typedef struct ContainerRNA { @@ -246,7 +245,7 @@ typedef struct CollectionPropertyRNA { PropCollectionLengthFunc length; /* optional */ PropCollectionLookupIntFunc lookupint; /* optional */ PropCollectionLookupStringFunc lookupstring; /* optional */ - PropCollectionAddFunc add; + FunctionRNA *add, *remove; struct StructRNA *type; } CollectionPropertyRNA; diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 5bff90df962..b97dd95c4d4 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -335,7 +335,7 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "data", "totelem"); RNA_def_property_struct_type(prop, "UnknownType"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_ShapeKey_data_begin", 0, 0, "rna_ShapeKey_data_get", "rna_ShapeKey_data_length", 0, 0, 0, 0); } static void rna_def_key(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 01999731f74..3af448b0233 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -99,7 +99,7 @@ static void rna_def_latticepoint(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Deformed Location", ""); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_LatticePoint_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_struct_type(prop, "VertexGroupElement"); RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this point is member of."); } @@ -159,7 +159,7 @@ static void rna_def_lattice(BlenderRNA *brna) prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "LatticePoint"); - RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Lattice_points_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Points", "Points of the lattice."); } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 78e1c7fb435..8d98036290a 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -219,7 +219,6 @@ void RNA_def_main(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - FunctionRNA *func; const char *lists[][5]= { {"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."}, @@ -265,7 +264,7 @@ void RNA_def_main(BlenderRNA *brna) { prop= RNA_def_property(srna, lists[i][0], PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, lists[i][1]); - RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, lists[i][2], "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, "add_mesh", "remove_mesh"); RNA_def_property_ui_text(prop, lists[i][3], lists[i][4]); } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c new file mode 100644 index 00000000000..6d56b2b00f9 --- /dev/null +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -0,0 +1,81 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_main.h" +#include "BKE_mesh.h" +#include "BKE_library.h" + +#include "DNA_mesh_types.h" + +Mesh *rna_Main_add_mesh(Main *main, char *name) +{ + Mesh *me= add_mesh(name); + me->id.us--; + return me; +} + +void rna_Main_remove_mesh(Main *main, ReportList *reports, Mesh *me) +{ + if(me->id.us == 0) + free_libblock(&main->mesh, me); + else + BKE_report(reports, RPT_ERROR, "Mesh must have zero users to be removed."); + + /* XXX python now has invalid pointer? */ +} + +#else + +void RNA_api_main(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *prop; + + func= RNA_def_function(srna, "add_mesh", "rna_Main_add_mesh"); + RNA_def_function_ui_description(func, "Add a new mesh."); + prop= RNA_def_string(func, "name", "Mesh", 0, "", "New name for the datablock."); + prop= RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh."); + RNA_def_function_return(func, prop); + + func= RNA_def_function(srna, "remove_mesh", "rna_Main_remove_mesh"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a mesh if it has zero users."); + prop= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh to remove."); + RNA_def_property_flag(prop, PROP_REQUIRED); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index b055b8d2f56..41f31594f6e 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -1143,7 +1143,7 @@ void rna_def_mtex_common(StructRNA *srna, const char *begin, const char *activeg /* mtex */ prop= RNA_def_property(srna, "textures", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, structname); - RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, begin, "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures."); prop= RNA_def_property(srna, "active_texture", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 3e5a26c8bd1..653f9d61fa5 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -484,33 +484,6 @@ static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value) tf->tpage= (struct Image*)id; } -static void rna_Mesh_verts_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - Mesh *me= (Mesh*)ptr->data; - rna_iterator_array_begin(iter, me->mvert, sizeof(MVert), me->totvert, NULL); -} - -/* extern struct EditVert *addvertlist(EditMesh *em, float *vec, struct EditVert *example); */ - -static void rna_Mesh_verts_add(PointerRNA *ptr, PointerRNA *ptr_item) -{ - Mesh *me= (Mesh*)ptr->data; - - /* - // XXX if item is not MVert we fail silently - if (item->type == RNA_MeshVertex) - return; - - // XXX this must be slow... - EditMesh *em= BKE_mesh_get_editmesh(me); - - MVert *v = (MVert*)ptr_item->ptr->data; - addvertlist(em, v->co, NULL); - - BKE_mesh_end_editmesh(me, em); - */ -} - /* path construction */ static char *rna_VertexGroupElement_path(PointerRNA *ptr) @@ -673,7 +646,7 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier 'Only Vertices' option"); prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshVertex_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_struct_type(prop, "VertexGroupElement"); RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of."); } @@ -788,7 +761,7 @@ static void rna_def_mtface(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshTextureFace"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshTextureFaceLayer_data_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshTextureFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshTextureFaceLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshTextureFace", NULL); RNA_def_struct_sdna(srna, "MTFace"); @@ -925,7 +898,7 @@ static void rna_def_mcol(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshColor"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshColorLayer_data_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshColorLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshColorLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshColor", NULL); RNA_def_struct_sdna(srna, "MCol"); @@ -971,7 +944,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshFloatProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshFloatPropertyLayer_data_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshFloatPropertyLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshFloatProperty", NULL); RNA_def_struct_sdna(srna, "MFloatProperty"); @@ -995,7 +968,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshIntProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshIntPropertyLayer_data_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshIntPropertyLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshIntProperty", NULL); RNA_def_struct_sdna(srna, "MIntProperty"); @@ -1019,7 +992,7 @@ static void rna_def_mproperties(BlenderRNA *brna) prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "MeshStringProperty"); RNA_def_property_ui_text(prop, "Data", ""); - RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshStringPropertyLayer_data_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_MeshStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_MeshStringPropertyLayer_data_length", 0, 0, 0, 0); srna= RNA_def_struct(brna, "MeshStringProperty", NULL); RNA_def_struct_sdna(srna, "MStringProperty"); @@ -1076,7 +1049,7 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert"); RNA_def_property_struct_type(prop, "MeshVertex"); RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh."); - RNA_def_property_collection_funcs(prop, "rna_Mesh_verts_begin", 0, 0, 0, 0, 0, 0, "rna_Mesh_verts_add"); + // XXX RNA_def_property_collection_funcs(prop, "rna_Mesh_verts_begin", 0, 0, 0, 0, 0, 0, "add_verts", "remove_verts"); prop= RNA_def_property(srna, "edges", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "medge", "totedge"); @@ -1095,31 +1068,31 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshTextureFaceLayer"); RNA_def_property_ui_text(prop, "UV Layers", ""); prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshColorLayer"); RNA_def_property_ui_text(prop, "Vertex Color Layers", ""); prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshFloatPropertyLayer"); RNA_def_property_ui_text(prop, "Float Property Layers", ""); prop= RNA_def_property(srna, "int_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshIntPropertyLayer"); RNA_def_property_ui_text(prop, "Int Property Layers", ""); prop= RNA_def_property(srna, "string_layers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer"); - RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0, 0, 0); RNA_def_property_struct_type(prop, "MeshStringPropertyLayer"); RNA_def_property_ui_text(prop, "String Property Layers", ""); diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c new file mode 100644 index 00000000000..26fb77777d7 --- /dev/null +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -0,0 +1,108 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_customdata.h" +#include "BKE_DerivedMesh.h" + +#include "DNA_mesh_types.h" +#include "DNA_scene_types.h" + +/* +void rna_Mesh_copy(Mesh *me, Mesh *from) +{ + copy_mesh_data(me, from); +} + +void rna_Mesh_copy_applied(Mesh *me, Scene *sce, Object *ob) +{ + DerivedMesh *dm= mesh_create_derived_view(sce, ob, CD_MASK_MESH); + DM_to_mesh(dm, me); + dm->release(dm); +} +*/ + +void rna_Mesh_transform(Mesh *me, float **mat) +{ +} + +#if 0 +/* extern struct EditVert *addvertlist(EditMesh *em, float *vec, struct EditVert *example); */ + +static void rna_Mesh_verts_add(PointerRNA *ptr, PointerRNA *ptr_item) +{ + //Mesh *me= (Mesh*)ptr->data; + + /* + // XXX if item is not MVert we fail silently + if (item->type == RNA_MeshVertex) + return; + + // XXX this must be slow... + EditMesh *em= BKE_mesh_get_editmesh(me); + + MVert *v = (MVert*)ptr_item->ptr->data; + addvertlist(em, v->co, NULL); + + BKE_mesh_end_editmesh(me, em); + */ +} +#endif + +#else + +void RNA_api_mesh(StructRNA *srna) +{ + /*FunctionRNA *func; + PropertyRNA *prop;*/ + + /* + func= RNA_def_function(srna, "copy", "rna_Mesh_copy"); + RNA_def_function_ui_description(func, "Copy mesh data."); + prop= RNA_def_pointer(func, "src", "Mesh", "", "A mesh to copy data from."); + RNA_def_property_flag(prop, PROP_REQUIRED);*/ + + /* + func= RNA_def_function(srna, "add_geom", "rna_Mesh_add_geom"); + RNA_def_function_ui_description(func, "Add geometry data to mesh."); + prop= RNA_def_collection(func, "verts", "?", "", "Vertices."); + RNA_def_property_flag(prop, PROP_REQUIRED); + prop= RNA_def_collection(func, "faces", "?", "", "Faces."); + RNA_def_property_flag(prop, PROP_REQUIRED); + */ +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index cc893774ebd..dab7a94584f 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1089,7 +1089,7 @@ static void rna_def_modifier_uvproject(BlenderRNA *brna) prop= RNA_def_property(srna, "projectors", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_UVProject_projectors_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_dereference_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Projectors", ""); prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9c1764802fa..ff9777d283e 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -584,7 +584,7 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Debug State", "Print state debug info in the game engine."); } -static StructRNA *rna_def_object(BlenderRNA *brna) +static void rna_def_object(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -739,7 +739,7 @@ static StructRNA *rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); RNA_def_property_struct_type(prop, "MaterialSlot"); - RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0, 0); /* don't dereference pointer! */ + RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, "rna_iterator_array_get", 0, 0, 0, 0, 0); /* don't dereference pointer! */ RNA_def_property_ui_text(prop, "Materials", "Material slots in the object."); prop= RNA_def_property(srna, "active_material", PROP_POINTER, PROP_NONE); @@ -799,11 +799,11 @@ static StructRNA *rna_def_object(BlenderRNA *brna) RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface."); - /* - // error on compile - prop= RNA_def_float_matrix(srna, "mat", 16, NULL, 0.0f, 0.0f, "Matrix", "Transform matrix of the object.", 0.0f, 0.0f); + /* matrix */ + prop= RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "obmat"); - */ + RNA_def_property_array(prop, 16); + RNA_def_property_ui_text(prop, "Matrix", "Transformation matrix."); /* collections */ prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); @@ -1109,8 +1109,8 @@ static StructRNA *rna_def_object(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "shapenr"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key index."); - - return srna; + + RNA_api_object(srna); } void RNA_def_object(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c new file mode 100644 index 00000000000..053ab115b3b --- /dev/null +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -0,0 +1,83 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_customdata.h" +#include "BKE_DerivedMesh.h" + +#include "DNA_mesh_types.h" +#include "DNA_scene_types.h" + +/* copied from init_render_mesh (render code) */ +Mesh *rna_Object_create_render_mesh(Object *ob, Scene *scene) +{ + CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; + DerivedMesh *dm; + Mesh *me; + + /* TODO: other types */ + if(ob->type != OB_MESH) + return NULL; + + dm= mesh_create_derived_render(scene, ob, mask); + + if(!dm) + return NULL; + + me= add_mesh("tmp_render_mesh"); + me->id.us--; /* we don't assign it to anything */ + DM_to_mesh(dm, me); + dm->release(dm); + + return me; +} + +#else + +void RNA_api_object(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *prop; + + func= RNA_def_function(srna, "create_render_mesh", "rna_Object_create_render_mesh"); + RNA_def_function_ui_description(func, "Create a Mesh datablock with all modifiers applied."); + prop= RNA_def_pointer(func, "scene", "Scene", "", ""); + RNA_def_property_flag(prop, PROP_REQUIRED); + prop= RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export."); + RNA_def_function_return(func, prop); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 0d621ef604a..bd3a8ae5580 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -611,13 +611,13 @@ static void rna_def_struct(BlenderRNA *brna) prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Struct_properties_begin", "rna_Struct_properties_next", "rna_iterator_listbase_end", "rna_Struct_properties_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Properties", "Properties in the struct."); prop= RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Function"); - RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", "rna_iterator_listbase_end", "rna_Struct_functions_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", "rna_iterator_listbase_end", "rna_Struct_functions_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Functions", ""); } @@ -719,7 +719,7 @@ static void rna_def_function(BlenderRNA *brna) prop= RNA_def_property(srna, "parameters", PROP_COLLECTION, PROP_NONE); /*RNA_def_property_clear_flag(prop, PROP_EDITABLE);*/ RNA_def_property_struct_type(prop, "Property"); - RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_Function_parameters_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Parameters", "Parameters for the function."); prop= RNA_def_property(srna, "registered", PROP_BOOLEAN, PROP_NONE); @@ -800,7 +800,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "items", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "EnumPropertyItem"); - RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_EnumProperty_items_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Items", "Possible values for the property."); srna= RNA_def_struct(brna, "EnumPropertyItem", NULL); @@ -895,7 +895,7 @@ void RNA_def_rna(BlenderRNA *brna) prop= RNA_def_property(srna, "structs", PROP_COLLECTION, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "Struct"); - RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, "rna_BlenderRNA_structs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0, 0, 0); RNA_def_property_ui_text(prop, "Structs", ""); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 27f46fe5fcc..1365ab75fc7 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -866,7 +866,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "base", NULL); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_ui_text(prop, "Objects", ""); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0, 0); prop= RNA_def_property(srna, "visible_layers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); diff --git a/source/blender/makesrna/intern/rna_sequence.c b/source/blender/makesrna/intern/rna_sequence.c index f21982cc3cd..055e67fb135 100644 --- a/source/blender/makesrna/intern/rna_sequence.c +++ b/source/blender/makesrna/intern/rna_sequence.c @@ -521,7 +521,7 @@ void rna_def_editor(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "metastack", NULL); RNA_def_property_struct_type(prop, "Sequence"); RNA_def_property_ui_text(prop, "Meta Stack", "Meta strip stack, last is currently edited meta strip."); - RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0, 0); + RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_SequenceEdtior_meta_stack_get", 0, 0, 0, 0, 0); prop= RNA_def_property(srna, "active_strip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act_seq"); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c new file mode 100644 index 00000000000..d06d4d4406d --- /dev/null +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -0,0 +1,251 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "RNA_define.h" +#include "RNA_types.h" + +#include "UI_interface.h" +#include "UI_resources.h" + +#ifdef RNA_RUNTIME + +#else + +#define DEF_ICON(name) {name, #name, 0, #name, ""}, +static EnumPropertyItem icon_items[] = { +#include "UI_icons.h" + {0, NULL, 0, NULL, NULL}}; +#undef DEF_ICON + +static void api_ui_item_common(FunctionRNA *func) +{ + PropertyRNA *prop; + + RNA_def_string(func, "text", "", 0, "", "Override automatic text of the item."); + + prop= RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, icon_items); + RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item."); + +} + +static void api_ui_item_op_common(FunctionRNA *func) +{ + PropertyRNA *parm; + + api_ui_item_common(func); + parm= RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); +} + +static void api_ui_item_rna_common(FunctionRNA *func) +{ + PropertyRNA *parm; + + parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data."); + RNA_def_property_flag(parm, PROP_REQUIRED); +} + +void RNA_api_ui_layout(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + static EnumPropertyItem curve_type_items[] = { + {0, "NONE", 0, "None", ""}, + {'v', "VECTOR", 0, "Vector", ""}, + {'c', "COLOR", 0, "Color", ""}, + {0, NULL, 0, NULL, NULL}}; + + /* simple layout specifiers */ + func= RNA_def_function(srna, "row", "uiLayoutRow"); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); + RNA_def_boolean(func, "align", 0, "", "Align buttons to each other."); + + func= RNA_def_function(srna, "column", "uiLayoutColumn"); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); + RNA_def_boolean(func, "align", 0, "", "Align buttons to each other."); + + func= RNA_def_function(srna, "column_flow", "uiLayoutColumnFlow"); + parm= RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic.", 0, INT_MAX); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); + RNA_def_boolean(func, "align", 0, "", "Align buttons to each other."); + + /* box layout */ + func= RNA_def_function(srna, "box", "uiLayoutBox"); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); + + /* split layout */ + func= RNA_def_function(srna, "split", "uiLayoutSplit"); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); + RNA_def_float(func, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f); + + /* items */ + func= RNA_def_function(srna, "itemR", "uiItemR"); + api_ui_item_common(func); + api_ui_item_rna_common(func); + RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); + RNA_def_boolean(func, "slider", 0, "", "Use slider widget for numeric values."); + RNA_def_boolean(func, "toggle", 0, "", "Use toggle widget for boolean values."); + + func= RNA_def_function(srna, "items_enumR", "uiItemsEnumR"); + api_ui_item_rna_common(func); + + func= RNA_def_function(srna, "item_menu_enumR", "uiItemMenuEnumR"); + api_ui_item_common(func); + api_ui_item_rna_common(func); + + /*func= RNA_def_function(srna, "item_enumR", "uiItemEnumR"); + api_ui_item_common(func); + api_ui_item_rna_common(func); + parm= RNA_def_string(func, "value", "", 0, "", "Enum property value."); + RNA_def_property_flag(parm, PROP_REQUIRED);*/ + + func= RNA_def_function(srna, "itemO", "uiItemO"); + api_ui_item_op_common(func); + + func= RNA_def_function(srna, "item_enumO", "uiItemEnumO_string"); + api_ui_item_op_common(func); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_string(func, "value", "", 0, "", "Enum property value."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "items_enumO", "uiItemsEnumO"); + parm= RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "item_menu_enumO", "uiItemMenuEnumO"); + api_ui_item_op_common(func); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "item_booleanO", "uiItemBooleanO"); + api_ui_item_op_common(func); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "item_intO", "uiItemIntO"); + api_ui_item_op_common(func); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "", "Value of the property to call the operator with.", INT_MIN, INT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "item_floatO", "uiItemFloatO"); + api_ui_item_op_common(func); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "", "Value of the property to call the operator with.", -FLT_MAX, FLT_MAX); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "item_stringO", "uiItemStringO"); + api_ui_item_op_common(func); + parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "itemL", "uiItemL"); + api_ui_item_common(func); + + func= RNA_def_function(srna, "itemM", "uiItemM"); + parm= RNA_def_pointer(func, "context", "Context", "", "Current context."); + RNA_def_property_flag(parm, PROP_REQUIRED); + api_ui_item_common(func); + parm= RNA_def_string(func, "menu", "", 0, "", "Identifier of the menu."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "itemS", "uiItemS"); + + /* context */ + func= RNA_def_function(srna, "set_context_pointer", "uiLayoutSetContextPointer"); + parm= RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + + /* templates */ + func= RNA_def_function(srna, "template_header", "uiTemplateHeader"); + parm= RNA_def_pointer(func, "context", "Context", "", "Current context."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "template_ID", "uiTemplateID"); + parm= RNA_def_pointer(func, "context", "Context", "", "Current context."); + RNA_def_property_flag(parm, PROP_REQUIRED); + api_ui_item_rna_common(func); + RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block."); + RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a new ID block."); + RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block."); + + func= RNA_def_function(srna, "template_modifier", "uiTemplateModifier"); + parm= RNA_def_pointer(func, "data", "Modifier", "", "Modifier data."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "template_constraint", "uiTemplateConstraint"); + parm= RNA_def_pointer(func, "data", "Constraint", "", "Constraint data."); + RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR); + parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "template_preview", "uiTemplatePreview"); + parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping"); + parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer."); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display."); + + func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp"); + parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer."); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail."); + + func= RNA_def_function(srna, "template_layers", "uiTemplateLayers"); + api_ui_item_rna_common(func); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c new file mode 100644 index 00000000000..fd34d7c4d70 --- /dev/null +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -0,0 +1,56 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Blender Foundation + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include + +#include "RNA_define.h" +#include "RNA_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_context.h" + +#include "WM_api.h" + +#else + +void RNA_api_wm(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *prop; + + func= RNA_def_function(srna, "add_fileselect", "WM_event_add_fileselect"); + RNA_def_function_flag(func, FUNC_NO_SELF|FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Show up the file selector."); + prop= RNA_def_pointer(func, "operator", "Operator", "", "Operator to call."); + RNA_def_property_flag(prop, PROP_REQUIRED); +} + +#endif + diff --git a/source/blender/makesrna/intern/wm_api.c b/source/blender/makesrna/intern/wm_api.c deleted file mode 100644 index a00c401b683..00000000000 --- a/source/blender/makesrna/intern/wm_api.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "WM_api.h" - -#include "BKE_context.h" - -void RNA_api_wm_add_fileselect(wmWindowManager *self, bContext *C, wmOperator *op) -{ - WM_event_add_fileselect(C, op); -} - diff --git a/source/blender/python/CMakeLists.txt b/source/blender/python/CMakeLists.txt index d15970e1df4..7700e6bc2aa 100644 --- a/source/blender/python/CMakeLists.txt +++ b/source/blender/python/CMakeLists.txt @@ -24,10 +24,12 @@ # ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC intern/*.c) +FILE(GLOB GENSRC generic/*.c) SET(INC . ../../../intern/guardedalloc ../blenlib ../makesdna ../makesrna ../blenkernel ../editors/include ../windowmanager ${PYTHON_INC} + ../../../extern/glew/include ) IF(WITH_OPENEXR) @@ -47,3 +49,5 @@ ENDIF(WITH_FFMPEG) ADD_DEFINITIONS(-DWITH_CCGSUBSURF) BLENDERLIB(bf_python "${SRC}" "${INC}") +BLENDERLIB(bf_gen_python "${GENSRC}" "${INC}") + diff --git a/source/blender/python/Makefile b/source/blender/python/Makefile index c830fbb3ccf..0c4b9ab6578 100644 --- a/source/blender/python/Makefile +++ b/source/blender/python/Makefile @@ -29,6 +29,6 @@ # Bounces make to subdirectories. SOURCEDIR = source/blender/python -DIRS = intern +DIRS = intern generic include nan_subdirs.mk diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index c974ebe1092..73dc171fc3e 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('intern/*.c') incs = '. ../editors/include ../makesdna ../makesrna ../blenlib ../blenkernel ../nodes' incs += ' ../imbuf ../blenloader ../render/extern/include ../windowmanager' -incs += ' #intern/guardedalloc #intern/memutil' +incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include' incs += ' ' + env['BF_PYTHON_INC'] defs = [] diff --git a/source/blender/python/generic/BGL.h b/source/blender/python/generic/BGL.h index 345536d64be..e2d1b0bb495 100755 --- a/source/blender/python/generic/BGL.h +++ b/source/blender/python/generic/BGL.h @@ -41,7 +41,8 @@ #endif #include -#include "BIF_gl.h" +#include +#include "../intern/bpy_compat.h" PyObject *BGL_Init( const char *from ); diff --git a/source/blender/python/generic/Makefile b/source/blender/python/generic/Makefile new file mode 100644 index 00000000000..20cf7f19ec7 --- /dev/null +++ b/source/blender/python/generic/Makefile @@ -0,0 +1,66 @@ +# +# $Id: Makefile 11904 2007-08-31 16:16:33Z sirdude $ +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# + +LIBNAME = gen_python +DIR = $(OCGDIR)/blender/$(LIBNAME) + +include nan_compile.mk + +CFLAGS += $(LEVEL_1_C_WARNINGS) + +# OpenGL and Python +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += $(OGL_CPPFLAGS) +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) + +# PreProcessor stuff + +CPPFLAGS += -I$(NAN_GHOST)/include +CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include $(NAN_SDLCFLAGS) + +# modules +CPPFLAGS += -I../../editors/include +CPPFLAGS += -I../../python +CPPFLAGS += -I../../makesdna +CPPFLAGS += -I../../makesrna +CPPFLAGS += -I../../blenlib +CPPFLAGS += -I../../blenkernel +CPPFLAGS += -I../../nodes +CPPFLAGS += -I../../imbuf +CPPFLAGS += -I../../blenloader +CPPFLAGS += -I../../windowmanager +CPPFLAGS += -I../../render/extern/include + +# path to the guarded memory allocator +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +CPPFLAGS += -I$(NAN_MEMUTIL)/include + +# path to our own headerfiles +CPPFLAGS += -I.. diff --git a/source/blender/python/generic/Mathutils.h b/source/blender/python/generic/Mathutils.h index 4c8153e5e54..173922fe09a 100644 --- a/source/blender/python/generic/Mathutils.h +++ b/source/blender/python/generic/Mathutils.h @@ -32,6 +32,7 @@ #define EXPP_Mathutils_H #include +#include "../intern/bpy_compat.h" #include "vector.h" #include "matrix.h" #include "quat.h" diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h index 9c3ce572cc4..475ec8dd118 100644 --- a/source/blender/python/generic/bpy_internal_import.h +++ b/source/blender/python/generic/bpy_internal_import.h @@ -32,6 +32,7 @@ #define EXPP_bpy_import_h #include +#include "../intern/bpy_compat.h" #include "compile.h" /* for the PyCodeObject */ #include "eval.h" /* for PyEval_EvalCode */ diff --git a/source/blender/python/generic/euler.h b/source/blender/python/generic/euler.h index f94f060a61d..773b024f174 100644 --- a/source/blender/python/generic/euler.h +++ b/source/blender/python/generic/euler.h @@ -32,6 +32,7 @@ #define EXPP_euler_h #include +#include "../intern/bpy_compat.h" extern PyTypeObject euler_Type; diff --git a/source/blender/python/generic/quat.h b/source/blender/python/generic/quat.h index f98665ded55..8a4602c1d8e 100644 --- a/source/blender/python/generic/quat.h +++ b/source/blender/python/generic/quat.h @@ -32,6 +32,7 @@ #define EXPP_quat_h #include +#include "../intern/bpy_compat.h" extern PyTypeObject quaternion_Type; diff --git a/source/blender/python/generic/vector.h b/source/blender/python/generic/vector.h index e53a0c1f24b..930e987fcc7 100644 --- a/source/blender/python/generic/vector.h +++ b/source/blender/python/generic/vector.h @@ -31,6 +31,7 @@ #define EXPP_vector_h #include +#include "../intern/bpy_compat.h" extern PyTypeObject vector_Type; diff --git a/source/blender/python/intern/Makefile b/source/blender/python/intern/Makefile index 3e28f5aac31..0c4a540a4bd 100644 --- a/source/blender/python/intern/Makefile +++ b/source/blender/python/intern/Makefile @@ -37,6 +37,7 @@ CFLAGS += $(LEVEL_1_C_WARNINGS) # OpenGL and Python CPPFLAGS += $(OGL_CPPFLAGS) +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) # PreProcessor stuff diff --git a/source/blender/python/intern/bpy_compat.h b/source/blender/python/intern/bpy_compat.h index ad6b7a5e85c..1ad9376c13b 100644 --- a/source/blender/python/intern/bpy_compat.h +++ b/source/blender/python/intern/bpy_compat.h @@ -88,6 +88,26 @@ typedef Py_ssize_t (*lenfunc)(PyObject *); #endif +#if PY_VERSION_HEX < 0x03000000 +#ifndef ssizeargfunc +#define ssizeargfunc intargfunc +#endif + +#ifndef ssizessizeargfunc +#define ssizessizeargfunc intintargfunc +#endif + +#ifndef ssizeobjargproc +#define ssizeobjargproc intobjargproc +#endif + +#ifndef ssizessizeobjargproc +#define ssizessizeobjargproc intintobjargproc +#endif +#endif + + + /* defined in bpy_util.c */ #if PY_VERSION_HEX < 0x03000000 PyObject *Py_CmpToRich(int op, int cmp); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 0c063c0192b..559ed537757 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -59,6 +59,7 @@ static void bpy_init_modules( void ) PyModule_AddObject( mod, "data", BPY_rna_module() ); /* PyModule_AddObject( mod, "doc", BPY_rna_doc() ); */ PyModule_AddObject( mod, "types", BPY_rna_types() ); + PyModule_AddObject( mod, "props", BPY_rna_props() ); PyModule_AddObject( mod, "ops", BPY_operator_module() ); PyModule_AddObject( mod, "ui", BPY_ui_module() ); // XXX very experemental, consider this a test, especially PyCObject is not meant to be perminant @@ -103,6 +104,7 @@ static PyObject *CreateGlobalDictionary( bContext *C ) {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, {NULL, NULL, 0, NULL} }; @@ -369,70 +371,76 @@ void BPY_run_ui_scripts(bContext *C, int reload) DIR *dir; struct dirent *de; char *file_extension; + char *dirname; char path[FILE_MAX]; - char *dirname= BLI_gethome_folder("ui"); - int filelen; /* filename length */ + char *dirs[] = {"io", "ui", NULL}; + int a, filelen; /* filename length */ PyGILState_STATE gilstate; PyObject *mod; PyObject *sys_path_orig; PyObject *sys_path_new; - - if(!dirname) - return; - - dir = opendir(dirname); - if(!dir) - return; - gilstate = PyGILState_Ensure(); - /* backup sys.path */ - sys_path_orig= PySys_GetObject("path"); - Py_INCREF(sys_path_orig); /* dont free it */ - - sys_path_new= PyList_New(1); - PyList_SET_ITEM(sys_path_new, 0, PyUnicode_FromString(dirname)); - PySys_SetObject("path", sys_path_new); - Py_DECREF(sys_path_new); - // XXX - evil, need to access context BPy_SetContext(C); bpy_import_main_set(CTX_data_main(C)); - - while((de = readdir(dir)) != NULL) { - /* We could stat the file but easier just to let python - * import it and complain if theres a problem */ + + for(a=0; dirs[a]; a++) { + dirname= BLI_gethome_folder(dirs[a]); + + if(!dirname) + continue; + + dir = opendir(dirname); + + if(!dir) + continue; + + /* backup sys.path */ + sys_path_orig= PySys_GetObject("path"); + Py_INCREF(sys_path_orig); /* dont free it */ - file_extension = strstr(de->d_name, ".py"); - - if(file_extension && *(file_extension + 3) == '\0') { - filelen = strlen(de->d_name); - BLI_strncpy(path, de->d_name, filelen-2); /* cut off the .py on copy */ + sys_path_new= PyList_New(1); + PyList_SET_ITEM(sys_path_new, 0, PyUnicode_FromString(dirname)); + PySys_SetObject("path", sys_path_new); + Py_DECREF(sys_path_new); - mod= PyImport_ImportModuleLevel(path, NULL, NULL, NULL, 0); - if (mod) { - if (reload) { - PyObject *mod_orig= mod; - mod= PyImport_ReloadModule(mod); - Py_DECREF(mod_orig); + while((de = readdir(dir)) != NULL) { + /* We could stat the file but easier just to let python + * import it and complain if theres a problem */ + + file_extension = strstr(de->d_name, ".py"); + + if(file_extension && *(file_extension + 3) == '\0') { + filelen = strlen(de->d_name); + BLI_strncpy(path, de->d_name, filelen-2); /* cut off the .py on copy */ + + mod= PyImport_ImportModuleLevel(path, NULL, NULL, NULL, 0); + if (mod) { + if (reload) { + PyObject *mod_orig= mod; + mod= PyImport_ReloadModule(mod); + Py_DECREF(mod_orig); + } } - } - - if(mod) { - Py_DECREF(mod); /* could be NULL from reloading */ - } else { - BPy_errors_to_report(NULL); // TODO - reports - fprintf(stderr, "unable to import \"%s\" %s/%s\n", path, dirname, de->d_name); + + if(mod) { + Py_DECREF(mod); /* could be NULL from reloading */ + } else { + BPy_errors_to_report(NULL); // TODO - reports + fprintf(stderr, "unable to import \"%s\" %s/%s\n", path, dirname, de->d_name); + } + } } - } - closedir(dir); - - PySys_SetObject("path", sys_path_orig); - Py_DECREF(sys_path_orig); + closedir(dir); + + PySys_SetObject("path", sys_path_orig); + Py_DECREF(sys_path_orig); + } bpy_import_main_set(NULL); diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c index 7c011b26487..f4fdd0c6194 100644 --- a/source/blender/python/intern/bpy_operator_wrap.c +++ b/source/blender/python/intern/bpy_operator_wrap.c @@ -40,6 +40,8 @@ #include "bpy_compat.h" #include "bpy_util.h" +#include "../generic/bpy_internal_import.h" // our own imports + #define PYOP_ATTR_PROP "__props__" #define PYOP_ATTR_UINAME "__label__" #define PYOP_ATTR_IDNAME "__name__" /* use pythons class name */ @@ -181,6 +183,8 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve PyObject *py_operator; PyGILState_STATE gilstate = PyGILState_Ensure(); + + bpy_import_main_set(CTX_data_main(C)); BPY_update_modules(); // XXX - the RNA pointers can change so update before running, would like a nicer solutuon for this. @@ -233,7 +237,7 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve PyTuple_SET_ITEM(args, 2, pyop_dict_from_event(event)); } else if (mode==PYOP_EXEC) { - item= PyObject_GetAttrString(py_class, "exec"); + item= PyObject_GetAttrString(py_class, "execute"); args = PyTuple_New(2); PyTuple_SET_ITEM(args, 1, pyrna_struct_CreatePyObject(&ptr_context)); @@ -292,7 +296,10 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve while(flag_def->name) { if (ret_flag & flag_def->flag) { - flag_str[1] ? sprintf(flag_str, "%s | %s", flag_str, flag_def->name) : strcpy(flag_str, flag_def->name); + if(flag_str[1]) + sprintf(flag_str, "%s | %s", flag_str, flag_def->name); + else + strcpy(flag_str, flag_def->name); } flag_def++; } @@ -302,10 +309,11 @@ static int PYTHON_OT_generic(int mode, bContext *C, wmOperator *op, wmEvent *eve Py_DECREF(item); strcpy(class_name, _PyUnicode_AsString(item)); - fprintf(stderr, "%s's %s returned %s\n", class_name, mode == PYOP_EXEC ? "exec" : "invoke", flag_str); + fprintf(stderr, "%s's %s returned %s\n", class_name, mode == PYOP_EXEC ? "execute" : "invoke", flag_str); } PyGILState_Release(gilstate); + bpy_import_main_set(NULL); return ret_flag; } @@ -355,7 +363,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata) /* api callbacks, detailed checks dont on adding */ if (PyObject_HasAttrString(py_class, "invoke")) ot->invoke= PYTHON_OT_invoke; - if (PyObject_HasAttrString(py_class, "exec")) + if (PyObject_HasAttrString(py_class, "execute")) ot->exec= PYTHON_OT_exec; if (PyObject_HasAttrString(py_class, "poll")) ot->poll= PYTHON_OT_poll; @@ -408,6 +416,7 @@ void PYTHON_OT_wrapper(wmOperatorType *ot, void *userdata) PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class) { PyObject *base_class, *item; + wmOperatorType *ot; char *idname= NULL; @@ -418,7 +427,7 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class) {PYOP_ATTR_UINAME, 's', 0, BPY_CLASS_ATTR_OPTIONAL}, {PYOP_ATTR_PROP, 'l', 0, BPY_CLASS_ATTR_OPTIONAL}, {PYOP_ATTR_DESCRIPTION, 's', 0, BPY_CLASS_ATTR_NONE_OK}, - {"exec", 'f', 2, BPY_CLASS_ATTR_OPTIONAL}, + {"execute", 'f', 2, BPY_CLASS_ATTR_OPTIONAL}, {"invoke", 'f', 3, BPY_CLASS_ATTR_OPTIONAL}, {"poll", 'f', 2, BPY_CLASS_ATTR_OPTIONAL}, {NULL, 0, 0, 0} @@ -438,9 +447,10 @@ PyObject *PYOP_wrap_add(PyObject *self, PyObject *py_class) Py_DECREF(item); idname = _PyUnicode_AsString(item); - if (WM_operatortype_find(idname)) { - PyErr_Format( PyExc_AttributeError, "Operator alredy exists with this name \"%s\"", idname); - return NULL; + /* remove if it already exists */ + if ((ot=WM_operatortype_find(idname))) { + Py_XDECREF((PyObject*)ot->pyop_data); + WM_operatortype_remove(idname); } /* If we have properties set, check its a list of dicts */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 55a3604e3f9..57a4de21443 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -38,7 +38,6 @@ #include "BKE_context.h" #include "BKE_global.h" /* evil G.* */ #include "BKE_report.h" -#include "BKE_utildefines.h" /* FILE_MAX */ static int pyrna_struct_compare( BPy_StructRNA * a, BPy_StructRNA * b ) { @@ -1311,11 +1310,19 @@ static PyObject * pyrna_func_call(PyObject * self, PyObject *args, PyObject *kw) ret= NULL; if (err==0) { /* call function */ - RNA_function_call(self_ptr, self_func, parms); + ReportList reports; + bContext *C= BPy_GetContext(); + + BKE_reports_init(&reports, RPT_STORE); + RNA_function_call(C, &reports, self_ptr, self_func, parms); + + err= (BPy_reports_to_error(&reports))? -1: 0; + BKE_reports_clear(&reports); /* return value */ - if(pret) - ret= pyrna_param_to_py(&funcptr, pret, retdata); + if(err==0) + if(pret) + ret= pyrna_param_to_py(&funcptr, pret, retdata); } /* cleanup */ @@ -1753,23 +1760,43 @@ PyObject *BPY_rna_types(void) return (PyObject *)self; } +static struct PyMethodDef props_methods[] = { + {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {NULL, NULL, 0, NULL} +}; + +#if PY_VERSION_HEX >= 0x03000000 +static struct PyModuleDef props_module = { + PyModuleDef_HEAD_INIT, + "bpyprops", + "", + -1,/* multiple "initialization" just copies the module dict. */ + props_methods, + NULL, NULL, NULL, NULL +}; +#endif + PyObject *BPY_rna_props( void ) { - PyObject *dict = PyDict_New( ); - PyMethodDef *ml; - static PyMethodDef bpy_prop_meths[] = { - {"FloatProperty", (PyCFunction)BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {"IntProperty", (PyCFunction)BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {"BoolProperty", (PyCFunction)BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {"StringProperty", (PyCFunction)BPy_StringProperty, METH_VARARGS|METH_KEYWORDS, ""}, - {NULL, NULL, 0, NULL} - }; - - for(ml = bpy_prop_meths; ml->ml_name; ml++) { - PyDict_SetItemString( dict, ml->ml_name, PyCFunction_New(ml, NULL)); - } - - return dict; + PyObject *submodule, *mod; +#if PY_VERSION_HEX >= 0x03000000 + submodule= PyModule_Create(&props_module); +#else /* Py2.x */ + submodule= Py_InitModule3( "bpy.props", props_methods, "" ); +#endif + + mod = PyModule_New("props"); + PyModule_AddObject( submodule, "props", mod ); + + /* INCREF since its its assumed that all these functions return the + * module with a new ref like PyDict_New, since they are passed to + * PyModule_AddObject which steals a ref */ + Py_INCREF(submodule); + + return submodule; } /* Orphan functions, not sure where they should go */ @@ -1790,7 +1817,7 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self) { + if (self && PyCObject_Check(self)) { StructRNA *srna = PyCObject_AsVoidPtr(self); RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); Py_RETURN_NONE; @@ -1817,7 +1844,7 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self) { + if (self && PyCObject_Check(self)) { StructRNA *srna = PyCObject_AsVoidPtr(self); RNA_def_int(srna, id, def, min, max, name, description, soft_min, soft_max); Py_RETURN_NONE; @@ -1844,7 +1871,7 @@ PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self) { + if (self && PyCObject_Check(self)) { StructRNA *srna = PyCObject_AsVoidPtr(self); RNA_def_boolean(srna, id, def, name, description); Py_RETURN_NONE; @@ -1861,7 +1888,7 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) { static char *kwlist[] = {"attr", "name", "description", "maxlen", "default", NULL}; char *id, *name="", *description="", *def=""; - int maxlen=FILE_MAX; // XXX need greater? + int maxlen=0; if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssis:StringProperty", kwlist, &id, &name, &description, &maxlen, &def)) return NULL; @@ -1871,7 +1898,7 @@ PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - if (self) { + if (self && PyCObject_Check(self)) { StructRNA *srna = PyCObject_AsVoidPtr(self); RNA_def_string(srna, id, def, maxlen, name, description); Py_RETURN_NONE; @@ -2166,7 +2193,7 @@ PyObject *pyrna_basetype_register(PyObject *self, PyObject *args) C= BPy_GetContext(); /* call the register callback */ - BKE_reports_init(&reports, RPT_PRINT); + BKE_reports_init(&reports, RPT_STORE); srna= reg(C, &reports, py_class, bpy_class_validate, bpy_class_call, bpy_class_free); if(!srna) { diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 7789e083a4e..d2f01b06336 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -63,6 +63,7 @@ typedef struct { PyObject *BPY_rna_module( void ); /*PyObject *BPY_rna_doc( void );*/ PyObject *BPY_rna_types( void ); +PyObject *BPY_rna_props( void ); PyObject *pyrna_struct_CreatePyObject( PointerRNA *ptr ); PyObject *pyrna_prop_CreatePyObject( PointerRNA *ptr, PropertyRNA *prop ); diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 221c0a92e09..4701eba810f 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -221,6 +221,7 @@ IF(UNIX) blender_radiosity blender_ONL bf_python + bf_gen_python bf_blenkernel bf_nodes bf_gpu @@ -269,6 +270,7 @@ IF(UNIX) extern_qhull bf_moto bf_python + bf_gen_python bf_quicktime extern_binreloc extern_glew diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 44692241e6f..031c2234ea8 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -49,6 +49,7 @@ SET(INC ../../../source/blender ../../../source/blender/include ../../../source/blender/makesdna + ../../../source/blender/makesrna ../../../source/gameengine/Rasterizer ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer ../../../source/gameengine/GameLogic diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index 938994e8b62..abded70f289 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -48,6 +48,7 @@ CPPFLAGS += -I../../blender CPPFLAGS += -I../../blender/windowmanager CPPFLAGS += -I../../blender/imbuf CPPFLAGS += -I../../blender/makesdna +CPPFLAGS += -I../../blender/makesrna CPPFLAGS += -I../../blender/editors/include CPPFLAGS += -I../../blender/blenlib CPPFLAGS += -I../../blender/blenkernel diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index ea097ddff5b..d3df36fbff0 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -18,6 +18,7 @@ #include "StringValue.h" #include "VoidValue.h" #include +#include #include "BoolValue.h" #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 4aaa49a8493..ee1ff2c6502 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -53,7 +53,8 @@ SET(INC ../../../source/gameengine/Ketsji ../../../source/blender/blenlib ../../../source/blender/blenkernel - ../../../source/blender/python/api2_2x + ../../../source/blender/python + ../../../source/blender/python/generic ../../../source/blender ../../../source/blender/include ../../../source/blender/makesdna diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index bdc0b335b02..59b3ff178fb 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -41,7 +41,7 @@ CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) CPPFLAGS += -I../../blender/python -CPPFLAGS += -I../../blender/python/api2_2x +CPPFLAGS += -I../../blender/python/generic CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include