Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_define.c
| Show First 20 Lines • Show All 1,806 Lines • ▼ Show 20 Lines | switch (prop->type) { | ||||
| default: | default: | ||||
| CLOG_ERROR( | CLOG_ERROR( | ||||
| &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier); | &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier); | ||||
| DefRNA.error = true; | DefRNA.error = true; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type) | void RNA_def_property_struct_runtime(StructOrFunctionRNA *cont, PropertyRNA *prop, StructRNA *type) | ||||
| { | { | ||||
| /* Never valid when defined from python. */ | |||||
| StructRNA *srna = DefRNA.laststruct; | StructRNA *srna = DefRNA.laststruct; | ||||
| if (DefRNA.preprocess) { | if (DefRNA.preprocess) { | ||||
| CLOG_ERROR(&LOG, "only at runtime."); | CLOG_ERROR(&LOG, "only at runtime."); | ||||
| return; | return; | ||||
| } | } | ||||
| const bool is_id_type = (type->flag & STRUCT_ID) != 0; | |||||
| switch (prop->type) { | switch (prop->type) { | ||||
| case PROP_POINTER: { | case PROP_POINTER: { | ||||
| PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop; | PointerPropertyRNA *pprop = (PointerPropertyRNA *)prop; | ||||
| pprop->type = type; | pprop->type = type; | ||||
| /* Check between `cont` and `srna` is mandatory, since when defined from python | |||||
| * `DefRNA.laststruct` is not valid. | |||||
| * This is not an issue as bpy code already checks for this case on its own. */ | |||||
| if (cont == srna && (srna->flag & STRUCT_NO_DATABLOCK_IDPROPERTIES) != 0 && is_id_type) { | |||||
| CLOG_ERROR(&LOG, | |||||
| "\"%s.%s\", this struct type (probably an Operator, Keymap or UserPreference) " | |||||
| "does not accept ID pointer properties.", | |||||
| CONTAINER_RNA_ID(cont), | |||||
| prop->identifier); | |||||
| DefRNA.error = true; | |||||
| return; | |||||
| } | |||||
| if (type && (type->flag & STRUCT_ID_REFCOUNT)) { | if (type && (type->flag & STRUCT_ID_REFCOUNT)) { | ||||
| prop->flag |= PROP_ID_REFCOUNT; | prop->flag |= PROP_ID_REFCOUNT; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| case PROP_COLLECTION: { | case PROP_COLLECTION: { | ||||
| CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop; | CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop; | ||||
| cprop->item_type = type; | cprop->item_type = type; | ||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| CLOG_ERROR( | CLOG_ERROR(&LOG, | ||||
| &LOG, "\"%s.%s\", invalid type for struct type.", srna->identifier, prop->identifier); | "\"%s.%s\", invalid type for struct type.", | ||||
| CONTAINER_RNA_ID(cont), | |||||
| prop->identifier); | |||||
| DefRNA.error = true; | DefRNA.error = true; | ||||
| break; | return; | ||||
| } | } | ||||
| if ((type->flag & STRUCT_ID) != 0) { | if (is_id_type) { | ||||
| prop->flag |= PROP_PTR_NO_OWNERSHIP; | prop->flag |= PROP_PTR_NO_OWNERSHIP; | ||||
| } | } | ||||
| } | } | ||||
| void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type) | void RNA_def_property_enum_native_type(PropertyRNA *prop, const char *native_enum_type) | ||||
| { | { | ||||
| StructRNA *srna = DefRNA.laststruct; | StructRNA *srna = DefRNA.laststruct; | ||||
| switch (prop->type) { | switch (prop->type) { | ||||
| ▲ Show 20 Lines • Show All 2,283 Lines • ▼ Show 20 Lines | PropertyRNA *RNA_def_pointer_runtime(StructOrFunctionRNA *cont_, | ||||
| StructRNA *type, | StructRNA *type, | ||||
| const char *ui_name, | const char *ui_name, | ||||
| const char *ui_description) | const char *ui_description) | ||||
| { | { | ||||
| ContainerRNA *cont = cont_; | ContainerRNA *cont = cont_; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE); | prop = RNA_def_property(cont, identifier, PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_struct_runtime(prop, type); | RNA_def_property_struct_runtime(cont, prop, type); | ||||
| if ((type->flag & STRUCT_ID) != 0) { | if ((type->flag & STRUCT_ID) != 0) { | ||||
| prop->flag |= PROP_EDITABLE; | prop->flag |= PROP_EDITABLE; | ||||
| } | } | ||||
| RNA_def_property_ui_text(prop, ui_name, ui_description); | RNA_def_property_ui_text(prop, ui_name, ui_description); | ||||
| return prop; | return prop; | ||||
| } | } | ||||
| Show All 18 Lines | PropertyRNA *RNA_def_collection_runtime(StructOrFunctionRNA *cont_, | ||||
| StructRNA *type, | StructRNA *type, | ||||
| const char *ui_name, | const char *ui_name, | ||||
| const char *ui_description) | const char *ui_description) | ||||
| { | { | ||||
| ContainerRNA *cont = cont_; | ContainerRNA *cont = cont_; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(cont, identifier, PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_struct_runtime(prop, type); | RNA_def_property_struct_runtime(cont, prop, type); | ||||
| RNA_def_property_ui_text(prop, ui_name, ui_description); | RNA_def_property_ui_text(prop, ui_name, ui_description); | ||||
| return prop; | return prop; | ||||
| } | } | ||||
| /* Function */ | /* Function */ | ||||
| static FunctionRNA *rna_def_function(StructRNA *srna, const char *identifier) | static FunctionRNA *rna_def_function(StructRNA *srna, const char *identifier) | ||||
| ▲ Show 20 Lines • Show All 536 Lines • Show Last 20 Lines | |||||