|
Blender V4.5
|
DNA handling. More...
#include <algorithm>#include <climits>#include <cstdio>#include <cstdlib>#include <cstring>#include <iostream>#include <fmt/format.h>#include "MEM_guardedalloc.h"#include "BLI_endian_switch.h"#include "BLI_ghash.h"#include "BLI_index_range.hh"#include "BLI_math_matrix_types.hh"#include "BLI_memarena.h"#include "BLI_set.hh"#include "BLI_utildefines.h"#include "DNA_genfile.h"#include "DNA_print.hh"#include "DNA_sdna_types.h"Go to the source code of this file.
Classes | |
| struct | ReconstructStep |
| struct | DNA_ReconstructInfo |
Namespaces | |
| namespace | blender |
| namespace | blender::dna |
Macros | |
| #define | MAKE_ID(a, b, c, d) |
Functions | |
| void | DNA_sdna_free (SDNA *sdna) |
| int | DNA_struct_size (const SDNA *sdna, int struct_index) |
| static bool | ispointer (const char *name) |
| int | DNA_struct_member_size (const SDNA *sdna, short type, short member_index) |
| 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) |
| int | DNA_struct_find_index_without_alias_ex (const SDNA *sdna, const char *str, uint *struct_index_last) |
| int | DNA_struct_find_index_with_alias_ex (const SDNA *sdna, const char *str, uint *struct_index_last) |
| int | DNA_struct_find_index_without_alias (const SDNA *sdna, const char *str) |
| int | DNA_struct_find_with_alias (const SDNA *sdna, const char *str) |
| bool | DNA_struct_exists_with_alias (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 bool do_alias, const char **r_error_message) |
| void | DNA_sdna_current_init () |
| const SDNA * | DNA_sdna_current_get () |
| void | DNA_sdna_current_free () |
| 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_without_alias (const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old) |
| static bool | elem_exists_with_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) |
| static int | elem_offset_without_alias (const SDNA *sdna, const char *type, const char *name, const SDNA_Struct *old) |
| static int | elem_offset_with_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 int | get_member_size_in_bytes (const SDNA *sdna, const SDNA_StructMember *member) |
| void | DNA_struct_switch_endian (const SDNA *sdna, int struct_index, char *data) |
| 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 void | reconstruct_struct (const DNA_ReconstructInfo *reconstruct_info, const int new_struct_index, const char *old_block, char *new_block) |
| void * | DNA_struct_reconstruct (const DNA_ReconstructInfo *reconstruct_info, int old_struct_index, int blocks, const void *old_blocks, const char *alloc_name) |
| 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 (const 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_struct_member_offset_by_name_without_alias (const SDNA *sdna, const char *stype, const char *vartype, const char *name) |
| int | DNA_struct_member_offset_by_name_with_alias (const SDNA *sdna, const char *stype, const char *vartype, const char *name) |
| bool | DNA_struct_exists_without_alias (const SDNA *sdna, const char *stype) |
| bool | DNA_struct_member_exists_without_alias (const SDNA *sdna, const char *stype, const char *vartype, const char *name) |
| bool | DNA_struct_member_exists_with_alias (const SDNA *sdna, const char *stype, const char *vartype, const char *name) |
| int | DNA_elem_type_size (const eSDNA_Type elem_nr) |
| int | DNA_struct_alignment (const SDNA *sdna, const int struct_index) |
| const char * | DNA_struct_identifier (SDNA *sdna, const int struct_index) |
| static void | blender::dna::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 void | blender::dna::print_single_struct_recursive (const SDNA &sdna, const SDNA_Struct &sdna_struct, const void *initial_data, const int indent, fmt::appender &dst) |
| static bool | blender::dna::char_array_startswith_simple_name (const char *data, const int array_len) |
| void | blender::dna::print_structs_at_address (const SDNA &sdna, int struct_id, const void *data, const void *address, int64_t element_num, std::ostream &stream) |
| void | blender::dna::print_struct_by_id (int struct_id, const void *data) |
Version Patch DNA | |
| static bool | DNA_sdna_patch_struct (SDNA *sdna, const int struct_index, const char *new_type_name) |
| bool | DNA_sdna_patch_struct_by_name (SDNA *sdna, const char *old_type_name, const char *new_type_name) |
| static bool | DNA_sdna_patch_struct_member (SDNA *sdna, const int struct_index, const char *old_member_name, const char *new_member_name) |
| bool | DNA_sdna_patch_struct_member_by_name (SDNA *sdna, const char *type_name, const char *old_member_name, const char *new_member_name) |
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 = nullptr |
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.cc.
| #define MAKE_ID | ( | a, | |
| b, | |||
| c, | |||
| d ) |
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_with_alias(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:
DONE:
IMPORTANT:
Definition at line 125 of file dna_genfile.cc.
Referenced by init_structDNA().
| 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 1186 of file dna_genfile.cc.
| Enumerator | |
|---|---|
| STRUCT_MEMBER_CATEGORY_STRUCT | |
| STRUCT_MEMBER_CATEGORY_PRIMITIVE | |
| STRUCT_MEMBER_CATEGORY_POINTER | |
Definition at line 1087 of file dna_genfile.cc.
|
static |
Definition at line 919 of file dna_genfile.cc.
Referenced by reconstruct_struct().
|
static |
Definition at line 928 of file dna_genfile.cc.
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 788 of file dna_genfile.cc.
References BLI_assert_msg, DNA_elem_type_size(), SDNA_TYPE_CHAR, SDNA_TYPE_DOUBLE, SDNA_TYPE_FLOAT, SDNA_TYPE_INT, SDNA_TYPE_INT64, SDNA_TYPE_INT8, SDNA_TYPE_RAW_DATA, 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 1590 of file dna_genfile.cc.
References ReconstructStep::data, ReconstructStep::memcpy, ReconstructStep::new_offset, ReconstructStep::old_offset, 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, ReconstructStep::size, step, 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 1565 of file dna_genfile.cc.
References get_member_size_in_bytes(), init_reconstruct_step_for_member(), MEM_calloc_arrayN(), SDNA_Struct::members, SDNA_Struct::members_num, and steps.
Referenced by DNA_reconstruct_info_create().
| int DNA_elem_type_size | ( | eSDNA_Type | elem_nr | ) |
Returns the size in bytes of a primitive type.
Definition at line 1755 of file dna_genfile.cc.
References BLI_assert_msg, SDNA_TYPE_CHAR, SDNA_TYPE_DOUBLE, SDNA_TYPE_FLOAT, SDNA_TYPE_INT, SDNA_TYPE_INT64, SDNA_TYPE_INT8, SDNA_TYPE_RAW_DATA, 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 1632 of file dna_genfile.cc.
References DNA_ReconstructInfo::compare_flags, compress_reconstruct_steps(), create_reconstruct_steps_for_struct(), DNA_struct_find_index_without_alias(), MEM_callocN(), MEM_malloc_arrayN(), SDNA_Struct::members_num, DNA_ReconstructInfo::newsdna, DNA_ReconstructInfo::oldsdna, print_reconstruct_step(), printf, DNA_ReconstructInfo::step_counts, DNA_ReconstructInfo::steps, steps, SDNA::structs, SDNA::structs_num, SDNA_Struct::type_index, and SDNA::types.
| void DNA_reconstruct_info_free | ( | DNA_ReconstructInfo * | reconstruct_info | ) |
Definition at line 1678 of file dna_genfile.cc.
References MEM_freeN(), DNA_ReconstructInfo::newsdna, DNA_ReconstructInfo::step_counts, DNA_ReconstructInfo::steps, and SDNA::structs_num.
Referenced by blo_filedata_free().
| void DNA_sdna_alias_data_ensure | ( | SDNA * | sdna | ) |
Definition at line 1971 of file dna_genfile.cc.
References 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(), SDNA::mem_arena, MEM_freeN(), MEM_malloc_arrayN(), SDNA_StructMember::member_index, member_map_alias_from_static, SDNA::members, SDNA_Struct::members, SDNA::members_num, SDNA_Struct::members_num, sdna_expand_names(), SDNA::structs, SDNA::structs_num, SDNA_Struct::type_index, type_map_alias_from_static, SDNA::types, and SDNA::types_num.
Referenced by DNA_sdna_alias_data_ensure_structs_map(), and DNA_struct_identifier().
| void DNA_sdna_alias_data_ensure_structs_map | ( | struct SDNA * | sdna | ) |
Separated from DNA_sdna_alias_data_ensure because it's not needed unless we want to lookup aliased struct names (DNA_struct_find_with_alias and friends).
Definition at line 2035 of file dna_genfile.cc.
References SDNA::alias, BLI_ghash_insert(), BLI_ghash_str_new_ex(), DNA_sdna_alias_data_ensure(), POINTER_FROM_INT, SDNA::structs, SDNA::structs_num, SDNA_Struct::type_index, SDNA::types, SDNA::types_to_structs_map, and UNUSED_VARS.
Referenced by DNA_sdna_from_data(), and read_file_dna().
|
static |
Definition at line 1947 of file dna_genfile.cc.
References BLI_ghash_lookup(), DNA_member_id_offset_start(), DNA_member_id_rename(), DNA_member_id_strip_copy(), and SDNA::mem_arena.
Referenced by DNA_sdna_alias_data_ensure().
| void DNA_sdna_current_free | ( | void | ) |
Definition at line 630 of file dna_genfile.cc.
References DNA_sdna_free(), and g_sdna.
Referenced by BlendfileLoadingBaseTest::TearDownTestCase(), and WM_exit_ex().
| const SDNA * DNA_sdna_current_get | ( | void | ) |
Definition at line 624 of file dna_genfile.cc.
References BLI_assert, and g_sdna.
Referenced by DNA_sdna_patch_struct(), filedata_new(), blender::dna::print_struct_by_id(), and writedata_new().
| void DNA_sdna_current_init | ( | void | ) |
Definition at line 619 of file dna_genfile.cc.
References DNA_sdna_from_data(), DNAlen, DNAstr, and g_sdna.
Referenced by main(), and BlendfileLoadingBaseTest::SetUpTestCase().
| void DNA_sdna_free | ( | SDNA * | sdna | ) |
Definition at line 130 of file dna_genfile.cc.
References SDNA::alias, BLI_ghash_free(), BLI_memarena_free(), SDNA::data, SDNA::data_alloc, SDNA::mem_arena, MEM_freeN(), MEM_SAFE_FREE, SDNA::members, SDNA::members_array_num, SDNA::structs, SDNA::types, SDNA::types_alignment, and SDNA::types_to_structs_map.
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, | ||
| bool | do_alias, | ||
| const char ** | r_error_message ) |
Constructs and returns a decoded SDNA structure from the given encoded SDNA data block.
Definition at line 573 of file dna_genfile.cc.
References data, SDNA::data, SDNA::data_alloc, SDNA::data_size, DNA_sdna_alias_data_ensure_structs_map(), DNA_sdna_free(), init_structDNA(), MEM_malloc_arrayN(), and MEM_mallocN().
Referenced by DNA_sdna_current_init(), read_file_dna(), and RNA_create().
|
static |
Definition at line 1798 of file dna_genfile.cc.
References BLI_assert, BLI_ghash_insert(), BLI_ghash_remove(), DNA_sdna_current_get(), DNA_struct_find_index_without_alias(), POINTER_FROM_INT, SDNA::structs, SDNA_Struct::type_index, SDNA::types, and SDNA::types_to_structs_map.
Referenced by DNA_sdna_patch_struct_by_name().
| bool DNA_sdna_patch_struct_by_name | ( | struct SDNA * | sdna, |
| const char * | old_type_name, | ||
| const char * | new_type_name ) |
Find the struct matching the given old_type_name, and rename its type (referenced by its SDNA_Struct.type_index) to the given new_type_name.
WARNING: Deprecated, do not use in new code. Only used to version some renaming done during early 2.80 development.
Definition at line 1811 of file dna_genfile.cc.
References DNA_sdna_patch_struct(), and DNA_struct_find_index_without_alias().
Referenced by blo_do_versions_dna().
|
static |
Definition at line 1823 of file dna_genfile.cc.
References SDNA::alias, BLI_assert, BLI_memarena_new(), BLI_MEMARENA_STD_BUFSIZE, DNA_member_id_match(), DNA_member_id_rename(), SDNA::mem_arena, MEM_recallocN, SDNA_StructMember::member_index, SDNA::members, SDNA_Struct::members, SDNA::members_array_num, SDNA::members_num, SDNA_Struct::members_num, SDNA::members_num_alloc, and SDNA::structs.
Referenced by DNA_sdna_patch_struct_member_by_name().
| 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 ) |
Rename old_member_name with new_member_name for struct matching type_name.
Handles search & replace, maintaining surrounding non-identifier characters such as pointer & array size.
WARNING: Deprecated, do not use in new code. Only used to version some renaming done during early 2.80 development.
Definition at line 1878 of file dna_genfile.cc.
References DNA_sdna_patch_struct_member(), and DNA_struct_find_index_without_alias().
Referenced by blo_do_versions_dna().
| int DNA_struct_alignment | ( | const SDNA * | sdna, |
| const int | struct_index ) |
Definition at line 1782 of file dna_genfile.cc.
References SDNA::types_alignment.
Referenced by DNA_struct_reconstruct().
| bool DNA_struct_exists_with_alias | ( | const SDNA * | sdna, |
| const char * | str ) |
Definition at line 308 of file dna_genfile.cc.
References DNA_struct_find_with_alias(), and str.
| bool DNA_struct_exists_without_alias | ( | const SDNA * | sdna, |
| const char * | stype ) |
Definition at line 1714 of file dna_genfile.cc.
References DNA_struct_find_index_without_alias().
Referenced by get_struct_member_category().
|
static |
Returns the index of the struct info for the struct with the specified name.
Definition at line 213 of file dna_genfile.cc.
References BLI_ghash_lookup_p(), POINTER_AS_INT, str, STREQ, structs, structs_num, SDNA_Struct::type_index, types, and types_num.
Referenced by DNA_struct_find_index_with_alias_ex(), and DNA_struct_find_index_without_alias_ex().
| int DNA_struct_find_index_with_alias_ex | ( | const SDNA * | sdna, |
| const char * | str, | ||
| uint * | struct_index_last ) |
Definition at line 277 of file dna_genfile.cc.
References SDNA::alias, BLI_assert, dna_struct_find_index_ex_impl(), str, SDNA::structs, SDNA::structs_num, SDNA::types, SDNA::types_num, and SDNA::types_to_structs_map.
Referenced by DNA_struct_find_with_alias().
| int DNA_struct_find_index_without_alias | ( | const SDNA * | sdna, |
| const char * | str ) |
Definition at line 296 of file dna_genfile.cc.
References DNA_struct_find_index_without_alias_ex(), str, and UINT_MAX.
Referenced by DNA_reconstruct_info_create(), DNA_sdna_patch_struct(), DNA_sdna_patch_struct_by_name(), DNA_sdna_patch_struct_member_by_name(), DNA_struct_exists_without_alias(), DNA_struct_member_exists_without_alias(), DNA_struct_member_offset_by_name_without_alias(), DNA_struct_reconstruct(), DNA_struct_switch_endian(), init_reconstruct_step_for_member(), init_structDNA(), and set_compare_flags_for_struct().
| int DNA_struct_find_index_without_alias_ex | ( | const SDNA * | sdna, |
| const char * | str, | ||
| uint * | struct_index_last ) |
Definition at line 256 of file dna_genfile.cc.
References BLI_assert, dna_struct_find_index_ex_impl(), str, SDNA::structs, SDNA::structs_num, SDNA::types, SDNA::types_num, and SDNA::types_to_structs_map.
Referenced by DNA_struct_find_index_without_alias(), and init_structDNA().
| int DNA_struct_find_with_alias | ( | const SDNA * | sdna, |
| const char * | str ) |
Definition at line 302 of file dna_genfile.cc.
References DNA_struct_find_index_with_alias_ex(), str, and UINT_MAX.
Referenced by DNA_struct_exists_with_alias(), DNA_struct_member_exists_with_alias(), and DNA_struct_member_offset_by_name_with_alias().
Definition at line 722 of file dna_genfile.cc.
References BLI_assert, BLI_STATIC_ASSERT, MEM_malloc_arrayN(), printf, SDNA_CMP_EQUAL, SDNA_CMP_NOT_EQUAL, SDNA_CMP_UNKNOWN, SDNA_RAW_DATA_STRUCT_INDEX, set_compare_flags_for_struct(), SDNA::structs, SDNA::structs_num, and SDNA::types.
| const char * DNA_struct_identifier | ( | struct SDNA * | sdna, |
| int | struct_index ) |
Return the current (alias) type name of the given struct index.
Definition at line 1787 of file dna_genfile.cc.
References SDNA::alias, DNA_sdna_alias_data_ensure(), SDNA::structs, SDNA_Struct::type_index, and SDNA::types.
Referenced by BLO_read_struct_by_name_array(), and get_alloc_name().
| bool DNA_struct_member_exists_with_alias | ( | const SDNA * | sdna, |
| const char * | stype, | ||
| const char * | vartype, | ||
| const char * | name ) |
Definition at line 1737 of file dna_genfile.cc.
References DNA_struct_find_with_alias(), elem_exists_with_alias(), and SDNA::structs.
| bool DNA_struct_member_exists_without_alias | ( | const SDNA * | sdna, |
| const char * | stype, | ||
| const char * | vartype, | ||
| const char * | name ) |
Definition at line 1719 of file dna_genfile.cc.
References DNA_struct_find_index_without_alias(), elem_exists_without_alias(), and SDNA::structs.
| int DNA_struct_member_offset_by_name_with_alias | ( | const SDNA * | sdna, |
| const char * | stype, | ||
| const char * | vartype, | ||
| const char * | name ) |
Definition at line 1703 of file dna_genfile.cc.
References BLI_assert, DNA_struct_find_with_alias(), elem_offset_with_alias(), and SDNA::structs.
| int DNA_struct_member_offset_by_name_without_alias | ( | const SDNA * | sdna, |
| const char * | stype, | ||
| const char * | vartype, | ||
| const char * | name ) |
Definition at line 1692 of file dna_genfile.cc.
References BLI_assert, DNA_struct_find_index_without_alias(), elem_offset_without_alias(), and SDNA::structs.
| int DNA_struct_member_size | ( | const SDNA * | sdna, |
| short | type, | ||
| short | member_index ) |
Definition at line 177 of file dna_genfile.cc.
References ispointer(), len, SDNA::members, SDNA::members_array_num, SDNA::pointer_size, and SDNA::types_size.
Referenced by elem_offset_impl().
| void * DNA_struct_reconstruct | ( | const DNA_ReconstructInfo * | reconstruct_info, |
| int | old_struct_index, | ||
| int | blocks, | ||
| const void * | old_blocks, | ||
| const char * | alloc_name ) |
Definition at line 1323 of file dna_genfile.cc.
References DNA_struct_alignment(), DNA_struct_find_index_without_alias(), MEM_calloc_arrayN_aligned, DNA_ReconstructInfo::newsdna, DNA_ReconstructInfo::oldsdna, reconstruct_structs(), SDNA::structs, SDNA_Struct::type_index, SDNA::types, and SDNA::types_size.
| int DNA_struct_size | ( | const SDNA * | sdna, |
| int | struct_index ) |
Definition at line 163 of file dna_genfile.cc.
References SDNA::structs, SDNA_Struct::type_index, and SDNA::types_size.
| void DNA_struct_switch_endian | ( | const SDNA * | sdna, |
| int | struct_index, | ||
| char * | data ) |
Definition at line 1118 of file dna_genfile.cc.
References 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_index_without_alias(), DNA_struct_switch_endian(), get_member_size_in_bytes(), get_struct_member_category(), SDNA_StructMember::member_index, SDNA_Struct::members, SDNA::members_array_num, SDNA_Struct::members_num, 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_index, SDNA::types, and SDNA::types_size.
Referenced by DNA_struct_switch_endian().
|
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 971 of file dna_genfile.cc.
References elem_streq(), SDNA_StructMember::member_index, SDNA_Struct::members, SDNA_Struct::members_num, STREQ, SDNA_StructMember::type_index, and types.
Referenced by elem_exists_with_alias(), and elem_exists_without_alias().
|
static |
Definition at line 1011 of file dna_genfile.cc.
References SDNA::alias, elem_exists_impl(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_exists_with_alias().
|
static |
| sdna | Old SDNA. |
Definition at line 996 of file dna_genfile.cc.
References elem_exists_impl(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_exists_without_alias().
|
static |
Definition at line 1026 of file dna_genfile.cc.
References DNA_struct_member_size(), elem_streq(), SDNA_StructMember::member_index, SDNA_Struct::members, SDNA_Struct::members_num, STREQ, SDNA_StructMember::type_index, and types.
Referenced by elem_offset_with_alias(), and elem_offset_without_alias().
|
static |
A version of elem_exists_without_alias that uses aliases.
Definition at line 1078 of file dna_genfile.cc.
References SDNA::alias, elem_offset_impl(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_offset_by_name_with_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 1067 of file dna_genfile.cc.
References elem_offset_impl(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_offset_by_name_without_alias().
|
static |
Equality test on name and oname excluding any array-size suffix.
Definition at line 943 of file dna_genfile.cc.
Referenced by elem_exists_impl(), elem_offset_impl(), and find_member_with_matching_name().
|
static |
Finds a member in the given struct with the given name.
Definition at line 1356 of file dna_genfile.cc.
References elem_streq(), get_member_size_in_bytes(), SDNA_StructMember::member_index, SDNA::members, SDNA_Struct::members, and SDNA_Struct::members_num.
Referenced by init_reconstruct_step_for_member().
|
static |
Definition at line 1107 of file dna_genfile.cc.
References ispointer(), SDNA_StructMember::member_index, SDNA::members, SDNA::members_array_num, SDNA::pointer_size, SDNA_StructMember::type_index, and SDNA::types_size.
Referenced by create_reconstruct_steps_for_struct(), DNA_struct_switch_endian(), find_member_with_matching_name(), and blender::dna::print_single_struct_recursive().
|
static |
Definition at line 1093 of file dna_genfile.cc.
References DNA_struct_exists_without_alias(), ispointer(), SDNA_StructMember::member_index, SDNA::members, STRUCT_MEMBER_CATEGORY_POINTER, STRUCT_MEMBER_CATEGORY_PRIMITIVE, STRUCT_MEMBER_CATEGORY_STRUCT, SDNA_StructMember::type_index, and SDNA::types.
Referenced by DNA_struct_switch_endian(), init_reconstruct_step_for_member(), and blender::dna::print_single_struct_recursive().
|
static |
Initializes a single reconstruct step for a member in the new struct.
Definition at line 1375 of file dna_genfile.cc.
References ReconstructStep::array_len, BLI_assert, BLI_assert_msg, ReconstructStep::cast_pointer, ReconstructStep::cast_primitive, ReconstructStep::data, DNA_struct_find_index_without_alias(), find_member_with_matching_name(), get_struct_member_category(), SDNA_StructMember::member_index, SDNA::members, SDNA::members_array_num, ReconstructStep::memcpy, ReconstructStep::new_offset, ReconstructStep::new_struct_index, ReconstructStep::new_type, ReconstructStep::old_offset, ReconstructStep::old_struct_index, ReconstructStep::old_type, 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, ReconstructStep::size, STREQ, STRUCT_MEMBER_CATEGORY_POINTER, STRUCT_MEMBER_CATEGORY_PRIMITIVE, STRUCT_MEMBER_CATEGORY_STRUCT, ReconstructStep::substruct, ReconstructStep::type, SDNA_StructMember::type_index, 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 325 of file dna_genfile.cc.
References blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), 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_member_array_num(), DNA_struct_find_index_without_alias(), DNA_struct_find_index_without_alias_ex(), DNA_struct_rename_legacy_hack_static_from_alias(), ELEM, MAKE_ID, SDNA::mem_arena, MEM_calloc_arrayN(), MEM_malloc_arrayN(), SDNA_StructMember::member_index, SDNA::members, SDNA_Struct::members, SDNA::members_array_num, SDNA::members_num, SDNA_Struct::members_num, SDNA::members_num_alloc, pad_up_4(), POINTER_FROM_INT, SDNA::pointer_size, SDNA_TYPE_VOID, STREQ, SDNA::structs, SDNA::structs_num, SDNA_Struct::type_index, SDNA_StructMember::type_index, SDNA::types, SDNA::types_alignment, SDNA::types_num, SDNA::types_size, SDNA::types_to_structs_map, and UNLIKELY.
Referenced by DNA_sdna_from_data().
|
static |
Return true if the name indicates a pointer of some kind.
Definition at line 171 of file dna_genfile.cc.
Referenced by DNA_struct_member_size(), 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 | ) |
Definition at line 317 of file dna_genfile.cc.
References BLI_INLINE, and ptr.
Referenced by init_structDNA().
|
static |
Useful function when debugging the reconstruct steps.
Definition at line 1503 of file dna_genfile.cc.
References printf, 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, step, SDNA::structs, SDNA_Struct::type_index, 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 1250 of file dna_genfile.cc.
References cast_pointer_32_to_64(), cast_pointer_64_to_32(), cast_primitive_type(), 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(), step, DNA_ReconstructInfo::step_counts, DNA_ReconstructInfo::steps, and steps.
Referenced by reconstruct_structs().
|
static |
Reconstructs an array of structs.
Definition at line 1303 of file dna_genfile.cc.
References DNA_ReconstructInfo::newsdna, DNA_ReconstructInfo::oldsdna, reconstruct_struct(), SDNA::structs, SDNA_Struct::type_index, and SDNA::types_size.
Referenced by DNA_struct_reconstruct(), and reconstruct_struct().
|
static |
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 1904 of file dna_genfile.cc.
References BLI_assert, BLI_memarena_alloc(), i, SDNA::mem_arena, MEM_freeN(), MEM_malloc_arrayN(), SDNA_StructMember::member_index, SDNA::members, SDNA_Struct::members, SDNA::members_array_num, SDNA::members_num, SDNA_Struct::members_num, SDNA::structs, and SDNA::structs_num.
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 644 of file dna_genfile.cc.
References DNA_struct_find_index_without_alias(), ispointer(), SDNA_StructMember::member_index, SDNA::members, SDNA_Struct::members, SDNA_Struct::members_num, SDNA::pointer_size, SDNA_CMP_EQUAL, SDNA_CMP_NOT_EQUAL, SDNA_CMP_REMOVED, SDNA_CMP_UNKNOWN, set_compare_flags_for_struct(), STREQ, SDNA::structs, SDNA_Struct::type_index, SDNA_StructMember::type_index, SDNA::types, and SDNA::types_size.
Referenced by DNA_struct_get_compareflags(), and set_compare_flags_for_struct().
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 617 of file dna_genfile.cc.
Referenced by DNA_sdna_current_free(), DNA_sdna_current_get(), and DNA_sdna_current_init().