Blender V4.3
DNA_genfile.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#pragma once
11
12#include "intern/dna_utils.h"
13
14struct SDNA;
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
25extern const unsigned char DNAstr[];
27extern const int DNAlen;
28
36typedef enum eSDNA_Type {
42 /* SDNA_TYPE_LONG = 5, */ /* deprecated (use as int) */
43 /* SDNA_TYPE_ULONG = 6, */ /* deprecated (use as int) */
46/* ,SDNA_TYPE_VOID = 9 */
47/* define so switch statements don't complain */
48#define SDNA_TYPE_VOID 9
60
65 /* Struct has disappeared
66 * (values of this struct type will not be loaded by the current Blender) */
68 /* Struct is the same
69 * (can be loaded with straight memory copy after any necessary endian conversion) */
71 /* Struct is different in some way
72 * (needs to be copied/converted field by field) */
74 /* This is only used temporarily by #DNA_struct_get_compareflags. */
76};
77
81struct SDNA *DNA_sdna_from_data(const void *data,
82 int data_len,
83 bool do_endian_swap,
84 bool data_alloc,
85 bool do_alias,
86 const char **r_error_message);
87void DNA_sdna_free(struct SDNA *sdna);
88
89/* Access for current Blender versions SDNA. */
90void DNA_sdna_current_init(void);
91/* borrowed reference */
92const struct SDNA *DNA_sdna_current_get(void);
93void DNA_sdna_current_free(void);
94
101 const struct SDNA *newsdna,
102 const char *compare_flags);
103void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info);
104
112 const char *str,
113 unsigned int *struct_index_last);
116 const char *str,
117 unsigned int *struct_index_last);
121int DNA_struct_find_with_alias(const struct SDNA *sdna, const char *str);
123int DNA_struct_find_index_without_alias(const struct SDNA *sdna, const char *str);
124
128bool DNA_struct_exists_with_alias(const struct SDNA *sdna, const char *str);
130bool DNA_struct_exists_without_alias(const struct SDNA *sdna, const char *stype);
135 const char *stype,
136 const char *vartype,
137 const char *name);
140 const char *stype,
141 const char *vartype,
142 const char *name);
143
151void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_index, char *data);
156const char *DNA_struct_get_compareflags(const struct SDNA *oldsdna, const struct SDNA *newsdna);
165void *DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info,
166 int old_struct_index,
167 int blocks,
168 const void *old_blocks,
169 const char *alloc_name);
170
176 const char *stype,
177 const char *vartype,
178 const char *name);
184 const char *stype,
185 const char *vartype,
186 const char *name);
187
195int DNA_struct_member_size(const struct SDNA *sdna, short type, short member_index);
196
200int DNA_elem_type_size(eSDNA_Type elem_nr);
201
207int DNA_struct_size(const struct SDNA *sdna, int struct_index);
208
212int DNA_struct_alignment(const struct SDNA *sdna, int struct_index);
213
217const char *DNA_struct_identifier(struct SDNA *sdna, int struct_index);
218
226bool DNA_sdna_patch_struct_by_name(struct SDNA *sdna,
227 const char *old_type_name,
228 const char *new_type_name);
239 const char *type_name,
240 const char *old_member_name,
241 const char *new_member_name);
242
243void DNA_sdna_alias_data_ensure(struct SDNA *sdna);
244
250
251/* For versioning, avoid verbosity selecting between with/without alias versions of functions. */
252#ifdef DNA_GENFILE_VERSIONING_MACROS
253# define DNA_struct_exists(sdna, str) DNA_struct_exists_with_alias(sdna, str)
254# define DNA_struct_member_exists(sdna, stype, vartype, name) \
255 DNA_struct_member_exists_with_alias(sdna, stype, vartype, name)
256#endif
257
258#ifdef __cplusplus
259}
260#endif
const char * DNA_struct_get_compareflags(const struct SDNA *oldsdna, const struct SDNA *newsdna)
void DNA_sdna_free(struct SDNA *sdna)
eSDNA_Type
Definition DNA_genfile.h:36
@ SDNA_TYPE_CHAR
Definition DNA_genfile.h:37
@ SDNA_TYPE_RAW_DATA
Definition DNA_genfile.h:58
@ SDNA_TYPE_INT
Definition DNA_genfile.h:41
@ SDNA_TYPE_UINT64
Definition DNA_genfile.h:50
@ SDNA_TYPE_DOUBLE
Definition DNA_genfile.h:45
@ SDNA_TYPE_SHORT
Definition DNA_genfile.h:39
@ SDNA_TYPE_UCHAR
Definition DNA_genfile.h:38
@ SDNA_TYPE_INT8
Definition DNA_genfile.h:51
@ SDNA_TYPE_INT64
Definition DNA_genfile.h:49
@ SDNA_TYPE_FLOAT
Definition DNA_genfile.h:44
@ SDNA_TYPE_USHORT
Definition DNA_genfile.h:40
const struct SDNA * DNA_sdna_current_get(void)
int DNA_struct_find_with_alias(const struct SDNA *sdna, const char *str)
const unsigned char DNAstr[]
int DNA_elem_type_size(eSDNA_Type elem_nr)
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_size(const struct SDNA *sdna, int struct_index)
const char * DNA_struct_identifier(struct SDNA *sdna, int struct_index)
void DNA_sdna_current_free(void)
bool DNA_sdna_patch_struct_by_name(struct SDNA *sdna, const char *old_type_name, const char *new_type_name)
void DNA_sdna_current_init(void)
void * DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info, int old_struct_index, int blocks, const void *old_blocks, const char *alloc_name)
bool DNA_struct_exists_without_alias(const struct SDNA *sdna, const char *stype)
struct DNA_ReconstructInfo * DNA_reconstruct_info_create(const struct SDNA *oldsdna, const struct SDNA *newsdna, const char *compare_flags)
void DNA_sdna_alias_data_ensure(struct SDNA *sdna)
bool DNA_struct_member_exists_with_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
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)
int DNA_struct_member_size(const struct SDNA *sdna, short type, short member_index)
int DNA_struct_find_index_with_alias_ex(const struct SDNA *sdna, const char *str, unsigned int *struct_index_last)
void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_index, char *data)
bool DNA_struct_member_exists_without_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
const int DNAlen
int DNA_struct_find_index_without_alias(const struct SDNA *sdna, const char *str)
void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info)
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)
int DNA_struct_alignment(const struct SDNA *sdna, int struct_index)
int DNA_struct_find_index_without_alias_ex(const struct SDNA *sdna, const char *str, unsigned int *struct_index_last)
eSDNA_StructCompare
Definition DNA_genfile.h:64
@ SDNA_CMP_EQUAL
Definition DNA_genfile.h:70
@ SDNA_CMP_REMOVED
Definition DNA_genfile.h:67
@ SDNA_CMP_UNKNOWN
Definition DNA_genfile.h:75
@ SDNA_CMP_NOT_EQUAL
Definition DNA_genfile.h:73
void DNA_sdna_alias_data_ensure_structs_map(struct SDNA *sdna)
bool DNA_struct_exists_with_alias(const struct SDNA *sdna, const char *str)
int DNA_struct_member_offset_by_name_without_alias(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
#define str(s)
const char * compare_flags
bool data_alloc