16#include <fmt/format.h>
43#define IDP_ARRAY_REALLOC_LIMIT 200
67#define GETPROP(prop, i) &(IDP_IDPArray(prop)[i])
89 for (
int i = 0; i < narray->
len; i++) {
108 for (
int i = 0; i < prop->
len; i++) {
121 if (index >= prop->
len || index < 0) {
153 if (newlen <= prop->totallen) {
155 for (
int i = newlen; i < prop->
len; i++) {
162 if (newlen >= prop->
len) {
169 if (newlen < prop->
len) {
171 for (
int i = newlen; i < prop->
len; i++) {
184 int newsize = newlen;
185 newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
198 if (newlen >= prop->
len) {
201 for (
int a = prop->
len; a < newlen; a++) {
209 for (
int a = newlen; a < prop->
len; a++) {
217 const bool is_grow = newlen >= prop->
len;
234 int newsize = newlen;
235 newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
237 if (is_grow ==
false) {
244 if (is_grow ==
true) {
321 if (prop->
ui_data !=
nullptr) {
339 for (a = 0; a < prop->
len; a++) {
358 const size_t st_maxncpy,
373 const int stlen =
int((st_maxncpy > 0) ?
BLI_strnlen(st, st_maxncpy - 1) : strlen(st)) + 1;
388 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);
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) {
659 if (prop_exist !=
nullptr) {
678 const bool do_overwrite,
689 if (prop_exist !=
nullptr) {
702 if (prop_exist !=
nullptr) {
772 return (idprop && idprop->
type == type) ? idprop :
nullptr;
797 switch (prop->
type) {
813 switch (prop->
type) {
829 switch (prop->
type) {
845 switch (prop->
type) {
871 std::swap(*dst, *idprop_tmp);
877 return id->properties;
882 if (id->properties ==
nullptr) {
890 return id->properties;
895 const bool is_strict)
897 if (prop1 ==
nullptr && prop2 ==
nullptr) {
900 if (prop1 ==
nullptr || prop2 ==
nullptr) {
901 return is_strict ?
false :
true;
907 switch (prop1->
type) {
911#if !defined(NDEBUG) && defined(WITH_PYTHON)
915 if ((p1 != p2) && ((
fabsf(p1 - p2) /
max_ff(p1, p2)) < 0.001f)) {
917 "WARNING: Comparing two float properties that have nearly the same value (%f vs. "
934 return ((prop1->
len == prop2->
len) &&
945 if (is_strict && prop1->
len != prop2->
len) {
963 if (prop1->
len != prop2->
len) {
967 for (
int i = 0; i < prop1->
len; i++) {
1003 *(
float *)&prop->
data.
val = val->
f;
1007 *(
double *)&prop->
data.
val = val->
d;
1036 if (st ==
nullptr) {
1050 if (st ==
nullptr || val->
string.
len <= 1) {
1088 prop->
flag = short(flags);
1191 switch (prop->
type) {
1211 if (prop->
ui_data !=
nullptr) {
1242 if (prop ==
nullptr) {
1246 if (reference !=
nullptr) {
1252 const int type_filter,
1255 if (!id_property_root) {
1259 if (type_filter == 0 || (1 << id_property_root->
type) & type_filter) {
1264 switch (id_property_root->
type) {
1273 for (
int i = 0; i < id_property_root->
len; i++) {
1356 for (
int i = 0; i < prop->
len; i++) {
1394 for (
int a = 0; a < prop->
len; a++) {
1418 switch (prop->
type) {
1432 if (prop->
ui_data !=
nullptr) {
1535 if (
array ==
nullptr) {
1540 for (
int i = 0; i < prop->
len; i++) {
1554 for (
int i = 0; i < prop->
len; i++) {
1601 switch (prop->
type) {
1637 "%s: found unknown IDProperty type %d, reset to Integer one !\n", __func__, prop->
type);
1644 if (prop->
ui_data !=
nullptr) {
1657 printf(
"%s: found non group data, freeing type %d!\n", caller_func_id, (*prop)->type);
1702 return &ui_data->
base;
1707 ui_data->
min = INT_MIN;
1708 ui_data->
max = INT_MAX;
1712 return &ui_data->
base;
1717 return &ui_data->
base;
1726 ui_data->
step = 1.0f;
1728 return &ui_data->
base;
1741 if (prop->
ui_data !=
nullptr) {
1907 auto clamp_double_to_int = [](
const double value) {
1908 return int(std::clamp<double>(value, INT_MIN, INT_MAX));
1912 dst->
min = clamp_double_to_int(src_float->
min);
1913 dst->
max = clamp_double_to_int(src_float->
max);
1916 dst->
step = clamp_double_to_int(src_float->
step);
#define IDP_IDPArray(prop)
@ IDP_UI_DATA_TYPE_BOOLEAN
@ IDP_UI_DATA_TYPE_UNSUPPORTED
@ IDP_UI_DATA_TYPE_STRING
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)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_insertlinkreplace(ListBase *listbase, void *vreplacelink, void *vnewlink) ATTR_NONNULL(1
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT 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
#define STRNCPY(dst, src)
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
#define STREQLEN(a, b, n)
void BLO_write_double_array(BlendWriter *writer, uint num, const double *data_ptr)
void BLO_write_int32_array(BlendWriter *writer, uint num, const int32_t *data_ptr)
void BLO_read_double_array(BlendDataReader *reader, int array_size, double **ptr_p)
void BLO_read_float_array(BlendDataReader *reader, int array_size, float **ptr_p)
void BLO_read_int32_array(BlendDataReader *reader, int array_size, int32_t **ptr_p)
#define BLO_write_struct(writer, struct_name, data_ptr)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void BLO_write_float_array(BlendWriter *writer, uint num, const float *data_ptr)
void BLO_write_string(BlendWriter *writer, const char *data_ptr)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
void BLO_write_int8_array(BlendWriter *writer, uint num, const int8_t *data_ptr)
void BLO_read_char_array(BlendDataReader *reader, int array_size, char **ptr_p)
bool BLO_read_requires_endian_switch(BlendDataReader *reader)
void BLO_write_char_array(BlendWriter *writer, uint num, const char *data_ptr)
#define BLO_read_struct_list(reader, struct_name, list)
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
void BLO_read_pointer_array(BlendDataReader *reader, int array_size, void **ptr_p)
#define BLO_read_struct(reader, struct_name, ptr_p)
void BLO_read_int8_array(BlendDataReader *reader, int array_size, int8_t **ptr_p)
void BLO_write_pointer_array(BlendWriter *writer, uint num, const void *data_ptr)
typedef double(DMatrix)[4][4]
#define CLOG_ERROR(clg_ref,...)
#define DEFAULT_ALLOC_FOR_NULL_STRINGS
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
void reserve(const int64_t n)
DEGForeachIDComponentCallback callback
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
#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)
void IDP_Reset(IDProperty *prop, const IDProperty *reference)
IDProperty * IDP_NewString(const char *st, const char *name, const eIDPropertyFlag flags)
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_GetPropertyFromGroup(const IDProperty *prop, const char *name)
void IDP_SyncGroupValues(IDProperty *dest, const IDProperty *src)
IDPropertyUIData * IDP_ui_data_copy(const IDProperty *prop)
IDProperty * IDP_New(const char type, const IDPropertyTemplate *val, const char *name, const eIDPropertyFlag flags)
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)
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)
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_ReplaceInGroup_ex(IDProperty *group, IDProperty *prop, IDProperty *prop_exist)
void IDP_foreach_property(IDProperty *id_property_root, const int type_filter, const blender::FunctionRef< void(IDProperty *id_property)> callback)
IDProperty * IDP_GetPropertyTypeFromGroup(const IDProperty *prop, const char *name, const char type)
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_GetIndexArray(IDProperty *prop, int index)
double IDP_coerce_to_double_or_zero(const IDProperty *prop)
IDProperty * IDP_NewStringMaxSize(const char *st, const size_t st_maxncpy, const char *name, const eIDPropertyFlag flags)
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)
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_NewIDPArray(const char *name)
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_malloc_arrayN)(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
std::unique_ptr< IDProperty, IDPropertyDeleter > create_group(StringRefNull 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::@30 array
struct IDPropertyTemplate::@29 string