Blender  V2.93
DNA_genfile.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
25 #pragma once
26 
27 #include "intern/dna_utils.h"
28 
29 struct SDNA;
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
40 extern const unsigned char DNAstr[];
42 extern const int DNAlen;
43 
51 typedef enum eSDNA_Type {
57  /* SDNA_TYPE_LONG = 5, */ /* deprecated (use as int) */
58  /* SDNA_TYPE_ULONG = 6, */ /* deprecated (use as int) */
61 /* ,SDNA_TYPE_VOID = 9 */
62 /* define so switch statements don't complain */
63 #define SDNA_TYPE_VOID 9
68 
73  /* Struct has disappeared
74  * (values of this struct type will not be loaded by the current Blender) */
76  /* Struct is the same
77  * (can be loaded with straight memory copy after any necessary endian conversion) */
79  /* Struct is different in some way
80  * (needs to be copied/converted field by field) */
82  /* This is only used temporarily by #DNA_struct_get_compareflags. */
84 };
85 
86 struct SDNA *DNA_sdna_from_data(const void *data,
87  const int data_len,
88  bool do_endian_swap,
89  bool data_alloc,
90  const char **r_error_message);
91 void DNA_sdna_free(struct SDNA *sdna);
92 
93 /* Access for current Blender versions SDNA*/
94 void DNA_sdna_current_init(void);
95 /* borrowed reference */
96 const struct SDNA *DNA_sdna_current_get(void);
97 void DNA_sdna_current_free(void);
98 
99 struct DNA_ReconstructInfo;
101  const struct SDNA *newsdna,
102  const char *compare_flags);
103 void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info);
104 
105 int DNA_struct_find_nr_ex(const struct SDNA *sdna, const char *str, unsigned int *index_last);
106 int DNA_struct_find_nr(const struct SDNA *sdna, const char *str);
107 void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_nr, char *data);
108 const char *DNA_struct_get_compareflags(const struct SDNA *sdna, const struct SDNA *newsdna);
109 void *DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info,
110  int old_struct_nr,
111  int blocks,
112  const void *old_blocks);
113 
114 int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name);
115 
116 int DNA_elem_size_nr(const struct SDNA *sdna, short type, short name);
117 
118 bool DNA_struct_find(const struct SDNA *sdna, const char *stype);
119 bool DNA_struct_elem_find(const struct SDNA *sdna,
120  const char *stype,
121  const char *vartype,
122  const char *name);
123 
124 int DNA_elem_type_size(const eSDNA_Type elem_nr);
125 
126 bool DNA_sdna_patch_struct(struct SDNA *sdna,
127  const char *struct_name_old,
128  const char *struct_name_new);
129 bool DNA_sdna_patch_struct_member(struct SDNA *sdna,
130  const char *struct_name,
131  const char *elem_old,
132  const char *elem_new);
133 
134 void DNA_sdna_alias_data_ensure(struct SDNA *sdna);
135 
136 /* Alias lookups (using runtime struct member names). */
137 int DNA_struct_alias_find_nr_ex(const struct SDNA *sdna,
138  const char *str,
139  unsigned int *index_last);
140 int DNA_struct_alias_find_nr(const struct SDNA *sdna, const char *str);
141 bool DNA_struct_alias_elem_find(const struct SDNA *sdna,
142  const char *stype,
143  const char *vartype,
144  const char *name);
146 
147 #ifdef __cplusplus
148 }
149 #endif
bool DNA_struct_find(const struct SDNA *sdna, const char *stype)
void DNA_sdna_free(struct SDNA *sdna)
Definition: dna_genfile.c:139
eSDNA_Type
Definition: DNA_genfile.h:51
@ SDNA_TYPE_CHAR
Definition: DNA_genfile.h:52
@ SDNA_TYPE_INT
Definition: DNA_genfile.h:56
@ SDNA_TYPE_UINT64
Definition: DNA_genfile.h:65
@ SDNA_TYPE_DOUBLE
Definition: DNA_genfile.h:60
@ SDNA_TYPE_SHORT
Definition: DNA_genfile.h:54
@ SDNA_TYPE_UCHAR
Definition: DNA_genfile.h:53
@ SDNA_TYPE_INT8
Definition: DNA_genfile.h:66
@ SDNA_TYPE_INT64
Definition: DNA_genfile.h:64
@ SDNA_TYPE_FLOAT
Definition: DNA_genfile.h:59
@ SDNA_TYPE_USHORT
Definition: DNA_genfile.h:55
struct SDNA * DNA_sdna_from_data(const void *data, const int data_len, bool do_endian_swap, bool data_alloc, const char **r_error_message)
Definition: dna_genfile.c:550
int DNA_elem_type_size(const eSDNA_Type elem_nr)
Definition: dna_genfile.c:1681
const unsigned char DNAstr[]
struct DNA_ReconstructInfo * DNA_reconstruct_info_create(const struct SDNA *oldsdna, const struct SDNA *newsdna, const char *compare_flags)
void DNA_struct_switch_endian(const struct SDNA *sdna, int struct_nr, char *data)
int DNA_struct_find_nr_ex(const struct SDNA *sdna, const char *str, unsigned int *index_last)
void DNA_sdna_current_free(void)
Definition: dna_genfile.c:603
int DNA_struct_alias_find_nr(const struct SDNA *sdna, const char *str)
int DNA_elem_size_nr(const struct SDNA *sdna, short type, short name)
void DNA_sdna_current_init(void)
Definition: dna_genfile.c:592
void * DNA_struct_reconstruct(const struct DNA_ReconstructInfo *reconstruct_info, int old_struct_nr, int blocks, const void *old_blocks)
bool DNA_sdna_patch_struct_member(struct SDNA *sdna, const char *struct_name, const char *elem_old, const char *elem_new)
Definition: dna_genfile.c:1788
void DNA_sdna_alias_data_ensure(struct SDNA *sdna)
Definition: dna_genfile.c:1879
bool DNA_struct_alias_elem_find(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
int DNA_struct_find_nr(const struct SDNA *sdna, const char *str)
const char * DNA_struct_get_compareflags(const struct SDNA *sdna, const struct SDNA *newsdna)
const int DNAlen
void DNA_reconstruct_info_free(struct DNA_ReconstructInfo *reconstruct_info)
Definition: dna_genfile.c:1612
const struct SDNA * DNA_sdna_current_get(void)
Definition: dna_genfile.c:597
int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
Definition: dna_genfile.c:1628
bool DNA_struct_elem_find(const struct SDNA *sdna, const char *stype, const char *vartype, const char *name)
bool DNA_sdna_patch_struct(struct SDNA *sdna, const char *struct_name_old, const char *struct_name_new)
Definition: dna_genfile.c:1726
eSDNA_StructCompare
Definition: DNA_genfile.h:72
@ SDNA_CMP_EQUAL
Definition: DNA_genfile.h:78
@ SDNA_CMP_REMOVED
Definition: DNA_genfile.h:75
@ SDNA_CMP_UNKNOWN
Definition: DNA_genfile.h:83
@ SDNA_CMP_NOT_EQUAL
Definition: DNA_genfile.h:81
void DNA_sdna_alias_data_ensure_structs_map(struct SDNA *sdna)
Definition: dna_genfile.c:1940
int DNA_struct_alias_find_nr_ex(const struct SDNA *sdna, const char *str, unsigned int *index_last)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
#define str(s)
const SDNA * newsdna
Definition: dna_genfile.c:1160
const SDNA * oldsdna
Definition: dna_genfile.c:1159
const char * compare_flags
Definition: dna_genfile.c:1161
int data_len
bool data_alloc