Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_define.c
| Show First 20 Lines • Show All 612 Lines • ▼ Show 20 Lines | #if 0 | ||||
| } | } | ||||
| #endif | #endif | ||||
| for (prop = srna->cont.properties.first; prop; prop = nextprop) { | for (prop = srna->cont.properties.first; prop; prop = nextprop) { | ||||
| nextprop = prop->next; | nextprop = prop->next; | ||||
| RNA_def_property_free_pointers(prop); | RNA_def_property_free_pointers(prop); | ||||
| if (prop->flag & PROP_RUNTIME) | if (prop->flag_internal & PROP_INTERN_RUNTIME) | ||||
| rna_freelinkN(&srna->cont.properties, prop); | rna_freelinkN(&srna->cont.properties, prop); | ||||
| } | } | ||||
| for (func = srna->functions.first; func; func = nextfunc) { | for (func = srna->functions.first; func; func = nextfunc) { | ||||
| nextfunc = func->cont.next; | nextfunc = func->cont.next; | ||||
| for (parm = func->cont.properties.first; parm; parm = nextparm) { | for (parm = func->cont.properties.first; parm; parm = nextparm) { | ||||
| nextparm = parm->next; | nextparm = parm->next; | ||||
| RNA_def_property_free_pointers(parm); | RNA_def_property_free_pointers(parm); | ||||
| if (parm->flag & PROP_RUNTIME) | if (parm->flag_internal & PROP_INTERN_RUNTIME) | ||||
| rna_freelinkN(&func->cont.properties, parm); | rna_freelinkN(&func->cont.properties, parm); | ||||
| } | } | ||||
| RNA_def_func_free_pointers(func); | RNA_def_func_free_pointers(func); | ||||
| if (func->flag & FUNC_RUNTIME) | if (func->flag & FUNC_RUNTIME) | ||||
| rna_freelinkN(&srna->functions, func); | rna_freelinkN(&srna->functions, func); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | StructRNA *RNA_def_struct_ptr(BlenderRNA *brna, const char *identifier, StructRNA *srnafrom) | ||||
| if (srnafrom) { | if (srnafrom) { | ||||
| srna->nameproperty = srnafrom->nameproperty; | srna->nameproperty = srnafrom->nameproperty; | ||||
| srna->iteratorproperty = srnafrom->iteratorproperty; | srna->iteratorproperty = srnafrom->iteratorproperty; | ||||
| } | } | ||||
| else { | else { | ||||
| /* define some builtin properties */ | /* define some builtin properties */ | ||||
| prop = RNA_def_property(&srna->cont, "rna_properties", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(&srna->cont, "rna_properties", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_flag(prop, PROP_BUILTIN); | prop->flag_internal |= PROP_INTERN_BUILTIN; | ||||
| RNA_def_property_ui_text(prop, "Properties", "RNA property collection"); | RNA_def_property_ui_text(prop, "Properties", "RNA property collection"); | ||||
| if (DefRNA.preprocess) { | if (DefRNA.preprocess) { | ||||
| RNA_def_property_struct_type(prop, "Property"); | RNA_def_property_struct_type(prop, "Property"); | ||||
| RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", | RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", | ||||
| "rna_iterator_listbase_end", "rna_builtin_properties_get", NULL, NULL, | "rna_iterator_listbase_end", "rna_builtin_properties_get", NULL, NULL, | ||||
| "rna_builtin_properties_lookup_string", NULL); | "rna_builtin_properties_lookup_string", NULL); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Lines | #endif | ||||
| case PROP_STRING: | case PROP_STRING: | ||||
| { | { | ||||
| StringPropertyRNA *sprop = (StringPropertyRNA *)prop; | StringPropertyRNA *sprop = (StringPropertyRNA *)prop; | ||||
| sprop->defaultvalue = ""; | sprop->defaultvalue = ""; | ||||
| break; | break; | ||||
| } | } | ||||
| case PROP_POINTER: | case PROP_POINTER: | ||||
| prop->flag |= PROP_THICK_WRAP; /* needed for default behavior when PROP_RNAPTR is set */ | prop->flag |= PROP_THICK_WRAP; /* needed for default behavior when PARM_RNAPTR is set */ | ||||
| break; | break; | ||||
| case PROP_ENUM: | case PROP_ENUM: | ||||
| case PROP_COLLECTION: | case PROP_COLLECTION: | ||||
| break; | break; | ||||
| default: | default: | ||||
| fprintf(stderr, "%s: \"%s.%s\", invalid property type.\n", __func__, CONTAINER_RNA_ID(cont), identifier); | fprintf(stderr, "%s: \"%s.%s\", invalid property type.\n", __func__, CONTAINER_RNA_ID(cont), identifier); | ||||
| DefRNA.error = 1; | DefRNA.error = 1; | ||||
| return NULL; | return NULL; | ||||
| ▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | switch (type) { | ||||
| case PROP_COLLECTION: | case PROP_COLLECTION: | ||||
| DefRNA.silent = 1; | DefRNA.silent = 1; | ||||
| RNA_def_property_collection_sdna(prop, NULL, identifier, NULL); | RNA_def_property_collection_sdna(prop, NULL, identifier, NULL); | ||||
| DefRNA.silent = 0; | DefRNA.silent = 0; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| prop->flag |= PROP_IDPROPERTY | PROP_RUNTIME; | prop->flag |= PROP_IDPROPERTY; | ||||
| prop->flag_internal |= PROP_INTERN_RUNTIME; | |||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| if (cont->prophash) | if (cont->prophash) | ||||
| BLI_ghash_insert(cont->prophash, (void *)prop->identifier, prop); | BLI_ghash_insert(cont->prophash, (void *)prop->identifier, prop); | ||||
| #endif | #endif | ||||
| } | } | ||||
| rna_addtail(&cont->properties, prop); | rna_addtail(&cont->properties, prop); | ||||
| return prop; | return prop; | ||||
| } | } | ||||
| void RNA_def_property_flag(PropertyRNA *prop, int flag) | void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag) | ||||
| { | { | ||||
| prop->flag |= flag; | prop->flag |= flag; | ||||
| } | } | ||||
| void RNA_def_property_clear_flag(PropertyRNA *prop, int flag) | void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag) | ||||
| { | { | ||||
| prop->flag &= ~flag; | prop->flag &= ~flag; | ||||
| } | } | ||||
| void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter) | |||||
| { | |||||
| prop->flag |= flag_property; | |||||
| prop->flag_parameter |= flag_parameter; | |||||
| } | |||||
| void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter) | |||||
| { | |||||
| prop->flag &= ~flag_property; | |||||
| prop->flag_parameter &= ~flag_parameter; | |||||
| } | |||||
| void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype) | void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype) | ||||
| { | { | ||||
| prop->subtype = subtype; | prop->subtype = subtype; | ||||
| } | } | ||||
| void RNA_def_property_array(PropertyRNA *prop, int length) | void RNA_def_property_array(PropertyRNA *prop, int length) | ||||
| { | { | ||||
| StructRNA *srna = DefRNA.laststruct; | StructRNA *srna = DefRNA.laststruct; | ||||
| ▲ Show 20 Lines • Show All 1,870 Lines • ▼ Show 20 Lines | void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret) | ||||
| BLI_assert(func->c_ret == NULL); | BLI_assert(func->c_ret == NULL); | ||||
| func->c_ret = ret; | func->c_ret = ret; | ||||
| RNA_def_function_output(func, ret); | RNA_def_function_output(func, ret); | ||||
| } | } | ||||
| void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret) | void RNA_def_function_output(FunctionRNA *UNUSED(func), PropertyRNA *ret) | ||||
| { | { | ||||
| ret->flag |= PROP_OUTPUT; | ret->flag_parameter |= PARM_OUTPUT; | ||||
| } | } | ||||
| void RNA_def_function_flag(FunctionRNA *func, int flag) | void RNA_def_function_flag(FunctionRNA *func, int flag) | ||||
| { | { | ||||
| func->flag |= flag; | func->flag |= flag; | ||||
| } | } | ||||
| void RNA_def_function_ui_description(FunctionRNA *func, const char *description) | void RNA_def_function_ui_description(FunctionRNA *func, const char *description) | ||||
| Show All 35 Lines | switch (ptype) { | ||||
| StringPropertyRNA *sparm = (StringPropertyRNA *)parm; | StringPropertyRNA *sparm = (StringPropertyRNA *)parm; | ||||
| return sizeof(char) * sparm->maxlength; | return sizeof(char) * sparm->maxlength; | ||||
| } | } | ||||
| else | else | ||||
| return sizeof(char *); | return sizeof(char *); | ||||
| case PROP_POINTER: | case PROP_POINTER: | ||||
| { | { | ||||
| #ifdef RNA_RUNTIME | #ifdef RNA_RUNTIME | ||||
| if (parm->flag & PROP_RNAPTR) | if (parm->flag_parameter & PARM_RNAPTR) | ||||
| if (parm->flag & PROP_THICK_WRAP) { | if (parm->flag & PROP_THICK_WRAP) { | ||||
| return sizeof(PointerRNA); | return sizeof(PointerRNA); | ||||
| } | } | ||||
| else { | else { | ||||
| return sizeof(PointerRNA *); | return sizeof(PointerRNA *); | ||||
| } | } | ||||
| else | else | ||||
| return sizeof(void *); | return sizeof(void *); | ||||
| #else | #else | ||||
| if (parm->flag & PROP_RNAPTR) { | if (parm->flag_parameter & PARM_RNAPTR) { | ||||
| if (parm->flag & PROP_THICK_WRAP) { | if (parm->flag & PROP_THICK_WRAP) { | ||||
| return sizeof(PointerRNA); | return sizeof(PointerRNA); | ||||
| } | } | ||||
| else { | else { | ||||
| return sizeof(PointerRNA *); | return sizeof(PointerRNA *); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 181 Lines • ▼ Show 20 Lines | case PROP_STRING: | ||||
| if (sprop->defaultvalue) | if (sprop->defaultvalue) | ||||
| sprop->defaultvalue = BLI_strdup(sprop->defaultvalue); | sprop->defaultvalue = BLI_strdup(sprop->defaultvalue); | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| prop->flag |= PROP_FREE_POINTERS; | prop->flag_internal |= PROP_INTERN_FREE_POINTERS; | ||||
| } | } | ||||
| void RNA_def_property_free_pointers(PropertyRNA *prop) | void RNA_def_property_free_pointers(PropertyRNA *prop) | ||||
| { | { | ||||
| if (prop->flag & PROP_FREE_POINTERS) { | if (prop->flag_internal & PROP_INTERN_FREE_POINTERS) { | ||||
| int a; | int a; | ||||
| if (prop->identifier) | if (prop->identifier) | ||||
| MEM_freeN((void *)prop->identifier); | MEM_freeN((void *)prop->identifier); | ||||
| if (prop->name) | if (prop->name) | ||||
| MEM_freeN((void *)prop->name); | MEM_freeN((void *)prop->name); | ||||
| if (prop->description) | if (prop->description) | ||||
| MEM_freeN((void *)prop->description); | MEM_freeN((void *)prop->description); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if (prop->flag_internal & PROP_INTERN_FREE_POINTERS) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void rna_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop) | static void rna_def_property_free(StructOrFunctionRNA *cont_, PropertyRNA *prop) | ||||
| { | { | ||||
| ContainerRNA *cont = cont_; | ContainerRNA *cont = cont_; | ||||
| if (prop->flag & PROP_RUNTIME) { | if (prop->flag_internal & PROP_INTERN_RUNTIME) { | ||||
| if (cont->prophash) | if (cont->prophash) | ||||
| BLI_ghash_remove(cont->prophash, prop->identifier, NULL, NULL); | BLI_ghash_remove(cont->prophash, prop->identifier, NULL, NULL); | ||||
| RNA_def_property_free_pointers(prop); | RNA_def_property_free_pointers(prop); | ||||
| rna_freelinkN(&cont->properties, prop); | rna_freelinkN(&cont->properties, prop); | ||||
| } | } | ||||
| else { | else { | ||||
| RNA_def_property_free_pointers(prop); | RNA_def_property_free_pointers(prop); | ||||
| } | } | ||||
| } | } | ||||
| /* note: only intended for removing dynamic props */ | /* note: only intended for removing dynamic props */ | ||||
| int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier) | int RNA_def_property_free_identifier(StructOrFunctionRNA *cont_, const char *identifier) | ||||
| { | { | ||||
| ContainerRNA *cont = cont_; | ContainerRNA *cont = cont_; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| for (prop = cont->properties.first; prop; prop = prop->next) { | for (prop = cont->properties.first; prop; prop = prop->next) { | ||||
| if (STREQ(prop->identifier, identifier)) { | if (STREQ(prop->identifier, identifier)) { | ||||
| if (prop->flag & PROP_RUNTIME) { | if (prop->flag_internal & PROP_INTERN_RUNTIME) { | ||||
| rna_def_property_free(cont_, prop); | rna_def_property_free(cont_, prop); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| else { | else { | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| #endif | #endif /* RNA_RUNTIME */ | ||||
| const char *RNA_property_typename(PropertyType type) | const char *RNA_property_typename(PropertyType type) | ||||
| { | { | ||||
| switch (type) { | switch (type) { | ||||
| case PROP_BOOLEAN: return "PROP_BOOLEAN"; | case PROP_BOOLEAN: return "PROP_BOOLEAN"; | ||||
| case PROP_INT: return "PROP_INT"; | case PROP_INT: return "PROP_INT"; | ||||
| case PROP_FLOAT: return "PROP_FLOAT"; | case PROP_FLOAT: return "PROP_FLOAT"; | ||||
| case PROP_STRING: return "PROP_STRING"; | case PROP_STRING: return "PROP_STRING"; | ||||
| case PROP_ENUM: return "PROP_ENUM"; | case PROP_ENUM: return "PROP_ENUM"; | ||||
| case PROP_POINTER: return "PROP_POINTER"; | case PROP_POINTER: return "PROP_POINTER"; | ||||
| case PROP_COLLECTION: return "PROP_COLLECTION"; | case PROP_COLLECTION: return "PROP_COLLECTION"; | ||||
| } | } | ||||
| return "PROP_UNKNOWN"; | return "PROP_UNKNOWN"; | ||||
| } | } | ||||