22#include <fmt/format.h>
122# define MAKE_ID(a, b, c, d) (int(a) << 24 | int(b) << 16 | (c) << 8 | (d))
125# define MAKE_ID(a, b, c, d) (int(d) << 24 | int(c) << 16 | (b) << 8 | (a))
174 return (name[0] ==
'*' || (name[0] ==
'(' && name[1] ==
'*'));
179 const char *cp = sdna->
members[member_index];
196static void printstruct(
SDNA *sdna,
short struct_index)
201 printf(
"struct %s\n", sdna->
types[struct_info->type]);
203 for (
int b = 0;
b < struct_info->members_len;
b++) {
205 printf(
" %s %s\n", sdna->
types[struct_member->type], sdna->names[struct_member->name]);
218 const int structs_num,
224 uint *struct_index_last)
226 if (*struct_index_last < structs_num) {
227 const SDNA_Struct *struct_info = structs[*struct_index_last];
229 return *struct_index_last;
236 if (struct_index_p) {
238 *struct_index_last = struct_index;
244 for (
int struct_index = 0; struct_index < types_num; struct_index++) {
245 const SDNA_Struct *struct_info = structs[struct_index];
246 if (
STREQ(types[struct_info->type],
str)) {
247 *struct_index_last = struct_index;
258 uint *struct_index_last)
319 return (
const char *)((uintptr_t(ptr) + 3) & ~3);
325 const void *
const data_pointer_end,
326 const char **r_error_message)
328 BLI_STATIC_ASSERT(std::is_pointer_v<T> && std::is_const_v<std::remove_pointer_t<T>>,
329 "Data type for this util must be a pointer to const data")
331 if ((
data +
num) > data_pointer_end) [[unlikely]] {
332 *r_error_message =
"Invalid data in SDNA file";
342 T data_pointer_current,
343 const void *
const data_pointer_end,
344 const char **r_error_message)
346 BLI_STATIC_ASSERT(std::is_pointer_v<T> && std::is_const_v<std::remove_pointer_t<T>>,
347 "Data type for this util must be a pointer to const data")
348 if (size < 0 || size > (
static_cast<T>(data_pointer_end) - data_pointer_current)) [[unlikely]] {
349 *r_error_message =
"Invalid array size data in SDNA file";
356 const void *
const data_pointer_end,
357 const char **r_error_message)
360 const char *str_end =
static_cast<const char *
>(
361 memchr(
data,
'\0',
size_t(
static_cast<const char *
>(data_pointer_end) -
data)));
362 if (!str_end) [[unlikely]] {
363 *r_error_message =
"Invalid string data in SDNA file";
369 if (!string_size) [[unlikely]] {
370 *r_error_message =
"Invalid string data in SDNA file";
374 data += (string_size + 1);
393 const int64_t voided_members_size,
394 const char **r_error_message)
396 int64_t members_size = voided_members_size;
400 const char *member_name = sdna->
members[member.member_index];
404 if (member_size < 0) [[unlikely]] {
405 *r_error_message =
"Invalid struct member size in SDNA file";
408 members_size += member_size * array_num;
411 *r_error_message =
"Invalid struct size in SDNA file";
424 const void *
const data_pointer_end = sdna->
data + sdna->
data_size;
426 int member_index_gravity_fix = -1;
429 const int *int_buf =
reinterpret_cast<const int *
>(sdna->
data);
431 const short *short_buf;
432 const short *short_data;
433 const char *char_buf;
436 sdna->
types =
nullptr;
456 if (*int_data !=
MAKE_ID(
'S',
'D',
'N',
'A')) {
457 *r_error_message =
"SDNA error in SDNA file";
465 if (*int_data ==
MAKE_ID(
'N',
'A',
'M',
'E')) {
471 if (do_endian_swap) {
475 sdna->
members_num, int_buf, data_pointer_end, r_error_message))
483 *r_error_message =
"NAME error in SDNA file";
487 char_buf =
reinterpret_cast<const char *
>(int_buf);
488 for (
int member_index = 0; member_index < sdna->
members_num; member_index++) {
490 char_buf, data_pointer_end, r_error_message);
491 if (orig_member_name ==
nullptr) {
494 sdna->
members[member_index] = orig_member_name;
499 if (
STREQ(orig_member_name,
"[3]")) {
500 if (member_index &&
STREQ(sdna->
members[member_index - 1],
"Cvi")) {
501 sdna->
members[member_index] =
"gravity[3]";
502 member_index_gravity_fix = member_index;
509 int_buf =
reinterpret_cast<const int *
>(char_buf);
513 if (*int_data ==
MAKE_ID(
'T',
'Y',
'P',
'E')) {
519 if (do_endian_swap) {
523 sdna->
types_num, int_buf, data_pointer_end, r_error_message))
530 *r_error_message =
"TYPE error in SDNA file";
534 char_buf =
reinterpret_cast<const char *
>(int_buf);
535 for (
int type_index = 0; type_index < sdna->
types_num; type_index++) {
537 char_buf, data_pointer_end, r_error_message);
538 if (orig_type_name ==
nullptr) {
547 int_buf =
reinterpret_cast<const int *
>(char_buf);
551 short_buf =
reinterpret_cast<const short *
>(int_buf);
552 if (*int_data ==
MAKE_ID(
'T',
'L',
'E',
'N')) {
555 short_buf, sdna->
types_num, data_pointer_end, r_error_message)))
559 sdna->
types_size =
const_cast<short *
>(short_data);
561 if (do_endian_swap) {
566 *r_error_message =
"TLEN error in SDNA file";
577 int_buf =
reinterpret_cast<const int *
>(short_buf);
581 if (*int_data ==
MAKE_ID(
'S',
'T',
'R',
'C')) {
587 if (do_endian_swap) {
591 sdna->
structs_num, int_buf, data_pointer_end, r_error_message))
598 *r_error_message =
"STRC error in SDNA file";
605 short_buf =
reinterpret_cast<const short *
>(int_buf);
606 for (
int struct_index = 0; struct_index < sdna->
structs_num; struct_index++) {
613 if (do_endian_swap) {
621 const int64_t struct_members_size = struct_member_short_size * struct_info->
members_num;
623 struct_members_size, short_buf, data_pointer_end, r_error_message) ||
628 sdna->
structs[struct_index] = struct_info;
630 if (do_endian_swap) {
631 for (
short a = 0; a < struct_info->
members_num; a++) {
639 *r_error_message =
"Invalid struct type index in SDNA file";
643 *r_error_message =
"Invalid duplicate struct type index in SDNA file";
649 *r_error_message =
"Invalid struct member's type index in SDNA file";
653 *r_error_message =
"Invalid struct member's member index in SDNA file";
665 if (member_index_gravity_fix > -1) {
666 constexpr int float_type_index = 7;
667 constexpr int void_type_index = 9;
668 constexpr int gravity_member_index = 4;
670 if (struct_info->
members_num < gravity_member_index + 2 ||
680 *r_error_message =
"Invalid data in SDNA file";
684 gravity_fix_struct = struct_info;
691 char_buf =
reinterpret_cast<const char *
>(short_buf);
692 if (char_buf != data_pointer_end) {
693 *r_error_message =
"Invalid data in SDNA file";
702 for (intptr_t struct_index = 0; struct_index < sdna->
structs_num; struct_index++) {
722 *r_error_message =
"ListBase struct error! Not found.";
732 *r_error_message =
"ListBase struct error: invalid computed pointer-size.";
741 for (
int member_index = 0; member_index < sdna->
members_num; member_index++) {
743 if (array_num < 0 || array_num > SHRT_MAX) [[unlikely]] {
744 *r_error_message =
"Invalid struct member array size in SDNA file";
747 members_array_num[member_index] = short(array_num);
754 const int64_t voided_members_size = (struct_info == gravity_fix_struct) ?
sizeof(
float) : 0;
761 for (
int type_index = 0; type_index < sdna->
types_num; type_index++) {
762 sdna->
types_alignment[type_index] = int(__STDCPP_DEFAULT_NEW_ALIGNMENT__);
767 uint dummy_index = 0;
769 sdna,
"mat4x4f", &dummy_index);
770 if (mat4x4f_struct_index > 0) {
772 const int mat4x4f_type_index = struct_info->
type_index;
785 const char **r_error_message)
788 const char *error_message =
nullptr;
793 memcpy(data_copy,
data, data_len);
794 sdna->
data = data_copy;
797 sdna->
data =
static_cast<const char *
>(
data);
808 if (r_error_message ==
nullptr) {
809 fprintf(stderr,
"Error decoding blend file SDNA: %s\n", error_message);
812 *r_error_message = error_message;
854 const int old_struct_index)
865 if (new_struct_index == -1) {
884 for (
int member_index = 0; member_index < old_struct->
members_num; member_index++) {
890 if (!
STREQ(old_type_name, new_type_name)) {
898 if (!
STREQ(old_member_name, new_member_name)) {
915 if (old_member_struct_index >= 0) {
932 printf(
"error: file without SDNA\n");
940 for (
int old_struct_index = 0; old_struct_index < oldsdna->
structs_num; old_struct_index++) {
972 for (
int a = 0; a < oldsdna->structs_len; a++) {
975 printf(
"changed: %s\n", oldsdna->
types[struct_info->type]);
980 return compare_flags;
998 const char *old_data,
1005 double old_value_f = 0.0;
1010 for (
int a = 0; a < array_len; a++) {
1013 const char value = *old_data;
1014 old_value_i = value;
1015 old_value_f = double(value);
1019 const uchar value = *
reinterpret_cast<const uchar *
>(old_data);
1020 old_value_i = value;
1021 old_value_f = double(value);
1025 const short value = *
reinterpret_cast<const short *
>(old_data);
1026 old_value_i = value;
1027 old_value_f = double(value);
1031 const ushort value = *
reinterpret_cast<const ushort *
>(old_data);
1032 old_value_i = value;
1033 old_value_f = double(value);
1037 const int value = *
reinterpret_cast<const int *
>(old_data);
1038 old_value_i = value;
1039 old_value_f = double(value);
1043 const float value = *
reinterpret_cast<const float *
>(old_data);
1046 old_value_f = value;
1050 const double value = *
reinterpret_cast<const double *
>(old_data);
1053 old_value_f = value;
1057 const int64_t value = *
reinterpret_cast<const int64_t *
>(old_data);
1059 old_value_f = double(value);
1064 old_value_i = value;
1065 old_value_f = double(value);
1069 const int8_t value = *
reinterpret_cast<const int8_t *
>(old_data);
1071 old_value_f = double(value);
1075 BLI_assert_msg(
false,
"Conversion from SDNA_TYPE_RAW_DATA is not supported");
1081 *new_data = char(old_value_i);
1084 *
reinterpret_cast<uchar *
>(new_data) =
uchar(old_value_i);
1087 *
reinterpret_cast<short *
>(new_data) =
short(old_value_i);
1090 *
reinterpret_cast<ushort *
>(new_data) =
ushort(old_value_i);
1093 *
reinterpret_cast<int *
>(new_data) =
int(old_value_i);
1097 old_value_f /= 255.0;
1099 *
reinterpret_cast<float *
>(new_data) = old_value_f;
1103 old_value_f /= 255.0;
1105 *
reinterpret_cast<double *
>(new_data) = old_value_f;
1111 *
reinterpret_cast<uint64_t *
>(new_data) = old_value_i;
1114 *
reinterpret_cast<int8_t *
>(new_data) = int8_t(old_value_i);
1117 BLI_assert_msg(
false,
"Conversion to SDNA_TYPE_RAW_DATA is not supported");
1127 const uint32_t *old_data,
1130 for (
int a = 0; a < array_len; a++) {
1131 new_data[a] = old_data[a];
1142 for (
int a = 0; a < array_len; a++) {
1143 new_data[a] = old_data[a] >> 3;
1155 if (name[a] != oname[a]) {
1158 if (name[a] ==
'[' || oname[a] ==
'[') {
1161 if (name[a] == 0 || oname[a] == 0) {
1190 const char *otype = types[member->
type_index];
1194 return STREQ(type, otype);
1246 const char *otype = types[member->
type_index];
1249 if (
STREQ(type, otype)) {
1322 return type_size * array_length;
1327 if (struct_index == -1) {
1333 int offset_in_bytes = 0;
1334 for (
int member_index = 0; member_index < struct_info->
members_num; member_index++) {
1337 char *member_data =
data + offset_in_bytes;
1341 switch (member_category) {
1346 for (
int a = 0; a < member_array_length; a++) {
1381 if (
sizeof(
void *) < 8) {
1443 const int old_struct_index,
1444 const int new_struct_index,
1445 const char *old_blocks,
1458 const int new_struct_index,
1459 const char *old_block,
1463 const int step_count = reconstruct_info->
step_counts[new_struct_index];
1466 for (
int a = 0; a < step_count; a++) {
1468 switch (
step->type) {
1470 memcpy(new_block +
step->data.memcpy.new_offset,
1471 old_block +
step->data.memcpy.old_offset,
1472 step->data.memcpy.size);
1476 step->data.cast_primitive.new_type,
1477 step->data.cast_primitive.array_len,
1478 old_block +
step->data.cast_primitive.old_offset,
1479 new_block +
step->data.cast_primitive.new_offset);
1483 (
const uint64_t *)(old_block +
step->data.cast_pointer.old_offset),
1484 (uint32_t *)(new_block +
step->data.cast_pointer.new_offset));
1488 (
const uint32_t *)(old_block +
step->data.cast_pointer.old_offset),
1489 (
uint64_t *)(new_block +
step->data.cast_pointer.new_offset));
1493 step->data.substruct.array_len,
1494 step->data.substruct.old_struct_index,
1495 step->data.substruct.new_struct_index,
1496 old_block +
step->data.substruct.old_offset,
1497 new_block +
step->data.substruct.new_offset);
1512 const int old_struct_index,
1513 const int new_struct_index,
1514 const char *old_blocks,
1523 for (
int a = 0; a < blocks; a++) {
1524 const char *old_block = old_blocks + a * old_block_size;
1525 char *new_block = new_blocks + a * new_block_size;
1531 int old_struct_index,
1533 const void *old_blocks,
1534 const char *alloc_name)
1543 if (new_struct_index == -1) {
1551 char *new_blocks =
static_cast<char *
>(
1557 static_cast<const char *
>(old_blocks),
1569 for (
int a = 0; a < struct_info->
members_num; a++) {
1583 const SDNA *newsdna,
1584 const char *compare_flags,
1587 const int new_member_offset,
1592 int old_member_offset;
1595 oldsdna, old_struct, new_name, &old_member_offset);
1597 if (old_member ==
nullptr) {
1607 if (new_category != old_category) {
1616 const int shared_array_length = std::min(new_array_length, old_array_length);
1621 switch (new_category) {
1623 if (
STREQ(new_type_name, old_type_name)) {
1627 compare_flags[old_struct_index]);
1632 r_step->
data.memcpy.new_offset = new_member_offset;
1633 r_step->
data.memcpy.old_offset = old_member_offset;
1635 shared_array_length;
1645 r_step->
data.substruct.new_offset = new_member_offset;
1646 r_step->
data.substruct.old_offset = old_member_offset;
1647 r_step->
data.substruct.array_len = shared_array_length;
1648 r_step->
data.substruct.new_struct_index = new_struct_index;
1649 r_step->
data.substruct.old_struct_index = old_struct_index;
1659 if (
STREQ(new_type_name, old_type_name)) {
1662 r_step->
data.memcpy.new_offset = new_member_offset;
1663 r_step->
data.memcpy.old_offset = old_member_offset;
1665 shared_array_length;
1670 r_step->
data.cast_primitive.array_len = shared_array_length;
1671 r_step->
data.cast_primitive.new_offset = new_member_offset;
1672 r_step->
data.cast_primitive.old_offset = old_member_offset;
1682 r_step->
data.memcpy.new_offset = new_member_offset;
1683 r_step->
data.memcpy.old_offset = old_member_offset;
1689 r_step->
data.cast_pointer.new_offset = new_member_offset;
1690 r_step->
data.cast_pointer.old_offset = old_member_offset;
1691 r_step->
data.cast_pointer.array_len = shared_array_length;
1696 r_step->
data.cast_pointer.new_offset = new_member_offset;
1697 r_step->
data.cast_pointer.old_offset = old_member_offset;
1698 r_step->
data.cast_pointer.array_len = shared_array_length;
1711 const SDNA *oldsdna,
1712 const SDNA *newsdna)
1714 switch (
step->type) {
1716 printf(
"initialize zero");
1720 printf(
"memcpy, size: %d, old offset: %d, new offset: %d",
1721 step->data.memcpy.size,
1722 step->data.memcpy.old_offset,
1723 step->data.memcpy.new_offset);
1728 "cast element, old type: %d ('%s'), new type: %d ('%s'), old offset: %d, new offset: "
1730 int(
step->data.cast_primitive.old_type),
1731 oldsdna->
types[
step->data.cast_primitive.old_type],
1732 int(
step->data.cast_primitive.new_type),
1733 newsdna->
types[
step->data.cast_primitive.new_type],
1734 step->data.cast_primitive.old_offset,
1735 step->data.cast_primitive.new_offset,
1736 step->data.cast_primitive.array_len);
1740 printf(
"pointer to 32, old offset: %d, new offset: %d, length: %d",
1741 step->data.cast_pointer.old_offset,
1742 step->data.cast_pointer.new_offset,
1743 step->data.cast_pointer.array_len);
1747 printf(
"pointer to 64, old offset: %d, new offset: %d, length: %d",
1748 step->data.cast_pointer.old_offset,
1749 step->data.cast_pointer.new_offset,
1750 step->data.cast_pointer.array_len);
1755 "substruct, old offset: %d, new offset: %d, new struct: %d ('%s', size per struct: %d), "
1757 step->data.substruct.old_offset,
1758 step->data.substruct.new_offset,
1759 step->data.substruct.new_struct_index,
1762 step->data.substruct.array_len);
1773 const SDNA *newsdna,
1774 const char *compare_flags,
1780 int new_member_offset = 0;
1781 for (
int new_member_index = 0; new_member_index < new_struct->
members_num; new_member_index++) {
1789 &steps[new_member_index]);
1799 int new_step_count = 0;
1800 for (
int a = 0; a < old_step_count; a++) {
1802 switch (
step->type) {
1807 if (new_step_count > 0) {
1812 if (prev_step->
data.memcpy.old_offset + prev_step->
data.memcpy.size ==
1813 step->data.memcpy.old_offset &&
1814 prev_step->
data.memcpy.new_offset + prev_step->
data.memcpy.size ==
1815 step->data.memcpy.new_offset)
1817 prev_step->
data.memcpy.size +=
step->data.memcpy.size;
1822 steps[new_step_count] = *
step;
1831 steps[new_step_count] = *
step;
1836 return new_step_count;
1840 const SDNA *newsdna,
1841 const char *compare_flags)
1844 reconstruct_info->
oldsdna = oldsdna;
1845 reconstruct_info->
newsdna = newsdna;
1852 for (
int new_struct_index = 0; new_struct_index < newsdna->
structs_num; new_struct_index++) {
1856 if (old_struct_index < 0) {
1857 reconstruct_info->
steps[new_struct_index] =
nullptr;
1858 reconstruct_info->
step_counts[new_struct_index] = 0;
1863 oldsdna, newsdna, compare_flags, old_struct, new_struct);
1868 reconstruct_info->
steps[new_struct_index] = steps;
1869 reconstruct_info->
step_counts[new_struct_index] = steps_len;
1873 printf(
"%s: \n", new_struct_name);
1874 for (
int a = 0; a < steps_len; a++) {
1882 return reconstruct_info;
1887 for (
int new_struct_index = 0; new_struct_index < reconstruct_info->
newsdna->
structs_num;
1890 if (reconstruct_info->
steps[new_struct_index] !=
nullptr) {
1901 const char *vartype,
1912 const char *vartype,
1928 const char *vartype,
1933 if (struct_index != -1) {
1946 const char *vartype,
1981 BLI_assert_msg(
false,
"Operations on the size of SDNA_TYPE_RAW_DATA is not supported");
2009#ifdef WITH_DNA_GHASH
2019 const char *old_type_name,
2020 const char *new_type_name)
2023 if (struct_index != -1) {
2031 const int struct_index,
2032 const char *old_member_name,
2033 const char *new_member_name)
2038 const int old_member_name_len = strlen(old_member_name);
2039 const int new_member_name_len = strlen(new_member_name);
2042 for (
int struct_member_index = struct_info->
members_num; struct_member_index > 0;
2043 struct_member_index--)
2048 uint old_member_name_full_offset_start;
2050 old_member_name_len,
2051 old_member_name_full,
2052 &old_member_name_full_offset_start))
2059 old_member_name_len,
2061 new_member_name_len,
2062 old_member_name_full,
2063 strlen(old_member_name_full),
2064 old_member_name_full_offset_start);
2074 const short old_member_index = member_info->
member_index;
2086 const char *type_name,
2087 const char *old_member_name,
2088 const char *new_member_name)
2091 if (struct_index != -1) {
2113 int names_expand_len = 0;
2114 for (
int struct_index = 0; struct_index < sdna->
structs_num; struct_index++) {
2121 int names_expand_index = 0;
2122 for (
int struct_index = 0; struct_index < sdna->
structs_num; struct_index++) {
2129 memcpy(struct_new, struct_old, array_size);
2130 sdna->
structs[struct_index] = struct_new;
2137 names_array_len_expand[names_expand_index] =
2142 names_expand_index++;
2155 GHash *elem_map_alias_from_static,
2156 const char *struct_name_static,
2157 const char *elem_static_full)
2159 const int elem_static_full_len = strlen(elem_static_full);
2160 char *elem_static =
static_cast<char *
>(alloca(elem_static_full_len + 1));
2162 const char *str_pair[2] = {struct_name_static, elem_static};
2163 const char *elem_alias =
static_cast<const char *
>(
2172 elem_static_full_len,
2185 const bool use_legacy_hack =
true;
2191 GHash *type_map_alias_from_static;
2192 GHash *member_map_alias_from_static;
2199 for (
int type_index = 0; type_index < sdna->
types_num; type_index++) {
2200 const char *type_name_static = sdna->
types[type_index];
2202 if (use_legacy_hack) {
2207 type_map_alias_from_static, type_name_static, (
void *)type_name_static));
2214 for (
int struct_index = 0; struct_index < sdna->
structs_num; struct_index++) {
2216 const char *struct_name_static = sdna->
types[struct_info->
type_index];
2218 if (use_legacy_hack) {
2222 for (
int a = 0; a < struct_info->
members_num; a++) {
2226 member_map_alias_from_static,
2229 if (member_alias_full !=
nullptr) {
2249#ifdef WITH_DNA_GHASH
2252 for (intptr_t struct_index = 0; struct_index < sdna->
structs_num; struct_index++) {
2275 const void *initial_data,
2278 fmt::appender &dst);
2281 const void *initial_data,
2283 fmt::appender &dst);
2290 const int string_length = strnlen(
data, array_len);
2291 if (string_length == array_len) {
2299 if (!std::isprint(c)) {
2313 if (element_num == 1) {
2322 fmt::format_to(dst,
"{:{}}{}: <{}>\n",
"", indent,
i, struct_name);
2329 const void *initial_data,
2334 const void *
data = initial_data;
2343 fmt::format_to(dst,
"{:{}}{} {}:",
"", indent, member_type_name, member_name);
2348 const char *str_data =
static_cast<const char *
>(
data);
2349 fmt::format_to(dst,
" ");
2351 fmt::format_to(dst,
"'{}'", str_data);
2354 for (
const int i :
IndexRange(member_array_len)) {
2355 fmt::format_to(dst,
"{} ",
int(str_data[
i]));
2358 fmt::format_to(dst,
"\n");
2361 switch (member_category) {
2363 fmt::format_to(dst,
"\n");
2367 sdna, sub_sdna_struct,
data, member_array_len, indent + 2, dst);
2371 fmt::format_to(dst,
" ");
2374 for ([[maybe_unused]]
const int elem_i :
IndexRange(member_array_len)) {
2378 const char value = *
reinterpret_cast<const char *
>(current_data);
2379 fmt::format_to(dst,
"{}",
int(value));
2383 const uchar value = *
reinterpret_cast<const uchar *
>(current_data);
2384 fmt::format_to(dst,
"{}",
int(value));
2388 fmt::format_to(dst,
"{}", *
reinterpret_cast<const int8_t *
>(current_data));
2392 fmt::format_to(dst,
"{}", *
reinterpret_cast<const short *
>(current_data));
2396 fmt::format_to(dst,
"{}", *
reinterpret_cast<const ushort *
>(current_data));
2400 fmt::format_to(dst,
"{}", *
reinterpret_cast<const int *
>(current_data));
2404 fmt::format_to(dst,
"{}", *
reinterpret_cast<const float *
>(current_data));
2408 fmt::format_to(dst,
"{}", *
reinterpret_cast<const double *
>(current_data));
2412 fmt::format_to(dst,
"{}", *
reinterpret_cast<const int64_t *
>(current_data));
2416 fmt::format_to(dst,
"{}", *
reinterpret_cast<const uint64_t *
>(current_data));
2424 fmt::format_to(dst,
" ");
2426 fmt::format_to(dst,
"\n");
2430 for ([[maybe_unused]]
const int elem_i :
IndexRange(member_array_len)) {
2432 fmt::format_to(dst,
" {}", *
reinterpret_cast<const void *
const *
>(current_data));
2434 fmt::format_to(dst,
"\n");
2445 const int struct_id,
2446 const void *initial_data,
2447 const void *address,
2449 std::ostream &stream)
2453 fmt::memory_buffer buf;
2454 fmt::appender dst{buf};
2457 fmt::format_to(dst,
"<{}> {}x at {}\n", struct_name, element_num, address);
2460 stream << fmt::to_string(buf);
#define BLI_assert_unreachable()
#define BLI_STATIC_ASSERT(a, msg)
#define BLI_assert_msg(a, msg)
#define BLI_STATIC_ASSERT_ALIGN(st, align)
BLI_INLINE void BLI_endian_switch_int32(int *val) ATTR_NONNULL(1)
void BLI_endian_switch_int32_array(int *val, int size) ATTR_NONNULL(1)
void BLI_endian_switch_uint64_array(uint64_t *val, int size) ATTR_NONNULL(1)
void BLI_endian_switch_int64_array(int64_t *val, int size) ATTR_NONNULL(1)
void BLI_endian_switch_int16_array(short *val, int size) ATTR_NONNULL(1)
BLI_INLINE void BLI_endian_switch_int16(short *val) ATTR_NONNULL(1)
void * BLI_ghash_lookup_default(const GHash *gh, const void *key, void *val_default) ATTR_WARN_UNUSED_RESULT
void ** BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
GHash * BLI_ghash_str_new_ex(const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
#define BLI_MEMARENA_STD_BUFSIZE
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
void * BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
ATTR_WARN_UNUSED_RESULT const size_t num
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
#define POINTER_OFFSET(v, ofs)
blenloader genfile private function prototypes
const char * DNA_struct_get_compareflags(const struct SDNA *oldsdna, const struct SDNA *newsdna)
void DNA_sdna_free(struct SDNA *sdna)
const struct SDNA * DNA_sdna_current_get(void)
int DNA_struct_find_with_alias(const struct SDNA *sdna, const char *str)
const unsigned char DNAstr[]
int DNA_elem_type_size(eSDNA_Type elem_nr)
int DNA_struct_member_offset_by_name_with_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
int DNA_struct_size(const struct SDNA *sdna, int struct_index)
const char * DNA_struct_identifier(struct SDNA *sdna, int struct_index)
void DNA_sdna_current_free(void)
bool DNA_sdna_patch_struct_by_name(struct SDNA *sdna, const char *old_type_name, const char *new_type_name)
void DNA_sdna_current_init(void)
void * DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info, int old_struct_index, int blocks, const void *old_blocks, const char *alloc_name)
bool DNA_struct_exists_without_alias(const struct SDNA *sdna, const char *stype)
struct DNA_ReconstructInfo * DNA_reconstruct_info_create(const struct SDNA *oldsdna, const struct SDNA *newsdna, const char *compare_flags)
void DNA_sdna_alias_data_ensure(struct SDNA *sdna)
bool DNA_struct_member_exists_with_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
struct SDNA * DNA_sdna_from_data(const void *data, int data_len, bool do_endian_swap, bool data_alloc, bool do_alias, const char **r_error_message)
int DNA_struct_member_size(const struct SDNA *sdna, short type, short member_index)
int DNA_struct_find_index_with_alias_ex(const struct SDNA *sdna, const char *str, unsigned int *struct_index_last)
void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_index, char *data)
bool DNA_struct_member_exists_without_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
int DNA_struct_find_index_without_alias(const struct SDNA *sdna, const char *str)
void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info)
bool DNA_sdna_patch_struct_member_by_name(struct SDNA *sdna, const char *type_name, const char *old_member_name, const char *new_member_name)
int DNA_struct_alignment(const struct SDNA *sdna, int struct_index)
int DNA_struct_find_index_without_alias_ex(const struct SDNA *sdna, const char *str, unsigned int *struct_index_last)
void DNA_sdna_alias_data_ensure_structs_map(struct SDNA *sdna)
bool DNA_struct_exists_with_alias(const struct SDNA *sdna, const char *str)
int DNA_struct_member_offset_by_name_without_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
#define SDNA_RAW_DATA_STRUCT_INDEX
struct SDNA_Struct SDNA_Struct
Read Guarded memory(de)allocation.
#define MAKE_ID(a, b, c, d)
BMesh const char void * data
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
constexpr IndexRange()=default
void reserve(const int64_t n)
static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error_message)
static void print_reconstruct_step(const ReconstructStep *step, const SDNA *oldsdna, const SDNA *newsdna)
static void reconstruct_struct(const DNA_ReconstructInfo *reconstruct_info, const int new_struct_index, const char *old_block, char *new_block)
static void reconstruct_structs(const DNA_ReconstructInfo *reconstruct_info, const int blocks, const int old_struct_index, const int new_struct_index, const char *old_blocks, char *new_blocks)
static bool sdna_struct_size_check(const SDNA *sdna, const SDNA_Struct *struct_info, const int64_t voided_members_size, const char **r_error_message)
@ RECONSTRUCT_STEP_CAST_POINTER_TO_32
@ RECONSTRUCT_STEP_CAST_POINTER_TO_64
@ RECONSTRUCT_STEP_INIT_ZERO
@ RECONSTRUCT_STEP_SUBSTRUCT
@ RECONSTRUCT_STEP_CAST_PRIMITIVE
@ RECONSTRUCT_STEP_MEMCPY
static bool ispointer(const char *name)
static bool DNA_sdna_patch_struct_member(SDNA *sdna, const int struct_index, const char *old_member_name, const char *new_member_name)
static bool elem_exists_impl(const char **types, const char **names, const char *type, const char *name, const SDNA_Struct *old)
static bool DNA_sdna_patch_struct(SDNA *sdna, const int struct_index, const char *new_type_name)
static int elem_offset_with_alias(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
static void cast_primitive_type(const eSDNA_Type old_type, const eSDNA_Type new_type, const int array_len, const char *old_data, char *new_data)
BLI_INLINE const char * pad_up_4(const char *ptr)
static void init_reconstruct_step_for_member(const SDNA *oldsdna, const SDNA *newsdna, const char *compare_flags, const SDNA_Struct *old_struct, const SDNA_StructMember *new_member, const int new_member_offset, ReconstructStep *r_step)
static void cast_pointer_64_to_32(const int array_len, const uint64_t *old_data, uint32_t *new_data)
static void sdna_expand_names(SDNA *sdna)
static int get_member_size_in_bytes(const SDNA *sdna, const SDNA_StructMember *member)
static int dna_struct_find_index_ex_impl(const char **types, const int, SDNA_Struct **const structs, const int structs_num, const char *str, uint *struct_index_last)
static const char * dna_sdna_alias_from_static_elem_full(SDNA *sdna, GHash *elem_map_alias_from_static, const char *struct_name_static, const char *elem_static_full)
static bool elem_exists_without_alias(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
static eStructMemberCategory get_struct_member_category(const SDNA *sdna, const SDNA_StructMember *member)
static bool elem_exists_with_alias(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
static void set_compare_flags_for_struct(const SDNA *oldsdna, const SDNA *newsdna, char *compare_flags, const int old_struct_index)
static const SDNA_StructMember * find_member_with_matching_name(const SDNA *sdna, const SDNA_Struct *struct_info, const char *name, int *r_offset)
static ReconstructStep * create_reconstruct_steps_for_struct(const SDNA *oldsdna, const SDNA *newsdna, const char *compare_flags, const SDNA_Struct *old_struct, const SDNA_Struct *new_struct)
static int elem_offset_without_alias(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
static int elem_offset_impl(const SDNA *sdna, const char **types, const char **names, const char *type, const char *name, const SDNA_Struct *old)
@ STRUCT_MEMBER_CATEGORY_STRUCT
@ STRUCT_MEMBER_CATEGORY_POINTER
@ STRUCT_MEMBER_CATEGORY_PRIMITIVE
static void cast_pointer_32_to_64(const int array_len, const uint32_t *old_data, uint64_t *new_data)
static bool elem_streq(const char *name, const char *oname)
static const char * sdna_data_pointer_read_string(const char *&data, const void *const data_pointer_end, const char **r_error_message)
static T sdna_data_pointer_read(T &data, const int64_t num, const void *const data_pointer_end, const char **r_error_message)
static int compress_reconstruct_steps(ReconstructStep *steps, const int old_step_count)
static bool sdna_data_validate_array_size(const int64_t size, T data_pointer_current, const void *const data_pointer_end, const char **r_error_message)
const char * DNA_struct_rename_legacy_hack_static_from_alias(const char *name)
const char * DNA_struct_rename_legacy_hack_alias_from_static(const char *name)
int DNA_member_array_num(const char *str)
bool DNA_member_id_match(const char *member_id, const int member_id_len, const char *member_full, uint *r_member_full_offset)
uint DNA_member_id_offset_start(const char *member_full)
uint DNA_member_id_strip_copy(char *member_id_dst, const char *member_full_src)
char * DNA_member_id_rename(MemArena *mem_arena, const char *member_id_src, const int member_id_src_len, const char *member_id_dst, const int member_id_dst_len, const char *member_full_src, const int member_full_src_len, const uint member_full_src_offset_len)
@ DNA_RENAME_ALIAS_FROM_STATIC
void DNA_alias_maps(enum eDNA_RenameDir version_dir, struct GHash **r_type_map, struct GHash **r_member_map)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define MEM_recallocN(vmemh, len)
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_freeN(void *vmemh)
void *(*) MEM_calloc_arrayN_aligned(size_t len, size_t size, size_t alignment, const char *str)
ccl_device_inline float len(const float2 a)
static void print_struct_array_recursive(const SDNA &sdna, const SDNA_Struct &sdna_struct, const void *initial_data, const int64_t element_num, const int indent, fmt::appender &dst)
static bool char_array_startswith_simple_name(const char *data, const int array_len)
static void print_single_struct_recursive(const SDNA &sdna, const SDNA_Struct &sdna_struct, const void *initial_data, const int indent, fmt::appender &dst)
void print_struct_by_id(int struct_id, const void *data)
void print_structs_at_address(const SDNA &sdna, int struct_id, const void *data, const void *address, int64_t element_num, std::ostream &stream)
MatBase< float, 4, 4 > float4x4
const char * compare_flags
eReconstructStepType type
union ReconstructStep::@071354107217270120033057222027047172212277333201 data
SDNA_StructMember members[]
struct GHash * types_to_structs_map
struct MemArena * mem_arena
struct SDNA::@202212146013366211022056013367272213111007374231 alias
short * members_array_num
struct ReconstructStep::@071354107217270120033057222027047172212277333201::@044123166360150113074235220132123363066272115022 cast_primitive
struct ReconstructStep::@071354107217270120033057222027047172212277333201::@024265075232010367206107235241134100000152136357 cast_pointer
struct ReconstructStep::@071354107217270120033057222027047172212277333201::@064020044043160367014130207226267156041225015165 substruct
struct ReconstructStep::@071354107217270120033057222027047172212277333201::@317035355061027230024155212135006366012152201143 memcpy