|
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) |
| template<typename T> | |
| static T | sdna_data_pointer_read (T &data, const int64_t num, const void *const data_pointer_end, const char **r_error_message) |
| template<typename T> | |
| 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) |
| static const char * | sdna_data_pointer_read_string (const char *&data, const void *const data_pointer_end, const char **r_error_message) |
| 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) |
| 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.
| 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 1393 of file dna_genfile.cc.
| Enumerator | |
|---|---|
| STRUCT_MEMBER_CATEGORY_STRUCT | |
| STRUCT_MEMBER_CATEGORY_PRIMITIVE | |
| STRUCT_MEMBER_CATEGORY_POINTER | |
Definition at line 1294 of file dna_genfile.cc.
|
static |
Definition at line 1126 of file dna_genfile.cc.
References cast_pointer_32_to_64().
Referenced by cast_pointer_32_to_64(), and reconstruct_struct().
|
static |
Definition at line 1135 of file dna_genfile.cc.
References cast_pointer_64_to_32().
Referenced by cast_pointer_64_to_32(), and 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 995 of file dna_genfile.cc.
References BLI_assert_msg, cast_primitive_type(), 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 cast_primitive_type(), and reconstruct_struct().
|
static |
Compresses an array of reconstruct steps in-place and returns the new step count.
Definition at line 1797 of file dna_genfile.cc.
References compress_reconstruct_steps(), ReconstructStep::data, 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, and ReconstructStep::type.
Referenced by compress_reconstruct_steps(), and 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 1772 of file dna_genfile.cc.
References create_reconstruct_steps_for_struct(), get_member_size_in_bytes(), init_reconstruct_step_for_member(), MEM_calloc_arrayN(), SDNA_Struct::members, and SDNA_Struct::members_num.
Referenced by create_reconstruct_steps_for_struct(), and 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 1962 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 cast_primitive_type(), DNA_elem_type_size(), and DNA_struct_member_size().
| DNA_ReconstructInfo * DNA_reconstruct_info_create | ( | const SDNA * | oldsdna, |
| const SDNA * | newsdna, | ||
| const char * | compare_flags ) |
Definition at line 1839 of file dna_genfile.cc.
References DNA_ReconstructInfo::compare_flags, compress_reconstruct_steps(), create_reconstruct_steps_for_struct(), DNA_reconstruct_info_create(), 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, SDNA::structs, SDNA::structs_num, SDNA_Struct::type_index, and SDNA::types.
| void DNA_reconstruct_info_free | ( | DNA_ReconstructInfo * | reconstruct_info | ) |
Definition at line 1885 of file dna_genfile.cc.
References DNA_reconstruct_info_free(), MEM_freeN(), DNA_ReconstructInfo::newsdna, DNA_ReconstructInfo::step_counts, DNA_ReconstructInfo::steps, and SDNA::structs_num.
Referenced by blo_filedata_free(), DNA_reconstruct_info_create(), and DNA_reconstruct_info_free().
| void DNA_sdna_alias_data_ensure | ( | SDNA * | sdna | ) |
Definition at line 2178 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_data_ensure(), 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, SDNA::members, SDNA_Struct::members, SDNA::members_num, SDNA_Struct::members_num, sdna_expand_names(), SDNA::structs, SDNA::structs_num, SDNA_Struct::type_index, SDNA::types, and SDNA::types_num.
Referenced by DNA_sdna_alias_data_ensure(), DNA_sdna_alias_data_ensure_structs_map(), DNA_struct_alignment(), 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 2242 of file dna_genfile.cc.
References SDNA::alias, BLI_ghash_insert(), BLI_ghash_str_new_ex(), DNA_sdna_alias_data_ensure(), DNA_sdna_alias_data_ensure_structs_map(), 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_alias_data_ensure_structs_map(), DNA_sdna_from_data(), DNA_struct_alignment(), and read_file_dna().
|
static |
Definition at line 2154 of file dna_genfile.cc.
References BLI_ghash_lookup(), DNA_member_id_offset_start(), DNA_member_id_rename(), DNA_member_id_strip_copy(), dna_sdna_alias_from_static_elem_full(), and SDNA::mem_arena.
Referenced by DNA_sdna_alias_data_ensure(), and dna_sdna_alias_from_static_elem_full().
| void DNA_sdna_current_free | ( | void | ) |
Definition at line 837 of file dna_genfile.cc.
References DNA_sdna_current_free(), DNA_sdna_free(), and g_sdna.
Referenced by DNA_sdna_current_free(), BlendfileLoadingBaseTest::TearDownTestCase(), and WM_exit_ex().
| const SDNA * DNA_sdna_current_get | ( | void | ) |
Definition at line 831 of file dna_genfile.cc.
References BLI_assert, DNA_sdna_current_get(), and g_sdna.
Referenced by DNA_sdna_current_get(), DNA_sdna_patch_struct(), filedata_new(), blender::dna::print_struct_by_id(), and writedata_new().
| void DNA_sdna_current_init | ( | void | ) |
Definition at line 826 of file dna_genfile.cc.
References DNA_sdna_current_init(), DNA_sdna_from_data(), DNAlen, DNAstr, and g_sdna.
Referenced by DNA_sdna_current_init(), 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, DNA_sdna_free(), 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_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 780 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(), DNA_sdna_from_data(), init_structDNA(), MEM_malloc_arrayN(), and MEM_mallocN().
Referenced by DNA_sdna_current_init(), DNA_sdna_from_data(), read_file_dna(), and RNA_create().
|
static |
Definition at line 2005 of file dna_genfile.cc.
References BLI_assert, BLI_ghash_insert(), BLI_ghash_remove(), DNA_sdna_current_get(), DNA_sdna_patch_struct(), 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(), and 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 2018 of file dna_genfile.cc.
References DNA_sdna_patch_struct(), DNA_sdna_patch_struct_by_name(), and DNA_struct_find_index_without_alias().
Referenced by blo_do_versions_dna(), DNA_sdna_patch_struct_by_name(), and DNA_struct_alignment().
|
static |
Definition at line 2030 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(), DNA_sdna_patch_struct_member(), 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(), and 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 2085 of file dna_genfile.cc.
References DNA_sdna_patch_struct_member(), DNA_sdna_patch_struct_member_by_name(), and DNA_struct_find_index_without_alias().
Referenced by blo_do_versions_dna(), DNA_sdna_patch_struct_member_by_name(), and DNA_struct_alignment().
| int DNA_struct_alignment | ( | const SDNA * | sdna, |
| const int | struct_index ) |
Definition at line 1989 of file dna_genfile.cc.
References DNA_struct_alignment(), and SDNA::types_alignment.
| bool DNA_struct_exists_with_alias | ( | const SDNA * | sdna, |
| const char * | str ) |
Definition at line 308 of file dna_genfile.cc.
References DNA_struct_exists_with_alias(), DNA_struct_find_with_alias(), and str.
| bool DNA_struct_exists_without_alias | ( | const SDNA * | sdna, |
| const char * | stype ) |
Definition at line 1921 of file dna_genfile.cc.
References DNA_struct_exists_without_alias(), and DNA_struct_find_index_without_alias().
|
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(), dna_struct_find_index_ex_impl(), POINTER_AS_INT, str, STREQ, and SDNA_Struct::type_index.
Referenced by dna_struct_find_index_ex_impl(), 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(), DNA_struct_find_index_with_alias_ex(), str, SDNA::structs, SDNA::structs_num, SDNA::types, SDNA::types_num, and SDNA::types_to_structs_map.
| 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(), DNA_struct_find_index_without_alias_ex(), str, and UINT_MAX.
| 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(), DNA_struct_find_index_without_alias_ex(), str, SDNA::structs, SDNA::structs_num, SDNA::types, SDNA::types_num, and SDNA::types_to_structs_map.
| 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(), DNA_struct_find_with_alias(), str, and UINT_MAX.
Definition at line 929 of file dna_genfile.cc.
References BLI_assert, BLI_STATIC_ASSERT, DNA_struct_get_compareflags(), 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 1994 of file dna_genfile.cc.
References SDNA::alias, DNA_sdna_alias_data_ensure(), DNA_struct_identifier(), SDNA::structs, SDNA_Struct::type_index, and SDNA::types.
Referenced by BLO_read_struct_by_name_array(), DNA_struct_alignment(), DNA_struct_identifier(), 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 1944 of file dna_genfile.cc.
References DNA_struct_find_with_alias(), DNA_struct_member_exists_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 1926 of file dna_genfile.cc.
References DNA_struct_find_index_without_alias(), DNA_struct_member_exists_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 1910 of file dna_genfile.cc.
References BLI_assert, DNA_struct_find_with_alias(), DNA_struct_member_offset_by_name_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 1899 of file dna_genfile.cc.
References BLI_assert, DNA_struct_find_index_without_alias(), DNA_struct_member_offset_by_name_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 DNA_struct_member_size(), ispointer(), len(), SDNA::members, SDNA::members_array_num, SDNA::pointer_size, and SDNA::types_size.
| 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 1530 of file dna_genfile.cc.
References DNA_struct_alignment(), DNA_struct_find_index_without_alias(), DNA_struct_reconstruct(), 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 DNA_struct_size(), 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 1325 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.
|
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 1178 of file dna_genfile.cc.
References elem_exists_impl(), elem_streq(), SDNA_StructMember::member_index, SDNA_Struct::members, SDNA_Struct::members_num, STREQ, and SDNA_StructMember::type_index.
Referenced by elem_exists_impl(), elem_exists_with_alias(), and elem_exists_without_alias().
|
static |
Definition at line 1218 of file dna_genfile.cc.
References SDNA::alias, elem_exists_impl(), elem_exists_with_alias(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_exists_with_alias(), and elem_exists_with_alias().
|
static |
| sdna | Old SDNA. |
Definition at line 1203 of file dna_genfile.cc.
References elem_exists_impl(), elem_exists_without_alias(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_exists_without_alias(), and elem_exists_without_alias().
|
static |
Definition at line 1233 of file dna_genfile.cc.
References DNA_struct_member_size(), elem_offset_impl(), elem_streq(), SDNA_StructMember::member_index, SDNA_Struct::members, SDNA_Struct::members_num, STREQ, and SDNA_StructMember::type_index.
Referenced by elem_offset_impl(), elem_offset_with_alias(), and elem_offset_without_alias().
|
static |
A version of elem_exists_without_alias that uses aliases.
Definition at line 1285 of file dna_genfile.cc.
References SDNA::alias, elem_offset_impl(), elem_offset_with_alias(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_offset_by_name_with_alias(), and elem_offset_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 1274 of file dna_genfile.cc.
References elem_offset_impl(), elem_offset_without_alias(), SDNA::members, and SDNA::types.
Referenced by DNA_struct_member_offset_by_name_without_alias(), and elem_offset_without_alias().
|
static |
Equality test on name and oname excluding any array-size suffix.
Definition at line 1150 of file dna_genfile.cc.
References elem_streq().
Referenced by elem_exists_impl(), elem_offset_impl(), elem_streq(), and find_member_with_matching_name().
|
static |
Finds a member in the given struct with the given name.
Definition at line 1563 of file dna_genfile.cc.
References elem_streq(), find_member_with_matching_name(), get_member_size_in_bytes(), SDNA_StructMember::member_index, SDNA::members, SDNA_Struct::members, and SDNA_Struct::members_num.
Referenced by find_member_with_matching_name(), and init_reconstruct_step_for_member().
|
static |
Definition at line 1314 of file dna_genfile.cc.
References get_member_size_in_bytes(), 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(), get_member_size_in_bytes(), and blender::dna::print_single_struct_recursive().
|
static |
Definition at line 1300 of file dna_genfile.cc.
References DNA_struct_exists_without_alias(), get_struct_member_category(), 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(), get_struct_member_category(), 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 1582 of file dna_genfile.cc.
References BLI_assert, BLI_assert_msg, ReconstructStep::data, DNA_struct_find_index_without_alias(), find_member_with_matching_name(), get_struct_member_category(), init_reconstruct_step_for_member(), SDNA_StructMember::member_index, SDNA::members, SDNA::members_array_num, 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::type, SDNA_StructMember::type_index, SDNA::types, and SDNA::types_size.
Referenced by create_reconstruct_steps_for_struct(), and init_reconstruct_step_for_member().
|
static |
In sdna->data the data, now we convert that to something understandable
Definition at line 420 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(), BLI_STATIC_ASSERT_ALIGN, SDNA::data, SDNA::data_size, 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, init_structDNA(), 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, blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::reserve(), sdna_data_pointer_read(), sdna_data_pointer_read_string(), sdna_data_validate_array_size(), sdna_struct_size_check(), 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(), and init_structDNA().
|
static |
Return true if the name indicates a pointer of some kind.
Definition at line 171 of file dna_genfile.cc.
References ispointer().
Referenced by DNA_struct_member_size(), get_member_size_in_bytes(), get_struct_member_category(), ispointer(), sdna_struct_size_check(), 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 pad_up_4().
Referenced by init_structDNA(), and pad_up_4().
|
static |
Useful function when debugging the reconstruct steps.
Definition at line 1710 of file dna_genfile.cc.
References print_reconstruct_step(), 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(), and print_reconstruct_step().
|
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 1457 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_struct(), reconstruct_structs(), step, DNA_ReconstructInfo::step_counts, and DNA_ReconstructInfo::steps.
Referenced by reconstruct_struct(), and reconstruct_structs().
|
static |
Reconstructs an array of structs.
Definition at line 1510 of file dna_genfile.cc.
References DNA_ReconstructInfo::newsdna, DNA_ReconstructInfo::oldsdna, reconstruct_struct(), reconstruct_structs(), SDNA::structs, SDNA_Struct::type_index, and SDNA::types_size.
Referenced by DNA_struct_reconstruct(), reconstruct_struct(), and reconstruct_structs().
|
static |
Definition at line 323 of file dna_genfile.cc.
References BLI_assert_msg, BLI_STATIC_ASSERT, data, num, ret, sdna_data_pointer_read(), and T.
Referenced by init_structDNA(), and sdna_data_pointer_read().
|
static |
Definition at line 355 of file dna_genfile.cc.
References BLI_assert, data, ret, and sdna_data_pointer_read_string().
Referenced by init_structDNA(), and sdna_data_pointer_read_string().
|
static |
Definition at line 341 of file dna_genfile.cc.
References BLI_STATIC_ASSERT, sdna_data_validate_array_size(), size(), and T.
Referenced by init_structDNA(), and sdna_data_validate_array_size().
|
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 2111 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_expand_names(), SDNA::structs, and SDNA::structs_num.
Referenced by DNA_sdna_alias_data_ensure(), and sdna_expand_names().
|
static |
Check a struct's declared size matches the sum of its member sizes.
Blender's own DNA always satisfies this (makesdna uses explicit _pad members, never implicit padding), so a mismatch means corrupt sizes - which would let struct reconstruction stride old_block past the end of the file data.
NOTE: must run after members_array_num, types_size & pointer_size are set up. SDNA_StructMember::member_index must already be initialized & validated too.
| voided_members_size | Size of members changed to void on load, which are still included in the declared struct size. |
Definition at line 391 of file dna_genfile.cc.
References ispointer(), SDNA::members, SDNA_Struct::members, SDNA::members_array_num, SDNA_Struct::members_num, SDNA::pointer_size, sdna_struct_size_check(), SDNA_Struct::type_index, and SDNA::types_size.
Referenced by init_structDNA(), and sdna_struct_size_check().
|
static |
This function changes compare_flags[old_struct_index] from SDNA_CMP_UNKNOWN to something else. It might call itself recursively.
Definition at line 851 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 824 of file dna_genfile.cc.
Referenced by DNA_sdna_current_free(), DNA_sdna_current_get(), and DNA_sdna_current_init().