Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt3
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c275
-rw-r--r--source/blender/makesdna/intern/dna_rename_defs.h2
-rw-r--r--source/blender/makesdna/intern/dna_utils.c17
-rw-r--r--source/blender/makesdna/intern/dna_utils.h5
-rw-r--r--source/blender/makesdna/intern/makesdna.c24
6 files changed, 177 insertions, 149 deletions
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 0f2761e311e..9808740e030 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -35,11 +35,13 @@ blender_include_dirs(
set(SRC
dna_utils.c
makesdna.c
+ ../../blenlib/intern/BLI_assert.c
../../blenlib/intern/BLI_ghash.c
../../blenlib/intern/BLI_ghash_utils.c
../../blenlib/intern/BLI_memarena.c
../../blenlib/intern/BLI_mempool.c
../../blenlib/intern/hash_mm2a.c # needed by 'BLI_ghash_utils.c', not used directly.
+ ../../../../intern/guardedalloc/intern/leak_detector.cc
../../../../intern/guardedalloc/intern/mallocn.c
../../../../intern/guardedalloc/intern/mallocn_guarded_impl.c
../../../../intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@ -125,6 +127,7 @@ set(INC_SYS
)
set(SRC
+ ../../blenlib/intern/BLI_assert.c
../../blenlib/intern/BLI_ghash.c
../../blenlib/intern/BLI_ghash_utils.c
../../blenlib/intern/BLI_linklist.c
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 3d95eba4aed..8ad0271f355 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -356,141 +356,140 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error
*r_error_message = "SDNA error in SDNA file";
return false;
}
- else {
- const char *cp;
- data++;
- /* Names array ('NAME') */
- if (*data == MAKE_ID('N', 'A', 'M', 'E')) {
- data++;
+ const char *cp;
- sdna->names_len = *data;
- if (do_endian_swap) {
- BLI_endian_switch_int32(&sdna->names_len);
- }
- sdna->names_len_alloc = sdna->names_len;
+ data++;
+ /* Names array ('NAME') */
+ if (*data == MAKE_ID('N', 'A', 'M', 'E')) {
+ data++;
- data++;
- sdna->names = MEM_callocN(sizeof(void *) * sdna->names_len, "sdnanames");
- }
- else {
- *r_error_message = "NAME error in SDNA file";
- return false;
+ sdna->names_len = *data;
+ if (do_endian_swap) {
+ BLI_endian_switch_int32(&sdna->names_len);
}
+ sdna->names_len_alloc = sdna->names_len;
- cp = (char *)data;
- for (int nr = 0; nr < sdna->names_len; nr++) {
- sdna->names[nr] = cp;
-
- /* "float gravity [3]" was parsed wrong giving both "gravity" and
- * "[3]" members. we rename "[3]", and later set the type of
- * "gravity" to "void" so the offsets work out correct */
- if (*cp == '[' && strcmp(cp, "[3]") == 0) {
- if (nr && strcmp(sdna->names[nr - 1], "Cvi") == 0) {
- sdna->names[nr] = "gravity[3]";
- gravity_fix = nr;
- }
- }
- while (*cp) {
- cp++;
+ data++;
+ sdna->names = MEM_callocN(sizeof(void *) * sdna->names_len, "sdnanames");
+ }
+ else {
+ *r_error_message = "NAME error in SDNA file";
+ return false;
+ }
+
+ cp = (char *)data;
+ for (int nr = 0; nr < sdna->names_len; nr++) {
+ sdna->names[nr] = cp;
+
+ /* "float gravity [3]" was parsed wrong giving both "gravity" and
+ * "[3]" members. we rename "[3]", and later set the type of
+ * "gravity" to "void" so the offsets work out correct */
+ if (*cp == '[' && STREQ(cp, "[3]")) {
+ if (nr && STREQ(sdna->names[nr - 1], "Cvi")) {
+ sdna->names[nr] = "gravity[3]";
+ gravity_fix = nr;
}
+ }
+ while (*cp) {
cp++;
}
+ cp++;
+ }
- cp = pad_up_4(cp);
-
- /* Type names array ('TYPE') */
- data = (int *)cp;
- if (*data == MAKE_ID('T', 'Y', 'P', 'E')) {
- data++;
+ cp = pad_up_4(cp);
- sdna->types_len = *data;
- if (do_endian_swap) {
- BLI_endian_switch_int32(&sdna->types_len);
- }
+ /* Type names array ('TYPE') */
+ data = (int *)cp;
+ if (*data == MAKE_ID('T', 'Y', 'P', 'E')) {
+ data++;
- data++;
- sdna->types = MEM_callocN(sizeof(void *) * sdna->types_len, "sdnatypes");
- }
- else {
- *r_error_message = "TYPE error in SDNA file";
- return false;
+ sdna->types_len = *data;
+ if (do_endian_swap) {
+ BLI_endian_switch_int32(&sdna->types_len);
}
- cp = (char *)data;
- for (int nr = 0; nr < sdna->types_len; nr++) {
- /* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */
- sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp);
- while (*cp) {
- cp++;
- }
+ data++;
+ sdna->types = MEM_callocN(sizeof(void *) * sdna->types_len, "sdnatypes");
+ }
+ else {
+ *r_error_message = "TYPE error in SDNA file";
+ return false;
+ }
+
+ cp = (char *)data;
+ for (int nr = 0; nr < sdna->types_len; nr++) {
+ /* WARNING! See: DNA_struct_rename_legacy_hack_static_from_alias docs. */
+ sdna->types[nr] = DNA_struct_rename_legacy_hack_static_from_alias(cp);
+ while (*cp) {
cp++;
}
+ cp++;
+ }
- cp = pad_up_4(cp);
-
- /* Type lengths array ('TLEN') */
- data = (int *)cp;
- if (*data == MAKE_ID('T', 'L', 'E', 'N')) {
- data++;
- sp = (short *)data;
- sdna->types_size = sp;
+ cp = pad_up_4(cp);
- if (do_endian_swap) {
- BLI_endian_switch_int16_array(sp, sdna->types_len);
- }
+ /* Type lengths array ('TLEN') */
+ data = (int *)cp;
+ if (*data == MAKE_ID('T', 'L', 'E', 'N')) {
+ data++;
+ sp = (short *)data;
+ sdna->types_size = sp;
- sp += sdna->types_len;
- }
- else {
- *r_error_message = "TLEN error in SDNA file";
- return false;
- }
- /* prevent BUS error */
- if (sdna->types_len & 1) {
- sp++;
+ if (do_endian_swap) {
+ BLI_endian_switch_int16_array(sp, sdna->types_len);
}
- /* Struct array ('STRC') */
- data = (int *)sp;
- if (*data == MAKE_ID('S', 'T', 'R', 'C')) {
- data++;
+ sp += sdna->types_len;
+ }
+ else {
+ *r_error_message = "TLEN error in SDNA file";
+ return false;
+ }
+ /* prevent BUS error */
+ if (sdna->types_len & 1) {
+ sp++;
+ }
- sdna->structs_len = *data;
- if (do_endian_swap) {
- BLI_endian_switch_int32(&sdna->structs_len);
- }
+ /* Struct array ('STRC') */
+ data = (int *)sp;
+ if (*data == MAKE_ID('S', 'T', 'R', 'C')) {
+ data++;
- data++;
- sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs");
- }
- else {
- *r_error_message = "STRC error in SDNA file";
- return false;
+ sdna->structs_len = *data;
+ if (do_endian_swap) {
+ BLI_endian_switch_int32(&sdna->structs_len);
}
- sp = (short *)data;
- for (int nr = 0; nr < sdna->structs_len; nr++) {
- sdna->structs[nr] = sp;
+ data++;
+ sdna->structs = MEM_callocN(sizeof(void *) * sdna->structs_len, "sdnastrcs");
+ }
+ else {
+ *r_error_message = "STRC error in SDNA file";
+ return false;
+ }
+
+ sp = (short *)data;
+ for (int nr = 0; nr < sdna->structs_len; nr++) {
+ sdna->structs[nr] = sp;
- if (do_endian_swap) {
- short a;
+ if (do_endian_swap) {
+ short a;
+ BLI_endian_switch_int16(&sp[0]);
+ BLI_endian_switch_int16(&sp[1]);
+
+ a = sp[1];
+ sp += 2;
+ while (a--) {
BLI_endian_switch_int16(&sp[0]);
BLI_endian_switch_int16(&sp[1]);
-
- a = sp[1];
sp += 2;
- while (a--) {
- BLI_endian_switch_int16(&sp[0]);
- BLI_endian_switch_int16(&sp[1]);
- sp += 2;
- }
- }
- else {
- sp += 2 * sp[1] + 2;
}
}
+ else {
+ sp += 2 * sp[1] + 2;
+ }
}
{
@@ -498,7 +497,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error
if (gravity_fix > -1) {
for (int nr = 0; nr < sdna->structs_len; nr++) {
sp = sdna->structs[nr];
- if (strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) {
+ if (STREQ(sdna->types[sp[0]], "ClothSimSettings")) {
sp[10] = SDNA_TYPE_VOID;
}
}
@@ -578,16 +577,15 @@ SDNA *DNA_sdna_from_data(const void *data,
if (init_structDNA(sdna, do_endian_swap, &error_message)) {
return sdna;
}
+
+ if (r_error_message == NULL) {
+ fprintf(stderr, "Error decoding blend file SDNA: %s\n", error_message);
+ }
else {
- if (r_error_message == NULL) {
- fprintf(stderr, "Error decoding blend file SDNA: %s\n", error_message);
- }
- else {
- *r_error_message = error_message;
- }
- DNA_sdna_free(sdna);
- return NULL;
+ *r_error_message = error_message;
}
+ DNA_sdna_free(sdna);
+ return NULL;
}
/**
@@ -700,13 +698,13 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna
while (b > 0) {
str1 = newsdna->types[sp_new[0]];
str2 = oldsdna->types[sp_old[0]];
- if (strcmp(str1, str2) != 0) {
+ if (!STREQ(str1, str2)) {
break;
}
str1 = newsdna->names[sp_new[1]];
str2 = oldsdna->names[sp_old[1]];
- if (strcmp(str1, str2) != 0) {
+ if (!STREQ(str1, str2)) {
break;
}
@@ -764,34 +762,33 @@ static eSDNA_Type sdna_type_nr(const char *dna_type)
if (STR_ELEM(dna_type, "char", "const char")) {
return SDNA_TYPE_CHAR;
}
- else if (STR_ELEM(dna_type, "uchar", "unsigned char")) {
+ if (STR_ELEM(dna_type, "uchar", "unsigned char")) {
return SDNA_TYPE_UCHAR;
}
- else if (STR_ELEM(dna_type, "short")) {
+ if (STR_ELEM(dna_type, "short")) {
return SDNA_TYPE_SHORT;
}
- else if (STR_ELEM(dna_type, "ushort", "unsigned short")) {
+ if (STR_ELEM(dna_type, "ushort", "unsigned short")) {
return SDNA_TYPE_USHORT;
}
- else if (STR_ELEM(dna_type, "int")) {
+ if (STR_ELEM(dna_type, "int")) {
return SDNA_TYPE_INT;
}
- else if (STR_ELEM(dna_type, "float")) {
+ if (STR_ELEM(dna_type, "float")) {
return SDNA_TYPE_FLOAT;
}
- else if (STR_ELEM(dna_type, "double")) {
+ if (STR_ELEM(dna_type, "double")) {
return SDNA_TYPE_DOUBLE;
}
- else if (STR_ELEM(dna_type, "int64_t")) {
+ if (STR_ELEM(dna_type, "int64_t")) {
return SDNA_TYPE_INT64;
}
- else if (STR_ELEM(dna_type, "uint64_t")) {
+ if (STR_ELEM(dna_type, "uint64_t")) {
return SDNA_TYPE_UINT64;
}
/* invalid! */
- else {
- return -1;
- }
+
+ return -1;
}
/**
@@ -940,13 +937,13 @@ static void cast_pointer(
/**
* Equality test on name and oname excluding any array-size suffix.
*/
-static int elem_strcmp(const char *name, const char *oname)
+static bool elem_streq(const char *name, const char *oname)
{
int a = 0;
while (1) {
if (name[a] != oname[a]) {
- return 1;
+ return false;
}
if (name[a] == '[' || oname[a] == '[') {
break;
@@ -956,7 +953,7 @@ static int elem_strcmp(const char *name, const char *oname)
}
a++;
}
- return 0;
+ return true;
}
/**
@@ -987,8 +984,8 @@ static bool elem_exists_impl(
otype = types[old[0]];
oname = names[old[1]];
- if (elem_strcmp(name, oname) == 0) { /* name equal */
- return strcmp(type, otype) == 0; /* type equal */
+ if (elem_streq(name, oname)) { /* name equal */
+ return STREQ(type, otype); /* type equal */
}
}
return false;
@@ -1063,8 +1060,8 @@ static const char *find_elem(const SDNA *sdna,
len = DNA_elem_size_nr(sdna, old[0], old[1]);
- if (elem_strcmp(name, oname) == 0) { /* name equal */
- if (strcmp(type, otype) == 0) { /* type equal */
+ if (elem_streq(name, oname)) { /* name equal */
+ if (STREQ(type, otype)) { /* type equal */
if (sppo) {
*sppo = old;
}
@@ -1132,7 +1129,7 @@ static void reconstruct_elem(const SDNA *newsdna,
oname = oldsdna->names[old[1]];
len = DNA_elem_size_nr(oldsdna, old[0], old[1]);
- if (strcmp(name, oname) == 0) { /* name equal */
+ if (STREQ(name, oname)) { /* name equal */
if (ispointer(name)) { /* pointer of functionpointer afhandelen */
cast_pointer(newsdna->pointer_size,
@@ -1141,7 +1138,7 @@ static void reconstruct_elem(const SDNA *newsdna,
curdata,
olddata);
}
- else if (strcmp(type, otype) == 0) { /* type equal */
+ else if (STREQ(type, otype)) { /* type equal */
memcpy(curdata, olddata, len);
}
else {
@@ -1150,7 +1147,7 @@ static void reconstruct_elem(const SDNA *newsdna,
return;
}
- else if (countpos != 0) { /* name is an array */
+ if (countpos != 0) { /* name is an array */
if (oname[countpos] == '[' && strncmp(name, oname, countpos) == 0) { /* basis equal */
const int new_name_array_len = newsdna->names_array_len[new_name_nr];
@@ -1161,7 +1158,7 @@ static void reconstruct_elem(const SDNA *newsdna,
cast_pointer(
newsdna->pointer_size, oldsdna->pointer_size, min_name_array_len, curdata, olddata);
}
- else if (strcmp(type, otype) == 0) { /* type equal */
+ else if (STREQ(type, otype)) { /* type equal */
/* size of single old array element */
mul = len / old_name_array_len;
/* smaller of sizes of old and new arrays */
@@ -1169,7 +1166,7 @@ static void reconstruct_elem(const SDNA *newsdna,
memcpy(curdata, olddata, mul);
- if (old_name_array_len > new_name_array_len && strcmp(type, "char") == 0) {
+ if (old_name_array_len > new_name_array_len && STREQ(type, "char")) {
/* string had to be truncated, ensure it's still null-terminated */
curdata[mul - 1] = '\0';
}
@@ -1368,7 +1365,7 @@ void DNA_struct_switch_endian(const SDNA *oldsdna, int oldSDNAnr, char *data)
/* exception: variable called blocktype: derived from ID_ */
bool skip = false;
if (name[0] == 'b' && name[1] == 'l') {
- if (strcmp(name, "blocktype") == 0) {
+ if (STREQ(name, "blocktype")) {
skip = true;
}
}
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index f2cf72843bd..a73fc747f84 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -67,6 +67,7 @@ DNA_STRUCT_RENAME_ELEM(Bone, scaleOut, scale_out_x)
DNA_STRUCT_RENAME_ELEM(BrushGpencilSettings, gradient_f, hardeness)
DNA_STRUCT_RENAME_ELEM(BrushGpencilSettings, gradient_s, aspect_ratio)
DNA_STRUCT_RENAME_ELEM(Camera, YF_dofdist, dof_distance)
+DNA_STRUCT_RENAME_ELEM(Curve, len_wchar, len_char32)
DNA_STRUCT_RENAME_ELEM(Camera, clipend, clip_end)
DNA_STRUCT_RENAME_ELEM(Camera, clipsta, clip_start)
DNA_STRUCT_RENAME_ELEM(Collection, dupli_ofs, instance_offset)
@@ -90,6 +91,7 @@ DNA_STRUCT_RENAME_ELEM(ParticleSettings, dupliweights, instance_weights)
DNA_STRUCT_RENAME_ELEM(Text, name, filepath)
DNA_STRUCT_RENAME_ELEM(ThemeSpace, scrubbing_background, time_scrub_background)
DNA_STRUCT_RENAME_ELEM(ThemeSpace, show_back_grad, background_type)
+DNA_STRUCT_RENAME_ELEM(UserDef, gp_manhattendist, gp_manhattandist)
DNA_STRUCT_RENAME_ELEM(VFont, name, filepath)
DNA_STRUCT_RENAME_ELEM(View3D, far, clip_end)
DNA_STRUCT_RENAME_ELEM(View3D, near, clip_start)
diff --git a/source/blender/makesdna/intern/dna_utils.c b/source/blender/makesdna/intern/dna_utils.c
index 6708365a4c8..3cf5c52a4c6 100644
--- a/source/blender/makesdna/intern/dna_utils.c
+++ b/source/blender/makesdna/intern/dna_utils.c
@@ -232,6 +232,23 @@ void DNA_alias_maps(enum eDNA_RenameDir version_dir, GHash **r_struct_map, GHash
for (int i = 0; i < ARRAY_SIZE(data); i++) {
BLI_ghash_insert(struct_map, (void *)data[i][elem_key], (void *)data[i][elem_val]);
}
+
+ if (version_dir == DNA_RENAME_STATIC_FROM_ALIAS) {
+ const char *renames[][2] = {
+ /* Disable 'int8_t' until we support 'signed char', since changing negative
+ * values to a different type isn't supported and will change the value. */
+ /* {"int8_t", "char"}, */
+ {"uint8_t", "uchar"},
+ {"int16_t", "short"},
+ {"uint16_t", "ushort"},
+ {"int32_t", "int"},
+ {"uint32_t", "int"},
+ };
+ for (int i = 0; i < ARRAY_SIZE(renames); i++) {
+ BLI_ghash_insert(struct_map, (void *)renames[i][0], (void *)renames[i][1]);
+ }
+ }
+
*r_struct_map = struct_map;
/* We know the direction of this, for local use. */
diff --git a/source/blender/makesdna/intern/dna_utils.h b/source/blender/makesdna/intern/dna_utils.h
index 123dd30a2b9..264310ef0fb 100644
--- a/source/blender/makesdna/intern/dna_utils.h
+++ b/source/blender/makesdna/intern/dna_utils.h
@@ -18,8 +18,7 @@
* \ingroup DNA
*/
-#ifndef __DNA_UTILS_H__
-#define __DNA_UTILS_H__
+#pragma once
struct GHash;
struct MemArena;
@@ -54,5 +53,3 @@ void DNA_alias_maps(enum eDNA_RenameDir version_dir,
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);
-
-#endif /* __DNA_UTILS_H__ */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 182296c0ba2..7aaedbff1ce 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -54,6 +54,7 @@
#include "BLI_ghash.h"
#include "BLI_memarena.h"
#include "BLI_sys_types.h" /* for intptr_t support */
+#include "BLI_system.h" /* for 'BLI_system_backtrace' stub. */
#include "BLI_utildefines.h"
#include "dna_utils.h"
@@ -98,6 +99,7 @@ static const char *includefiles[] = {
"DNA_sdna_types.h",
"DNA_fileglobal_types.h",
"DNA_sequence_types.h",
+ "DNA_session_uuid_types.h",
"DNA_effect_types.h",
"DNA_outliner_types.h",
"DNA_sound_types.h",
@@ -358,7 +360,7 @@ static int add_type(const char *str, int size)
if (str[0] == 0) {
return -1;
}
- else if (strchr(str, '*')) {
+ if (strchr(str, '*')) {
/* note: this is valid C syntax but we can't parse, complain!
* `struct SomeStruct* some_var;` <-- correct but we cant handle right now. */
return -1;
@@ -368,7 +370,7 @@ static int add_type(const char *str, int size)
/* search through type array */
for (int index = 0; index < types_len; index++) {
- if (strcmp(str, types[index]) == 0) {
+ if (STREQ(str, types[index])) {
if (size) {
types_size_native[index] = size;
types_size_32[index] = size;
@@ -521,7 +523,7 @@ static int add_name(const char *str)
/* search name array */
for (nr = 0; nr < names_len; nr++) {
- if (strcmp(name, names[nr]) == 0) {
+ if (STREQ(name, names[nr])) {
return nr;
}
}
@@ -1530,12 +1532,21 @@ int main(int argc, char **argv)
#endif /* if 0 */
-/* even though DNA supports, 'long' shouldn't be used since it can be either 32 or 64bit,
- * use int or int64_t instead.
+/**
+ * Disable types:
+ *
+ * - 'long': even though DNA supports, 'long' shouldn't be used since it can be either 32 or 64bit,
+ * use int, int32_t or int64_t instead.
+ * - 'int8_t': as DNA doesn't yet support 'signed char' types,
+ * all char types are assumed to be unsigned.
+ * We should be able to support this, it's just not something which has been added yet.
+ *
* Only valid use would be as a runtime variable if an API expected a long,
- * but so far we dont have this happening. */
+ * but so far we don't have this happening.
+ */
#ifdef __GNUC__
# pragma GCC poison long
+# pragma GCC poison int8_t
#endif
#include "DNA_ID.h"
@@ -1592,6 +1603,7 @@ int main(int argc, char **argv)
#include "DNA_screen_types.h"
#include "DNA_sdna_types.h"
#include "DNA_sequence_types.h"
+#include "DNA_session_uuid_types.h"
#include "DNA_shader_fx_types.h"
#include "DNA_simulation_types.h"
#include "DNA_sound_types.h"