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:
authorLukas Tönne <lukas.toenne@gmail.com>2021-07-18 14:14:23 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2021-07-18 14:14:23 +0300
commitca50a1f762703d477ee84cf494dec601fd540299 (patch)
treefbd86a77e77015d7cc6becc1255a63e436a45b2a /source/blender/makesdna/intern
parentd35969a74ff7a71fc0ca233ae65a2f1c47eb9a25 (diff)
parente82c5c660778b3805f50f3f2901923692c17db2a (diff)
Merge branch 'master' into geometry-nodes-unnamed-attributesgeometry-nodes-unnamed-attributes
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r--source/blender/makesdna/intern/dna_defaults.c4
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c6
-rw-r--r--source/blender/makesdna/intern/dna_rename_defs.h1
-rw-r--r--source/blender/makesdna/intern/makesdna.c66
4 files changed, 61 insertions, 16 deletions
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 2d55ea05867..a573e2f9e8c 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -152,6 +152,7 @@
/* DNA_asset_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(AssetMetaData);
+SDNA_DEFAULT_DECL_STRUCT(AssetLibraryReference);
/* DNA_armature_defaults.h */
SDNA_DEFAULT_DECL_STRUCT(bArmature);
@@ -315,6 +316,7 @@ SDNA_DEFAULT_DECL_STRUCT(TextureGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(ThickGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(TimeGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(TintGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(WeightGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(LineartGpencilModifierData);
SDNA_DEFAULT_DECL_STRUCT(LengthGpencilModifierData);
@@ -347,6 +349,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
/* DNA_asset_defaults.h */
SDNA_DEFAULT_DECL(AssetMetaData),
+ SDNA_DEFAULT_DECL(AssetLibraryReference),
/* DNA_armature_defaults.h */
SDNA_DEFAULT_DECL(bArmature),
@@ -541,6 +544,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL(ThickGpencilModifierData),
SDNA_DEFAULT_DECL(TimeGpencilModifierData),
SDNA_DEFAULT_DECL(TintGpencilModifierData),
+ SDNA_DEFAULT_DECL(WeightGpencilModifierData),
SDNA_DEFAULT_DECL(LineartGpencilModifierData),
SDNA_DEFAULT_DECL(LengthGpencilModifierData),
};
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 2a4bf53702f..d23b9441822 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -47,7 +47,7 @@
/**
* \section dna_genfile Overview
*
- * - please note: no builtin security to detect input of double structs
+ * - please NOTE: no builtin security to detect input of double structs
* - if you want a struct not to be in DNA file: add two hash marks above it `(#<enter>#<enter>)`.
*
* Structure DNA data is added to each blender file and to each executable, this to detect
@@ -1060,7 +1060,7 @@ void DNA_struct_switch_endian(const SDNA *sdna, int struct_nr, char *data)
}
case SDNA_TYPE_INT:
case SDNA_TYPE_FLOAT: {
- /* Note, intentionally ignore long/ulong, because these could be 4 or 8 bytes.
+ /* NOTE: intentionally ignore long/ulong, because these could be 4 or 8 bytes.
* Fortunately, we only use these types for runtime variables and only once for a
* struct type that is no longer used. */
BLI_endian_switch_int32_array((int32_t *)member_data, member_array_length);
@@ -1398,7 +1398,7 @@ static void init_reconstruct_step_for_member(const SDNA *oldsdna,
r_step->data.cast_pointer.array_len = shared_array_length;
}
else {
- BLI_assert(!"invalid pointer size");
+ BLI_assert_msg(0, "invalid pointer size");
r_step->type = RECONSTRUCT_STEP_INIT_ZERO;
}
break;
diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h
index 735be0c10bf..d363e40e4f0 100644
--- a/source/blender/makesdna/intern/dna_rename_defs.h
+++ b/source/blender/makesdna/intern/dna_rename_defs.h
@@ -136,4 +136,5 @@ DNA_STRUCT_RENAME_ELEM(wmWindow, global_area_map, global_areas)
DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, line_types, edge_types)
DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, transparency_flags, mask_switches)
DNA_STRUCT_RENAME_ELEM(LineartGpencilModifierData, transparency_mask, material_mask_bits)
+DNA_STRUCT_RENAME_ELEM(SurfaceDeformModifierData, numverts, num_bind_verts)
DNA_STRUCT_RENAME_ELEM(MaterialLineArt, transparency_mask, material_mask_bits)
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 24cfc1d84f6..f2a75a60a44 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -43,6 +43,7 @@
#define DNA_DEPRECATED_ALLOW
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -272,6 +273,37 @@ void print_struct_sizes(void);
* Make DNA string (write to file).
* \{ */
+static bool match_identifier_with_len(const char *str,
+ const char *identifier,
+ const size_t identifier_len)
+{
+ if (strncmp(str, identifier, identifier_len) == 0) {
+ /* Check `str` isn't a prefix to a longer identifier. */
+ if (isdigit(str[identifier_len]) || isalpha(str[identifier_len]) ||
+ (str[identifier_len] == '_')) {
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+static bool match_identifier(const char *str, const char *identifier)
+{
+ const size_t identifier_len = strlen(identifier);
+ return match_identifier_with_len(str, identifier, identifier_len);
+}
+
+static bool match_identifier_and_advance(char **str_ptr, const char *identifier)
+{
+ const size_t identifier_len = strlen(identifier);
+ if (match_identifier_with_len(*str_ptr, identifier, identifier_len)) {
+ (*str_ptr) += identifier_len;
+ return true;
+ }
+ return false;
+}
+
static const char *version_struct_static_from_alias(const char *str)
{
const char *str_test = BLI_ghash_lookup(g_version_data.struct_map_static_from_alias, str);
@@ -360,7 +392,7 @@ static int add_type(const char *str, int size)
return -1;
}
if (strchr(str, '*')) {
- /* note: this is valid C syntax but we can't parse, complain!
+ /* NOTE: this is valid C syntax but we can't parse, complain!
* `struct SomeStruct* some_var;` <-- correct but we can't handle right now. */
return -1;
}
@@ -422,7 +454,7 @@ static int add_name(const char *str)
int isfuncptr = (strchr(str + 1, '(')) != NULL;
DEBUG_PRINTF(3, "\t\t\t\t*** Function pointer or multidim array pointer found\n");
- /* functionpointer: transform the type (sometimes) */
+ /* function-pointer: transform the type (sometimes). */
int i = 0;
while (str[i] != ')') {
@@ -567,7 +599,7 @@ static short *add_struct(int namecode)
static int preprocess_include(char *maindata, const int maindata_len)
{
- /* note: len + 1, last character is a dummy to prevent
+ /* NOTE: len + 1, last character is a dummy to prevent
* comparisons using uninitialized memory */
char *temp = MEM_mallocN(maindata_len + 1, "preprocess_include");
temp[maindata_len] = ' ';
@@ -619,7 +651,7 @@ static int preprocess_include(char *maindata, const int maindata_len)
else if (cp[-1] == '*' && cp[0] == ' ') {
/* pointers with a space */
} /* skip special keywords */
- else if (strncmp("DNA_DEPRECATED", cp, 14) == 0) {
+ else if (match_identifier(cp, "DNA_DEPRECATED")) {
/* single values are skipped already, so decrement 1 less */
a -= 13;
cp += 13;
@@ -721,7 +753,7 @@ static int convert_include(const char *filename)
md1++;
/* we've got a struct name when... */
- if (strncmp(md1 - 7, "struct", 6) == 0) {
+ if (match_identifier(md1 - 7, "struct")) {
const int strct = add_type(md1, 0);
if (strct == -1) {
@@ -756,14 +788,22 @@ static int convert_include(const char *filename)
/* skip when it says 'struct' or 'unsigned' or 'const' */
if (*md1) {
- if (strncmp(md1, "struct", 6) == 0) {
- md1 += 7;
- }
- if (strncmp(md1, "unsigned", 8) == 0) {
- md1 += 9;
- }
- if (strncmp(md1, "const", 5) == 0) {
- md1 += 6;
+ const char *md1_prev = md1;
+ while (match_identifier_and_advance(&md1, "struct") ||
+ match_identifier_and_advance(&md1, "unsigned") ||
+ match_identifier_and_advance(&md1, "const")) {
+ if (UNLIKELY(!ELEM(*md1, '\0', ' '))) {
+ /* This will happen with: `unsigned(*value)[3]` which isn't supported. */
+ fprintf(stderr,
+ "File '%s' contains non white space character "
+ "\"%c\" after identifier \"%s\"\n",
+ filename,
+ *md1,
+ md1_prev);
+ return 1;
+ }
+ /* Skip ' ' or '\0'. */
+ md1++;
}
/* we've got a type! */