Blender V4.3
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_assert.h"
#include "BLI_ghash.h"
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
#include "BLI_memarena.h"
#include "dna_utils.h"
#include "dna_rename_defs.h"

Go to the source code of this file.

Macros

#define DNA_STRUCT_RENAME(old, new)   {#old, #new},
 
#define DNA_STRUCT_RENAME_MEMBER(struct_name, old, new)
 
#define DNA_STRUCT_RENAME(old, new)
 
#define DNA_STRUCT_RENAME_MEMBER(struct_name, old, new)   {#struct_name, #old, #new},
 

Functions

Struct Member Evaluation
int DNA_member_array_num (const char *str)
 
Struct Member Manipulation
static bool is_identifier (const char c)
 
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, const int member_id_len, const char *member_full, uint *r_member_full_offset)
 
char * DNA_member_id_rename (MemArena *mem_arena, const char *member_id_src, const int member_id_src_len, const char *member_id_dst, const int member_id_dst_len, const char *member_full_src, const int member_full_src_len, const uint member_full_src_offset_len)
 
Versioning
static uint strhash_pair_p (const void *ptr)
 
static bool strhash_pair_cmp (const void *a, const void *b)
 
void DNA_alias_maps (enum eDNA_RenameDir version_dir, GHash **r_type_map, GHash **r_member_map)
 
Struct Name Legacy Hack
const char * DNA_struct_rename_legacy_hack_static_from_alias (const char *name)
 
const char * DNA_struct_rename_legacy_hack_alias_from_static (const char *name)
 
Internal helpers for C++
void _DNA_internal_memcpy (void *dst, const void *src, size_t size)
 
void _DNA_internal_memzero (void *dst, size_t size)
 
void _DNA_internal_swap (void *a, void *b, size_t size)
 

Detailed Description

Utilities for stand-alone makesdna.cc and Blender to share.

Definition in file dna_utils.cc.

Macro Definition Documentation

◆ DNA_STRUCT_RENAME [1/2]

#define DNA_STRUCT_RENAME ( old,
new )   {#old, #new},

◆ DNA_STRUCT_RENAME [2/2]

#define DNA_STRUCT_RENAME ( old,
new )

◆ DNA_STRUCT_RENAME_MEMBER [1/2]

#define DNA_STRUCT_RENAME_MEMBER ( struct_name,
old,
new )

◆ DNA_STRUCT_RENAME_MEMBER [2/2]

#define DNA_STRUCT_RENAME_MEMBER ( struct_name,
old,
new )   {#struct_name, #old, #new},

Function Documentation

◆ _DNA_internal_memcpy()

void _DNA_internal_memcpy ( void * dst,
const void * src,
size_t size )

Definition at line 332 of file dna_utils.cc.

◆ _DNA_internal_memzero()

void _DNA_internal_memzero ( void * dst,
size_t size )

Definition at line 338 of file dna_utils.cc.

◆ _DNA_internal_swap()

void _DNA_internal_swap ( void * a,
void * b,
size_t size )

Definition at line 344 of file dna_utils.cc.

References b.

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

◆ is_identifier()

static bool is_identifier ( const char c)
static

◆ strhash_pair_cmp()

static bool strhash_pair_cmp ( const void * a,
const void * b )
static

Definition at line 186 of file dna_utils.cc.

References b, and STREQ.

Referenced by DNA_alias_maps().

◆ strhash_pair_p()

static uint strhash_pair_p ( const void * ptr)
static

Definition at line 180 of file dna_utils.cc.

References BLI_ghashutil_strhash_p(), and ptr.

Referenced by DNA_alias_maps().