/* 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);
}
static void script_main_area_listener(ARegion *ar, wmNotifier *wmn)
struct bContext;
struct ID;
struct Main;
+struct ReportList;
/* Types */
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 */
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);
+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 */
/* 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,
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;
# ***** 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}")
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
# 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.
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'))
+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()
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);
}
}
}
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);
}
}
FunctionRNA *func;
PropertyDefRNA *dparm;
char *funcname, *ptrstr;
+ int first;
srna= dsrna->srna;
func= dfunc->func;
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);
}
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);
}
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);
}
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);
}
}
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);
}
FunctionRNA *func;
PropertyDefRNA *dparm;
StructDefRNA *dsrna;
+ int first;
dsrna= rna_find_struct_def(srna);
func= dfunc->func;
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");
case PROP_COLLECTION: {
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
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");
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;
}
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");
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;
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");
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");
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);
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)
#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"
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);
void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *r_ptr)
{
IDProperty *idprop;
+ //CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
if((idprop=rna_idproperty_check(&prop, ptr))) {
IDPropertyTemplate val = {0};
MEM_freeN(item);
}
}
+#if 0
+ else if(cprop->add){
+ 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: only supported for id properties.\n", ptr->type->identifier, prop->identifier);
+ printf("RNA_property_collection_add %s.%s: not implemented for this property.\n", ptr->type->identifier, prop->identifier);
if(r_ptr) {
if(idprop) {
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;
}
}
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);
}
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;
}
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;
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 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;
}
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<flen && format[ofs++]=='R') {
return err;
}
-int RNA_function_call_direct_va_lookup(PointerRNA *ptr, const char *identifier, const char *format, va_list args)
+int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args)
{
FunctionRNA *func;
func= RNA_struct_find_function(ptr, identifier);
if(func)
- return RNA_function_call_direct_va(ptr, func, format, args);
+ return RNA_function_call_direct_va(C, reports, ptr, func, format, args);
return 0;
}
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);
+ 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", "");
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);
+ 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);
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);
+ 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
}
}
-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)
+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;
if(length) cprop->length= (PropCollectionLengthFunc)length;
if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint;
if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring;
+ if(add) cprop->add= (FunctionRNA*)add;
+ if(remove) cprop->remove= (FunctionRNA*)remove;
break;
}
default:
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);
+ 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);
/* API functions */
+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);
/* ID Properties */
PropCollectionLengthFunc length; /* optional */
PropCollectionLookupIntFunc lookupint; /* optional */
PropCollectionLookupStringFunc lookupstring; /* optional */
+ FunctionRNA *add, *remove;
struct StructRNA *type;
} CollectionPropertyRNA;
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);
+ 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)
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);
+ 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.");
}
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);
+ 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.");
}
#ifdef RNA_RUNTIME
#include "BKE_main.h"
+#include "BKE_mesh.h"
/* all the list begin functions are added manually here, Main is not in SDNA */
{
StructRNA *srna;
PropertyRNA *prop;
+
const char *lists[][5]= {
{"cameras", "Camera", "rna_Main_camera_begin", "Cameras", "Camera datablocks."},
{"scenes", "Scene", "rna_Main_scene_begin", "Scenes", "Scene datablocks."},
{
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);
+ 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]);
}
+
+ RNA_api_main(srna);
}
#endif
--- /dev/null
+/**
+ * $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 <stdlib.h>
+#include <stdio.h>
+
+#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
+
/* 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);
+ 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);
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);
+ 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.");
}
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);
+ 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");
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);
+ 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");
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);
+ 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");
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);
+ 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");
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);
+ 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");
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.");
+ // 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");
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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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", "");
RNA_def_property_ui_text(prop, "Shape Keys", "");
rna_def_texmat_common(srna, "rna_Mesh_texspace_editable");
+
+ RNA_api_mesh(srna);
}
void RNA_def_mesh(BlenderRNA *brna)
--- /dev/null
+/**
+ * $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 <stdlib.h>
+#include <stdio.h>
+
+#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
+
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);
+ 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);
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;
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); /* 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);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Lock Scale", "Lock editing of scale in the interface.");
+ /* 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);
RNA_def_property_struct_type(prop, "Constraint");
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)
--- /dev/null
+/**
+ * $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 <stdlib.h>
+#include <stdio.h>
+
+#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
+
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);
+ 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);
+ 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", "");
}
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);
+ 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);
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);
+ 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);
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);
+ 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", "");
}
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);
+ 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);
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);
+ 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");
#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"
api_ui_item_rna_common(func);
}
+#endif
+
prop= RNA_def_property(srna, "operators", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "Operator");
RNA_def_property_ui_text(prop, "Operators", "Operator registry.");
+
+ RNA_api_wm(srna);
}
void RNA_def_wm(BlenderRNA *brna)
--- /dev/null
+/**
+ * $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 <stdlib.h>
+#include <stdio.h>
+
+#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
+
# ***** 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)
ADD_DEFINITIONS(-DWITH_CCGSUBSURF)
BLENDERLIB(bf_python "${SRC}" "${INC}")
+BLENDERLIB(bf_gen_python "${GENSRC}" "${INC}")
+
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 */
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) {