Blender V4.3
rna_internal_types.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include <optional>
12#include <string>
13
14#include "DNA_listBase.h"
15
16#include "RNA_access.hh"
17#include "RNA_define.hh"
18#include "RNA_types.hh"
19
20struct BlenderRNA;
22struct ContainerRNA;
23struct FunctionRNA;
24struct GHash;
27struct IDProperty;
28struct Main;
29struct PointerRNA;
30struct PropertyRNA;
31struct ReportList;
32struct Scene;
33struct StructRNA;
34struct bContext;
35
36/* Function Callbacks */
37
48using UpdateFunc = void (*)(Main *bmain, Scene *active_scene, PointerRNA *ptr);
51
52using EditableFunc = int (*)(const PointerRNA *ptr, const char **r_info);
53using ItemEditableFunc = int (*)(const PointerRNA *ptr, int index);
56using StructPathFunc = std::optional<std::string> (*)(const PointerRNA *ptr);
57
60using PropBooleanSetFunc = void (*)(PointerRNA *ptr, bool value);
61using PropBooleanArrayGetFunc = void (*)(PointerRNA *ptr, bool *values);
62using PropBooleanArraySetFunc = void (*)(PointerRNA *ptr, const bool *values);
64using PropIntSetFunc = void (*)(PointerRNA *ptr, int value);
65using PropIntArrayGetFunc = void (*)(PointerRNA *ptr, int *values);
66using PropIntArraySetFunc = void (*)(PointerRNA *ptr, const int *values);
67using PropIntRangeFunc = void (*)(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax);
69using PropFloatSetFunc = void (*)(PointerRNA *ptr, float value);
70using PropFloatArrayGetFunc = void (*)(PointerRNA *ptr, float *values);
71using PropFloatArraySetFunc = void (*)(PointerRNA *ptr, const float *values);
73 void (*)(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax);
74using PropStringGetFunc = void (*)(PointerRNA *ptr, char *value);
76using PropStringSetFunc = void (*)(PointerRNA *ptr, const char *value);
78using PropEnumSetFunc = void (*)(PointerRNA *ptr, int value);
81 PropertyRNA *prop,
82 bool *r_free);
85using PropPointerSetFunc = void (*)(PointerRNA *ptr, const PointerRNA value, ReportList *reports);
86using PropPointerPollFunc = bool (*)(PointerRNA *ptr, const PointerRNA value);
88 const PointerRNA value,
89 const PropertyRNA *prop);
95using PropCollectionLookupIntFunc = bool (*)(PointerRNA *ptr, int key, PointerRNA *r_ptr);
97 const char *key,
98 PointerRNA *r_ptr);
100 int key,
101 const PointerRNA *assign_ptr);
102
103/* extended versions with PropertyRNA argument */
105using PropBooleanSetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, bool value);
106using PropBooleanArrayGetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, bool *values);
107using PropBooleanArraySetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, const bool *values);
109using PropIntSetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, int value);
110using PropIntArrayGetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, int *values);
111using PropIntArraySetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, const int *values);
113 void (*)(PointerRNA *ptr, PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax);
115using PropFloatSetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, float value);
116using PropFloatArrayGetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, float *values);
117using PropFloatArraySetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, const float *values);
118using PropFloatRangeFuncEx = void (*)(
119 PointerRNA *ptr, PropertyRNA *prop, float *min, float *max, float *softmin, float *softmax);
120using PropStringGetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, char *value);
122using PropStringSetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, const char *value);
124using PropEnumSetFuncEx = void (*)(PointerRNA *ptr, PropertyRNA *prop, int value);
125
126/* Handling override operations, and also comparison. */
127
185
198 /* Using #PropertyRNAOrID for properties info here allows to cover all three cases ('real' RNA
199 * properties, 'runtime' RNA properties created from python and stored in IDPropertoies, and
200 * 'pure' IDProperties).
201 *
202 * This is necessary, because we cannot perform 'set/unset' checks on resolved properties
203 * (unset IDProperties would merely be nullptr then). */
206
208
211 const char *rna_path = nullptr;
212 size_t rna_path_len = 0;
214
220 int comparison = 0;
224};
225using RNAPropOverrideDiff = void (*)(Main *bmain, RNAPropertyOverrideDiffContext &rnadiff_ctx);
226
237using RNAPropOverrideStore = bool (*)(Main *bmain,
238 PointerRNA *ptr_local,
239 PointerRNA *ptr_reference,
240 PointerRNA *ptr_storage,
241 PropertyRNA *prop_local,
242 PropertyRNA *prop_reference,
243 PropertyRNA *prop_storage,
244 int len_local,
245 int len_reference,
246 int len_storage,
248
288using RNAPropOverrideApply = bool (*)(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx);
289
290/* Container - generic abstracted container of RNA properties */
292 void *next, *prev;
293
296};
297
299 /* structs are containers of properties */
301
302 /* unique identifier, keep after 'cont' */
303 const char *identifier;
304 /* various options */
305 int flag;
306
307 /* single line description, displayed in the tooltip for example */
308 const char *description;
309
310 /* callback to execute the function */
312
313 /* parameter for the return value
314 * NOTE: this is only the C return value, rna functions can have multiple return values. */
316};
317
320
321 /* magic bytes to distinguish with IDProperty */
322 int magic;
323
324 /* unique identifier */
325 const char *identifier;
326 /* various options */
327 int flag;
328 /* various override options */
330 /* Function parameters flags. */
332 /* Internal ("private") flags. */
334 /* The subset of StructRNA.prop_tag_defines values that applies to this property. */
335 short tags;
336
337 /* user readable name */
338 const char *name;
339 /* single line description, displayed in the tooltip for example */
340 const char *description;
341 /* icon ID */
342 int icon;
343 /* context for translation */
345
346 /* property type as it appears to the outside */
348 /* subtype, 'interpretation' of the property */
350 /* if non-NULL, overrides arraylength. Must not return 0? */
352 /* dimension of array */
353 unsigned int arraydimension;
354 /* Array lengths for all dimensions (when `arraydimension > 0`). */
356 unsigned int totarraylength;
357
358 /* callback for updates on change */
361
362 /* Callback for testing if editable. Its r_info parameter can be used to
363 * return info on editable state that might be shown to user. E.g. tooltips
364 * of disabled buttons can show reason why button is disabled using this. */
366 /* callback for testing if array-item editable (if applicable) */
368
369 /* Override handling callbacks (diff is also used for comparison). */
373
374 /* raw access */
377
378 /* This is used for accessing props/functions of this property
379 * any property can have this but should only be used for collections and arrays
380 * since python will convert int/bool/pointer's */
381 StructRNA *srna; /* attributes attached directly to this collection */
382
383 /* python handle to hold all callbacks
384 * (in a pointer array at the moment, may later be a tuple) */
385 void *py_data;
386};
387
388/* internal flags WARNING! 16bits only! */
395 /* Negative mirror of PROP_PTR_NO_OWNERSHIP, used to prevent automatically setting that one in
396 * makesrna when pointer is an ID... */
398};
399
400/* Property Types */
401
420
446
474
499
516
528
543
544/* changes to this struct require updating rna_generate_struct in makesrna.cc */
545struct StructRNA {
546 /* structs are containers of properties */
548
549 /* unique identifier, keep after 'cont' */
550 const char *identifier;
551
554 void *py_type;
556
557 /* various options */
558 int flag;
559 /* Each StructRNA type can define its own tags which properties can set
560 * (PropertyRNA.tags) for changed behavior based on struct-type. */
562
563 /* user readable name */
564 const char *name;
565 /* single line description, displayed in the tooltip for example */
566 const char *description;
567 /* context for translation */
569 /* icon ID */
570 int icon;
571
572 /* property that defines the name */
574
575 /* property to iterate over properties */
577
580
581 /* only use for nested structs, where both the parent and child access
582 * the same C Struct but nesting is used for grouping properties.
583 * The parent property is used so we know NULL checks are not needed,
584 * and that this struct will never exist without its parent */
586
587 /* function to give the more specific type */
589
590 /* function to find path to this struct in an ID */
592
593 /* function to register/unregister subclasses */
608
611
612 /* functions of this struct */
614};
615
616/* Blender RNA
617 *
618 * Root RNA data structure that lists all struct types. */
619
622 /* A map of structs: {StructRNA.identifier -> StructRNA}
623 * These are ensured to have unique names (with STRUCT_PUBLIC_NAMESPACE enabled). */
625 /* Needed because types with an empty identifier aren't included in 'structs_map'. */
626 unsigned int structs_len;
627};
628
629#define CONTAINER_RNA_ID(cont) (*(const char **)(((ContainerRNA *)(cont)) + 1))
unsigned int uint
These structs are the foundation for all linked lists in the library system.
eRNAOverrideApplyFlag
@ RNA_OVERRIDE_APPLY_FLAG_NOP
eRNAOverrideMatch
eRNACompareMode
@ RNA_EQ_COMPARE
eRNAOverrideMatchResult
#define RNA_MAX_ARRAY_DIMENSION
Definition RNA_define.hh:26
PropertyScaleType
Definition RNA_types.hh:106
eStringPropertySearchFlag
Definition RNA_types.hh:570
PropertyType
Definition RNA_types.hh:64
bool(*)(Main *bmain, StructRNA *type) StructUnregisterFunc
Definition RNA_types.hh:760
void(*)(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *edit_text, blender::FunctionRef< void(StringPropertySearchVisitParams)> visit_fn) StringPropertySearchFunc
Definition RNA_types.hh:598
void **(*)(PointerRNA *ptr) StructInstanceFunc
Definition RNA_types.hh:761
StructRNA *(*)(Main *bmain, ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) StructRegisterFunc
Definition RNA_types.hh:752
void(*)(bContext *C, ReportList *reports, PointerRNA *ptr, ParameterList *parms) CallFunc
Definition RNA_types.hh:711
RawPropertyType
Definition RNA_types.hh:471
PropertySubType
Definition RNA_types.hh:135
#define C
Definition RandGen.cpp:29
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
bool(*)(Main *bmain, RNAPropertyOverrideApplyContext &rnaapply_ctx) RNAPropOverrideApply
const EnumPropertyItem *(*)(bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool *r_free) PropEnumItemFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const int *values) PropIntArraySetFuncEx
int(*)(PointerRNA *ptr, PropertyRNA *prop) PropStringLengthFuncEx
void(*)(PointerRNA *ptr, PropertyRNA *prop, int value) PropEnumSetFuncEx
StructRNA *(*)(PointerRNA *ptr) StructRefineFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, int *min, int *max, int *softmin, int *softmax) PropIntRangeFuncEx
void(*)(PointerRNA *ptr, PropertyRNA *prop, int value) PropIntSetFuncEx
void(*)(PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax) PropFloatRangeFunc
void(*)(PointerRNA *ptr, bool *values) PropBooleanArrayGetFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, bool value) PropBooleanSetFuncEx
void(*)(CollectionPropertyIterator *iter) PropCollectionNextFunc
int(*)(PointerRNA *ptr) PropStringLengthFunc
void(*)(CollectionPropertyIterator *iter, PointerRNA *ptr) PropCollectionBeginFunc
void(*)(bContext *C, PointerRNA *ptr, PropertyRNA *prop) ContextPropUpdateFunc
bool(*)(PointerRNA *ptr, int key, PointerRNA *r_ptr) PropCollectionLookupIntFunc
PointerRNA(*)(CollectionPropertyIterator *iter) PropCollectionGetFunc
void(*)(bContext *C, PointerRNA *ptr) ContextUpdateFunc
IDProperty **(*)(PointerRNA *ptr) IDPropertiesFunc
void(*)(PointerRNA *ptr, const PointerRNA value, ReportList *reports) PropPointerSetFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const bool *values) PropBooleanArraySetFuncEx
PropertyFlagIntern
@ PROP_INTERN_BUILTIN
@ PROP_INTERN_RAW_ACCESS
@ PROP_INTERN_PTR_OWNERSHIP_FORCED
@ PROP_INTERN_FREE_POINTERS
@ PROP_INTERN_RAW_ARRAY
@ PROP_INTERN_RUNTIME
void(*)(PointerRNA *ptr, PropertyRNA *prop, const char *value) PropStringSetFuncEx
int(*)(const PointerRNA *ptr, int index) ItemEditableFunc
bool(*)(PointerRNA *ptr, PropertyRNA *prop) PropBooleanGetFuncEx
void(*)(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) PropIntRangeFunc
void(*)(PointerRNA *ptr, int value) PropEnumSetFunc
int(*)(PointerRNA *ptr) PropEnumGetFunc
void(*)(Main *bmain, Scene *active_scene, PointerRNA *ptr) UpdateFunc
int(*)(const PointerRNA *ptr, const char **r_info) EditableFunc
bool(*)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) PropCollectionLookupStringFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop) PropEnumGetFuncEx
void(*)(PointerRNA *ptr, PropertyRNA *prop, char *value) PropStringGetFuncEx
void(*)(PointerRNA *ptr, PropertyRNA *prop, float value) PropFloatSetFuncEx
void(*)(PointerRNA *ptr, int value) PropIntSetFunc
int(*)(const PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION]) PropArrayLengthGetFunc
PointerRNA(*)(PointerRNA *ptr) PropPointerGetFunc
void(*)( PointerRNA *ptr, PropertyRNA *prop, float *min, float *max, float *softmin, float *softmax) PropFloatRangeFuncEx
bool(*)(PointerRNA *ptr, const PointerRNA value) PropPointerPollFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, const float *values) PropFloatArraySetFuncEx
void(*)(PointerRNA *ptr, PropertyRNA *prop, float *values) PropFloatArrayGetFuncEx
void(*)(PointerRNA *ptr, const float *values) PropFloatArraySetFunc
StructRNA *(*)(PointerRNA *ptr) PropPointerTypeFunc
void(*)(Main *bmain, RNAPropertyOverrideDiffContext &rnadiff_ctx) RNAPropOverrideDiff
void(*)(PointerRNA *ptr, char *value) PropStringGetFunc
void(*)(PointerRNA *ptr, bool value) PropBooleanSetFunc
bool(*)(Main *bmain, PointerRNA *ptr_local, PointerRNA *ptr_reference, PointerRNA *ptr_storage, PropertyRNA *prop_local, PropertyRNA *prop_reference, PropertyRNA *prop_storage, int len_local, int len_reference, int len_storage, IDOverrideLibraryPropertyOperation *opop) RNAPropOverrideStore
std::optional< std::string >(*)(const PointerRNA *ptr) StructPathFunc
int(*)(PointerRNA *ptr) PropCollectionLengthFunc
void(*)(PointerRNA *ptr, PropertyRNA *prop, int *values) PropIntArrayGetFuncEx
void(*)(PointerRNA *ptr, PropertyRNA *prop, bool *values) PropBooleanArrayGetFuncEx
void(*)(PointerRNA *ptr, const bool *values) PropBooleanArraySetFunc
bool(*)(PointerRNA *ptr) PropBooleanGetFunc
bool(*)(PointerRNA *ptr, int key, const PointerRNA *assign_ptr) PropCollectionAssignIntFunc
void(*)(PointerRNA *ptr, int *values) PropIntArrayGetFunc
void(*)(PointerRNA *ptr, float value) PropFloatSetFunc
bool(*)(PointerRNA *ptr, const PointerRNA value, const PropertyRNA *prop) PropPointerPollFuncPy
void(*)(PointerRNA *ptr, const int *values) PropIntArraySetFunc
int(*)(PointerRNA *ptr, PropertyRNA *prop) PropIntGetFuncEx
int(*)(PointerRNA *ptr) PropIntGetFunc
float(*)(PointerRNA *ptr, PropertyRNA *prop) PropFloatGetFuncEx
void(*)(PointerRNA *ptr, const char *value) PropStringSetFunc
float(*)(PointerRNA *ptr) PropFloatGetFunc
void(*)(PointerRNA *ptr, float *values) PropFloatArrayGetFunc
void(*)(CollectionPropertyIterator *iter) PropCollectionEndFunc
#define min(a, b)
Definition sort.c:32
unsigned int structs_len
PropBooleanGetFuncEx get_default
PropBooleanArraySetFuncEx setarray_ex
PropBooleanArrayGetFuncEx getarray_ex
PropBooleanArraySetFunc setarray
const bool * defaultarray
PropBooleanArrayGetFuncEx get_default_array
PropBooleanSetFunc set
PropBooleanGetFunc get
PropBooleanSetFuncEx set_ex
PropBooleanGetFuncEx get_ex
PropBooleanArrayGetFunc getarray
PropCollectionNextFunc next
PropCollectionLookupStringFunc lookupstring
PropCollectionLengthFunc length
PropCollectionLookupIntFunc lookupint
PropCollectionBeginFunc begin
PropCollectionAssignIntFunc assignint
PropCollectionEndFunc end
PropCollectionGetFunc get
struct GHash * prophash
const EnumPropertyItem * item
PropEnumSetFuncEx set_ex
PropEnumGetFunc get
const char * native_enum_type
PropEnumItemFunc item_fn
PropEnumGetFuncEx get_ex
PropEnumSetFunc set
PropFloatSetFuncEx set_ex
PropertyScaleType ui_scale_type
PropFloatGetFunc get
PropFloatRangeFuncEx range_ex
PropFloatArrayGetFuncEx getarray_ex
PropFloatArraySetFuncEx setarray_ex
PropFloatArrayGetFunc getarray
PropFloatGetFuncEx get_default
PropFloatSetFunc set
const float * defaultarray
PropFloatRangeFunc range
PropFloatArraySetFunc setarray
PropFloatGetFuncEx get_ex
PropFloatArrayGetFuncEx get_default_array
const char * identifier
PropertyRNA * c_ret
ContainerRNA cont
const char * description
PropIntRangeFuncEx range_ex
PropIntArrayGetFunc getarray
PropIntArrayGetFuncEx getarray_ex
PropIntRangeFunc range
PropIntArraySetFunc setarray
PropIntGetFuncEx get_ex
PropIntArrayGetFuncEx get_default_array
PropIntArraySetFuncEx setarray_ex
PropertyScaleType ui_scale_type
PropIntGetFuncEx get_default
PropIntSetFuncEx set_ex
PropPointerTypeFunc type_fn
PropPointerGetFunc get
PropPointerPollFunc poll
PropPointerSetFunc set
ItemEditableFunc itemeditable
PropArrayLengthGetFunc getlength
const char * translation_context
RNAPropOverrideApply override_apply
unsigned int arraydimension
PropertyRNA * prev
EditableFunc editable
RNAPropOverrideStore override_store
PropertyRNA * next
RNAPropOverrideDiff override_diff
PropertySubType subtype
unsigned int arraylength[RNA_MAX_ARRAY_DIMENSION]
const char * description
const char * name
unsigned int totarraylength
const char * identifier
RawPropertyType rawtype
PropertyType type
IDOverrideLibraryProperty * liboverride_property
IDOverrideLibraryPropertyOperation * liboverride_operation
eRNAOverrideMatchResult report_flag
PropStringSetFunc set
PropStringLengthFuncEx length_ex
PropStringLengthFunc length
PropStringGetFuncEx get_ex
PropStringSetFuncEx set_ex
PropStringGetFunc get
StringPropertySearchFunc search
eStringPropertySearchFlag search_flag
StructRNA * nested
StructRegisterFunc reg
StructUnregisterFunc unreg
const char * name
const char * identifier
StructInstanceFunc instance
ContainerRNA cont
const char * translation_context
const EnumPropertyItem * prop_tag_defines
PropertyRNA * nameproperty
const char * description
IDPropertiesFunc idproperties
PropertyRNA * iteratorproperty
StructRNA * base
StructRefineFunc refine
StructPathFunc path
float max
PointerRNA * ptr
Definition wm_files.cc:4126