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:
authorCampbell Barton <ideasman42@gmail.com>2019-02-12 09:03:16 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-12 09:09:57 +0300
commitd968db82b7aac37cd788a490997376004b5ce9eb (patch)
tree77724503d5638cbcc226e6a94b16a6ff8fe0275a /source/blender/makesdna/intern/makesdna.c
parentf96bfde4a5ef3c3c0b2878dec3828a967fda86cc (diff)
makesdna: add shared utility module
Currently only a single function was duplicated which isn't so bad, this change is to allow DNA versioning code to be shared between dna_genfile.c and makesdna.c.
Diffstat (limited to 'source/blender/makesdna/intern/makesdna.c')
-rw-r--r--source/blender/makesdna/intern/makesdna.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index f957bf637c3..e2616d91b27 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -49,6 +49,8 @@
#include "BLI_sys_types.h" /* for intptr_t support */
#include "BLI_memarena.h"
+#include "dna_utils.h"
+
#define SDNA_MAX_FILENAME_LENGTH 255
/* Included the path relative from /source/blender/ here, so we can move */
@@ -210,11 +212,6 @@ static int preprocess_include(char *maindata, int len);
static int convert_include(const char *filename);
/**
- * Determine how many bytes are needed for an array.
- */
-static int arraysize(const char *str);
-
-/**
* Determine how many bytes are needed for each struct.
*/
static int calculate_structlens(int);
@@ -723,25 +720,6 @@ static int convert_include(const char *filename)
return 0;
}
-static int arraysize(const char *str)
-{
- int a, mul = 1;
- const char *cp = NULL;
-
- for (a = 0; str[a]; a++) {
- if (str[a] == '[') {
- cp = &(str[a + 1]);
- }
- else if (str[a] == ']' && cp) {
- /* if 'cp' is a preprocessor definition, it will evaluate to 0,
- * the caller needs to check for this case and throw an error */
- mul *= atoi(cp);
- }
- }
-
- return mul;
-}
-
static bool check_field_alignment(int firststruct, int structtype, int type, int len,
const char *name, const char *detail)
{
@@ -798,7 +776,9 @@ static int calculate_structlens(int firststruct)
has_pointer = 1;
/* has the name an extra length? (array) */
int mul = 1;
- if (cp[namelen - 1] == ']') mul = arraysize(cp);
+ if (cp[namelen - 1] == ']') {
+ mul = DNA_elem_array_size(cp);
+ }
if (mul == 0) {
fprintf(stderr, "Zero array size found or could not parse %s: '%.*s'\n",
@@ -843,7 +823,9 @@ static int calculate_structlens(int firststruct)
else if (typelens_native[type]) {
/* has the name an extra length? (array) */
int mul = 1;
- if (cp[namelen - 1] == ']') mul = arraysize(cp);
+ if (cp[namelen - 1] == ']') {
+ mul = DNA_elem_array_size(cp);
+ }
if (mul == 0) {
fprintf(stderr, "Zero array size found or could not parse %s: '%.*s'\n",