Blender V4.3

Go to the source code of this file.

Enumerations

enum  eDNA_RenameDir { DNA_RENAME_STATIC_FROM_ALIAS = -1 , DNA_RENAME_ALIAS_FROM_STATIC = 1 }
 

Functions

int DNA_member_array_num (const char *str)
 
uint DNA_member_id_offset_start (const char *member_full)
 
uint DNA_member_id_offset_end (const char *member_full_trimmed)
 
uint DNA_member_id_strip_copy (char *member_id_dst, const char *member_full_src)
 
uint DNA_member_id_strip (char *member)
 
bool DNA_member_id_match (const char *member_id, int member_id_len, const char *member_full, uint *r_member_full_offset)
 
char * DNA_member_id_rename (struct MemArena *mem_arena, const char *member_id_src, int member_id_src_len, const char *member_id_dst, int member_id_dst_len, const char *member_full_src, int member_full_src_len, uint member_full_src_offset_len)
 
void DNA_alias_maps (enum eDNA_RenameDir version_dir, struct GHash **r_type_map, struct GHash **r_member_map)
 
const char * DNA_struct_rename_legacy_hack_alias_from_static (const char *name)
 
const char * DNA_struct_rename_legacy_hack_static_from_alias (const char *name)
 

Enumeration Type Documentation

◆ eDNA_RenameDir

When requesting version info, support both directions.

  • 'Static' is the original name of the data, the one that is still stored in blend-files DNA info (to avoid breaking forward compatibility).
  • 'Alias' is the current name of the data, the one used in current DNA definition code.
Enumerator
DNA_RENAME_STATIC_FROM_ALIAS 
DNA_RENAME_ALIAS_FROM_STATIC 

Definition at line 87 of file dna_utils.h.

Function Documentation

◆ DNA_alias_maps()

◆ DNA_member_array_num()

int DNA_member_array_num ( const char * str)

Naming convention in this header:

  • member_full refers to the full definition of a struct member, including its prefixes (like the pointer * ones) and suffixes (like the [] array ones).
  • member_id (for member identifier) refers to the bare name of the struct member (e.g. var is the member identifier of the *var[n1][n2] full member). Parse the [n1][n2]... at the end of an array struct member.
Returns
the total number of array elements n1 * n2 ..., or 1 if the member is not an array.

Definition at line 29 of file dna_utils.cc.

References result, and str.

Referenced by calculate_struct_sizes(), init_structDNA(), and rna_find_sdna_member().

◆ DNA_member_id_match()

bool DNA_member_id_match ( const char * member_id,
int member_id_len,
const char * member_full,
uint * r_member_full_offset )

Check if the member identifier given in member_id matches the full name given in member_full. E.g. var matches full names like var or *var[3], but not variable.

Returns
true if it does, with the start offset of the match in r_member_full_offset.

Definition at line 116 of file dna_utils.cc.

References BLI_assert, DNA_member_id_offset_start(), and is_identifier().

Referenced by DNA_sdna_patch_struct_member().

◆ DNA_member_id_offset_end()

uint DNA_member_id_offset_end ( const char * member_full_trimmed)

Find the end offset of the member id (the name) within the trimmed full member definition.

WARNING: Expects an input string which has already been trimmed from its non-identifier prefixes. E.g. passing *var[n1] to this function will return 0, while passing var[n1] will return the expected 3 value.

Definition at line 87 of file dna_utils.cc.

References is_identifier().

Referenced by DNA_member_id_rename(), DNA_member_id_strip(), and DNA_member_id_strip_copy().

◆ DNA_member_id_offset_start()

uint DNA_member_id_offset_start ( const char * member_full)

Find the start offset of the member id (the name) within the full member definition.

Definition at line 74 of file dna_utils.cc.

References is_identifier().

Referenced by DNA_member_id_match(), DNA_member_id_rename(), DNA_member_id_strip(), DNA_member_id_strip_copy(), dna_sdna_alias_from_static_elem_full(), and version_member_static_from_alias().

◆ DNA_member_id_rename()

char * DNA_member_id_rename ( struct MemArena * mem_arena,
const char * member_id_src,
int member_id_src_len,
const char * member_id_dst,
int member_id_dst_len,
const char * member_full_src,
int member_full_src_len,
uint member_full_src_offset_len )

Rename a struct member to a different name.

Replace the source member identifier (member_id_src) by the destination one (member_id_dst), while preserving the potential prefixes and suffixes.

Returns
a renamed DNA full member, allocated from mem_arena.

Definition at line 134 of file dna_utils.cc.

References BLI_assert, BLI_memarena_alloc(), DNA_member_id_offset_end(), DNA_member_id_offset_start(), mem_arena, and UNUSED_VARS_NDEBUG.

Referenced by dna_sdna_alias_from_static_elem_full(), DNA_sdna_patch_struct_member(), and version_member_static_from_alias().

◆ DNA_member_id_strip()

uint DNA_member_id_strip ( char * member)

Same as DNA_member_id_strip_copy, but modifies the given member string in place.

Definition at line 106 of file dna_utils.cc.

References DNA_member_id_offset_end(), and DNA_member_id_offset_start().

Referenced by make_structDNA().

◆ DNA_member_id_strip_copy()

uint DNA_member_id_strip_copy ( char * member_id_dst,
const char * member_full_src )

Copy the member id part (the bare name) of the full source member into member_id_dst.

Parameters
member_id_dstdestination char buffer, must be at least the size of member_src_full.

Definition at line 96 of file dna_utils.cc.

References DNA_member_id_offset_end(), and DNA_member_id_offset_start().

Referenced by calculate_struct_sizes(), dna_sdna_alias_from_static_elem_full(), is_name_legal(), and version_member_static_from_alias().

◆ DNA_struct_rename_legacy_hack_alias_from_static()

const char * DNA_struct_rename_legacy_hack_alias_from_static ( const char * name)

DNA Compatibility Hack.

Definition at line 309 of file dna_utils.cc.

References STREQ.

Referenced by DNA_sdna_alias_data_ensure().

◆ DNA_struct_rename_legacy_hack_static_from_alias()

const char * DNA_struct_rename_legacy_hack_static_from_alias ( const char * name)

Definition at line 293 of file dna_utils.cc.

References STREQ.

Referenced by DNA_struct_find_index_wrapper(), and init_structDNA().