Blender
V3.3
|
DNA handling. More...
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BLI_endian_switch.h"
#include "BLI_memarena.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "DNA_genfile.h"
#include "DNA_sdna_types.h"
Go to the source code of this file.
Classes | |
struct | ReconstructStep |
struct | DNA_ReconstructInfo |
Macros | |
#define | MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a)) |
Typedefs | |
typedef enum eStructMemberCategory | eStructMemberCategory |
typedef enum eReconstructStepType | eReconstructStepType |
typedef struct ReconstructStep | ReconstructStep |
typedef struct DNA_ReconstructInfo | DNA_ReconstructInfo |
Functions | |
void | DNA_sdna_free (SDNA *sdna) |
static bool | ispointer (const char *name) |
int | DNA_elem_size_nr (const SDNA *sdna, short type, short name) |
static int | dna_struct_find_nr_ex_impl (const char **types, const int UNUSED(types_len), SDNA_Struct **const structs, const int structs_len, const char *str, unsigned int *index_last) |
int | DNA_struct_find_nr_ex (const SDNA *sdna, const char *str, unsigned int *index_last) |
int | DNA_struct_alias_find_nr_ex (const SDNA *sdna, const char *str, unsigned int *index_last) |
int | DNA_struct_find_nr (const SDNA *sdna, const char *str) |
int | DNA_struct_alias_find_nr (const SDNA *sdna, const char *str) |
BLI_INLINE const char * | pad_up_4 (const char *ptr) |
static bool | init_structDNA (SDNA *sdna, bool do_endian_swap, const char **r_error_message) |
SDNA * | DNA_sdna_from_data (const void *data, const int data_len, bool do_endian_swap, bool data_alloc, const char **r_error_message) |
void | DNA_sdna_current_init (void) |
const struct SDNA * | DNA_sdna_current_get (void) |
void | DNA_sdna_current_free (void) |
static void | set_compare_flags_for_struct (const SDNA *oldsdna, const SDNA *newsdna, char *compare_flags, const int old_struct_index) |
const char * | DNA_struct_get_compareflags (const SDNA *oldsdna, const SDNA *newsdna) |
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) |
static void | cast_pointer_32_to_64 (const int array_len, const uint32_t *old_data, uint64_t *new_data) |
static void | cast_pointer_64_to_32 (const int array_len, const uint64_t *old_data, uint32_t *new_data) |
static bool | elem_streq (const char *name, const char *oname) |
static bool | elem_exists_impl (const char **types, const char **names, const char *type, const char *name, const SDNA_Struct *old) |
static bool | elem_exists (const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old) |
static bool | elem_exists_alias (const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old) |
static int | elem_offset (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 int | get_member_size_in_bytes (const SDNA *sdna, const SDNA_StructMember *member) |
void | DNA_struct_switch_endian (const SDNA *sdna, int struct_nr, char *data) |
static void | reconstruct_structs (const DNA_ReconstructInfo *reconstruct_info, const int blocks, const int old_struct_nr, const int new_struct_nr, const char *old_blocks, char *new_blocks) |
static void | reconstruct_struct (const DNA_ReconstructInfo *reconstruct_info, const int new_struct_nr, const char *old_block, char *new_block) |
void * | DNA_struct_reconstruct (const DNA_ReconstructInfo *reconstruct_info, int old_struct_nr, int blocks, const void *old_blocks) |
static const SDNA_StructMember * | find_member_with_matching_name (const SDNA *sdna, const SDNA_Struct *struct_info, const char *name, int *r_offset) |
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 | print_reconstruct_step (ReconstructStep *step, const SDNA *oldsdna, const SDNA *newsdna) |
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 | compress_reconstruct_steps (ReconstructStep *steps, const int old_step_count) |
DNA_ReconstructInfo * | DNA_reconstruct_info_create (const SDNA *oldsdna, const SDNA *newsdna, const char *compare_flags) |
void | DNA_reconstruct_info_free (DNA_ReconstructInfo *reconstruct_info) |
int | DNA_elem_offset (SDNA *sdna, const char *stype, const char *vartype, const char *name) |
bool | DNA_struct_find (const SDNA *sdna, const char *stype) |
bool | DNA_struct_elem_find (const SDNA *sdna, const char *stype, const char *vartype, const char *name) |
bool | DNA_struct_alias_elem_find (const SDNA *sdna, const char *stype, const char *vartype, const char *name) |
int | DNA_elem_type_size (const eSDNA_Type elem_nr) |
Version Patch DNA | |
static bool | DNA_sdna_patch_struct_nr (SDNA *sdna, const int struct_name_old_nr, const char *struct_name_new) |
bool | DNA_sdna_patch_struct (SDNA *sdna, const char *struct_name_old, const char *struct_name_new) |
static bool | DNA_sdna_patch_struct_member_nr (SDNA *sdna, const int struct_name_nr, const char *elem_old, const char *elem_new) |
bool | DNA_sdna_patch_struct_member (SDNA *sdna, const char *struct_name, const char *elem_old, const char *elem_new) |
Versioning (Forward Compatible) | |
Versioning that allows new names. | |
static void | sdna_expand_names (SDNA *sdna) |
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) |
void | DNA_sdna_alias_data_ensure (SDNA *sdna) |
void | DNA_sdna_alias_data_ensure_structs_map (SDNA *sdna) |
Variables | |
static SDNA * | g_sdna = NULL |
DNA handling.
Lowest-level functions for decoding the parts of a saved .blend file, including interpretation of its SDNA block and conversion of contents of other parts according to the differences between that SDNA and the SDNA of the current (running) version of Blender.
Definition in file dna_genfile.c.
#define MAKE_ID | ( | a, | |
b, | |||
c, | |||
d | |||
) | ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a)) |
(#<enter>#<enter>)
.Structure DNA data is added to each blender file and to each executable, this to detect in .blend files new variables in structs, changed array sizes, etc. It's also used for converting endian and pointer size (32-64 bits) As an extra, Python uses a call to detect run-time the contents of a blender struct.
Create a structDNA: only needed when one of the input include (.h) files change. File Syntax:
Remember to read/write integer and short aligned!
While writing a file, the names of a struct is indicated with a type number, to be found with: type = DNA_struct_find_nr(SDNA *, const char *)
The value of type
corresponds with the index within the structs array
For the moment: the complete DNA file is included in a .blend file. For the future we can think of smarter methods, like only included the used structs. Only needed to keep a file short though...
ALLOWED AND TESTED CHANGES IN STRUCTS:
NOT YET:
vec[3]
) to float struct (vec3f
).DONE:
IMPORTANT:
uint
, but unsigned int instead, ushort
and ulong
are allowed.Definition at line 118 of file dna_genfile.c.
typedef struct DNA_ReconstructInfo DNA_ReconstructInfo |
typedef enum eReconstructStepType eReconstructStepType |
typedef enum eStructMemberCategory eStructMemberCategory |
typedef struct ReconstructStep ReconstructStep |
enum eReconstructStepType |
Enumerator | |
---|---|
RECONSTRUCT_STEP_MEMCPY | |
RECONSTRUCT_STEP_CAST_PRIMITIVE | |
RECONSTRUCT_STEP_CAST_POINTER_TO_32 | |
RECONSTRUCT_STEP_CAST_POINTER_TO_64 | |
RECONSTRUCT_STEP_SUBSTRUCT | |
RECONSTRUCT_STEP_INIT_ZERO |
Definition at line 1078 of file dna_genfile.c.
Enumerator | |
---|---|
STRUCT_MEMBER_CATEGORY_STRUCT | |
STRUCT_MEMBER_CATEGORY_PRIMITIVE | |
STRUCT_MEMBER_CATEGORY_POINTER |
Definition at line 979 of file dna_genfile.c.
|
static |
Definition at line 833 of file dna_genfile.c.
References Freestyle::a.
Referenced by reconstruct_struct().
|
static |
Definition at line 842 of file dna_genfile.c.
References Freestyle::a.
Referenced by reconstruct_struct().
|
static |
Converts a value of one primitive type to another.
old_type | Type to convert from. |
new_type | Type to convert to. |
array_len | Number of elements to convert. |
old_data | Buffer containing the old values. |
new_data | Buffer the converted values will be written to. |
Definition at line 709 of file dna_genfile.c.
References Freestyle::a, DNA_elem_type_size(), double(), SDNA_TYPE_CHAR, SDNA_TYPE_DOUBLE, SDNA_TYPE_FLOAT, SDNA_TYPE_INT, SDNA_TYPE_INT64, SDNA_TYPE_INT8, SDNA_TYPE_SHORT, SDNA_TYPE_UCHAR, SDNA_TYPE_UINT64, and SDNA_TYPE_USHORT.
Referenced by reconstruct_struct().
|
static |
Compresses an array of reconstruct steps in-place and returns the new step count.
Definition at line 1471 of file dna_genfile.c.
References Freestyle::a, ReconstructStep::data, ReconstructStep::memcpy, RECONSTRUCT_STEP_CAST_POINTER_TO_32, RECONSTRUCT_STEP_CAST_POINTER_TO_64, RECONSTRUCT_STEP_CAST_PRIMITIVE, RECONSTRUCT_STEP_INIT_ZERO, RECONSTRUCT_STEP_MEMCPY, RECONSTRUCT_STEP_SUBSTRUCT, steps, and ReconstructStep::type.
Referenced by DNA_reconstruct_info_create().
|
static |
Generate an array of reconstruct steps for the given #new_struct. There will be one reconstruct step for every member.
Definition at line 1445 of file dna_genfile.c.
References get_member_size_in_bytes(), init_reconstruct_step_for_member(), MEM_calloc_arrayN, SDNA_Struct::members, SDNA_Struct::members_len, and steps.
Referenced by DNA_reconstruct_info_create().
int DNA_elem_offset | ( | struct SDNA * | sdna, |
const char * | stype, | ||
const char * | vartype, | ||
const char * | name | ||
) |
Returns the offset of the field with the specified name and type within the specified struct type in SDNA, -1 on failure.
Definition at line 1571 of file dna_genfile.c.
References BLI_assert, DNA_struct_find_nr(), elem_offset(), and SDNA::structs.
Referenced by read_file_dna().
int DNA_elem_size_nr | ( | const SDNA * | sdna, |
short | type, | ||
short | name | ||
) |
Definition at line 164 of file dna_genfile.c.
References ispointer(), len, SDNA::names, SDNA::names_array_len, SDNA::pointer_size, type, and SDNA::types_size.
Referenced by elem_offset().
int DNA_elem_type_size | ( | eSDNA_Type | elem_nr | ) |
Returns the size in bytes of a primitive type.
Definition at line 1620 of file dna_genfile.c.
References SDNA_TYPE_CHAR, SDNA_TYPE_DOUBLE, SDNA_TYPE_FLOAT, SDNA_TYPE_INT, SDNA_TYPE_INT64, SDNA_TYPE_INT8, SDNA_TYPE_SHORT, SDNA_TYPE_UCHAR, SDNA_TYPE_UINT64, and SDNA_TYPE_USHORT.
Referenced by cast_primitive_type().
DNA_ReconstructInfo* DNA_reconstruct_info_create | ( | const SDNA * | oldsdna, |
const SDNA * | newsdna, | ||
const char * | compare_flags | ||
) |
Definition at line 1512 of file dna_genfile.c.
References Freestyle::a, DNA_ReconstructInfo::compare_flags, compress_reconstruct_steps(), create_reconstruct_steps_for_struct(), DNA_struct_find_nr(), MEM_callocN, MEM_malloc_arrayN, SDNA_Struct::members_len, DNA_ReconstructInfo::newsdna, NULL, DNA_ReconstructInfo::oldsdna, print_reconstruct_step(), DNA_ReconstructInfo::step_counts, steps, DNA_ReconstructInfo::steps, SDNA::structs, SDNA::structs_len, SDNA_Struct::type, SDNA::types, and UNUSED_VARS.
void DNA_reconstruct_info_free | ( | DNA_ReconstructInfo * | reconstruct_info | ) |
Definition at line 1559 of file dna_genfile.c.
References Freestyle::a, MEM_freeN, DNA_ReconstructInfo::newsdna, NULL, DNA_ReconstructInfo::step_counts, DNA_ReconstructInfo::steps, and SDNA::structs_len.
Referenced by blo_filedata_free().
Definition at line 1810 of file dna_genfile.c.
References Freestyle::a, SDNA::alias, BLI_ghash_free(), BLI_ghash_lookup_default(), BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, DNA_alias_maps(), DNA_RENAME_ALIAS_FROM_STATIC, dna_sdna_alias_from_static_elem_full(), DNA_struct_rename_legacy_hack_alias_from_static(), elem_map_alias_from_static, SDNA::mem_arena, MEM_freeN, MEM_mallocN, SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names, SDNA::names_len, NULL, sdna_expand_names(), struct_map_alias_from_static, SDNA::structs, SDNA::structs_len, SDNA_Struct::type, SDNA::types, and SDNA::types_len.
Referenced by DNA_sdna_alias_data_ensure_structs_map(), and RNA_create().
Separated from DNA_sdna_alias_data_ensure because it's not needed unless we want to lookup aliased struct names (DNA_struct_alias_find_nr and friends).
Definition at line 1867 of file dna_genfile.c.
References SDNA::alias, BLI_ghash_insert(), BLI_ghash_str_new_ex(), DNA_sdna_alias_data_ensure(), POINTER_FROM_INT, SDNA::structs, SDNA::structs_len, SDNA::structs_map, SDNA_Struct::type, SDNA::types, and UNUSED_VARS.
|
static |
Definition at line 1787 of file dna_genfile.c.
References BLI_ghash_lookup(), DNA_elem_id_offset_start(), DNA_elem_id_rename(), DNA_elem_id_strip_copy(), elem_map_alias_from_static, SDNA::mem_arena, and NULL.
Referenced by DNA_sdna_alias_data_ensure().
Definition at line 572 of file dna_genfile.c.
References DNA_sdna_free(), g_sdna, and NULL.
Referenced by BlendfileLoadingBaseTest::TearDownTestCase(), and WM_exit_ex().
Definition at line 566 of file dna_genfile.c.
References BLI_assert, g_sdna, and NULL.
Referenced by DNA_sdna_patch_struct_nr(), filedata_new(), and writedata_new().
Definition at line 561 of file dna_genfile.c.
References DNA_sdna_from_data(), DNAlen, DNAstr, g_sdna, and NULL.
Referenced by main(), and BlendfileLoadingBaseTest::SetUpTestCase().
Definition at line 123 of file dna_genfile.c.
References SDNA::alias, BLI_ghash_free(), BLI_memarena_free(), SDNA::data, SDNA::data_alloc, SDNA::mem_arena, MEM_freeN, MEM_SAFE_FREE, SDNA::names, SDNA::names_array_len, NULL, SDNA::structs, SDNA::structs_map, and SDNA::types.
Referenced by blo_filedata_free(), DNA_sdna_current_free(), DNA_sdna_from_data(), and RNA_define_free().
SDNA* DNA_sdna_from_data | ( | const void * | data, |
int | data_len, | ||
bool | do_endian_swap, | ||
bool | data_alloc, | ||
const char ** | r_error_message | ||
) |
Constructs and returns a decoded SDNA structure from the given encoded SDNA data block.
Definition at line 519 of file dna_genfile.c.
References data, SDNA::data, SDNA::data_alloc, SDNA::data_len, DNA_sdna_free(), init_structDNA(), MEM_mallocN, and NULL.
Referenced by DNA_sdna_current_init(), read_file_dna(), and RNA_create().
bool DNA_sdna_patch_struct | ( | struct SDNA * | sdna, |
const char * | struct_name_old, | ||
const char * | struct_name_new | ||
) |
Rename a struct
Definition at line 1662 of file dna_genfile.c.
References DNA_sdna_patch_struct_nr(), and DNA_struct_find_nr().
Referenced by blo_do_versions_dna().
bool DNA_sdna_patch_struct_member | ( | struct SDNA * | sdna, |
const char * | struct_name, | ||
const char * | elem_old, | ||
const char * | elem_new | ||
) |
Replace elem_old with elem_new for struct struct_name handles search & replace, maintaining surrounding non-identifier characters such as pointer & array size.
Definition at line 1719 of file dna_genfile.c.
References DNA_sdna_patch_struct_member_nr(), and DNA_struct_find_nr().
Referenced by blo_do_versions_dna().
|
static |
Definition at line 1672 of file dna_genfile.c.
References SDNA::alias, BLI_assert, BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, DNA_elem_id_match(), DNA_elem_id_rename(), SDNA::mem_arena, MEM_recallocN, SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names, SDNA::names_array_len, SDNA::names_len, SDNA::names_len_alloc, NULL, and SDNA::structs.
Referenced by DNA_sdna_patch_struct_member().
|
static |
Definition at line 1648 of file dna_genfile.c.
References BLI_assert, BLI_ghash_insert(), BLI_ghash_remove(), DNA_sdna_current_get(), DNA_struct_find_nr(), NULL, POINTER_FROM_INT, SDNA::structs, SDNA::structs_map, SDNA_Struct::type, and SDNA::types.
Referenced by DNA_sdna_patch_struct().
bool DNA_struct_alias_elem_find | ( | const SDNA * | sdna, |
const char * | stype, | ||
const char * | vartype, | ||
const char * | name | ||
) |
Definition at line 1602 of file dna_genfile.c.
References DNA_struct_alias_find_nr(), elem_exists_alias(), and SDNA::structs.
int DNA_struct_alias_find_nr | ( | const SDNA * | sdna, |
const char * | str | ||
) |
Definition at line 286 of file dna_genfile.c.
References DNA_struct_alias_find_nr_ex(), str, and UINT_MAX.
Referenced by DNA_struct_alias_elem_find().
int DNA_struct_alias_find_nr_ex | ( | const SDNA * | sdna, |
const char * | str, | ||
unsigned int * | index_last | ||
) |
Definition at line 261 of file dna_genfile.c.
References SDNA::alias, BLI_assert, dna_struct_find_nr_ex_impl(), NULL, str, SDNA::structs, SDNA::structs_len, SDNA::structs_map, SDNA::types, and SDNA::types_len.
Referenced by DNA_struct_alias_find_nr().
bool DNA_struct_elem_find | ( | const SDNA * | sdna, |
const char * | stype, | ||
const char * | vartype, | ||
const char * | name | ||
) |
Definition at line 1584 of file dna_genfile.c.
References DNA_struct_find_nr(), elem_exists(), and SDNA::structs.
Definition at line 1579 of file dna_genfile.c.
References DNA_struct_find_nr().
Referenced by get_struct_member_category().
int DNA_struct_find_nr | ( | const SDNA * | sdna, |
const char * | str | ||
) |
Definition at line 280 of file dna_genfile.c.
References DNA_struct_find_nr_ex(), str, and UINT_MAX.
Referenced by DNA_elem_offset(), DNA_reconstruct_info_create(), DNA_sdna_patch_struct(), DNA_sdna_patch_struct_member(), DNA_sdna_patch_struct_nr(), DNA_struct_elem_find(), DNA_struct_find(), DNA_struct_reconstruct(), DNA_struct_switch_endian(), init_reconstruct_step_for_member(), init_structDNA(), and set_compare_flags_for_struct().
int DNA_struct_find_nr_ex | ( | const SDNA * | sdna, |
const char * | str, | ||
unsigned int * | index_last | ||
) |
Definition at line 245 of file dna_genfile.c.
References dna_struct_find_nr_ex_impl(), str, SDNA::structs, SDNA::structs_len, SDNA::structs_map, SDNA::types, and SDNA::types_len.
Referenced by DNA_struct_find_nr().
|
static |
Returns the index of the struct info for the struct with the specified name.
Definition at line 202 of file dna_genfile.c.
References BLI_ghash_lookup_p(), POINTER_AS_INT, str, STREQ, structs, structs_len, SDNA_Struct::type, and types.
Referenced by DNA_struct_alias_find_nr_ex(), and DNA_struct_find_nr_ex().
Definition at line 663 of file dna_genfile.c.
References Freestyle::a, BLI_assert, MEM_mallocN, NULL, SDNA_CMP_EQUAL, SDNA_CMP_NOT_EQUAL, SDNA_CMP_UNKNOWN, set_compare_flags_for_struct(), SDNA::structs, SDNA::structs_len, SDNA_Struct::type, and SDNA::types.
void* DNA_struct_reconstruct | ( | const DNA_ReconstructInfo * | reconstruct_info, |
int | old_struct_nr, | ||
int | blocks, | ||
const void * | old_blocks | ||
) |
Definition at line 1215 of file dna_genfile.c.
References DNA_struct_find_nr(), MEM_callocN, DNA_ReconstructInfo::newsdna, NULL, DNA_ReconstructInfo::oldsdna, reconstruct_structs(), SDNA::structs, SDNA_Struct::type, SDNA::types, and SDNA::types_size.
Definition at line 1010 of file dna_genfile.c.
References Freestyle::a, BLI_assert, BLI_endian_switch_int16_array(), BLI_endian_switch_int32_array(), BLI_endian_switch_int64_array(), BLI_endian_switch_uint64_array(), data, DNA_struct_find_nr(), get_member_size_in_bytes(), get_struct_member_category(), SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names_array_len, SDNA::pointer_size, SDNA_TYPE_DOUBLE, SDNA_TYPE_FLOAT, SDNA_TYPE_INT, SDNA_TYPE_INT64, SDNA_TYPE_SHORT, SDNA_TYPE_UINT64, SDNA_TYPE_USHORT, STRUCT_MEMBER_CATEGORY_POINTER, STRUCT_MEMBER_CATEGORY_PRIMITIVE, STRUCT_MEMBER_CATEGORY_STRUCT, SDNA::structs, SDNA_StructMember::type, SDNA::types, and SDNA::types_size.
|
static |
sdna | Old SDNA. |
Definition at line 910 of file dna_genfile.c.
References elem_exists_impl(), SDNA::names, type, and SDNA::types.
Referenced by DNA_struct_elem_find().
|
static |
Definition at line 925 of file dna_genfile.c.
References SDNA::alias, elem_exists_impl(), SDNA::names, type, and SDNA::types.
Referenced by DNA_struct_alias_elem_find().
|
static |
Returns whether the specified field exists according to the struct format pointed to by old.
type | Current field type name. |
name | Current field name. |
old | Pointer to struct information in sdna. |
Definition at line 885 of file dna_genfile.c.
References Freestyle::a, elem_streq(), SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, names, STREQ, type, SDNA_StructMember::type, and types.
Referenced by elem_exists(), and elem_exists_alias().
|
static |
Return the offset in bytes or -1 on failure to find the struct member with its expected type.
sdna | Old SDNA. |
type | Current field type name. |
name | Current field name. |
old | Pointer to struct information in SDNA. |
Definition at line 954 of file dna_genfile.c.
References Freestyle::a, DNA_elem_size_nr(), elem_streq(), SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names, offset, STREQ, type, SDNA_StructMember::type, and SDNA::types.
Referenced by BM_mesh_elem_index_ensure_ex(), DNA_elem_id_strip(), DNA_elem_offset(), and EDBM_mesh_elem_index_ensure_multi().
|
static |
Equality test on name and oname excluding any array-size suffix.
Definition at line 857 of file dna_genfile.c.
References Freestyle::a.
Referenced by elem_exists_impl(), elem_offset(), and find_member_with_matching_name().
|
static |
Finds a member in the given struct with the given name.
Definition at line 1241 of file dna_genfile.c.
References Freestyle::a, elem_streq(), get_member_size_in_bytes(), SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names, NULL, and offset.
Referenced by init_reconstruct_step_for_member().
|
static |
Definition at line 999 of file dna_genfile.c.
References ispointer(), SDNA_StructMember::name, SDNA::names, SDNA::names_array_len, SDNA::pointer_size, SDNA_StructMember::type, and SDNA::types_size.
Referenced by create_reconstruct_steps_for_struct(), DNA_struct_switch_endian(), and find_member_with_matching_name().
|
static |
Definition at line 985 of file dna_genfile.c.
References DNA_struct_find(), ispointer(), SDNA_StructMember::name, SDNA::names, STRUCT_MEMBER_CATEGORY_POINTER, STRUCT_MEMBER_CATEGORY_PRIMITIVE, STRUCT_MEMBER_CATEGORY_STRUCT, SDNA_StructMember::type, and SDNA::types.
Referenced by DNA_struct_switch_endian(), and init_reconstruct_step_for_member().
|
static |
Initializes a single reconstruct step for a member in the new struct.
Definition at line 1260 of file dna_genfile.c.
References BLI_assert, BLI_assert_msg, ReconstructStep::cast_pointer, ReconstructStep::cast_primitive, ReconstructStep::data, DNA_struct_find_nr(), find_member_with_matching_name(), get_struct_member_category(), ReconstructStep::memcpy, MIN2, SDNA_StructMember::name, SDNA::names, SDNA::names_array_len, NULL, SDNA::pointer_size, RECONSTRUCT_STEP_CAST_POINTER_TO_32, RECONSTRUCT_STEP_CAST_POINTER_TO_64, RECONSTRUCT_STEP_CAST_PRIMITIVE, RECONSTRUCT_STEP_INIT_ZERO, RECONSTRUCT_STEP_MEMCPY, RECONSTRUCT_STEP_SUBSTRUCT, SDNA_CMP_EQUAL, SDNA_CMP_NOT_EQUAL, SDNA_CMP_REMOVED, STREQ, STRUCT_MEMBER_CATEGORY_POINTER, STRUCT_MEMBER_CATEGORY_PRIMITIVE, STRUCT_MEMBER_CATEGORY_STRUCT, ReconstructStep::substruct, SDNA_StructMember::type, ReconstructStep::type, SDNA::types, and SDNA::types_size.
Referenced by create_reconstruct_steps_for_struct().
|
static |
In sdna->data the data, now we convert that to something understandable
Definition at line 304 of file dna_genfile.c.
References Freestyle::a, SDNA::alias, BLI_endian_switch_int16(), BLI_endian_switch_int16_array(), BLI_endian_switch_int32(), BLI_ghash_insert(), BLI_ghash_str_new_ex(), data, SDNA::data, DNA_elem_array_size(), DNA_struct_find_nr(), DNA_struct_rename_legacy_hack_static_from_alias(), ELEM, if(), MAKE_ID, SDNA::mem_arena, MEM_callocN, MEM_mallocN, SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names, SDNA::names_array_len, SDNA::names_len, SDNA::names_len_alloc, NULL, pad_up_4(), POINTER_FROM_INT, SDNA::pointer_size, SDNA_TYPE_VOID, STREQ, SDNA::structs, SDNA::structs_len, SDNA::structs_map, SDNA_StructMember::type, SDNA_Struct::type, SDNA::types, SDNA::types_len, SDNA::types_size, and UNLIKELY.
Referenced by DNA_sdna_from_data().
|
static |
Return true if the name indicates a pointer of some kind.
Definition at line 158 of file dna_genfile.c.
Referenced by DNA_elem_size_nr(), get_member_size_in_bytes(), get_struct_member_category(), and set_compare_flags_for_struct().
BLI_INLINE const char* pad_up_4 | ( | const char * | ptr | ) |
|
static |
Useful function when debugging the reconstruct steps.
Definition at line 1385 of file dna_genfile.c.
References ReconstructStep::cast_pointer, ReconstructStep::cast_primitive, ReconstructStep::data, ReconstructStep::memcpy, RECONSTRUCT_STEP_CAST_POINTER_TO_32, RECONSTRUCT_STEP_CAST_POINTER_TO_64, RECONSTRUCT_STEP_CAST_PRIMITIVE, RECONSTRUCT_STEP_INIT_ZERO, RECONSTRUCT_STEP_MEMCPY, RECONSTRUCT_STEP_SUBSTRUCT, SDNA::structs, ReconstructStep::substruct, SDNA_Struct::type, ReconstructStep::type, SDNA::types, and SDNA::types_size.
Referenced by DNA_reconstruct_info_create().
|
static |
Converts the contents of an entire struct from oldsdna to newsdna format.
reconstruct_info | Preprocessed reconstruct information generated by DNA_reconstruct_info_create. |
new_struct_nr | Index in newsdna->structs of the struct that is being reconstructed. |
old_block | Memory buffer containing the old struct. |
new_block | Where to put converted struct contents. |
Definition at line 1142 of file dna_genfile.c.
References Freestyle::a, ReconstructStep::cast_pointer, cast_pointer_32_to_64(), cast_pointer_64_to_32(), ReconstructStep::cast_primitive, cast_primitive_type(), ReconstructStep::data, ReconstructStep::memcpy, RECONSTRUCT_STEP_CAST_POINTER_TO_32, RECONSTRUCT_STEP_CAST_POINTER_TO_64, RECONSTRUCT_STEP_CAST_PRIMITIVE, RECONSTRUCT_STEP_INIT_ZERO, RECONSTRUCT_STEP_MEMCPY, RECONSTRUCT_STEP_SUBSTRUCT, reconstruct_structs(), DNA_ReconstructInfo::step_counts, steps, DNA_ReconstructInfo::steps, ReconstructStep::substruct, and ReconstructStep::type.
Referenced by reconstruct_structs().
|
static |
Reconstructs an array of structs.
Definition at line 1195 of file dna_genfile.c.
References Freestyle::a, DNA_ReconstructInfo::newsdna, DNA_ReconstructInfo::oldsdna, reconstruct_struct(), SDNA::structs, SDNA_Struct::type, and SDNA::types_size.
Referenced by DNA_struct_reconstruct(), and reconstruct_struct().
Names are shared between structs which causes problems renaming. Make sure every struct member gets its own name so renaming only ever impacts a single struct.
The resulting SDNA is never written to disk.
Definition at line 1745 of file dna_genfile.c.
References BLI_assert, BLI_memarena_alloc(), SDNA::mem_arena, MEM_freeN, MEM_mallocN, SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names, SDNA::names_array_len, SDNA::names_len, SDNA::structs, and SDNA::structs_len.
Referenced by DNA_sdna_alias_data_ensure().
|
static |
This function changes compare_flags[old_struct_index] from SDNA_CMP_UNKNOWN to something else. It might call itself recursively.
Definition at line 586 of file dna_genfile.c.
References DNA_struct_find_nr(), ispointer(), SDNA_Struct::members, SDNA_Struct::members_len, SDNA_StructMember::name, SDNA::names, SDNA::pointer_size, SDNA_CMP_EQUAL, SDNA_CMP_NOT_EQUAL, SDNA_CMP_REMOVED, SDNA_CMP_UNKNOWN, STREQ, SDNA::structs, SDNA_StructMember::type, SDNA_Struct::type, SDNA::types, and SDNA::types_size.
Referenced by DNA_struct_get_compareflags().
Using a global is acceptable here, the data is read-only and only changes between Blender versions.
So it is safe to create once and reuse.
Definition at line 559 of file dna_genfile.c.
Referenced by DNA_sdna_current_free(), DNA_sdna_current_get(), and DNA_sdna_current_init().