Blender V4.3

DNA handling. More...

#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_endian_switch.h"
#include "BLI_math_matrix_types.hh"
#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))
 

Enumerations

enum  eStructMemberCategory { STRUCT_MEMBER_CATEGORY_STRUCT , STRUCT_MEMBER_CATEGORY_PRIMITIVE , STRUCT_MEMBER_CATEGORY_POINTER }
 
enum  eReconstructStepType {
  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
}
 

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)
 
SDNADNA_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 SDNADNA_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_StructMemberfind_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 ReconstructStepcreate_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_ReconstructInfoDNA_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)
 
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 SDNAg_sdna = nullptr
 

Detailed Description

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.

Macro Definition Documentation

◆ MAKE_ID

#define MAKE_ID ( a,
b,
c,
d )   (int(d) << 24 | int(c) << 16 | (b) << 8 | (a))

Overview

  • please NOTE: no builtin security to detect input of double structs
  • if you want a struct not to be in DNA file: add two hash marks above it (#<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:

SDNA (4 bytes) (magic number)
NAME (4 bytes)
<nr> (4 bytes) amount of names `int`.
<string>
<string>
...
...
TYPE (4 bytes)
<nr> amount of types `int`.
<string>
<string>
...
...
TLEN (4 bytes)
<len> (short) the lengths of types
<len>
...
...
STRC (4 bytes)
<nr> amount of structs `int`.
<typenr><nr_of_elems> <typenr><namenr> <typenr><namenr> ...

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:

  • Type change (a char to float will be divided by 255).
  • Location within a struct (everything can be randomly mixed up).
  • Struct within struct (within struct etc), this is recursive.
  • Adding new elements, will be default initialized zero.
  • Removing elements.
  • Change of array sizes.
  • Change of a pointer type: when the name doesn't change the contents is copied.

NOT YET:

  • array (vec[3]) to float struct (vec3f).

DONE:

  • Endian compatibility.
  • Pointer conversion (32-64 bits).

IMPORTANT:

  • Do not use #defines in structs for array lengths, this cannot be read by the dna functions.
  • Do not use uint, but unsigned int instead, ushort and ulong are allowed.
  • Only use a long in Blender if you want this to be the size of a pointer. so it is 32 bits or 64 bits, dependent at the cpu architecture.
  • Chars are always unsigned
  • Alignment of variables has to be done in such a way, that any system does not create 'padding' (gaps) in structures. So make sure that:
    • short: 2 aligned.
    • int: 4 aligned.
    • float: 4 aligned.
    • double: 8 aligned.
    • long: 8 aligned.
    • int64: 8 aligned.
    • struct: 8 aligned.
  • the sdna functions have several error prints builtin, always check blender running from a console.

Definition at line 121 of file dna_genfile.cc.

Referenced by init_structDNA().

Enumeration Type Documentation

◆ 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 1175 of file dna_genfile.cc.

◆ eStructMemberCategory

Enumerator
STRUCT_MEMBER_CATEGORY_STRUCT 
STRUCT_MEMBER_CATEGORY_PRIMITIVE 
STRUCT_MEMBER_CATEGORY_POINTER 

Definition at line 1076 of file dna_genfile.cc.

Function Documentation

◆ cast_pointer_32_to_64()

static void cast_pointer_32_to_64 ( const int array_len,
const uint32_t * old_data,
uint64_t * new_data )
static

Definition at line 908 of file dna_genfile.cc.

Referenced by reconstruct_struct().

◆ cast_pointer_64_to_32()

static void cast_pointer_64_to_32 ( const int array_len,
const uint64_t * old_data,
uint32_t * new_data )
static

Definition at line 917 of file dna_genfile.cc.

Referenced by reconstruct_struct().

◆ cast_primitive_type()

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

Converts a value of one primitive type to another.

Note
there is no optimization for the case where otype and ctype are the same: assumption is that caller will handle this case.
Parameters
old_typeType to convert from.
new_typeType to convert to.
array_lenNumber of elements to convert.
old_dataBuffer containing the old values.
new_dataBuffer the converted values will be written to.

Definition at line 777 of file dna_genfile.cc.

References BLI_assert_msg, 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_RAW_DATA, SDNA_TYPE_SHORT, SDNA_TYPE_UCHAR, SDNA_TYPE_UINT64, and SDNA_TYPE_USHORT.

Referenced by reconstruct_struct().

◆ compress_reconstruct_steps()

◆ create_reconstruct_steps_for_struct()

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

Generate an array of reconstruct steps for the given #new_struct. There will be one reconstruct step for every member.

Definition at line 1554 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().

◆ DNA_elem_type_size()

int DNA_elem_type_size ( eSDNA_Type elem_nr)

◆ DNA_reconstruct_info_create()

◆ DNA_reconstruct_info_free()

void DNA_reconstruct_info_free ( DNA_ReconstructInfo * reconstruct_info)

◆ DNA_sdna_alias_data_ensure()

◆ DNA_sdna_alias_data_ensure_structs_map()

void DNA_sdna_alias_data_ensure_structs_map ( struct SDNA * sdna)

◆ dna_sdna_alias_from_static_elem_full()

static const char * dna_sdna_alias_from_static_elem_full ( SDNA * sdna,
GHash * elem_map_alias_from_static,
const char * struct_name_static,
const char * elem_static_full )
static

◆ DNA_sdna_current_free()

void DNA_sdna_current_free ( void )

Definition at line 619 of file dna_genfile.cc.

References DNA_sdna_free(), and g_sdna.

Referenced by BlendfileLoadingBaseTest::TearDownTestCase(), and WM_exit_ex().

◆ DNA_sdna_current_get()

const SDNA * DNA_sdna_current_get ( void )

Definition at line 613 of file dna_genfile.cc.

References BLI_assert, and g_sdna.

Referenced by DNA_sdna_patch_struct(), filedata_new(), and writedata_new().

◆ DNA_sdna_current_init()

void DNA_sdna_current_init ( void )

Definition at line 608 of file dna_genfile.cc.

References DNA_sdna_from_data(), DNAlen, DNAstr, and g_sdna.

Referenced by main(), and BlendfileLoadingBaseTest::SetUpTestCase().

◆ DNA_sdna_free()

◆ DNA_sdna_from_data()

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 562 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(), and MEM_mallocN.

Referenced by DNA_sdna_current_init(), read_file_dna(), and RNA_create().

◆ DNA_sdna_patch_struct()

static bool DNA_sdna_patch_struct ( SDNA * sdna,
const int struct_index,
const char * new_type_name )
static

◆ 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 1803 of file dna_genfile.cc.

References DNA_sdna_patch_struct(), and DNA_struct_find_index_without_alias().

Referenced by blo_do_versions_dna().

◆ DNA_sdna_patch_struct_member()

◆ 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 1870 of file dna_genfile.cc.

References DNA_sdna_patch_struct_member(), and DNA_struct_find_index_without_alias().

Referenced by blo_do_versions_dna().

◆ DNA_struct_alignment()

int DNA_struct_alignment ( const SDNA * sdna,
const int struct_index )

Definition at line 1774 of file dna_genfile.cc.

References SDNA::types_alignment.

Referenced by DNA_struct_reconstruct().

◆ DNA_struct_exists_with_alias()

bool DNA_struct_exists_with_alias ( const SDNA * sdna,
const char * str )

Definition at line 304 of file dna_genfile.cc.

References DNA_struct_find_with_alias(), and str.

◆ DNA_struct_exists_without_alias()

bool DNA_struct_exists_without_alias ( const SDNA * sdna,
const char * stype )

Definition at line 1706 of file dna_genfile.cc.

References DNA_struct_find_index_without_alias().

Referenced by get_struct_member_category().

◆ dna_struct_find_index_ex_impl()

static int dna_struct_find_index_ex_impl ( const char ** types,
const int ,
SDNA_Struct **const structs,
const int structs_num,
const char * str,
uint * struct_index_last )
static

Returns the index of the struct info for the struct with the specified name.

Definition at line 209 of file dna_genfile.cc.

References BLI_ghash_lookup_p(), POINTER_AS_INT, str, STREQ, structs, structs_num, SDNA_Struct::type_index, and types_num.

Referenced by DNA_struct_find_index_with_alias_ex(), and DNA_struct_find_index_without_alias_ex().

◆ DNA_struct_find_index_with_alias_ex()

int DNA_struct_find_index_with_alias_ex ( const SDNA * sdna,
const char * str,
uint * struct_index_last )

◆ DNA_struct_find_index_without_alias()

◆ DNA_struct_find_index_without_alias_ex()

int DNA_struct_find_index_without_alias_ex ( const SDNA * sdna,
const char * str,
uint * struct_index_last )

◆ DNA_struct_find_with_alias()

int DNA_struct_find_with_alias ( const SDNA * sdna,
const char * str )

◆ DNA_struct_get_compareflags()

const char * DNA_struct_get_compareflags ( const SDNA * oldsdna,
const SDNA * newsdna )

◆ DNA_struct_identifier()

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 1779 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().

◆ DNA_struct_member_exists_with_alias()

bool DNA_struct_member_exists_with_alias ( const SDNA * sdna,
const char * stype,
const char * vartype,
const char * name )

◆ DNA_struct_member_exists_without_alias()

bool DNA_struct_member_exists_without_alias ( const SDNA * sdna,
const char * stype,
const char * vartype,
const char * name )

◆ DNA_struct_member_offset_by_name_with_alias()

int DNA_struct_member_offset_by_name_with_alias ( const SDNA * sdna,
const char * stype,
const char * vartype,
const char * name )

◆ DNA_struct_member_offset_by_name_without_alias()

int DNA_struct_member_offset_by_name_without_alias ( const SDNA * sdna,
const char * stype,
const char * vartype,
const char * name )

◆ DNA_struct_member_size()

int DNA_struct_member_size ( const SDNA * sdna,
short type,
short member_index )

◆ DNA_struct_reconstruct()

void * DNA_struct_reconstruct ( const DNA_ReconstructInfo * reconstruct_info,
int old_struct_index,
int blocks,
const void * old_blocks,
const char * alloc_name )

◆ DNA_struct_size()

int DNA_struct_size ( const SDNA * sdna,
int struct_index )

Definition at line 159 of file dna_genfile.cc.

References SDNA::structs, SDNA_Struct::type_index, and SDNA::types_size.

◆ DNA_struct_switch_endian()

◆ elem_exists_impl()

static bool elem_exists_impl ( const char ** types,
const char ** names,
const char * type,
const char * name,
const SDNA_Struct * old )
static

Returns whether the specified field exists according to the struct format pointed to by old.

Parameters
typeCurrent field type name.
nameCurrent field name.
oldPointer to struct information in sdna.
Returns
true when existing, false otherwise..

Definition at line 960 of file dna_genfile.cc.

References elem_streq(), SDNA_StructMember::member_index, SDNA_Struct::members, SDNA_Struct::members_num, STREQ, and SDNA_StructMember::type_index.

Referenced by elem_exists_with_alias(), and elem_exists_without_alias().

◆ elem_exists_with_alias()

static bool elem_exists_with_alias ( const SDNA * sdna,
const char * type,
const char * name,
const SDNA_Struct * old )
static

◆ elem_exists_without_alias()

static bool elem_exists_without_alias ( const SDNA * sdna,
const char * type,
const char * name,
const SDNA_Struct * old )
static
Parameters
sdnaOld SDNA.

Definition at line 985 of file dna_genfile.cc.

References elem_exists_impl(), SDNA::members, and SDNA::types.

Referenced by DNA_struct_member_exists_without_alias().

◆ elem_offset_impl()

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

◆ elem_offset_with_alias()

static int elem_offset_with_alias ( const SDNA * sdna,
const char * type,
const char * name,
const SDNA_Struct * old )
static

A version of elem_exists_without_alias that uses aliases.

Definition at line 1067 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().

◆ elem_offset_without_alias()

static int elem_offset_without_alias ( const SDNA * sdna,
const char * type,
const char * name,
const SDNA_Struct * old )
static

Return the offset in bytes or -1 on failure to find the struct member with its expected type.

Parameters
sdnaOld SDNA.
typeCurrent field type name.
nameCurrent field name.
oldPointer to struct information in SDNA.
Returns
The offset or -1 on failure.
Note
Use elem_exists_without_alias if additional information provided by this function is not needed.
We could have a version of this function that returns the SDNA_StructMember currently it's not needed.

Definition at line 1056 of file dna_genfile.cc.

References elem_offset_impl(), SDNA::members, and SDNA::types.

Referenced by DNA_struct_member_offset_by_name_without_alias().

◆ elem_streq()

static bool elem_streq ( const char * name,
const char * oname )
static

Equality test on name and oname excluding any array-size suffix.

Definition at line 932 of file dna_genfile.cc.

Referenced by elem_exists_impl(), elem_offset_impl(), and find_member_with_matching_name().

◆ find_member_with_matching_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

Finds a member in the given struct with the given name.

Definition at line 1345 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().

◆ get_member_size_in_bytes()

◆ get_struct_member_category()

◆ init_reconstruct_step_for_member()

◆ init_structDNA()

◆ ispointer()

static bool ispointer ( const char * name)
static

Return true if the name indicates a pointer of some kind.

Definition at line 167 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().

◆ pad_up_4()

BLI_INLINE const char * pad_up_4 ( const char * ptr)

Definition at line 313 of file dna_genfile.cc.

References ptr.

Referenced by init_structDNA().

◆ print_reconstruct_step()

static void print_reconstruct_step ( const ReconstructStep * step,
const SDNA * oldsdna,
const SDNA * newsdna )
static

◆ reconstruct_struct()

static void reconstruct_struct ( const DNA_ReconstructInfo * reconstruct_info,
const int new_struct_index,
const char * old_block,
char * new_block )
static

Converts the contents of an entire struct from oldsdna to newsdna format.

Parameters
reconstruct_infoPreprocessed reconstruct information generated by DNA_reconstruct_info_create.
new_struct_nrIndex in newsdna->structs of the struct that is being reconstructed.
old_blockMemory buffer containing the old struct.
new_blockWhere to put converted struct contents.

Definition at line 1239 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(), DNA_ReconstructInfo::step_counts, DNA_ReconstructInfo::steps, and steps.

Referenced by reconstruct_structs().

◆ reconstruct_structs()

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

◆ sdna_expand_names()

static void sdna_expand_names ( SDNA * sdna)
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 1896 of file dna_genfile.cc.

References BLI_assert, BLI_memarena_alloc(), SDNA::mem_arena, MEM_freeN(), MEM_mallocN, 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().

◆ set_compare_flags_for_struct()

static void set_compare_flags_for_struct ( const SDNA * oldsdna,
const SDNA * newsdna,
char * compare_flags,
const int old_struct_index )
static

Variable Documentation

◆ g_sdna

SDNA* g_sdna = nullptr
static

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 606 of file dna_genfile.cc.

Referenced by DNA_sdna_current_free(), DNA_sdna_current_get(), and DNA_sdna_current_init().