16#include <fmt/format.h>
42#define IDP_ARRAY_REALLOC_LIMIT 200
66#define GETPROP(prop, i) &(IDP_IDPArray(prop)[i])
87 for (
int i = 0;
i < narray->
len;
i++) {
106 for (
int i = 0;
i < prop->
len;
i++) {
119 if (index >= prop->
len || index < 0) {
151 if (newlen <= prop->totallen) {
153 for (
int i = newlen;
i < prop->
len;
i++) {
160 if (newlen >= prop->
len) {
167 if (newlen < prop->
len) {
169 for (
int i = newlen;
i < prop->
len;
i++) {
182 int newsize = newlen;
183 newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
196 if (newlen >= prop->
len) {
199 for (
int a = prop->
len; a < newlen; a++) {
207 for (
int a = newlen; a < prop->
len; a++) {
215 const bool is_grow = newlen >= prop->
len;
232 int newsize = newlen;
233 newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
235 if (is_grow ==
false) {
242 if (is_grow ==
true) {
319 if (prop->
ui_data !=
nullptr) {
337 for (a = 0; a < prop->
len; a++) {
356 const size_t st_maxncpy,
364 "id property string 1");
371 const int stlen = int((st_maxncpy > 0) ?
BLI_strnlen(st, st_maxncpy - 1) : strlen(st)) + 1;
386 prop->
flag = short(flags);
420 const int stlen = int((st_maxncpy > 0) ?
BLI_strnlen(st, st_maxncpy - 1) : strlen(st)) +
425 if (is_byte ==
false) {
469 const int value =
IDP_Int(prop);
473 if (item.value == value) {
482 void (*error_fn)(
const char *))
486 used_values.
reserve(items_num);
487 used_identifiers.
reserve(items_num);
489 bool is_valid =
true;
494 const std::string msg =
"Item identifier is empty";
495 error_fn(msg.c_str());
501 const std::string msg = fmt::format(
"Item identifier '{}' is already used",
503 error_fn(msg.c_str());
509 const std::string msg = fmt::format(
510 "Item value {} for item '{}' is already used", item.
value, item.
identifier);
511 error_fn(msg.c_str());
586 if (other && prop->
type == other->
type) {
587 switch (prop->type) {
592 other->
data = prop->data;
611 if (prop_src !=
nullptr) {
613 if ((prop_dst->type != prop_src->
type || prop_dst->subtype != prop_src->
subtype) ||
615 (prop_src->
len != prop_dst->len)))
646 if (loop ==
nullptr) {
662 if (prop_exist !=
nullptr) {
681 const bool do_overwrite,
692 if (prop_exist !=
nullptr) {
705 if (prop_exist !=
nullptr) {
770 [&](
const IDProperty &elem) { return elem.name == name; });
784 return (idprop && idprop->
type == type) ? idprop :
nullptr;
809 switch (prop->
type) {
825 switch (prop->
type) {
841 switch (prop->
type) {
857 switch (prop->
type) {
883 std::swap(*dst, *idprop_tmp);
889 return id->properties;
902 return id->properties;
907 const bool is_strict)
909 if (prop1 ==
nullptr && prop2 ==
nullptr) {
912 if (prop1 ==
nullptr || prop2 ==
nullptr) {
913 return is_strict ?
false :
true;
919 switch (prop1->
type) {
923#if !defined(NDEBUG) && defined(WITH_PYTHON)
929 "WARNING: Comparing two float properties that have nearly the same value (%f vs. "
946 return ((prop1->
len == prop2->
len) &&
957 if (is_strict && prop1->
len != prop2->
len) {
975 if (prop1->
len != prop2->
len) {
979 for (
int i = 0;
i < prop1->
len;
i++) {
1015 *(
float *)&prop->
data.
val = val->
f;
1019 *(
double *)&prop->
data.
val = val->
d;
1048 if (st ==
nullptr) {
1050 "id property string 1");
1057 "id property string 2");
1064 if (st ==
nullptr || val->
string.
len <= 1) {
1066 "id property string 1");
1075 "id property string 3");
1104 prop->
flag = short(flags);
1207 switch (prop->
type) {
1227 if (prop->
ui_data !=
nullptr) {
1258 if (prop ==
nullptr) {
1262 if (reference !=
nullptr) {
1268 const int type_filter,
1271 if (!id_property_root) {
1275 if (type_filter == 0 || (1 << id_property_root->
type) & type_filter) {
1276 callback(id_property_root);
1280 switch (id_property_root->
type) {
1289 for (
int i = 0;
i < id_property_root->
len;
i++) {
1372 for (
int i = 0;
i < prop->
len;
i++) {
1379 writer, uint32_t(prop->
len),
static_cast<double *
>(prop->
data.
pointer));
1386 writer, uint32_t(prop->
len),
static_cast<float *
>(prop->
data.
pointer));
1390 writer, uint32_t(prop->
len),
static_cast<int8_t *
>(prop->
data.
pointer));
1410 for (
int a = 0; a < prop->
len; a++) {
1434 switch (prop->
type) {
1448 if (prop->
ui_data !=
nullptr) {
1551 if (
array ==
nullptr) {
1556 for (
int i = 0;
i < prop->
len;
i++) {
1570 for (
int i = 0;
i < prop->
len;
i++) {
1617 switch (prop->
type) {
1653 "%s: found unknown IDProperty type %d, reset to Integer one !\n", __func__, prop->
type);
1660 if (prop->
ui_data !=
nullptr) {
1673 printf(
"%s: found non group data, freeing type %d!\n", caller_func_id, (*prop)->type);
1713 return &ui_data->
base;
1717 return &ui_data->
base;
1721 ui_data->
min = INT_MIN;
1722 ui_data->
max = INT_MAX;
1726 return &ui_data->
base;
1730 return &ui_data->
base;
1738 ui_data->
step = 1.0f;
1740 return &ui_data->
base;
1753 if (prop->
ui_data !=
nullptr) {
1836 dst->
min = double(src_int->
min);
1837 dst->
max = double(src_int->
max);
1919 auto clamp_double_to_int = [](
const double value) {
1920 return int(std::clamp<double>(value, INT_MIN, INT_MAX));
1924 dst->
min = clamp_double_to_int(src_float->
min);
1925 dst->
max = clamp_double_to_int(src_float->
max);
1928 dst->
step = clamp_double_to_int(src_float->
step);
#define IDP_IDPArray(prop)
eIDPropertyUIDataType IDP_ui_data_type(const IDProperty *prop)
@ IDP_UI_DATA_TYPE_BOOLEAN
@ IDP_UI_DATA_TYPE_UNSUPPORTED
@ IDP_UI_DATA_TYPE_STRING
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
IDProperty * IDP_CopyProperty(const IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void IDP_print(const IDProperty *prop)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
#define BLI_assert_unreachable()
BLI_INLINE void BLI_endian_switch_int64(int64_t *val) ATTR_NONNULL(1)
BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_NONNULL(1)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_insertlinkreplace(ListBase *listbase, void *vreplacelink, void *vnewlink) ATTR_NONNULL(1
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
T * BLI_listbase_find(const ListBase &listbase, Fn &&predicate)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
int char char int int int int size_t BLI_strnlen(const char *str, size_t maxlen) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
char * STRNCPY(char(&dst)[N], const char *src)
#define STREQLEN(a, b, n)
void BLO_write_float_array(BlendWriter *writer, int64_t num, const float *data_ptr)
void BLO_write_int32_array(BlendWriter *writer, int64_t num, const int32_t *data_ptr)
void BLO_read_float_array(BlendDataReader *reader, int64_t array_size, float **ptr_p)
void BLO_read_int32_array(BlendDataReader *reader, int64_t array_size, int32_t **ptr_p)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_write_int8_array(BlendWriter *writer, int64_t num, const int8_t *data_ptr)
void BLO_read_double_array(BlendDataReader *reader, int64_t array_size, double **ptr_p)
void BLO_write_double_array(BlendWriter *writer, int64_t num, const double *data_ptr)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
bool BLO_read_requires_endian_switch(BlendDataReader *reader)
void BLO_read_int8_array(BlendDataReader *reader, int64_t array_size, int8_t **ptr_p)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
void BLO_read_char_array(BlendDataReader *reader, int64_t array_size, char **ptr_p)
#define BLO_read_struct(reader, struct_name, ptr_p)
void BLO_write_pointer_array(BlendWriter *writer, int64_t num, const void *data_ptr)
void BLO_read_pointer_array(BlendDataReader *reader, int64_t array_size, void **ptr_p)
void BLO_write_char_array(BlendWriter *writer, int64_t num, const char *data_ptr)
#define CLOG_ERROR(clg_ref,...)
Read Guarded memory(de)allocation.
void reserve(const int64_t n)
void copy_utf8_truncated(char *dst, int64_t dst_size) const
#define MEM_recallocN(vmemh, len)
#define DEFAULT_ALLOC_FOR_NULL_STRINGS
#define IDP_ARRAY_REALLOC_LIMIT
static IDProperty * IDP_CopyArray(const IDProperty *prop, const int flag)
void IDP_SyncGroupTypes(IDProperty *dest, const IDProperty *src, const bool do_arraylen)
bool IDP_EqualsProperties(const IDProperty *prop1, const IDProperty *prop2)
IDProperty * IDP_NewStringMaxSize(const char *st, const size_t st_maxncpy, const blender::StringRef name, const eIDPropertyFlag flags)
void IDP_Reset(IDProperty *prop, const IDProperty *reference)
void IDP_ui_data_free(IDProperty *prop)
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, const int flag)
bool IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew)
bool IDP_AddToGroup(IDProperty *group, IDProperty *prop)
static void IDP_WriteGroup(const IDProperty *prop, BlendWriter *writer)
static IDProperty * IDP_CopyGroup(const IDProperty *prop, const int flag)
float IDP_coerce_to_float_or_zero(const IDProperty *prop)
static IDProperty * idp_generic_copy(const IDProperty *prop, const int)
IDPropertyUIData * IDP_TryConvertUIData(IDPropertyUIData *src, const eIDPropertyUIDataType src_type, const eIDPropertyUIDataType dst_type)
static IDProperty * IDP_CopyID(const IDProperty *prop, const int flag)
IDProperty * IDP_CopyProperty(const IDProperty *prop)
eIDPropertyUIDataType IDP_ui_data_type(const IDProperty *prop)
bool IDP_ui_data_supported(const IDProperty *prop)
static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr)
IDProperty * IDP_GetPropertyTypeFromGroup(const IDProperty *prop, const blender::StringRef name, const char type)
void IDP_SyncGroupValues(IDProperty *dest, const IDProperty *src)
IDPropertyUIData * IDP_ui_data_copy(const IDProperty *prop)
void IDP_ReplaceGroupInGroup(IDProperty *dest, const IDProperty *src)
IDProperty * IDP_GetProperties(ID *id)
void IDP_MergeGroup_ex(IDProperty *dest, const IDProperty *src, const bool do_overwrite, const int flag)
static void IDP_FreeIDPArray(IDProperty *prop, const bool do_id_user)
void IDP_FreeString(IDProperty *prop)
bool IDP_EnumItemsValidate(const IDPropertyUIDataEnumItem *items, const int items_num, void(*error_fn)(const char *))
static void IDP_DirectLinkIDPArray(IDProperty *prop, BlendDataReader *reader)
void IDP_WriteProperty_OnlyData(const IDProperty *prop, BlendWriter *writer)
IDProperty * IDP_NewString(const char *st, const blender::StringRef name, const eIDPropertyFlag flags)
void IDP_RemoveFromGroup(IDProperty *group, IDProperty *prop)
void IDP_FreeProperty(IDProperty *prop)
static size_t idp_size_table[]
void IDP_AssignID(IDProperty *prop, ID *id, const int flag)
int IDP_coerce_to_int_or_zero(const IDProperty *prop)
IDProperty * IDP_NewIDPArray(const blender::StringRef name)
void IDP_CopyPropertyContent(IDProperty *dst, const IDProperty *src)
void IDP_FreeProperty_ex(IDProperty *prop, const bool do_id_user)
static IDPropertyUIData * ui_data_alloc(const eIDPropertyUIDataType type)
void IDP_FreePropertyContent(IDProperty *prop)
void IDP_AssignStringMaxSize(IDProperty *prop, const char *st, const size_t st_maxncpy)
void IDP_foreach_property(IDProperty *id_property_root, const int type_filter, const blender::FunctionRef< void(IDProperty *id_property)> callback)
void IDP_FreePropertyContent_ex(IDProperty *prop, const bool do_id_user)
static void IDP_DirectLinkGroup(IDProperty *prop, BlendDataReader *reader)
void IDP_FreeFromGroup(IDProperty *group, IDProperty *prop)
static void IDP_DirectLinkString(IDProperty *prop, BlendDataReader *reader)
void IDP_ClearProperty(IDProperty *prop)
static void ui_data_free(IDPropertyUIData *ui_data, const eIDPropertyUIDataType type)
IDProperty * IDP_New(const char type, const IDPropertyTemplate *val, const blender::StringRef name, const eIDPropertyFlag flags)
IDProperty * IDP_GetIndexArray(IDProperty *prop, int index)
IDProperty * IDP_GetPropertyFromGroup(const IDProperty *prop, const blender::StringRef name)
double IDP_coerce_to_double_or_zero(const IDProperty *prop)
void IDP_ResizeIDPArray(IDProperty *prop, int newlen)
static void IDP_DirectLinkProperty(IDProperty *prop, BlendDataReader *reader)
static IDPropertyUIData * convert_base_ui_data(IDPropertyUIData *src, const eIDPropertyUIDataType dst_type)
static void IDP_FreeGroup(IDProperty *prop, const bool do_id_user)
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite)
void IDP_ReplaceInGroup_ex(IDProperty *group, IDProperty *prop, IDProperty *prop_exist, const int flag)
bool IDP_EqualsProperties_ex(const IDProperty *prop1, const IDProperty *prop2, const bool is_strict)
static void IDP_int_ui_data_free_enum_items(IDPropertyUIDataInt *ui_data)
static void IDP_DirectLinkArray(IDProperty *prop, BlendDataReader *reader)
void IDP_AppendArray(IDProperty *prop, IDProperty *item)
static void IDP_WriteString(const IDProperty *prop, BlendWriter *writer)
void IDP_SetIndexArray(IDProperty *prop, int index, IDProperty *item)
void IDP_ResizeArray(IDProperty *prop, int newlen)
void IDP_ui_data_free_unique_contents(IDPropertyUIData *ui_data, const eIDPropertyUIDataType type, const IDPropertyUIData *other)
static IDProperty * IDP_CopyString(const IDProperty *prop, const int flag)
void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
static void IDP_WriteArray(const IDProperty *prop, BlendWriter *writer)
void IDP_BlendWrite(BlendWriter *writer, const IDProperty *prop)
static void write_ui_data(const IDProperty *prop, BlendWriter *writer)
static void read_ui_data(IDProperty *prop, BlendDataReader *reader)
IDPropertyUIData * IDP_ui_data_ensure(IDProperty *prop)
void IDP_FreeArray(IDProperty *prop)
IDProperty * IDP_EnsureProperties(ID *id)
static void IDP_WriteIDPArray(const IDProperty *prop, BlendWriter *writer)
void IDP_BlendReadData_impl(BlendDataReader *reader, IDProperty **prop, const char *caller_func_id)
const IDPropertyUIDataEnumItem * IDP_EnumItemFind(const IDProperty *prop)
IDProperty * IDP_CopyIDPArray(const IDProperty *array, const int flag)
void IDP_AssignString(IDProperty *prop, const char *st)
void * MEM_mallocN(size_t len, const char *str)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRef prop_name, eIDPropertyFlag flags={})
Allocate a new IDProperty of type IDP_GROUP.
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
IDPropertyUIDataEnumItem * enum_items
IDPropertyUIData * ui_data
struct IDPropertyTemplate::@347174163205254236177334334344125337263066142041 string
struct IDPropertyTemplate::@057340115353163137130262213324257034202360355133 array