diff options
author | Joseph Eagar <joeedh@gmail.com> | 2011-02-27 09:19:40 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2011-02-27 09:19:40 +0300 |
commit | f01261d040be27337db9f9996d648a279c89b7c4 (patch) | |
tree | c448230939b3c90d53ce8852dd00925d6052e3a4 /source/blender/makesdna/intern | |
parent | dcaeda5c4e3a0687251b8511de4f2e8b85ef75c0 (diff) | |
parent | 2198cfdb2deec8b2e85e242c74a032f43d0b26ca (diff) |
merge with/from trunk at r35190
Diffstat (limited to 'source/blender/makesdna/intern')
-rw-r--r-- | source/blender/makesdna/intern/CMakeLists.txt | 40 | ||||
-rw-r--r-- | source/blender/makesdna/intern/Makefile | 87 | ||||
-rw-r--r-- | source/blender/makesdna/intern/SConscript | 41 | ||||
-rw-r--r-- | source/blender/makesdna/intern/dna_genfile.c | 44 | ||||
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 40 |
5 files changed, 112 insertions, 140 deletions
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 0eb42373d6d..bb95e2c0fbc 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- mode: cmake; indent-tabs-mode: t; -*- # $Id$ # ***** BEGIN GPL LICENSE BLOCK ***** # @@ -24,22 +25,45 @@ # # ***** END GPL LICENSE BLOCK ***** -INCLUDE_DIRECTORIES(../../../../intern/guardedalloc ..) -FILE(GLOB INC_FILES ../*.h) +# message(STATUS "Configuring makesdna") + +blender_include_dirs( + ../../../../intern/guardedalloc + ../../blenloader + .. +) # Build makesdna executable -SET(SRC makesdna.c ../../../../intern/guardedalloc/intern/mallocn.c ../../../../intern/guardedalloc/intern/mmap_win.c) -ADD_EXECUTABLE(makesdna ${SRC} ${INC_FILES}) +set(SRC + makesdna.c + ../../../../intern/guardedalloc/intern/mallocn.c +) + +if(WIN32 AND NOT UNIX) + list(APPEND SRC + ../../../../intern/guardedalloc/intern/mmap_win.c + ) +endif() + +# SRC_DNA_INC is defined in the parent dir + +add_executable(makesdna ${SRC} ${SRC_DNA_INC}) # Output dna.c -ADD_CUSTOM_COMMAND( +add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dna.c COMMAND ${CMAKE_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/makesdna ${CMAKE_CURRENT_BINARY_DIR}/dna.c ${CMAKE_SOURCE_DIR}/source/blender/makesdna/ DEPENDS makesdna ) # Build bf_dna library -SET(SRC dna_genfile.c dna.c) -BLENDERLIB(bf_dna "${SRC}" "${INC}") +set(INC +) + +set(SRC + dna_genfile.c + dna.c + ${SRC_DNA_INC} +) -MESSAGE(STATUS "Configuring makesdna") +blender_add_lib(bf_dna "${SRC}" "${INC}") diff --git a/source/blender/makesdna/intern/Makefile b/source/blender/makesdna/intern/Makefile deleted file mode 100644 index 55b0c42acda..00000000000 --- a/source/blender/makesdna/intern/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** -# -# - -LIBNAME = dna -DIR = $(OCGDIR)/blender/makesdna -CSRCS = DNA.c $(wildcard dna_*.c) - -include nan_compile.mk - -CFLAGS += $(LEVEL_1_C_WARNINGS) - -CPPFLAGS += -I$(OPENGL_HEADERS) -CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include -CPPFLAGS += -I../../blenlib -CPPFLAGS += -I.. - -ifeq ($(OS),windows) - # Windows needs these extra libs because of winstuff... It is not - # _really_ needed, but it is the easiest fix for now. If you have - # some spare time, try to trace down the exact dep. Then again, you - # could also spend that time making the sdna system more robust. - ifneq ($(FREE_WINDOWS),true) - WINLIBS = kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib - WINLIBS += advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib - WINLIBS += winmm.lib opengl32.lib glu32.lib largeint.lib - WINLIBS += /link /nodefaultlib:libc - else - LDFLAGS += -mwindows -mno-cygwin - endif -endif - -ifeq ($(OS), darwin) - LDFLAGS += -arch $(MACOSX_ARCHITECTURE) #-isysroot $(MACOSX_SDK) -mmacosx-version-min=$(MACOSX_MIN_VERS) -endif - -clean:: - @$(RM) $(DIR)/makesdna* $(DIR)/DNA.c - @$(RM) $(DIR)/debug/makesdna* $(DIR)/debug/DNA.c - -# TODO include right .mk for ldflags - -# A small note: we do not use the debug version of the alloc lib. That -# is done quite intentionally. If there is a bug in that lib, it needs -# to be fixed by the module maintainer. -DNAOBJS = $(filter-out %DNA.o, $(OBJS)) - -$(DIR)/$(DEBUG_DIR)makesdna: $(DNAOBJS) $(DIR)/$(DEBUG_DIR)makesdna.o $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a - $(CC) $(LDFLAGS) -o $@ $^ - -$(DIR)/$(DEBUG_DIR)DNA.c: $(DIR)/$(DEBUG_DIR)makesdna - ifeq ($(OS),windows) - $(SRCHOME)/tools/cygwin/cl_wrapper.pl - $(DIR)/$(DEBUG_DIR)makesdna \ - $(DIR)/$(DEBUG_DIR)DNA.c - else - $(DIR)/$(DEBUG_DIR)makesdna $(DIR)/$(DEBUG_DIR)DNA.c - endif - -$(DIR)/$(DEBUG_DIR)makesdna.o: makesdna.c $(wildcard ../*.h) - $(CC) -c $(CFLAGS) $(CPPFLAGS) makesdna.c -o $@ - diff --git a/source/blender/makesdna/intern/SConscript b/source/blender/makesdna/intern/SConscript index ac897eaed14..23a71ae104e 100644 --- a/source/blender/makesdna/intern/SConscript +++ b/source/blender/makesdna/intern/SConscript @@ -3,7 +3,7 @@ import sys import os def normpath(path): - return os.path.abspath(os.path.normpath(path)) + return os.path.abspath(os.path.normpath(path)) Import ('env') cflags = '' @@ -18,21 +18,25 @@ dna = env.Clone() makesdna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesdna/\\"" ') makesdna_tool.Append (CPPPATH = ['#/intern/guardedalloc', +<<<<<<< .working '../../makesdna', '../', '../../bmesh']) +======= + '../../makesdna', '../../blenloader']) +>>>>>>> .merge-right.r35190 if env['OURPLATFORM'] == 'linuxcross': - USE_WINE = True # when cross compiling on linux 64bit this is useful + USE_WINE = True # when cross compiling on linux 64bit this is useful else: - USE_WINE = False + USE_WINE = False if not USE_WINE: - if env['OURPLATFORM'] == 'linuxcross': - makesdna_tool.Replace(CC='gcc') - makesdna_tool.Replace(AR='ar') - makesdna_tool.Replace(LINK='gcc') + if env['OURPLATFORM'] == 'linuxcross': + makesdna_tool.Replace(CC='gcc') + makesdna_tool.Replace(AR='ar') + makesdna_tool.Replace(LINK='gcc') if sys.platform != 'cygwin': - makesdna_tool.Append (CCFLAGS = cflags) + makesdna_tool.Append (CCFLAGS = cflags) makesdna_tool.Append (CPPDEFINES = defines) makesdna_tool.Append( CFLAGS = env['CFLAGS']) makesdna_tool.Append( CCFLAGS = env['CCFLAGS']) @@ -40,15 +44,15 @@ makesdna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS']) targetdir = normpath(root_build_dir+'/lib') if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'): - targetdir = '#'+targetdir + targetdir = '#'+targetdir makesdna_tool.Append (LIBPATH = targetdir) if env['BF_PROFILE']: - makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_LINKFLAGS']) + makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_LINKFLAGS']) targetdir = normpath(root_build_dir + '/makesdna') if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'): - targetdir = '#' + targetdir + targetdir = '#' + targetdir #root_build_dir = "#" makesdna = makesdna_tool.Program (target = targetdir, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_blenlib']) @@ -60,11 +64,12 @@ dna.Depends ('dna.c', header_files) ap = os.path.abspath if env['OURPLATFORM'] != 'linuxcross': - if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'): - dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET") - else: - dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET") + if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'): + dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET") + else: + dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET") else: +<<<<<<< .working if USE_WINE: dna.Command ('dna.c', '', 'wine ' + ap(root_build_dir+os.sep+"makesdna $TARGET")) else: @@ -72,6 +77,12 @@ else: dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET") else: dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna $TARGET") +======= + if USE_WINE: + dna.Command ('dna.c', '', 'wine ' + root_build_dir+os.sep+"makesdna $TARGET") + else: + dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna.exe $TARGET") +>>>>>>> .merge-right.r35190 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 fd98fd4ef08..3b6aafaffa0 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -31,6 +31,11 @@ * DNA handling */ +/** \file blender/makesdna/intern/dna_genfile.c + * \ingroup DNA + */ + + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -43,7 +48,7 @@ /* gcc 4.1 on mingw was complaining that __int64 was already defined actually is saw the line below as typedef long long long long... -Anyhow, since its already defined, its safe to do an ifndef here- Cambpell*/ +Anyhow, since its already defined, its safe to do an ifndef here- Campbell */ #ifdef FREE_WINDOWS #ifndef __int64 typedef long long __int64; @@ -196,7 +201,7 @@ void DNA_sdna_free(SDNA *sdna) MEM_freeN(sdna); } -static int ispointer(char *name) +static int ispointer(const char *name) { /* check if pointer or function pointer */ return (name[0]=='*' || (name[0]=='(' && name[1]=='*')); @@ -206,7 +211,7 @@ static int elementsize(SDNA *sdna, short type, short name) /* call with numbers from struct-array */ { int mul, namelen, len; - char *cp; + const char *cp; cp= sdna->names[name]; len= 0; @@ -251,7 +256,7 @@ static void printstruct(SDNA *sdna, short strnr) } #endif -static short *findstruct_name(SDNA *sdna, char *str) +static short *findstruct_name(SDNA *sdna, const char *str) { int a; short *sp=0; @@ -502,7 +507,7 @@ static void recurs_test_compflags(SDNA *sdna, char *compflags, int structnr) { int a, b, typenr, elems; short *sp; - char *cp; + const char *cp; /* check all structs, test if it's inside another struct */ sp= sdna->structs[structnr]; @@ -546,7 +551,7 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna) */ int a, b; short *spold, *spcur; - char *str1, *str2; + const char *str1, *str2; char *compflags; if(sdna->nr_structs==0) { @@ -627,7 +632,7 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna) return compflags; } -static void cast_elem(char *ctype, char *otype, char *name, char *curdata, char *olddata) +static void cast_elem(char *ctype, char *otype, const char *name, char *curdata, char *olddata) { double val = 0.0; int arrlen, curlen=1, oldlen=1, ctypenr, otypenr; @@ -721,7 +726,7 @@ static void cast_elem(char *ctype, char *otype, char *name, char *curdata, char } } -static void cast_pointer(int curlen, int oldlen, char *name, char *curdata, char *olddata) +static void cast_pointer(int curlen, int oldlen, const char *name, char *curdata, char *olddata) { #ifdef WIN32 __int64 lval; @@ -764,7 +769,7 @@ static void cast_pointer(int curlen, int oldlen, char *name, char *curdata, char } } -static int elem_strcmp(char *name, char *oname) +static int elem_strcmp(const char *name, const char *oname) { int a=0; @@ -780,10 +785,10 @@ static int elem_strcmp(char *name, char *oname) return 0; } -static char *find_elem(SDNA *sdna, char *type, char *name, short *old, char *olddata, short **sppo) +static char *find_elem(SDNA *sdna, const char *type, const char *name, short *old, char *olddata, short **sppo) { int a, elemcount, len; - char *otype, *oname; + const char *otype, *oname; /* without arraypart, so names can differ: return old namenr and type */ @@ -811,7 +816,7 @@ static char *find_elem(SDNA *sdna, char *type, char *name, short *old, char *old return 0; } -static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, char *name, char *curdata, short *old, char *olddata) +static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, const char *name, char *curdata, short *old, char *olddata) { /* rules: test for NAME: - name equal: @@ -823,7 +828,8 @@ static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, char *nam can I force this?) */ int a, elemcount, len, array, oldsize, cursize, mul; - char *otype, *oname, *cp; + char *otype; + const char *oname, *cp; /* is 'name' an array? */ cp= name; @@ -868,6 +874,10 @@ static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, char *nam mul= len/oldsize; mul*= (cursize < oldsize)? cursize: oldsize; memcpy(curdata, olddata, mul); + + /* terminate strings */ + if(oldsize > cursize && strcmp(type, "char")==0) + curdata[mul-1]= 0; } else { if(cursize>oldsize) cast_elem(type, otype, oname, curdata, olddata); @@ -888,7 +898,8 @@ static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna, char *compflags, in */ int a, elemcount, elen, eleno, mul, mulo, firststructtypenr; short *spo, *spc, *sppo; - char *name, *nameo, *type, *cpo, *cpc; + char *type, *cpo, *cpc; + const char *name, *nameo; if(oldSDNAnr== -1) return; if(curSDNAnr== -1) return; @@ -965,7 +976,8 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) */ int a, mul, elemcount, elen, elena, firststructtypenr; short *spo, *spc, skip; - char *name, *type, *cpo, *cur, cval; + char *type, *cpo, *cur, cval; + const char *name; if(oldSDNAnr== -1) return; firststructtypenr= *(oldsdna->structs[0]); @@ -1095,7 +1107,7 @@ void *DNA_struct_reconstruct(SDNA *newsdna, SDNA *oldsdna, char *compflags, int return cur; } -int DNA_elem_offset(SDNA *sdna, char *stype, char *vartype, char *name) +int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const char *name) { int SDNAnr= DNA_struct_find_nr(sdna, stype); diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 7a2d659755a..711d7a08687 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** @@ -25,9 +25,13 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file makesdna.c + * \brief Struct muncher for making SDNA. + * \ingroup DNA * - * Struct muncher for making SDNA - * + * \section aboutmakesdnac About makesdna tool * Originally by Ton, some mods by Frank, and some cleaning and * extension by Nzc. * @@ -42,7 +46,7 @@ * and the offsets for reaching a particular one. * * There is a facility to get verbose output from sdna. Search for - * debugSDNA. This int can be set to 0 (no output) to some int. Higher + * \ref debugSDNA. This int can be set to 0 (no output) to some int. Higher * numbers give more output. * */ @@ -62,7 +66,7 @@ /* Included the path relative from /source/blender/ here, so we can move */ /* headers around with more freedom. */ -char *includefiles[] = { +const char *includefiles[] = { // if you add files here, please add them at the end // of makesdna.c (this file) as well @@ -145,7 +149,8 @@ short **structs, *structdata; /* at sp= structs[a] is the first address of a str 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: * - 0 = no output, except errors * - 1 = detail actions @@ -160,12 +165,15 @@ int additional_slen_offset; /* ************************************************************************** */ /** - * Add type <str> to struct indexed by <len>, if it was not yet found. + * Add type \c str to struct indexed by \c len, if it was not yet found. + * \param str char + * \param len int */ -int add_type(char *str, int len); +int add_type(const char *str, int len); /** - * Add variable <str> to + * Add variable \c str to + * \param str */ int add_name(char *str); @@ -214,7 +222,7 @@ void printStructLenghts(void); /* ************************* MAKEN DNA ********************** */ -int add_type(char *str, int len) +int add_type(const char *str, int len) { int nr; char *cp; @@ -244,7 +252,7 @@ int add_type(char *str, int len) if(nr_types>=maxnr) { printf("too many types\n"); - return nr_types-1;; + return nr_types-1; } nr_types++; @@ -269,7 +277,7 @@ int add_name(char *str) additional_slen_offset = 0; - if((str[0]==0) /* || (str[1]==0) */) return -1; + if(str[0]==0 /* || (str[1]==0) */) return -1; if (str[0] == '(' && str[1] == '*') { /* we handle function pointer and special array cases here, e.g. @@ -281,7 +289,6 @@ int add_name(char *str) if (debugSDNA > 3) printf("\t\t\t\t*** Function pointer or multidim array pointer found\n"); /* functionpointer: transform the type (sometimes) */ i = 0; - j = 0; while (str[i] != ')') { buf[i] = str[i]; @@ -421,7 +428,11 @@ int preprocess_include(char *maindata, int len) int a, newlen, comment = 0; char *cp, *temp, *md; - temp= MEM_mallocN(len, "preprocess_include"); + /* note: len + 1, last character is a dummy to prevent + * comparisons using uninitialized memory */ + temp= MEM_mallocN(len + 1, "preprocess_include"); + temp[len]= ' '; + memcpy(temp, maindata, len); // remove all c++ comments @@ -1056,6 +1067,7 @@ int make_structDNA(char *baseDirectory, FILE *file) MEM_freeN(names); MEM_freeN(types); MEM_freeN(typelens); + MEM_freeN(alphalens); MEM_freeN(structs); if (debugSDNA > -1) printf("done.\n"); |