71 current = current * 10 + (
c -
'0');
87 return ((
c >=
'a' &&
c <=
'z') || (
c >=
'A' &&
c <=
'Z') || (
c >=
'0' &&
c <=
'9') ||
93 uint elem_full_offset = 0;
97 return elem_full_offset;
102 uint elem_full_offset = 0;
106 return elem_full_offset;
115 const char *elem_src_trim = elem_src + elem_src_offset;
117 memcpy(elem_dst, elem_src_trim, elem_src_trim_len);
118 elem_dst[elem_src_trim_len] =
'\0';
119 return elem_src_trim_len;
127 memmove(elem, elem_trim, elem_trim_len);
128 elem[elem_trim_len] =
'\0';
129 return elem_trim_len;
137 const int elem_search_len,
138 const char *elem_full,
139 uint *r_elem_full_offset)
141 BLI_assert(strlen(elem_search) == elem_search_len);
143 const char *elem_full_trim = elem_full + elem_full_offset;
144 if (strncmp(elem_search, elem_full_trim, elem_search_len) == 0) {
145 const char c = elem_full_trim[elem_search_len];
147 *r_elem_full_offset = elem_full_offset;
158 const char *elem_src,
159 const int elem_src_len,
160 const char *elem_dst,
161 const int elem_dst_len,
162 const char *elem_src_full,
163 const int elem_src_full_len,
164 const uint elem_src_full_offset_len)
168 BLI_assert(strlen(elem_src_full) == elem_src_full_len);
172 const int elem_final_len = (elem_src_full_len - elem_src_len) + elem_dst_len;
175 if (elem_src_full_offset_len != 0) {
176 memcpy(elem_dst_full, elem_src_full, elem_src_full_offset_len);
177 i = elem_src_full_offset_len;
179 memcpy(&elem_dst_full[i], elem_dst, elem_dst_len + 1);
181 uint elem_src_full_offset_end = elem_src_full_offset_len + elem_src_len;
182 if (elem_src_full[elem_src_full_offset_end] !=
'\0') {
183 const int elem_full_tail_len = (elem_src_full_len - elem_src_full_offset_end);
184 memcpy(&elem_dst_full[i], &elem_src_full[elem_src_full_offset_end], elem_full_tail_len + 1);
185 i += elem_full_tail_len;
187 BLI_assert((strlen(elem_dst_full) == elem_final_len) && (i == elem_final_len));
188 return elem_dst_full;
199 const char *
const *pair =
ptr;
205 const char *
const *pair_a =
a;
206 const char *
const *pair_b = b;
207 return (
STREQ(pair_a[0], pair_b[0]) &&
STREQ(pair_a[1], pair_b[1])) ? false :
true;
214 const char *
data[][2] = {
215 #define DNA_STRUCT_RENAME(old, new) {#old, #new},
216 #define DNA_STRUCT_RENAME_ELEM(struct_name, old, new)
218 #undef DNA_STRUCT_RENAME
219 #undef DNA_STRUCT_RENAME_ELEM
222 int elem_key, elem_val;
237 const char *renames[][2] = {
238 {
"uint8_t",
"uchar"},
239 {
"int16_t",
"short"},
240 {
"uint16_t",
"ushort"},
244 for (
int i = 0; i <
ARRAY_SIZE(renames); i++) {
249 *r_struct_map = struct_map;
258 if (r_elem_map !=
NULL) {
259 const char *
data[][3] = {
260 #define DNA_STRUCT_RENAME(old, new)
261 #define DNA_STRUCT_RENAME_ELEM(struct_name, old, new) {#struct_name, #old, #new},
263 #undef DNA_STRUCT_RENAME
264 #undef DNA_STRUCT_RENAME_ELEM
267 int elem_key, elem_val;
279 const char **str_pair =
MEM_mallocN(
sizeof(
char *) * 2, __func__);
281 str_pair[1] =
data[i][elem_key];
284 *r_elem_map = elem_map;
287 if (struct_map_local) {
314 if (
STREQ(
"bScreen", name)) {
318 if (
STREQ(
"Collection", name)) {
321 if (
STREQ(
"CollectionObject", name)) {
322 return "GroupObject";
330 if (
STREQ(
"Screen", name)) {
334 if (
STREQ(
"Group", name)) {
337 if (
STREQ(
"GroupObject", name)) {
338 return "CollectionObject";
GHash * BLI_ghash_new_ex(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
GHash * BLI_ghash_str_new_ex(const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup_default(GHash *gh, const void *key, void *val_default) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
#define UNUSED_VARS_NDEBUG(...)
Read Guarded memory(de)allocation.
static int elem_offset(const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old)
static bool strhash_pair_cmp(const void *a, const void *b)
uint DNA_elem_id_strip(char *elem)
const char * DNA_struct_rename_legacy_hack_static_from_alias(const char *name)
char * DNA_elem_id_rename(struct MemArena *mem_arena, const char *elem_src, const int elem_src_len, const char *elem_dst, const int elem_dst_len, const char *elem_src_full, const int elem_src_full_len, const uint elem_src_full_offset_len)
void DNA_alias_maps(enum eDNA_RenameDir version_dir, GHash **r_struct_map, GHash **r_elem_map)
uint DNA_elem_id_offset_start(const char *elem_full)
uint DNA_elem_id_offset_end(const char *elem_full)
bool DNA_elem_id_match(const char *elem_search, const int elem_search_len, const char *elem_full, uint *r_elem_full_offset)
const char * DNA_struct_rename_legacy_hack_alias_from_static(const char *name)
uint DNA_elem_id_strip_copy(char *elem_dst, const char *elem_src)
int DNA_elem_array_size(const char *str)
static bool is_identifier(const char c)
static uint strhash_pair_p(const void *ptr)
@ DNA_RENAME_ALIAS_FROM_STATIC
@ DNA_RENAME_STATIC_FROM_ALIAS
static MemArena * mem_arena
void *(* MEM_mallocN)(size_t len, const char *str)