Blender  V3.3
Macros | Typedefs | Enumerations | Functions | Variables

blenloader genfile private function prototypes More...

#include "intern/dna_utils.h"

Go to the source code of this file.

Macros

#define SDNA_TYPE_VOID   9
 

Typedefs

typedef enum eSDNA_Type eSDNA_Type
 

Enumerations

enum  eSDNA_Type {
  SDNA_TYPE_CHAR = 0 , SDNA_TYPE_UCHAR = 1 , SDNA_TYPE_SHORT = 2 , SDNA_TYPE_USHORT = 3 ,
  SDNA_TYPE_INT = 4 , SDNA_TYPE_FLOAT = 7 , SDNA_TYPE_DOUBLE = 8 , SDNA_TYPE_INT64 = 10 ,
  SDNA_TYPE_UINT64 = 11 , SDNA_TYPE_INT8 = 12
}
 
enum  eSDNA_StructCompare { SDNA_CMP_REMOVED = 0 , SDNA_CMP_EQUAL = 1 , SDNA_CMP_NOT_EQUAL = 2 , SDNA_CMP_UNKNOWN = 3 }
 

Functions

struct SDNADNA_sdna_from_data (const void *data, int data_len, bool do_endian_swap, bool data_alloc, const char **r_error_message)
 
void DNA_sdna_free (struct SDNA *sdna)
 
void DNA_sdna_current_init (void)
 
const struct SDNADNA_sdna_current_get (void)
 
void DNA_sdna_current_free (void)
 
struct DNA_ReconstructInfoDNA_reconstruct_info_create (const struct SDNA *oldsdna, const struct SDNA *newsdna, const char *compare_flags)
 
void DNA_reconstruct_info_free (struct DNA_ReconstructInfo *reconstruct_info)
 
int DNA_struct_find_nr_ex (const struct SDNA *sdna, const char *str, unsigned int *index_last)
 
int DNA_struct_find_nr (const struct SDNA *sdna, const char *str)
 
void DNA_struct_switch_endian (const struct SDNA *sdna, int struct_nr, char *data)
 
const char * DNA_struct_get_compareflags (const struct SDNA *sdna, const struct SDNA *newsdna)
 
voidDNA_struct_reconstruct (const struct DNA_ReconstructInfo *reconstruct_info, int old_struct_nr, int blocks, const void *old_blocks)
 
int DNA_elem_offset (struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
 
int DNA_elem_size_nr (const struct SDNA *sdna, short type, short name)
 
bool DNA_struct_find (const struct SDNA *sdna, const char *stype)
 
bool DNA_struct_elem_find (const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
 
int DNA_elem_type_size (eSDNA_Type elem_nr)
 
bool DNA_sdna_patch_struct (struct SDNA *sdna, const char *struct_name_old, const char *struct_name_new)
 
bool DNA_sdna_patch_struct_member (struct SDNA *sdna, const char *struct_name, const char *elem_old, const char *elem_new)
 
void DNA_sdna_alias_data_ensure (struct SDNA *sdna)
 
int DNA_struct_alias_find_nr_ex (const struct SDNA *sdna, const char *str, unsigned int *index_last)
 
int DNA_struct_alias_find_nr (const struct SDNA *sdna, const char *str)
 
bool DNA_struct_alias_elem_find (const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
 
void DNA_sdna_alias_data_ensure_structs_map (struct SDNA *sdna)
 

Variables

const unsigned char DNAstr []
 
const int DNAlen
 

Detailed Description

blenloader genfile private function prototypes

Definition in file DNA_genfile.h.

Macro Definition Documentation

◆ SDNA_TYPE_VOID

#define SDNA_TYPE_VOID   9

Definition at line 47 of file DNA_genfile.h.

Typedef Documentation

◆ eSDNA_Type

typedef enum eSDNA_Type eSDNA_Type

Primitive (non-struct, non-pointer/function/array) types,

Warning
Don't change these values! Currently changes here will work on native endianness, however DNA_struct_switch_endian currently checks these hard-coded values against those from old files.

Enumeration Type Documentation

◆ eSDNA_StructCompare

For use with DNA_struct_reconstruct & DNA_struct_get_compareflags

Enumerator
SDNA_CMP_REMOVED 
SDNA_CMP_EQUAL 
SDNA_CMP_NOT_EQUAL 
SDNA_CMP_UNKNOWN 

Definition at line 56 of file DNA_genfile.h.

◆ eSDNA_Type

enum eSDNA_Type

Primitive (non-struct, non-pointer/function/array) types,

Warning
Don't change these values! Currently changes here will work on native endianness, however DNA_struct_switch_endian currently checks these hard-coded values against those from old files.
Enumerator
SDNA_TYPE_CHAR 
SDNA_TYPE_UCHAR 
SDNA_TYPE_SHORT 
SDNA_TYPE_USHORT 
SDNA_TYPE_INT 
SDNA_TYPE_FLOAT 
SDNA_TYPE_DOUBLE 
SDNA_TYPE_INT64 
SDNA_TYPE_UINT64 
SDNA_TYPE_INT8 

Definition at line 35 of file DNA_genfile.h.

Function Documentation

◆ DNA_elem_offset()

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

Returns the offset of the field with the specified name and type within the specified struct type in SDNA, -1 on failure.

Definition at line 1571 of file dna_genfile.c.

References BLI_assert, DNA_struct_find_nr(), elem_offset(), and SDNA::structs.

Referenced by read_file_dna().

◆ DNA_elem_size_nr()

int DNA_elem_size_nr ( const struct SDNA sdna,
short  type,
short  name 
)

Returns the size of struct fields of the specified type and name.

Parameters
typeIndex into sdna->types/types_size
nameIndex into sdna->names, needed to extract possible pointer/array information.

Referenced by rna_find_sdna_member().

◆ DNA_elem_type_size()

int DNA_elem_type_size ( eSDNA_Type  elem_nr)

Returns the size in bytes of a primitive type.

Definition at line 1620 of file dna_genfile.c.

References SDNA_TYPE_CHAR, SDNA_TYPE_DOUBLE, SDNA_TYPE_FLOAT, SDNA_TYPE_INT, SDNA_TYPE_INT64, SDNA_TYPE_INT8, SDNA_TYPE_SHORT, SDNA_TYPE_UCHAR, SDNA_TYPE_UINT64, and SDNA_TYPE_USHORT.

Referenced by cast_primitive_type().

◆ DNA_reconstruct_info_create()

struct DNA_ReconstructInfo* DNA_reconstruct_info_create ( const struct SDNA oldsdna,
const struct SDNA newsdna,
const char *  compare_flags 
)

Pre-process information about how structs in newsdna can be reconstructed from structs in oldsdna. This information is then used to speedup DNA_struct_reconstruct.

Referenced by read_file_dna().

◆ DNA_reconstruct_info_free()

void DNA_reconstruct_info_free ( struct DNA_ReconstructInfo reconstruct_info)

◆ DNA_sdna_alias_data_ensure()

void DNA_sdna_alias_data_ensure ( struct SDNA sdna)

◆ DNA_sdna_alias_data_ensure_structs_map()

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_alias_find_nr and friends).

Definition at line 1867 of file dna_genfile.c.

References SDNA::alias, BLI_ghash_insert(), BLI_ghash_str_new_ex(), DNA_sdna_alias_data_ensure(), POINTER_FROM_INT, SDNA::structs, SDNA::structs_len, SDNA::structs_map, SDNA_Struct::type, SDNA::types, and UNUSED_VARS.

◆ DNA_sdna_current_free()

void DNA_sdna_current_free ( void  )

Definition at line 572 of file dna_genfile.c.

References DNA_sdna_free(), g_sdna, and NULL.

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

◆ DNA_sdna_current_get()

const struct SDNA* DNA_sdna_current_get ( void  )

Definition at line 566 of file dna_genfile.c.

References BLI_assert, g_sdna, and NULL.

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

◆ DNA_sdna_current_init()

void DNA_sdna_current_init ( void  )

Definition at line 561 of file dna_genfile.c.

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

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

◆ DNA_sdna_free()

void DNA_sdna_free ( struct SDNA sdna)

◆ DNA_sdna_from_data()

struct SDNA* DNA_sdna_from_data ( const void data,
int  data_len,
bool  do_endian_swap,
bool  data_alloc,
const char **  r_error_message 
)

Constructs and returns a decoded SDNA structure from the given encoded SDNA data block.

Definition at line 519 of file dna_genfile.c.

References data, SDNA::data, SDNA::data_alloc, SDNA::data_len, DNA_sdna_free(), init_structDNA(), MEM_mallocN, and NULL.

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

◆ DNA_sdna_patch_struct()

bool DNA_sdna_patch_struct ( struct SDNA sdna,
const char *  struct_name_old,
const char *  struct_name_new 
)

Rename a struct

Definition at line 1662 of file dna_genfile.c.

References DNA_sdna_patch_struct_nr(), and DNA_struct_find_nr().

Referenced by blo_do_versions_dna().

◆ DNA_sdna_patch_struct_member()

bool DNA_sdna_patch_struct_member ( struct SDNA sdna,
const char *  struct_name,
const char *  elem_old,
const char *  elem_new 
)

Replace elem_old with elem_new for struct struct_name handles search & replace, maintaining surrounding non-identifier characters such as pointer & array size.

Definition at line 1719 of file dna_genfile.c.

References DNA_sdna_patch_struct_member_nr(), and DNA_struct_find_nr().

Referenced by blo_do_versions_dna().

◆ DNA_struct_alias_elem_find()

bool DNA_struct_alias_elem_find ( const struct SDNA sdna,
const char *  stype,
const char *  vartype,
const char *  name 
)
Note
requires DNA_sdna_alias_data_ensure_structs_map to be called.

◆ DNA_struct_alias_find_nr()

int DNA_struct_alias_find_nr ( const struct SDNA sdna,
const char *  str 
)
Note
requires DNA_sdna_alias_data_ensure_structs_map to be called.

◆ DNA_struct_alias_find_nr_ex()

int DNA_struct_alias_find_nr_ex ( const struct SDNA sdna,
const char *  str,
unsigned int *  index_last 
)
Note
requires DNA_sdna_alias_data_ensure_structs_map to be called.

◆ DNA_struct_elem_find()

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

◆ DNA_struct_find()

bool DNA_struct_find ( const struct SDNA sdna,
const char *  stype 
)

◆ DNA_struct_find_nr()

int DNA_struct_find_nr ( const struct SDNA sdna,
const char *  str 
)

◆ DNA_struct_find_nr_ex()

int DNA_struct_find_nr_ex ( const struct SDNA sdna,
const char *  str,
unsigned int *  index_last 
)

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

◆ DNA_struct_get_compareflags()

const char* DNA_struct_get_compareflags ( const struct SDNA sdna,
const struct SDNA newsdna 
)

Constructs and returns an array of byte flags with one element for each struct in oldsdna, indicating how it compares to newsdna.

Referenced by read_file_dna().

◆ DNA_struct_reconstruct()

void* DNA_struct_reconstruct ( const struct DNA_ReconstructInfo reconstruct_info,
int  old_struct_nr,
int  blocks,
const void old_blocks 
)
Parameters
reconstruct_infoInformation preprocessed by DNA_reconstruct_info_create.
old_struct_nrIndex of struct info within oldsdna.
blocksThe number of array elements.
old_blocksArray of struct data.
Returns
An allocated reconstructed struct.

Referenced by read_struct().

◆ DNA_struct_switch_endian()

void DNA_struct_switch_endian ( const struct SDNA sdna,
int  struct_nr,
char *  data 
)

Does endian swapping on the fields of a struct value.

Parameters
sdnaSDNA of the struct_nr belongs to
struct_nrIndex of struct info within sdna
dataStruct data that is to be converted

Referenced by switch_endian_structs().

Variable Documentation

◆ DNAlen

const int DNAlen
extern

Length of DNAstr.

Referenced by DNA_sdna_current_init(), and RNA_create().

◆ DNAstr

const unsigned char DNAstr[]
extern

DNAstr contains the prebuilt SDNA structure defining the layouts of the types used by this version of Blender. It is defined in a file dna.c, which is generated by the makesdna program during the build process (see makesdna.c).

Referenced by DNA_sdna_current_init(), and RNA_create().