diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-11-29 06:09:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-11-29 06:13:34 +0300 |
commit | 26a64ba23a8e5586f2dfb72195a30bcf8acd9c90 (patch) | |
tree | e6ae8646ea73d073d4ee9a42d83c48d89bf7d21e /source/blender/makesrna | |
parent | ad625acda82281461267a3379c57ce76d54325a1 (diff) |
RNA: sync API changes from 2.8
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 81 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 41 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 4 |
5 files changed, 98 insertions, 41 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 5f97724eaa6..c497de3dee5 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -131,6 +131,7 @@ extern StructRNA RNA_CompositorNodeCombRGBA; extern StructRNA RNA_CompositorNodeCombYCCA; extern StructRNA RNA_CompositorNodeCombYUVA; extern StructRNA RNA_CompositorNodeComposite; +extern StructRNA RNA_CompositorNodeCornerPin; extern StructRNA RNA_CompositorNodeCrop; extern StructRNA RNA_CompositorNodeCurveRGB; extern StructRNA RNA_CompositorNodeCurveVec; @@ -174,6 +175,7 @@ extern StructRNA RNA_CompositorNodeSepYCCA; extern StructRNA RNA_CompositorNodeSepYUVA; extern StructRNA RNA_CompositorNodeSetAlpha; extern StructRNA RNA_CompositorNodeSplitViewer; +extern StructRNA RNA_CompositorNodeSunBeams; extern StructRNA RNA_CompositorNodeSwitchView; extern StructRNA RNA_CompositorNodeTexture; extern StructRNA RNA_CompositorNodeTime; @@ -744,10 +746,11 @@ const char *RNA_struct_ui_description_raw(const StructRNA *type); const char *RNA_struct_translation_context(const StructRNA *type); int RNA_struct_ui_icon(const StructRNA *type); -PropertyRNA *RNA_struct_name_property(StructRNA *type); +PropertyRNA *RNA_struct_name_property(const StructRNA *type); const EnumPropertyItem *RNA_struct_property_tag_defines(const StructRNA *type); PropertyRNA *RNA_struct_iterator_property(StructRNA *type); StructRNA *RNA_struct_base(StructRNA *type); +const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type); bool RNA_struct_is_ID(const StructRNA *type); bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna); @@ -773,6 +776,7 @@ bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier); PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier); bool RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test); +unsigned int RNA_struct_count_properties(StructRNA *srna); /* lower level functions for access to type properties */ const struct ListBase *RNA_struct_type_properties(StructRNA *srna); @@ -1191,9 +1195,12 @@ int RNA_function_call_direct_va(struct bContext *C, struct ReportList *reports, int RNA_function_call_direct_va_lookup(struct bContext *C, struct ReportList *reports, PointerRNA *ptr, const char *identifier, const char *format, va_list args); +const char *RNA_translate_ui_text( + const char *text, const char *text_ctxt, struct StructRNA *type, struct PropertyRNA *prop, int translate); + /* ID */ -short RNA_type_to_ID_code(StructRNA *type); +short RNA_type_to_ID_code(const StructRNA *type); StructRNA *ID_code_to_RNA_type(short idcode); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index c748d00de84..9d42ba55ecc 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -136,48 +136,54 @@ static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info)) return PROP_EDITABLE; } -short RNA_type_to_ID_code(StructRNA *type) +short RNA_type_to_ID_code(const StructRNA *type) { - if (RNA_struct_is_a(type, &RNA_Action)) return ID_AC; - if (RNA_struct_is_a(type, &RNA_Armature)) return ID_AR; - if (RNA_struct_is_a(type, &RNA_Brush)) return ID_BR; - if (RNA_struct_is_a(type, &RNA_CacheFile)) return ID_CF; - if (RNA_struct_is_a(type, &RNA_Camera)) return ID_CA; - if (RNA_struct_is_a(type, &RNA_Curve)) return ID_CU; - if (RNA_struct_is_a(type, &RNA_GreasePencil)) return ID_GD; - if (RNA_struct_is_a(type, &RNA_Group)) return ID_GR; - if (RNA_struct_is_a(type, &RNA_Image)) return ID_IM; - if (RNA_struct_is_a(type, &RNA_Key)) return ID_KE; - if (RNA_struct_is_a(type, &RNA_Lamp)) return ID_LA; - if (RNA_struct_is_a(type, &RNA_Library)) return ID_LI; - if (RNA_struct_is_a(type, &RNA_FreestyleLineStyle)) return ID_LS; - if (RNA_struct_is_a(type, &RNA_Lattice)) return ID_LT; - if (RNA_struct_is_a(type, &RNA_Material)) return ID_MA; - if (RNA_struct_is_a(type, &RNA_MetaBall)) return ID_MB; - if (RNA_struct_is_a(type, &RNA_MovieClip)) return ID_MC; - if (RNA_struct_is_a(type, &RNA_Mesh)) return ID_ME; - if (RNA_struct_is_a(type, &RNA_Mask)) return ID_MSK; - if (RNA_struct_is_a(type, &RNA_NodeTree)) return ID_NT; - if (RNA_struct_is_a(type, &RNA_Object)) return ID_OB; - if (RNA_struct_is_a(type, &RNA_ParticleSettings)) return ID_PA; - if (RNA_struct_is_a(type, &RNA_Palette)) return ID_PAL; - if (RNA_struct_is_a(type, &RNA_PaintCurve)) return ID_PC; - if (RNA_struct_is_a(type, &RNA_Scene)) return ID_SCE; - if (RNA_struct_is_a(type, &RNA_Screen)) return ID_SCR; - if (RNA_struct_is_a(type, &RNA_Sound)) return ID_SO; - if (RNA_struct_is_a(type, &RNA_Speaker)) return ID_SPK; - if (RNA_struct_is_a(type, &RNA_Texture)) return ID_TE; - if (RNA_struct_is_a(type, &RNA_Text)) return ID_TXT; - if (RNA_struct_is_a(type, &RNA_VectorFont)) return ID_VF; - if (RNA_struct_is_a(type, &RNA_World)) return ID_WO; - if (RNA_struct_is_a(type, &RNA_WindowManager)) return ID_WM; + const StructRNA *base_type = RNA_struct_base_child_of(type, &RNA_ID); + if (UNLIKELY(base_type == NULL)) { + return 0; + } + if (base_type == &RNA_Action) return ID_AC; + if (base_type == &RNA_Armature) return ID_AR; + if (base_type == &RNA_Brush) return ID_BR; + if (base_type == &RNA_CacheFile) return ID_CF; + if (base_type == &RNA_Camera) return ID_CA; + if (base_type == &RNA_Curve) return ID_CU; + if (base_type == &RNA_GreasePencil) return ID_GD; + if (base_type == &RNA_Group) return ID_GR; + if (base_type == &RNA_Image) return ID_IM; + if (base_type == &RNA_Key) return ID_KE; + if (base_type == &RNA_Lamp) return ID_LA; + if (base_type == &RNA_Library) return ID_LI; + if (base_type == &RNA_FreestyleLineStyle) return ID_LS; + if (base_type == &RNA_Lattice) return ID_LT; + if (base_type == &RNA_Material) return ID_MA; + if (base_type == &RNA_MetaBall) return ID_MB; + if (base_type == &RNA_MovieClip) return ID_MC; + if (base_type == &RNA_Mesh) return ID_ME; + if (base_type == &RNA_Mask) return ID_MSK; + if (base_type == &RNA_NodeTree) return ID_NT; + if (base_type == &RNA_Object) return ID_OB; + if (base_type == &RNA_ParticleSettings) return ID_PA; + if (base_type == &RNA_Palette) return ID_PAL; + if (base_type == &RNA_PaintCurve) return ID_PC; + if (base_type == &RNA_Scene) return ID_SCE; + if (base_type == &RNA_Screen) return ID_SCR; + if (base_type == &RNA_Sound) return ID_SO; + if (base_type == &RNA_Speaker) return ID_SPK; + if (base_type == &RNA_Texture) return ID_TE; + if (base_type == &RNA_Text) return ID_TXT; + if (base_type == &RNA_VectorFont) return ID_VF; + if (base_type == &RNA_World) return ID_WO; + if (base_type == &RNA_WindowManager) return ID_WM; return 0; } StructRNA *ID_code_to_RNA_type(short idcode) { - switch (idcode) { + /* Note, this switch doesn't use a 'default', + * so adding new ID's causes a warning. */ + switch ((ID_Type)idcode) { case ID_AC: return &RNA_Action; case ID_AR: return &RNA_Armature; case ID_BR: return &RNA_Brush; @@ -212,8 +218,11 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_WM: return &RNA_WindowManager; case ID_WO: return &RNA_World; - default: return &RNA_ID; + /* deprecated */ + case ID_IP: break; } + + return &RNA_ID; } StructRNA *rna_ID_refine(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 7f5c57b1e24..af3a48882ca 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -560,7 +560,7 @@ const char *RNA_struct_translation_context(const StructRNA *type) return type->translation_context; } -PropertyRNA *RNA_struct_name_property(StructRNA *type) +PropertyRNA *RNA_struct_name_property(const StructRNA *type) { return type->nameproperty; } @@ -580,6 +580,22 @@ StructRNA *RNA_struct_base(StructRNA *type) return type->base; } +/** + * Use to find the subtype directly below a base-type. + * + * So if type were `RNA_SpotLamp`, `RNA_struct_base_of(type, &RNA_ID)` would return `&RNA_Lamp`. + */ +const StructRNA *RNA_struct_base_child_of(const StructRNA *type, const StructRNA *parent_type) +{ + while (type) { + if (type->base == parent_type) { + return type; + } + type = type->base; + } + return NULL; +} + bool RNA_struct_is_ID(const StructRNA *type) { return (type->flag & STRUCT_ID) != 0; @@ -710,6 +726,23 @@ bool RNA_struct_contains_property(PointerRNA *ptr, PropertyRNA *prop_test) return found; } +unsigned int RNA_struct_count_properties(StructRNA *srna) +{ + PointerRNA struct_ptr; + unsigned int counter = 0; + + RNA_pointer_create(NULL, srna, NULL, &struct_ptr); + + RNA_STRUCT_BEGIN (&struct_ptr, prop) + { + counter++; + UNUSED_VARS(prop); + } + RNA_STRUCT_END; + + return counter; +} + /* low level direct access to type->properties, note this ignores parent classes so should be used with care */ const struct ListBase *RNA_struct_type_properties(StructRNA *srna) { @@ -6822,6 +6855,12 @@ int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, Pointer return 0; } +const char *RNA_translate_ui_text( + const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, int translate) +{ + return rna_translate_ui_text(text, text_ctxt, type, prop, translate); +} + bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index) { int len; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index dfd5af788f6..01c3c8033cf 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -413,6 +413,8 @@ void rna_mtex_texture_slots_clear(struct ID *self, struct bContext *C, struct Re int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct PointerRNA *assign_ptr); +const char *rna_translate_ui_text( + const char *text, const char *text_ctxt, struct StructRNA *type, struct PropertyRNA *prop, int translate); /* Internal functions that cycles uses so we need to declare (tsk tsk) */ void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values); diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 69636788493..7f7b1d05ffc 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -60,8 +60,8 @@ const EnumPropertyItem rna_enum_icon_items[] = { #ifdef RNA_RUNTIME -static const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, - int translate) +const char *rna_translate_ui_text( + const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, int translate) { /* Also return text if UI labels translation is disabled. */ if (!text || !text[0] || !translate || !BLT_translate_iface()) { |