Blender V4.3

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 , SDNA_TYPE_RAW_DATA = 13
}
 
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, bool do_alias, 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_index_with_alias_ex (const struct SDNA *sdna, const char *str, unsigned int *struct_index_last)
 
int DNA_struct_find_index_without_alias_ex (const struct SDNA *sdna, const char *str, unsigned int *struct_index_last)
 
int DNA_struct_find_with_alias (const struct SDNA *sdna, const char *str)
 
int DNA_struct_find_index_without_alias (const struct SDNA *sdna, const char *str)
 
bool DNA_struct_exists_with_alias (const struct SDNA *sdna, const char *str)
 
bool DNA_struct_exists_without_alias (const struct SDNA *sdna, const char *stype)
 
bool DNA_struct_member_exists_with_alias (const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
 
bool DNA_struct_member_exists_without_alias (const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
 
void DNA_struct_switch_endian (const struct SDNA *sdna, int struct_index, char *data)
 
const char * DNA_struct_get_compareflags (const struct SDNA *oldsdna, const struct SDNA *newsdna)
 
void * DNA_struct_reconstruct (const struct DNA_ReconstructInfo *reconstruct_info, int old_struct_index, int blocks, const void *old_blocks, const char *alloc_name)
 
int DNA_struct_member_offset_by_name_without_alias (const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
 
int DNA_struct_member_offset_by_name_with_alias (const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
 
int DNA_struct_member_size (const struct SDNA *sdna, short type, short member_index)
 
int DNA_elem_type_size (eSDNA_Type elem_nr)
 
int DNA_struct_size (const struct SDNA *sdna, int struct_index)
 
int DNA_struct_alignment (const struct SDNA *sdna, int struct_index)
 
const char * DNA_struct_identifier (struct SDNA *sdna, int struct_index)
 
bool DNA_sdna_patch_struct_by_name (struct SDNA *sdna, const char *old_type_name, const char *new_type_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)
 
void DNA_sdna_alias_data_ensure (struct SDNA *sdna)
 
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 48 of file DNA_genfile.h.

Referenced by init_structDNA().

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 64 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 
SDNA_TYPE_RAW_DATA 

Type used for untyped raw bytes buffers (written by BLO_write_raw and read by BLO_read_data_address).

Technically, it also covers all 'raw data' types above.

Definition at line 36 of file DNA_genfile.h.

Function Documentation

◆ DNA_elem_type_size()

int DNA_elem_type_size ( eSDNA_Type elem_nr)

◆ 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()

◆ DNA_sdna_alias_data_ensure_structs_map()

void DNA_sdna_alias_data_ensure_structs_map ( struct SDNA * sdna)

◆ 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 struct 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()

struct 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_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_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 struct SDNA * sdna,
int struct_index )

Get the alignment that should be used when allocating memory for this type.

Referenced by read_struct().

◆ DNA_struct_exists_with_alias()

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

A convenience function, the equivalent of: DNA_struct_find_with_alias(..) != -1

◆ DNA_struct_exists_without_alias()

bool DNA_struct_exists_without_alias ( const struct SDNA * sdna,
const char * stype )
Note
prefer DNA_struct_exists_with_alias unless there is a good reason not to.

◆ DNA_struct_find_index_with_alias_ex()

int DNA_struct_find_index_with_alias_ex ( const struct SDNA * sdna,
const char * str,
unsigned int * struct_index_last )
Parameters
struct_index_lastSupport faster lookups when there is the possibility of the same name being looked up multiple times. Initialize to UINT_MAX.
Returns
the index of the struct or -1 on failure.

◆ DNA_struct_find_index_without_alias()

int DNA_struct_find_index_without_alias ( const struct SDNA * sdna,
const char * str )
Note
prefer DNA_struct_find_with_alias unless there is a good reason not to.

Referenced by DNA_struct_find_index_wrapper().

◆ DNA_struct_find_index_without_alias_ex()

int DNA_struct_find_index_without_alias_ex ( const struct SDNA * sdna,
const char * str,
unsigned int * struct_index_last )
Note
prefer #DNA_struct_find_with_alias_ex unless there is a good reason not to.

◆ DNA_struct_find_with_alias()

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

◆ DNA_struct_get_compareflags()

const char * DNA_struct_get_compareflags ( const struct SDNA * oldsdna,
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_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 struct SDNA * sdna,
const char * stype,
const char * vartype,
const char * name )

A convenience function, the equivalent of: DNA_struct_member_find_with_alias(..) != -1

◆ DNA_struct_member_exists_without_alias()

bool DNA_struct_member_exists_without_alias ( const struct SDNA * sdna,
const char * stype,
const char * vartype,
const char * name )
Note
prefer DNA_struct_exists_with_alias unless there is a good reason not to.

◆ DNA_struct_member_offset_by_name_with_alias()

int DNA_struct_member_offset_by_name_with_alias ( const 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.

Referenced by read_file_dna().

◆ DNA_struct_member_offset_by_name_without_alias()

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

A version of DNA_struct_member_offset_by_name_with_alias that uses the non-aliased name. Always prefer aliased names where possible.

◆ DNA_struct_member_size()

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

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

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

Referenced by rna_find_sdna_member().

◆ DNA_struct_reconstruct()

void * DNA_struct_reconstruct ( const struct DNA_ReconstructInfo * reconstruct_info,
int old_struct_index,
int blocks,
const void * old_blocks,
const char * alloc_name )
Parameters
reconstruct_infoInformation preprocessed by DNA_reconstruct_info_create.
old_struct_indexIndex of struct info within oldsdna.
blocksThe number of array elements.
old_blocksArray of struct data.
alloc_nameString to pass to the allocation calls for reconstructed data.
Returns
An allocated reconstructed struct.

Referenced by read_struct().

◆ DNA_struct_size()

int DNA_struct_size ( const struct SDNA * sdna,
int struct_index )

Returns the size of a struct.

Parameters
struct_indexIndex into the #sdna.structs array (aka BHead.SDNAnr).

Referenced by BLO_read_struct_by_name_array(), switch_endian_structs(), and writestruct_at_address_nr().

◆ DNA_struct_switch_endian()

void DNA_struct_switch_endian ( const struct SDNA * sdna,
int struct_index,
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.cc).

Referenced by DNA_sdna_current_init(), and RNA_create().