16#include <fmt/format.h>
41#define IDP_ARRAY_REALLOC_LIMIT 200
65#define GETPROP(prop, i) &(IDP_property_array_get(prop)[i])
72 name.copy_utf8_truncated(prop->
name);
86 for (
int i = 0;
i < narray->
len;
i++) {
105 for (
int i = 0;
i < prop->
len;
i++) {
118 if (index >= prop->
len || index < 0) {
158 if (newlen <= prop->totallen) {
160 for (
int i = newlen;
i < prop->
len;
i++) {
167 if (newlen >= prop->
len) {
174 if (newlen < prop->
len) {
176 for (
int i = newlen;
i < prop->
len;
i++) {
189 int newsize = newlen;
190 newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
203 if (newlen >= prop->
len) {
206 for (
int a = prop->
len; a < newlen; a++) {
214 for (
int a = newlen; a < prop->
len; a++) {
222 const bool is_grow = newlen >= prop->
len;
239 int newsize = newlen;
240 newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
242 if (is_grow ==
false) {
249 if (is_grow ==
true) {
326 if (prop->
ui_data !=
nullptr) {
345 for (a = 0; a < prop->
len; a++) {
364 const size_t st_maxncpy,
372 "id property string 1");
379 const int stlen = int((st_maxncpy > 0) ?
BLI_strnlen(st, st_maxncpy - 1) : strlen(st)) + 1;
393 name.copy_utf8_truncated(prop->
name);
394 prop->
flag = short(flags);
428 const int stlen = int((st_maxncpy > 0) ?
BLI_strnlen(st, st_maxncpy - 1) : strlen(st)) +
433 if (is_byte ==
false) {
481 if (item.value == value) {
490 void (*error_fn)(
const char *))
494 used_values.
reserve(items_num);
495 used_identifiers.
reserve(items_num);
497 bool is_valid =
true;
502 const std::string msg =
"Item identifier is empty";
503 error_fn(msg.c_str());
509 const std::string msg = fmt::format(
"Item identifier '{}' is already used",
511 error_fn(msg.c_str());
517 const std::string msg = fmt::format(
518 "Item value {} for item '{}' is already used", item.
value, item.
identifier);
519 error_fn(msg.c_str());
592 if (other && prop->
type == other->
type) {
593 switch (prop->type) {
598 other->
data = prop->data;
616 if (prop_src !=
nullptr) {
618 if ((prop_dst->type != prop_src->
type || prop_dst->subtype != prop_src->
subtype) ||
620 (prop_src->
len != prop_dst->len)))
653 if (prop_exist !=
nullptr) {
675 const bool do_overwrite,
686 if (prop_exist !=
nullptr) {
699 if (prop_exist !=
nullptr) {
750 if (prop->
len == 0) {
773 return (idprop && idprop->
type == type) ? idprop :
nullptr;
799 switch (prop->
type) {
815 switch (prop->
type) {
831 switch (prop->
type) {
847 switch (prop->
type) {
873 std::swap(*dst, *idprop_tmp);
879 return id->properties;
892 return id->properties;
897 return id->system_properties;
910 return id->system_properties;
915 const bool is_strict)
917 if (prop1 ==
nullptr && prop2 ==
nullptr) {
920 if (prop1 ==
nullptr || prop2 ==
nullptr) {
921 return is_strict ?
false :
true;
927 switch (prop1->
type) {
931#if !defined(NDEBUG) && defined(WITH_PYTHON)
937 "WARNING: Comparing two float properties that have nearly the same value (%f vs. "
954 return ((prop1->
len == prop2->
len) &&
965 if (is_strict && prop1->
len != prop2->
len) {
983 if (prop1->
len != prop2->
len) {
987 for (
int i = 0;
i < prop1->
len;
i++) {
1023 *(
float *)&prop->
data.
val = val->
f;
1027 *(
double *)&prop->
data.
val = val->
d;
1056 if (st ==
nullptr) {
1058 "id property string 1");
1065 "id property string 2");
1072 if (st ==
nullptr || val->
string.
len <= 1) {
1074 "id property string 1");
1083 "id property string 3");
1111 name.copy_utf8_truncated(prop->
name);
1112 prop->
flag = short(flags);
1215 switch (prop->
type) {
1235 if (prop->
ui_data !=
nullptr) {
1266 if (prop ==
nullptr) {
1270 if (reference !=
nullptr) {
1276 const int type_filter,
1279 if (!id_property_root) {
1283 if (type_filter == 0 || (1 << id_property_root->
type) & type_filter) {
1284 callback(id_property_root);
1288 switch (id_property_root->
type) {
1297 for (
int i = 0;
i < id_property_root->
len;
i++) {
1380 for (
int i = 0;
i < prop->
len;
i++) {
1387 writer, uint32_t(prop->
len),
static_cast<double *
>(prop->
data.
pointer));
1394 writer, uint32_t(prop->
len),
static_cast<float *
>(prop->
data.
pointer));
1398 writer, uint32_t(prop->
len),
static_cast<int8_t *
>(prop->
data.
pointer));
1418 for (
int a = 0; a < prop->
len; a++) {
1442 switch (prop->
type) {
1456 if (prop->
ui_data !=
nullptr) {
1559 if (
array ==
nullptr) {
1564 for (
int i = 0;
i < prop->
len;
i++) {
1578 for (
int i = 0;
i < prop->
len;
i++) {
1626 CLOG_WARN(&
LOG,
"duplicate ID property '%s' in group", loop->name);
1633 switch (prop->
type) {
1663 "%s: found unknown IDProperty type %d, reset to Integer one !\n", __func__, prop->
type);
1670 if (prop->
ui_data !=
nullptr) {
1683 printf(
"%s: found non group data, freeing type %d!\n", caller_func_id, (*prop)->type);
1723 return &ui_data->
base;
1727 return &ui_data->
base;
1731 ui_data->
min = INT_MIN;
1732 ui_data->
max = INT_MAX;
1736 return &ui_data->
base;
1740 return &ui_data->
base;
1748 ui_data->
step = 1.0f;
1750 return &ui_data->
base;
1763 if (prop->
ui_data !=
nullptr) {
1846 dst->
min = double(src_int->
min);
1847 dst->
max = double(src_int->
max);
1929 auto clamp_double_to_int = [](
const double value) {
1930 return int(std::clamp<double>(value, INT_MIN, INT_MAX));
1934 dst->
min = clamp_double_to_int(src_float->
min);
1935 dst->
max = clamp_double_to_int(src_float->
max);
1938 dst->
step = clamp_double_to_int(src_float->
step);
#define IDP_float_get(prop)
#define IDP_array_voidp_get(prop)
eIDPropertyUIDataType IDP_ui_data_type(const IDProperty *prop)
#define IDP_int_get(prop)
@ IDP_UI_DATA_TYPE_BOOLEAN
@ IDP_UI_DATA_TYPE_UNSUPPORTED
@ IDP_UI_DATA_TYPE_STRING
#define IDP_int_set(prop, value)
#define IDP_string_get(prop)
#define IDP_double_get(prop)
#define IDP_property_array_get(prop)
void IDP_print(const IDProperty *prop)
#define IDP_bool_get(prop)
@ LIB_ID_CREATE_NO_USER_REFCOUNT
#define BLI_assert_unreachable()
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
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_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)
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,...)
#define CLOG_WARN(clg_ref,...)
#define DEFAULT_ALLOC_FOR_NULL_STRINGS
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
void reserve(const int64_t n)
#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)
IDProperty * IDP_ID_system_properties_ensure(ID *id)
void IDP_ui_data_free(IDProperty *prop)
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, const int flag)
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)
const IDProperty * _IDP_assert_type(const IDProperty *prop, const char ty)
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)
static void idp_group_children_map_ensure(IDProperty &prop)
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)
const IDProperty * _IDP_assert_type_mask(const IDProperty *prop, const int ty_mask)
double IDP_coerce_to_double_or_zero(const IDProperty *prop)
IDProperty * IDP_ID_system_properties_get(ID *id)
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)
IDProperty * IDP_GetPropertyFromGroup_null(const IDProperty *prop, const blender::StringRef name)
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 IDProperty * _IDP_assert_type_and_subtype(const IDProperty *prop, const char ty, const char sub_ty)
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)
IDPropertyGroupChildrenSet * children_map
IDPropertyUIDataEnumItem * enum_items
IDPropertyUIData * ui_data
IDProperty * system_properties
struct IDPropertyTemplate::@032057005265002020267344110225167212360002125060 array
struct IDPropertyTemplate::@306303166102371126056157213146124155011254157272 string