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.txt26
-rw-r--r--source/blender/makesdna/intern/SConscript1
-rw-r--r--source/blender/makesdna/intern/dna_genfile.c42
-rw-r--r--source/blender/makesdna/intern/makesdna.c48
4 files changed, 91 insertions, 26 deletions
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 429db63b526..5edebfe3903 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -27,12 +27,17 @@
# message(STATUS "Configuring makesdna")
+# add_definitions(-DWITH_DNA_GHASH)
+
blender_include_dirs(
../../../../intern/guardedalloc
../../blenloader
+ ../../blenlib
..
)
+
+# -----------------------------------------------------------------------------
# Build makesdna executable
set(SRC
makesdna.c
@@ -56,6 +61,8 @@ add_custom_command(
DEPENDS makesdna
)
+
+# -----------------------------------------------------------------------------
# Build bf_dna library
set(INC
@@ -72,3 +79,22 @@ set(SRC
)
blender_add_lib(bf_dna "${SRC}" "${INC}" "${INC_SYS}")
+
+
+# -----------------------------------------------------------------------------
+# Build bf_dna_blenlib library
+set(INC
+
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+ ../../blenlib/intern/BLI_mempool.c
+ ../../blenlib/intern/listbase.c
+ ../../blenlib/intern/BLI_ghash.c
+)
+
+blender_add_lib(bf_dna_blenlib "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/makesdna/intern/SConscript b/source/blender/makesdna/intern/SConscript
index e51ee53e078..8185676cbfc 100644
--- a/source/blender/makesdna/intern/SConscript
+++ b/source/blender/makesdna/intern/SConscript
@@ -67,5 +67,6 @@ else:
else:
dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna.exe $TARGET")
+# TODO, get WITH_DNA_GHASH working, see CMake's 'WITH_DNA_GHASH'
obj = ['intern/dna.c', 'intern/dna_genfile.c']
Return ('obj')
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 4e9b023b326..ebcfce84e37 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -42,6 +42,10 @@
#include "MEM_guardedalloc.h" // for MEM_freeN MEM_mallocN MEM_callocN
+#ifdef WITH_DNA_GHASH
+# include "BLI_ghash.h"
+#endif
+
#include "DNA_genfile.h"
#include "DNA_sdna_types.h" // for SDNA ;-)
@@ -197,7 +201,11 @@ void DNA_sdna_free(SDNA *sdna)
MEM_freeN((void *)sdna->names);
MEM_freeN(sdna->types);
MEM_freeN(sdna->structs);
-
+
+#ifdef WITH_DNA_GHASH
+ BLI_ghash_free(sdna->structs_map, NULL, NULL);
+#endif
+
MEM_freeN(sdna);
}
@@ -275,24 +283,30 @@ static short *findstruct_name(SDNA *sdna, const char *str)
int DNA_struct_find_nr(SDNA *sdna, const char *str)
{
short *sp= NULL;
- int a;
if(sdna->lastfind<sdna->nr_structs) {
sp= sdna->structs[sdna->lastfind];
if(strcmp( sdna->types[ sp[0] ], str )==0) return sdna->lastfind;
}
- for(a=0; a<sdna->nr_structs; a++) {
+#ifdef WITH_DNA_GHASH
+ return (intptr_t)BLI_ghash_lookup(sdna->structs_map, str) - 1;
+#else
+ {
+ int a;
- sp= sdna->structs[a];
-
- if(strcmp( sdna->types[ sp[0] ], str )==0) {
- sdna->lastfind= a;
- return a;
+ for(a=0; a<sdna->nr_structs; a++) {
+
+ sp= sdna->structs[a];
+
+ if(strcmp( sdna->types[ sp[0] ], str )==0) {
+ sdna->lastfind= a;
+ return a;
+ }
}
}
-
return -1;
+#endif
}
/* ************************* END DIV ********************** */
@@ -481,6 +495,16 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
sp[10]= 9;
}
}
+
+#ifdef WITH_DNA_GHASH
+ /* create a ghash lookup to speed up */
+ sdna->structs_map= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "init_structDNA gh");
+
+ for(nr = 0; nr < sdna->nr_structs; nr++) {
+ sp= sdna->structs[nr];
+ BLI_ghash_insert(sdna->structs_map, (void *)sdna->types[sp[0]], (void *)(nr + 1));
+ }
+#endif
}
}
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 8b841b67e54..694b403c7c5 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -132,23 +132,24 @@ const char *includefiles[] = {
"DNA_anim_types.h",
"DNA_boid_types.h",
"DNA_smoke_types.h",
+ "DNA_speaker_types.h",
// empty string to indicate end of includefiles
""
};
-int maxdata= 500000, maxnr= 50000;
-int nr_names=0;
-int nr_types=0;
-int nr_structs=0;
-char **names, *namedata; /* at address names[a] is string a */
-char **types, *typedata; /* at address types[a] is string a */
-short *typelens; /* at typelens[a] is de length of type a */
-short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits) */
-short **structs, *structdata; /* at sp= structs[a] is the first address of a struct definition
- sp[0] is type number
- sp[1] is amount of elements
- sp[2] sp[3] is typenr, namenr (etc) */
+static int maxdata= 500000, maxnr= 50000;
+static int nr_names=0;
+static int nr_types=0;
+static int nr_structs=0;
+static char **names, *namedata; /* at address names[a] is string a */
+static char **types, *typedata; /* at address types[a] is string a */
+static short *typelens; /* at typelens[a] is de length of type a */
+static short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits), infact any 64bit system */
+static short **structs, *structdata;/* at sp= structs[a] is the first address of a struct definition
+ sp[0] is type number
+ sp[1] is amount of elements
+ sp[2] sp[3] is typenr, namenr (etc) */
/**
* Variable to control debug output of makesdna.
* debugSDNA:
@@ -157,8 +158,8 @@ short **structs, *structdata; /* at sp= structs[a] is the first address of a str
* - 2 = full trace, tell which names and types were found
* - 4 = full trace, plus all gritty details
*/
-int debugSDNA = 0;
-int additional_slen_offset;
+static int debugSDNA = 0;
+static int additional_slen_offset;
/* ************************************************************************** */
/* Functions */
@@ -670,6 +671,8 @@ int arraysize(char *astr, int len)
}
else if( str[a]==']' && cp) {
str[a]= 0;
+ /* 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);
}
}
@@ -713,7 +716,12 @@ static int calculate_structlens(int firststruct)
/* has the name an extra length? (array) */
mul= 1;
if( cp[namelen-1]==']') mul= arraysize(cp, namelen);
-
+
+ if (mul == 0) {
+ printf("Zero array size found or could not parse %s: '%.*s'\n", types[structtype], namelen + 1, cp);
+ dna_error = 1;
+ }
+
/* 4-8 aligned/ */
if(sizeof(void *) == 4) {
if (len % 4) {
@@ -743,7 +751,12 @@ static int calculate_structlens(int firststruct)
/* has the name an extra length? (array) */
mul= 1;
if( cp[namelen-1]==']') mul= arraysize(cp, namelen);
-
+
+ if (mul == 0) {
+ printf("Zero array size found or could not parse %s: '%.*s'\n", types[structtype], namelen + 1, cp);
+ dna_error = 1;
+ }
+
/* struct alignment */
if(type >= firststruct) {
if(sizeof(void *)==8 && (len % 8) ) {
@@ -877,7 +890,7 @@ void printStructLenghts(void)
}
-int make_structDNA(char *baseDirectory, FILE *file)
+static int make_structDNA(char *baseDirectory, FILE *file)
{
int len, i;
short *sp;
@@ -1184,4 +1197,5 @@ int main(int argc, char ** argv)
#include "DNA_anim_types.h"
#include "DNA_boid_types.h"
#include "DNA_smoke_types.h"
+#include "DNA_speaker_types.h"
/* end of list */