RNA / Data API
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 31 Oct 2008 23:50:02 +0000 (23:50 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 31 Oct 2008 23:50:02 +0000 (23:50 +0000)
This is the first code for the Data API, also known as RNA system in the
2.5 Branch. It does not include a user interface, and only wraps some
Scene properties for testing. It is integrated with Scons and Makefiles,
and compiles a 'makesrna' program that generates an RNA.c file.

http://wiki.blender.org/index.php/BlenderDev/Blender2.5/DataAPI
http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNA

The changes are quite local, basically adding a makesrna module which
works similar to the makesdna module. The one external change is in
moving genfile.c from blenloader to the makesdna module, so that it can
be reused by the RNA code. This also meant changing the DNA makefiles.
It seems to be doing dependencies correct still in my tests, but if
there is an issue with the DNA not being rebuilt this commit might be
the one causing it. Also it seems for scons the makesdna and makesrna
modules are compiling without warnings. Not a new issue but this should
be fixed.

The RNA code supports all types as defined in the Data API design, so
in that sense it is fairly complete and I hope that aspect will not
have to change much. Some obviously missing parts are context related
code, notify() functions for updates and user defined / ID properties.

25 files changed:
source/Makefile
source/blender/Makefile
source/blender/SConscript
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/makesdna/DNA_genfile.h [moved from source/blender/blenloader/intern/genfile.h with 65% similarity]
source/blender/makesdna/DNA_sdna_types.h
source/blender/makesdna/SConscript
source/blender/makesdna/intern/Makefile
source/blender/makesdna/intern/SConscript
source/blender/makesdna/intern/dna_genfile.c [moved from source/blender/blenloader/intern/genfile.c with 86% similarity]
source/blender/makesrna/Makefile [new file with mode: 0644]
source/blender/makesrna/RNA_access.h [new file with mode: 0644]
source/blender/makesrna/RNA_define.h [new file with mode: 0644]
source/blender/makesrna/RNA_types.h [new file with mode: 0644]
source/blender/makesrna/SConscript [new file with mode: 0644]
source/blender/makesrna/intern/Makefile [new file with mode: 0644]
source/blender/makesrna/intern/SConscript [new file with mode: 0644]
source/blender/makesrna/intern/makesrna.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_access.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_define.c [new file with mode: 0644]
source/blender/makesrna/intern/rna_internal.h [new file with mode: 0644]
source/blender/makesrna/intern/rna_object.c [moved from source/blender/blenloader/BLO_genfile.h with 56% similarity]
source/blender/makesrna/intern/rna_scene.c [new file with mode: 0644]

index 0704bde02a3c9aaf4af1a7bd907ceb6f6f0d37b9..7efb45bdca9039f9f4ef7f223eb5311bf4a83ddf 100644 (file)
@@ -73,8 +73,7 @@ endif
 # PLUGAPPLIB libs that form the application to be plugged in
 # Note: the order is important here
 
-GRPLIB = $(OCGDIR)/blender/makesdna/$(DEBUG_DIR)DNA.o
-GRPLIB += $(OCGDIR)/creator/$(DEBUG_DIR)libcreator.a
+GRPLIB = $(OCGDIR)/creator/$(DEBUG_DIR)libcreator.a
 GRPLIB += $(OCGDIR)/blender/windowmanager/$(DEBUG_DIR)libwindowmanager.a
 GRPLIB += $(NAN_BSP)/lib/$(DEBUG_DIR)libbsp.a
 GRPLIB += $(NAN_BOOLOP)/lib/$(DEBUG_DIR)libboolop.a
@@ -149,6 +148,7 @@ ifneq ($(NAN_NO_KETSJI),true)
     COMLIB += $(NAN_BULLET2)/lib/libbullet2.a
 endif
 
+COMLIB += $(OCGDIR)/blender/makesdna/$(DEBUG_DIR)libdna.a
 COMLIB += $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a
 COMLIB += $(NAN_MEMUTIL)/lib/libmemutil.a
 COMLIB += $(NAN_BMFONT)/lib/$(DEBUG_DIR)libbmfont.a
@@ -230,7 +230,7 @@ PULIB += $(OCGDIR)/blender/ed_view3d/libed_view3d.a
 PULIB += $(OCGDIR)/blender/ed_interface/libed_interface.a
 PULIB += $(OCGDIR)/blender/windowmanager/libwindowmanager.a
 PULIB += $(OCGDIR)/blender/python/$(DEBUG_DIR)libpython.a
-
+PULIB += $(OCGDIR)/blender/makesrna/$(DEBUG_DIR)librna.a
 
 ifeq ($(NAN_NO_KETSJI),true)
     PULIB += $(NAN_MOTO)/lib/libmoto.a
@@ -244,12 +244,12 @@ SPLIB1 += $(OCGDIR)/gameengine/GamePlayer/common/$(DEBUG_DIR)libcommon.a
 SPLIB1 += $(NAN_STRING)/lib/$(DEBUG_DIR)libstring.a
 SPLIB1 += $(NAN_GHOST)/lib/$(DEBUG_DIR)libghost.a
 
-SPLIB = $(OCGDIR)/blender/makesdna/$(DEBUG_DIR)DNA.o
-SPLIB += $(OCGDIR)/blender/readblenfile/$(DEBUG_DIR)libreadblenfile.a
+SPLIB = $(OCGDIR)/blender/readblenfile/$(DEBUG_DIR)libreadblenfile.a
 # this is used for the plugin. It uses some things from libz.a, 
 # but somehow it consistently fails to resolve these symbols... or 
 # can I just not check them? nm claims they aren't...
 SPLIB += $(OCGDIR)/blender/blenkernel/blenkernel_blc/$(DEBUG_DIR)libblenkernel_blc.a
+SPLIB += $(OCGDIR)/blender/makesrna/$(DEBUG_DIR)librna.a
 
 # These three need to be explicitly mentioned on the cl, because 
 # if they are offered as a lib, they are optimized away. (nzc)
index 7bd48aa777277eb7f29ccb67e0f4ef59568d3ed0..e66c32443a5785d146718eb6cc2909712cc81d14 100644 (file)
@@ -33,7 +33,7 @@ include nan_definitions.mk
 DIRS = windowmanager editors blenloader readblenfile
 DIRS += avi imbuf render radiosity blenlib blenkernel blenpluginapi
 DIRS += nodes
-DIRS += makesdna yafray
+DIRS += makesdna makesrna yafray
 DIRS += python
 
 ifeq ($(INTERNATIONAL), true)
index 3d3fa6e2f696ec5d970478962935404a29140055..2c39a6d6ff85cd9a12720115d66b323e37e4bc38 100644 (file)
@@ -11,6 +11,7 @@ SConscript(['avi/SConscript',
                        'imbuf/SConscript',
                        'imbuf/intern/cineon/SConscript',
                        'makesdna/SConscript',
+                       'makesrna/SConscript',
                        'python/SConscript',
                        'radiosity/SConscript',
                        'readblenfile/SConscript',
index f56b261efe27df6bc8a72b58dbfdf71e1211fc4c..24239b3e088beddb81e72ec62a2a4e7b30729564 100644 (file)
@@ -43,6 +43,7 @@
 #include "BLI_ghash.h"
 #include "BLI_linklist.h"
 
+#include "DNA_genfile.h"
 #include "DNA_sdna_types.h"
 #include "DNA_space_types.h"
 #include "DNA_userdef_types.h"
@@ -59,7 +60,6 @@
 #include "BLO_undofile.h"
 
 #include "readfile.h"
-#include "genfile.h"
 
 #include "BLO_readblenfile.h"
 
@@ -237,7 +237,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype)
                        }
                } else if (bhead->code==DATA) {
                        if (looking) {
-                               if (bhead->SDNAnr == dna_findstruct_nr(fd->filesdna, "PreviewImage") ) {
+                               if (bhead->SDNAnr == DNA_struct_find_nr(fd->filesdna, "PreviewImage") ) {
                                        prv = (PreviewImage*) (bhead+1);
                                        npreviews = 0;                          
                                        memcpy(new_prv, prv, sizeof(PreviewImage));
index f5abbc7bfab59ad644b608e2b99aff5f379359b7..4fffaf02b09102a536094221af956b232070dd0d 100644 (file)
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
 #include "zlib.h"
 
 #ifdef WIN32
@@ -51,8 +47,6 @@
     #include <io.h> // for open close read
 #endif
 
-//XXX #include "nla.h"
-
 #include "DNA_action_types.h"
 #include "DNA_armature_types.h"
 #include "DNA_ID.h"
@@ -66,6 +60,7 @@
 #include "DNA_customdata_types.h"
 #include "DNA_effect_types.h"
 #include "DNA_fileglobal_types.h"
+#include "DNA_genfile.h"
 #include "DNA_group_types.h"
 #include "DNA_ipo_types.h"
 #include "DNA_image_types.h"
 
 #include "readfile.h"
 
-#include "genfile.h"
-
 //XXX #include "wm_event_types.h"
 
 #include <errno.h>
@@ -792,12 +785,12 @@ static int read_file_dna(FileData *fd)
                if (bhead->code==DNA1) {
                        int do_endian_swap= (fd->flags&FD_FLAGS_SWITCH_ENDIAN)?1:0;
 
-                       fd->filesdna= dna_sdna_from_data(&bhead[1], bhead->len, do_endian_swap);
+                       fd->filesdna= DNA_sdna_from_data(&bhead[1], bhead->len, do_endian_swap);
                        if (fd->filesdna) {
                                
-                               fd->compflags= dna_get_structDNA_compareflags(fd->filesdna, fd->memsdna);
+                               fd->compflags= DNA_struct_get_compareflags(fd->filesdna, fd->memsdna);
                                /* used to retrieve ID names from (bhead+1) */
-                               fd->id_name_offs= dna_elem_offset(fd->filesdna, "ID", "char", "name[]");
+                               fd->id_name_offs= DNA_elem_offset(fd->filesdna, "ID", "char", "name[]");
                        }
 
                        return 1;
@@ -895,8 +888,6 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, int size)
 
 static FileData *filedata_new(void)
 {
-       extern unsigned char DNAstr[];  /* DNA.c */
-       extern int DNAlen;
        FileData *fd = MEM_callocN(sizeof(FileData), "FileData");
 
        fd->filedes = -1;
@@ -906,7 +897,7 @@ static FileData *filedata_new(void)
                 * but it keeps us reentrant,  remove once we have
                 * a lib that provides a nice lock. - zr
                 */
-       fd->memsdna = dna_sdna_from_data(DNAstr,  DNAlen,  0);
+       fd->memsdna = DNA_sdna_from_data(DNAstr,  DNAlen,  0);
 
        fd->datamap = oldnewmap_new();
        fd->globmap = oldnewmap_new();
@@ -1011,9 +1002,9 @@ void blo_freefiledata(FileData *fd)
                BLI_freelistN(&fd->listbase);
 
                if (fd->memsdna)
-                       dna_freestructDNA(fd->memsdna);
+                       DNA_sdna_free(fd->memsdna);
                if (fd->filesdna)
-                       dna_freestructDNA(fd->filesdna);
+                       DNA_sdna_free(fd->filesdna);
                if (fd->compflags)
                        MEM_freeN(fd->compflags);
 
@@ -1191,7 +1182,7 @@ static void switch_endian_structs(struct SDNA *filesdna, BHead *bhead)
 
        nblocks= bhead->nr;
        while(nblocks--) {
-               dna_switch_endian_struct(filesdna, bhead->SDNAnr, data);
+               DNA_struct_switch_endian(filesdna, bhead->SDNAnr, data);
 
                data+= blocksize;
        }
@@ -1208,7 +1199,7 @@ static void *read_struct(FileData *fd, BHead *bh, char *blockname)
 
                if (fd->compflags[bh->SDNAnr]) {        /* flag==0: doesn't exist anymore */
                        if(fd->compflags[bh->SDNAnr]==2) {
-                               temp= dna_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh+1));
+                               temp= DNA_struct_reconstruct(fd->memsdna, fd->filesdna, fd->compflags, bh->SDNAnr, bh->nr, (bh+1));
                        } else {
                                temp= MEM_mallocN(bh->len, blockname);
                                memcpy(temp, (bh+1), bh->len);
index 0351ef155d92bdb194305ae96f909fafd5a857af..383a732fbcad9bfe3d08f388c67aa4f880dd7772 100644 (file)
@@ -100,6 +100,7 @@ Any case: direct data is ALWAYS after the lib block
 #include "DNA_curve_types.h"
 #include "DNA_customdata_types.h"
 #include "DNA_effect_types.h"
+#include "DNA_genfile.h"
 #include "DNA_group_types.h"
 #include "DNA_image_types.h"
 #include "DNA_ipo_types.h"
@@ -168,7 +169,6 @@ Any case: direct data is ALWAYS after the lib block
 #include "BLO_undofile.h"
 
 #include "readfile.h"
-#include "genfile.h"
 
 #include <errno.h>
 
@@ -186,9 +186,6 @@ typedef struct {
 
 static WriteData *writedata_new(int file)
 {
-       extern unsigned char DNAstr[];  /* DNA.c */
-       extern int DNAlen;
-
        WriteData *wd= MEM_callocN(sizeof(*wd), "writedata");
 
                /* XXX, see note about this in readfile.c, remove
@@ -197,7 +194,7 @@ static WriteData *writedata_new(int file)
 
        if (wd == NULL) return NULL;
 
-       wd->sdna= dna_sdna_from_data(DNAstr, DNAlen, 0);
+       wd->sdna= DNA_sdna_from_data(DNAstr, DNAlen, 0);
 
        wd->file= file;
 
@@ -224,7 +221,7 @@ static void writedata_do_write(WriteData *wd, void *mem, int memlen)
 
 static void writedata_free(WriteData *wd)
 {
-       dna_freestructDNA(wd->sdna);
+       DNA_sdna_free(wd->sdna);
 
        MEM_freeN(wd->buf);
        MEM_freeN(wd);
@@ -329,7 +326,7 @@ static void writestruct(WriteData *wd, int filecode, char *structname, int nr, v
        bh.old= adr;
        bh.nr= nr;
 
-       bh.SDNAnr= dna_findstruct_nr(wd->sdna, structname);
+       bh.SDNAnr= DNA_struct_find_nr(wd->sdna, structname);
        if(bh.SDNAnr== -1) {
                printf("error: can't find SDNA code <%s>\n", structname);
                return;
similarity index 65%
rename from source/blender/blenloader/intern/genfile.h
rename to source/blender/makesdna/DNA_genfile.h
index 81475252c464869aa332a9dbd7d34880e5664d6b..4b9401bf4b95eab20c52196763b8dad01fa39ca3 100644 (file)
 
 struct SDNA;
 
-int dna_findstruct_nr(struct SDNA *sdna, char *str);
-char *dna_get_structDNA_compareflags(struct SDNA *sdna, struct SDNA *newsdna);
-void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data);
-void *dna_reconstruct(struct SDNA *newsdna, struct SDNA *oldsdna, char *compflags, int oldSDNAnr, int blocks, void *data);
-int dna_elem_offset(struct SDNA *sdna, char *stype, char *vartype, char *name);
+extern unsigned char DNAstr[];  /* DNA.c */
+extern int DNAlen;
 
-struct SDNA *dna_sdna_from_data(void *data, int datalen, int do_endian_swap);
-void dna_freestructDNA(struct SDNA *sdna);
+struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap);
+void DNA_sdna_free(struct SDNA *sdna);
+
+int DNA_struct_find_nr(struct SDNA *sdna, const char *str);
+void DNA_struct_switch_endian(struct SDNA *oldsdna, int oldSDNAnr, char *data);
+char *DNA_struct_get_compareflags(struct SDNA *sdna, struct SDNA *newsdna);
+void *DNA_struct_reconstruct(struct SDNA *newsdna, struct SDNA *oldsdna, char *compflags, int oldSDNAnr, int blocks, void *data);
+
+int DNA_elem_array_size(const char *astr, int len);
+int DNA_elem_offset(struct SDNA *sdna, char *stype, char *vartype, char *name);
 
 #endif
 
+
index ac0b77aacf991d1be0ab6958bdf2dfe2eee7d808..5726837a7230fee9682ed9e6c7006d1ebae20889 100644 (file)
 
 #
 #
-struct SDNA {
-       char *data;
-       int datalen, nr_names;
-       char **names;
-       int nr_types, pointerlen;
-       char **types;
-       short *typelens;
-       int nr_structs;
-       short **structs;
+typedef struct SDNA {
+       char *data;                     /* full copy of 'encoded' data */
+       int datalen;            /* length of data */
+
+       int nr_names;           /* total number of struct members */
+       char **names;           /* struct member names */
+
+       int pointerlen;         /* size of a pointer in bytes */
+
+       int nr_types;           /* number of basic types + struct types */
+       char **types;           /* type names */
+       short *typelens;        /* type lengths */
+
+       int nr_structs;         /* number of struct types */
+       short **structs;        /* sp= structs[a] is the adress of a struct definintion
+                                  sp[0] is struct type number, sp[1] amount of members
+
+                                                  (sp[2], sp[3]), (sp[4], sp[5]), .. are the member
+                                                  type and name numbers respectively */
        
                /* wrong place for this really, its a simple
                 * cache for findstruct_nr.
                 */
        int lastfind;
-};
+} SDNA;
 
 #
 #
index d67be4955c446cc264f43b6238ec24c2c1c0aa2f..cdb4caef8fdbe3dd37cff0a11401c5f832a78cca 100644 (file)
@@ -4,8 +4,8 @@ Import ('env')
 objs = []
 
 o = SConscript('intern/SConscript')
-objs.append (o)
+objs += o
 
-incs = '#/intern/guardedalloc'
+incs = '#/intern/guardedalloc .'
 
 env.BlenderLib ( 'bf_dna', objs, Split(incs), [], libtype=['common','player'], priority = [10, 215] )
index 1dc82a542c79d3f1b487cc2b897286a8075140fb..857e53d2573061c4713f1f9cb916fba5e1769f3e 100644 (file)
 #
 #
 
+LIBNAME = dna
 DIR = $(OCGDIR)/blender/makesdna
-CSRCS = $(wildcard *.c)
-
-ALLTARGETS = $(OBJS) $(DIR)/$(DEBUG_DIR)makesdna $(DIR)/$(SHARED_DIR)$(DEBUG_DIR)DNA.o
+CSRCS = DNA.c $(wildcard dna_*.c)
 
 include nan_compile.mk
 
@@ -66,9 +65,10 @@ clean::
 # 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.
-$(DIR)/$(DEBUG_DIR)makesdna: $(OBJS) $(OCGDIR)/blender/blenlib/$(DEBUG_DIR)libblenlib.a 
-       $(CC) $(LDFLAGS) -o $@ $(OBJS) \
-       $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a $(WINLIBS)
+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)
@@ -78,6 +78,6 @@ $(DIR)/$(DEBUG_DIR)DNA.c: $(DIR)/$(DEBUG_DIR)makesdna
        $(DIR)/$(DEBUG_DIR)makesdna $(DIR)/$(DEBUG_DIR)DNA.c
     endif
 
-$(DIR)/$(SHARED_DIR)$(DEBUG_DIR)DNA.o: $(DIR)/$(DEBUG_DIR)DNA.c
-       $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+$(DIR)/$(DEBUG_DIR)makesdna.o: makesdna.c $(wildcard ../*.h)
+       $(CC) -c $(CFLAGS) $(CPPFLAGS) makesdna.c -o $@
 
index 417c6e8feb1cf071048dd5b99d3ea535f98c93a2..65072d1fed2581d639cb2a7833829f80348c6c1c 100644 (file)
@@ -8,34 +8,38 @@ defines = []
 root_build_dir=env['BF_BUILDDIR']
 
 source_files = ['makesdna.c']
+header_files = env.Glob('../*.h')
 
-makesdna_tool = env.Clone()
-dna = env.Clone()
+makesdna_tool = env.Copy()
+dna = env.Copy()
 makesdna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesdna/\\"" ')
 
 makesdna_tool.Append (CPPPATH = ['#/intern/guardedalloc',
-                                                                '../../makesdna'])
+                                 '../../makesdna'])
 
 if env['OURPLATFORM'] == 'linuxcross':
-       makesdna_tool.Replace(CC='gcc')
-       makesdna_tool.Replace(AR='ar')
-       makesdna_tool.Replace(LINK='gcc')
+    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 (LIBPATH = '#'+root_build_dir+'/lib')
+if env['BF_PROFILE']:
+       makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
 
 if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep:
-       makesdna = makesdna_tool.Program (target = root_build_dir+'/makesdna', source = source_files, LIBS=['bf_guardedalloc'])
+    makesdna = makesdna_tool.Program (target = root_build_dir+'/makesdna', source = source_files, LIBS=['bf_guardedalloc'])
 else:
-       makesdna = makesdna_tool.Program (target = '#'+root_build_dir+'/makesdna', source = source_files, LIBS=['bf_guardedalloc'])
+    makesdna = makesdna_tool.Program (target = '#'+root_build_dir+'/makesdna', source = source_files, LIBS=['bf_guardedalloc'])
 
 dna_dict = dna.Dictionary()
 dna.Depends ('dna.c', makesdna)
+dna.Depends ('dna.c', header_files)
 if env['OURPLATFORM'] != 'linuxcross':
-       dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna $TARGET")
+    dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna $TARGET")
 else:
-       dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna.exe $TARGET")
-obj = 'intern/dna.c'
+    dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna.exe $TARGET")
+obj = ['intern/dna.c', 'intern/dna_genfile.c']
 Return ('obj')
similarity index 86%
rename from source/blender/blenloader/intern/genfile.c
rename to source/blender/makesdna/intern/dna_genfile.c
index 7eb6220066e2014bd5247c546ede93717edbf572..0ffc170a5aa65e3d6696469ebf91eb4a58a5a0d6 100644 (file)
@@ -1,4 +1,4 @@
-/* genfile.c
+/* dna_genfile.c
  *
  * Functions for struct-dna, the genetic file dot c!
  *
  * DNA handling
  */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifndef WIN32 
-#include <unistd.h> // for read close
-#else
-#include <io.h> // for open close read
-#endif
-
-#include <string.h> // strncmp
-#include <stdio.h> // for printf
-#include <stdlib.h> // for atoi
-#include <fcntl.h> // for open O_RDONLY
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include "MEM_guardedalloc.h" // for MEM_freeN MEM_mallocN MEM_callocN
-#include "BLI_blenlib.h"      // for  BLI_filesize
-
-#include "BKE_utildefines.h" // for O_BINARY TRUE MIN2
 
+#include "DNA_genfile.h"
 #include "DNA_sdna_types.h" // for SDNA ;-)
 
-#include "BLO_writefile.h"
-#include "BLO_genfile.h"
-
-#include "genfile.h"
 
 /* gcc 4.1 on mingw was complaining that __int64 was alredy defined
 actually is saw the line below as typedef long long long long... 
@@ -179,31 +162,31 @@ static int le_int(int temp)
 /* ************************* MAKE DNA ********************** */
 
 /* allowed duplicate code from makesdna.c */
-static int arraysize(char *astr, int len)
+int DNA_elem_array_size(const char *astr, int len)
 {
-        int a, mul=1;
-        char str[100], *cp=0;
-
-        memcpy(str, astr, len+1);
-
-        for(a=0; a<len; a++) {
-                if( str[a]== '[' ) {
-                        cp= &(str[a+1]);
-                }
-                else if( str[a]==']' && cp) {
-                        str[a]= 0;
-                        mul*= atoi(cp);
-                }
-        }
-
-        return mul;
+       int a, mul=1;
+       char str[100], *cp=0;
+
+       memcpy(str, astr, len+1);
+
+       for(a=0; a<len; a++) {
+               if( str[a]== '[' ) {
+                       cp= &(str[a+1]);
+               }
+               else if( str[a]==']' && cp) {
+                       str[a]= 0;
+                       mul*= atoi(cp);
+               }
+       }
+
+       return mul;
 }
 
 /* ************************* END MAKE DNA ********************** */
 
 /* ************************* DIV ********************** */
 
-void dna_freestructDNA(struct SDNA *sdna)
+void DNA_sdna_free(SDNA *sdna)
 {
        MEM_freeN(sdna->data);
        MEM_freeN(sdna->names);
@@ -213,7 +196,13 @@ void dna_freestructDNA(struct SDNA *sdna)
        MEM_freeN(sdna);
 }
 
-static int elementsize(struct SDNA *sdna, short type, short name)
+static int ispointer(char *name)
+{
+       /* check if pointer or function pointer */
+       return (name[0]=='*' || (name[0]=='(' && name[1]=='*'));
+}
+
+static int elementsize(SDNA *sdna, short type, short name)
 /* call with numbers from struct-array */
 {
        int mul, namelen, len;
@@ -224,17 +213,17 @@ static int elementsize(struct SDNA *sdna, short type, short name)
        
        namelen= strlen(cp);
        /* is it a pointer or function pointer? */
-       if(cp[0]=='*' || cp[1]=='*') {
+       if(ispointer(cp)) {
                /* has the naam an extra length? (array) */
                mul= 1;
-               if( cp[namelen-1]==']') mul= arraysize(cp, namelen);
+               if( cp[namelen-1]==']') mul= DNA_elem_array_size(cp, namelen);
                
                len= sdna->pointerlen*mul;
        }
        else if( sdna->typelens[type] ) {
                /* has the naam an extra length? (array) */
                mul= 1;
-               if( cp[namelen-1]==']') mul= arraysize(cp, namelen);
+               if( cp[namelen-1]==']') mul= DNA_elem_array_size(cp, namelen);
                
                len= mul*sdna->typelens[type];
                
@@ -244,7 +233,7 @@ static int elementsize(struct SDNA *sdna, short type, short name)
 }
 
 #if 0
-static void printstruct(struct SDNA *sdna, short strnr)
+static void printstruct(SDNA *sdna, short strnr)
 {
        /* is for debug */
        int b, nr;
@@ -262,7 +251,7 @@ static void printstruct(struct SDNA *sdna, short strnr)
 }
 #endif
 
-static short *findstruct_name(struct SDNA *sdna, char *str)
+static short *findstruct_name(SDNA *sdna, char *str)
 {
        int a;
        short *sp=0;
@@ -278,7 +267,7 @@ static short *findstruct_name(struct SDNA *sdna, char *str)
        return 0;
 }
 
-int dna_findstruct_nr(struct SDNA *sdna, char *str)
+int DNA_struct_find_nr(SDNA *sdna, const char *str)
 {
        short *sp=0;
        int a;
@@ -305,11 +294,11 @@ int dna_findstruct_nr(struct SDNA *sdna, char *str)
 
 /* ************************* READ DNA ********************** */
 
-static void init_structDNA(struct SDNA *sdna, int do_endian_swap)
+static void init_structDNA(SDNA *sdna, int do_endian_swap)
 /* in sdna->data the data, now we convert that to something understandable */
 {
        int *data, *verg;
-       long nr;
+       long nr; /* intptr_t 2.48 XXX */
        short *sp;
        char str[8], *cp;
        
@@ -345,7 +334,7 @@ static void init_structDNA(struct SDNA *sdna, int do_endian_swap)
                        cp++;
                        nr++;
                }
-               nr= (long)cp;           /* prevent BUS error */
+               nr= (long)cp;           /* prevent BUS error */ /* intptr_t 2.48 XXX */
                nr= (nr+3) & ~3;
                cp= (char *)nr;
                
@@ -383,7 +372,7 @@ static void init_structDNA(struct SDNA *sdna, int do_endian_swap)
                        cp++;
                        nr++;
                }
-               nr= (long)cp;           /* prevent BUS error */
+               nr= (long)cp;           /* prevent BUS error */ /* intptr_t 2.48 XXX */
                nr= (nr+3) & ~3;
                cp= (char *)nr;
                
@@ -471,9 +460,9 @@ static void init_structDNA(struct SDNA *sdna, int do_endian_swap)
        }
 }
 
-struct SDNA *dna_sdna_from_data(void *data, int datalen, int do_endian_swap)
+SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap)
 {
-       struct SDNA *sdna= MEM_mallocN(sizeof(*sdna), "sdna");
+       SDNA *sdna= MEM_mallocN(sizeof(*sdna), "sdna");
        
        sdna->lastfind= 0;
 
@@ -490,7 +479,7 @@ struct SDNA *dna_sdna_from_data(void *data, int datalen, int do_endian_swap)
 
 /* ******************* HANDLE DNA ***************** */
 
-static void recurs_test_compflags(struct SDNA *sdna, char *compflags, int structnr)
+static void recurs_test_compflags(SDNA *sdna, char *compflags, int structnr)
 {
        int a, b, typenr, elems;
        short *sp;
@@ -508,7 +497,7 @@ static void recurs_test_compflags(struct SDNA *sdna, char *compflags, int struct
                        for(b=0; b<elems; b++, sp+=2) {
                                if(sp[0]==typenr) {
                                        cp= sdna->names[ sp[1] ];
-                                       if(cp[0]!= '*') {
+                                       if(!ispointer(cp)) {
                                                compflags[a]= 2;
                                                recurs_test_compflags(sdna, compflags, a);
                                        }
@@ -530,7 +519,7 @@ static void recurs_test_compflags(struct SDNA *sdna, char *compflags, int struct
  */
 
 
-char *dna_get_structDNA_compareflags(struct SDNA *sdna, struct SDNA *newsdna)
+char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna)
 {
        /* flag: 0: doesn't exist anymore (or not yet)
         *       1: is equal
@@ -579,7 +568,7 @@ char *dna_get_structDNA_compareflags(struct SDNA *sdna, struct SDNA *newsdna)
                                                 if(strcmp(str1, str2)!=0) break;
                                                 
                                                 /* same type and same name, now pointersize */
-                                                if(str1[0]=='*') {
+                                                if(ispointer(str1)) {
                                                         if(sdna->pointerlen!=newsdna->pointerlen) break;
                                                 }
                                                 
@@ -624,7 +613,7 @@ static void cast_elem(char *ctype, char *otype, char *name, char *curdata, char
        double val = 0.0;
        int arrlen, curlen=1, oldlen=1, ctypenr, otypenr;
        
-       arrlen= arraysize(name, strlen(name));
+       arrlen= DNA_elem_array_size(name, strlen(name));
        
        /* define otypenr */
        if(strcmp(otype, "char")==0) otypenr= 0; 
@@ -721,7 +710,7 @@ static void cast_pointer(int curlen, int oldlen, char *name, char *curdata, char
 #endif
        int arrlen;
        
-       arrlen= arraysize(name, strlen(name));
+       arrlen= DNA_elem_array_size(name, strlen(name));
        
        while(arrlen>0) {
        
@@ -761,7 +750,7 @@ static int elem_strcmp(char *name, char *oname)
        
        /* strcmp without array part */
        
-       while(TRUE) {
+       while(1) {
                if(name[a] != oname[a]) return 1;
                if(name[a]=='[') break;
                if(name[a]==0) break;
@@ -771,7 +760,7 @@ static int elem_strcmp(char *name, char *oname)
        return 0;
 }
 
-static char *find_elem(struct SDNA *sdna, char *type, char *name, short *old, char *olddata, short **sppo)
+static char *find_elem(SDNA *sdna, char *type, char *name, short *old, char *olddata, short **sppo)
 {
        int a, elemcount, len;
        char *otype, *oname;
@@ -802,7 +791,7 @@ static char *find_elem(struct SDNA *sdna, char *type, char *name, short *old, ch
        return 0;
 }
 
-static void reconstruct_elem(struct SDNA *newsdna, struct SDNA *oldsdna, char *type, char *name, char *curdata, short *old, char *olddata)
+static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, char *name, char *curdata, short *old, char *olddata)
 {
        /* rules: test for NAME:
                        - name equal:
@@ -834,7 +823,7 @@ static void reconstruct_elem(struct SDNA *newsdna, struct SDNA *oldsdna, char *t
                
                if( strcmp(name, oname)==0 ) {  /* name equal */
                        
-                       if( name[0]=='*') {             /* pointer afhandelen */
+                       if(ispointer(name)) {   /* pointer of functionpointer afhandelen */
                                cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, name, curdata, olddata);
                        }
                        else if( strcmp(type, otype)==0 ) {     /* type equal */
@@ -848,16 +837,16 @@ static void reconstruct_elem(struct SDNA *newsdna, struct SDNA *oldsdna, char *t
 
                        if(oname[array]=='[' && strncmp(name, oname, array)==0 ) {                      /* basis equal */
                                
-                               cursize= arraysize(name, strlen(name));
-                               oldsize= arraysize(oname, strlen(oname));
+                               cursize= DNA_elem_array_size(name, strlen(name));
+                               oldsize= DNA_elem_array_size(oname, strlen(oname));
 
-                               if( name[0]=='*') {             /* handle pointer */
+                               if(ispointer(name)) {           /* handle pointer or functionpointer */
                                        if(cursize>oldsize) cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, oname, curdata, olddata);
                                        else cast_pointer(newsdna->pointerlen, oldsdna->pointerlen, name, curdata, olddata);
                                }
                                else if(name[0]=='*' || strcmp(type, otype)==0 ) {      /* type equal */
                                        mul= len/oldsize;
-                                       mul*= MIN2(cursize, oldsize);
+                                       mul*= (cursize < oldsize)? cursize: oldsize;
                                        memcpy(curdata, olddata, mul);
                                }
                                else {
@@ -871,7 +860,7 @@ static void reconstruct_elem(struct SDNA *newsdna, struct SDNA *oldsdna, char *t
        }
 }
 
-static void reconstruct_struct(struct SDNA *newsdna, struct SDNA *oldsdna, char *compflags, int oldSDNAnr, char *data, int curSDNAnr, char *cur)
+static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna, char *compflags, int oldSDNAnr, char *data, int curSDNAnr, char *cur)
 {
        /* Recursive!
         * Per element from cur_struct, read data from old_struct.
@@ -909,19 +898,19 @@ static void reconstruct_struct(struct SDNA *newsdna, struct SDNA *oldsdna, char
                elen= elementsize(newsdna, spc[0], spc[1]);
 
                /* test: is type a struct? */
-               if(spc[0]>=firststructtypenr  &&  name[0]!='*') {
+               if(spc[0]>=firststructtypenr  &&  !ispointer(name)) {
                
                        /* where does the old struct data start (and is there an old one?) */
                        cpo= find_elem(oldsdna, type, name, spo, data, &sppo);
                        
                        if(cpo) {
-                               oldSDNAnr= dna_findstruct_nr(oldsdna, type);
-                               curSDNAnr= dna_findstruct_nr(newsdna, type);
+                               oldSDNAnr= DNA_struct_find_nr(oldsdna, type);
+                               curSDNAnr= DNA_struct_find_nr(newsdna, type);
                                
                                /* array! */
-                               mul= arraysize(name, strlen(name));
+                               mul= DNA_elem_array_size(name, strlen(name));
                                nameo= oldsdna->names[sppo[1]];
-                               mulo= arraysize(nameo, strlen(nameo));
+                               mulo= DNA_elem_array_size(nameo, strlen(nameo));
                                
                                eleno= elementsize(oldsdna, sppo[0], sppo[1]);
                                
@@ -949,7 +938,7 @@ static void reconstruct_struct(struct SDNA *newsdna, struct SDNA *oldsdna, char
        }
 }
 
-void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data)
+void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data)
 {
        /* Recursive!
         * If element is a struct, call recursive.
@@ -976,27 +965,27 @@ void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data)
                elen= elementsize(oldsdna, spc[0], spc[1]);
 
                /* test: is type a struct? */
-               if(spc[0]>=firststructtypenr  &&  name[0]!='*') {
+               if(spc[0]>=firststructtypenr  &&  !ispointer(name)) {
                        /* where does the old data start (is there one?) */
                        cpo= find_elem(oldsdna, type, name, spo, data, 0);
                        if(cpo) {
-                               oldSDNAnr= dna_findstruct_nr(oldsdna, type);
+                               oldSDNAnr= DNA_struct_find_nr(oldsdna, type);
                                
-                               mul= arraysize(name, strlen(name));
+                               mul= DNA_elem_array_size(name, strlen(name));
                                elena= elen/mul;
 
                                while(mul--) {
-                                       dna_switch_endian_struct(oldsdna, oldSDNAnr, cpo);
+                                       DNA_struct_switch_endian(oldsdna, oldSDNAnr, cpo);
                                        cpo += elena;
                                }
                        }
                }
                else {
                        
-                       if( name[0]=='*' ) {
+                       if(ispointer(name)) {
                                if(oldsdna->pointerlen==8) {
                                        
-                                       mul= arraysize(name, strlen(name));
+                                       mul= DNA_elem_array_size(name, strlen(name));
                                        cpo= cur;
                                        while(mul--) {
                                                cval= cpo[0]; cpo[0]= cpo[7]; cpo[7]= cval;
@@ -1023,7 +1012,7 @@ void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data)
                                        }
                                        
                                        if(skip==0) {
-                                               mul= arraysize(name, strlen(name));
+                                               mul= DNA_elem_array_size(name, strlen(name));
                                                cpo= cur;
                                                while(mul--) {
                                                        cval= cpo[0];
@@ -1035,7 +1024,7 @@ void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data)
                                }
                                else if(spc[0]>3 && spc[0]<8) { /* int-long-ulong-float */
 
-                                       mul= arraysize(name, strlen(name));
+                                       mul= DNA_elem_array_size(name, strlen(name));
                                        cpo= cur;
                                        while(mul--) {
                                                cval= cpo[0];
@@ -1053,7 +1042,7 @@ void dna_switch_endian_struct(struct SDNA *oldsdna, int oldSDNAnr, char *data)
        }
 }
 
-void *dna_reconstruct(struct SDNA *newsdna, struct SDNA *oldsdna, char *compflags, int oldSDNAnr, int blocks, void *data)
+void *DNA_struct_reconstruct(SDNA *newsdna, SDNA *oldsdna, char *compflags, int oldSDNAnr, int blocks, void *data)
 {
        int a, curSDNAnr, curlen=0, oldlen;
        short *spo, *spc;
@@ -1063,7 +1052,7 @@ void *dna_reconstruct(struct SDNA *newsdna, struct SDNA *oldsdna, char *compflag
        spo= oldsdna->structs[oldSDNAnr];
        type= oldsdna->types[ spo[0] ];
        oldlen= oldsdna->typelens[ spo[0] ];
-       curSDNAnr= dna_findstruct_nr(newsdna, type);
+       curSDNAnr= DNA_struct_find_nr(newsdna, type);
 
        /* init data and alloc */
        if(curSDNAnr >= 0) {
@@ -1086,14 +1075,12 @@ void *dna_reconstruct(struct SDNA *newsdna, struct SDNA *oldsdna, char *compflag
        return cur;
 }
 
-int dna_elem_offset(struct SDNA *sdna, char *stype, char *vartype, char *name)
+int DNA_elem_offset(SDNA *sdna, char *stype, char *vartype, char *name)
 {
        
-       int SDNAnr= dna_findstruct_nr(sdna, stype);
+       int SDNAnr= DNA_struct_find_nr(sdna, stype);
        short *spo= sdna->structs[SDNAnr];
        char *cp= find_elem(sdna, vartype, name, spo, NULL, NULL);
-       return (int)((long)cp);
+       return (int)((long)cp); /* intptr_t 2.48 XXX */
 }
 
-
-
diff --git a/source/blender/makesrna/Makefile b/source/blender/makesrna/Makefile
new file mode 100644 (file)
index 0000000..bed3e85
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# Contributor(s): Blender Foundation (2008).
+#
+# ***** END GPL LICENSE BLOCK *****
+#
+# This module does not build normal .o's, but a RNA.c file, to be
+# compiled with the rest of the sources.
+#
+
+SOURCEDIR = source/blender/makesrna
+DIRS = intern
+
+include nan_subdirs.mk
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
new file mode 100644 (file)
index 0000000..828bcff
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef RNA_ACCESS
+#define RNA_ACCESS
+
+struct bContext;
+struct BlenderRNA;
+struct PropertyRNA;
+struct StructRNA;
+struct CollectionPropertyIterator;
+
+/* Property */
+
+void RNA_property_notify(struct PropertyRNA *prop, struct bContext *C, void *data);
+int RNA_property_readonly(struct PropertyRNA *prop, struct bContext *C, void *data);
+
+int RNA_property_boolean_get(struct PropertyRNA *prop, void *data);
+void RNA_property_boolean_set(struct PropertyRNA *prop, void *data, int value);
+int RNA_property_boolean_get_array(struct PropertyRNA *prop, void *data, int index);
+void RNA_property_boolean_set_array(struct PropertyRNA *prop, void *data, int index, int value);
+
+int RNA_property_int_get(struct PropertyRNA *prop, void *data);
+void RNA_property_int_set(struct PropertyRNA *prop, void *data, int value);
+int RNA_property_int_get_array(struct PropertyRNA *prop, void *data, int index);
+void RNA_property_int_set_array(struct PropertyRNA *prop, void *data, int index, int value);
+
+float RNA_property_float_get(struct PropertyRNA *prop, void *data);
+void RNA_property_float_set(struct PropertyRNA *prop, void *data, float value);
+float RNA_property_float_get_array(struct PropertyRNA *prop, void *data, int index);
+void RNA_property_float_set_array(struct PropertyRNA *prop, void *data, int index, float value);
+
+void RNA_property_string_get(struct PropertyRNA *prop, void *data, char *value);
+int RNA_property_string_length(struct PropertyRNA *prop, void *data);
+void RNA_property_string_set(struct PropertyRNA *prop, void *data, const char *value);
+
+int RNA_property_enum_get(struct PropertyRNA *prop, void *data);
+void RNA_property_enum_set(struct PropertyRNA *prop, void *data, int value);
+
+void *RNA_property_pointer_get(struct PropertyRNA *prop, void *data);
+void RNA_property_pointer_set(struct PropertyRNA *prop, void *data, void *value);
+struct StructRNA *RNA_property_pointer_type(struct PropertyRNA *prop, void *data);
+
+void RNA_property_collection_begin(struct PropertyRNA *prop, struct CollectionPropertyIterator *iter, void *data);
+void RNA_property_collection_next(struct PropertyRNA *prop, struct CollectionPropertyIterator *iter);
+void RNA_property_collection_end(struct PropertyRNA *prop, struct CollectionPropertyIterator *iter);
+void *RNA_property_collection_get(struct PropertyRNA *prop, struct CollectionPropertyIterator *iter);
+struct StructRNA *RNA_property_collection_type(struct PropertyRNA *prop, struct CollectionPropertyIterator *iter);
+int RNA_property_collection_length(struct PropertyRNA *prop, void *data);
+void *RNA_property_collection_lookup_int(struct PropertyRNA *prop, void *data, int key, struct StructRNA **type);
+void *RNA_property_collection_lookup_string(struct PropertyRNA *prop, void *data, const char *key, struct StructRNA **type);
+
+#endif /* RNA_ACCESS */
+
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
new file mode 100644 (file)
index 0000000..0eb96da
--- /dev/null
@@ -0,0 +1,96 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef RNA_DEFINE_H
+#define RNA_DEFINE_H
+
+/* Functions used during preprocess, for defining the RNA.
+ *
+ * This is currently only used internally in the module, but should eventually
+ * also become available outside of that, at runtime for python and plugins.
+ * Where the result of such runtime RNA is stored and how it integrates needs
+ * to be figured out still. */
+
+#include "DNA_listBase.h"
+
+struct BlenderRNA;
+struct StructRNA;
+struct PropertyRNA;
+struct PropertyEnumItem;
+
+/* Blender RNA */
+
+struct BlenderRNA *RNA_create(void);
+void RNA_define_free(struct BlenderRNA *brna);
+void RNA_free(struct BlenderRNA *brna);
+
+/* Struct */
+
+struct StructRNA *RNA_def_struct(struct BlenderRNA *brna, const char *cname, const char *name);
+void RNA_def_struct_sdna(struct StructRNA *rna, const char *structname);
+void RNA_def_struct_name_property(struct StructRNA *rna, struct PropertyRNA *prop);
+
+/* Property */
+
+struct PropertyRNA *RNA_def_property(struct StructRNA *strct, const char *cname, int type, int subtype);
+
+void RNA_def_property_boolean_sdna(struct PropertyRNA *prop, const char *structname, const char *propname, int bit);
+void RNA_def_property_int_sdna(struct PropertyRNA *prop, const char *structname, const char *propname);
+void RNA_def_property_float_sdna(struct PropertyRNA *prop, const char *structname, const char *propname);
+void RNA_def_property_string_sdna(struct PropertyRNA *prop, const char *structname, const char *propname);
+void RNA_def_property_enum_sdna(struct PropertyRNA *prop, const char *structname, const char *propname);
+void RNA_def_property_pointer_sdna(struct PropertyRNA *prop, const char *structname, const char *propname);
+void RNA_def_property_collection_sdna(struct PropertyRNA *prop, const char *structname, const char *propname);
+
+void RNA_def_property_array(struct PropertyRNA *prop, int arraylength);
+void RNA_def_property_access(struct PropertyRNA *prop, int editable, int evaluatable);
+void RNA_def_property_range(struct PropertyRNA *prop, double min, double max);
+
+void RNA_def_property_enum_items(struct PropertyRNA *prop, const struct PropertyEnumItem *item);
+void RNA_def_property_string_maxlength(struct PropertyRNA *prop, int maxlength);
+void RNA_def_property_struct_type(struct PropertyRNA *prop, const char *type);
+
+void RNA_def_property_boolean_default(struct PropertyRNA *prop, int value);
+void RNA_def_property_boolean_array_default(struct PropertyRNA *prop, const int *array);
+void RNA_def_property_int_default(struct PropertyRNA *prop, int value);
+void RNA_def_property_int_array_default(struct PropertyRNA *prop, const int *array);
+void RNA_def_property_float_default(struct PropertyRNA *prop, float value);
+void RNA_def_property_float_array_default(struct PropertyRNA *prop, const float *array);
+void RNA_def_property_enum_default(struct PropertyRNA *prop, int value);
+void RNA_def_property_string_default(struct PropertyRNA *prop, const char *value);
+
+void RNA_def_property_ui_text(struct PropertyRNA *prop, const char *name, const char *description);
+void RNA_def_property_ui_range(struct PropertyRNA *prop, double min, double max, double step, double precision);
+
+void RNA_def_property_funcs(struct PropertyRNA *prop, char *notify, char *readonly);
+void RNA_def_property_boolean_funcs(struct PropertyRNA *prop, char *get, char *set);
+void RNA_def_property_int_funcs(struct PropertyRNA *prop, char *get, char *set);
+void RNA_def_property_float_funcs(struct PropertyRNA *prop, char *get, char *set);
+void RNA_def_property_enum_funcs(struct PropertyRNA *prop, char *get, char *set);
+void RNA_def_property_string_funcs(struct PropertyRNA *prop, char *get, char *length, char *set);
+void RNA_def_property_pointer_funcs(struct PropertyRNA *prop, char *get, char *type, char *set);
+void RNA_def_property_collection_funcs(struct PropertyRNA *prop, char *begin, char *next, char *end, char *get, char *type, char *length, char *lookupint, char *lookupstring);
+
+#endif /* RNA_DEFINE_H */
+
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
new file mode 100644 (file)
index 0000000..9faa8b2
--- /dev/null
@@ -0,0 +1,247 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef RNA_TYPES
+#define RNA_TYPES
+
+#include "DNA_listBase.h"
+
+struct BlenderRNA;
+struct StructRNA;
+struct PropertyRNA;
+struct CollectionPropertyIterator;
+struct bContext;
+
+typedef void (*PropNotifyFunc)(struct bContext *C, void *data);
+typedef int (*PropBooleanGetFunc)(void *data);
+typedef void (*PropBooleanSetFunc)(void *data, int value);
+typedef int (*PropBooleanArrayGetFunc)(void *data, int index);
+typedef void (*PropBooleanArraySetFunc)(void *data, int index, int value);
+typedef int (*PropIntGetFunc)(void *data);
+typedef void (*PropIntSetFunc)(void *data, int value);
+typedef int (*PropIntArrayGetFunc)(void *data, int index);
+typedef void (*PropIntArraySetFunc)(void *data, int index, int value);
+typedef float (*PropFloatGetFunc)(void *data);
+typedef void (*PropFloatSetFunc)(void *data, float value);
+typedef float (*PropFloatArrayGetFunc)(void *data, int index);
+typedef void (*PropFloatArraySetFunc)(void *data, int index, float value);
+typedef void (*PropStringGetFunc)(void *data, char *value);
+typedef int (*PropStringLengthFunc)(void *data);
+typedef void (*PropStringSetFunc)(void *data, const char *value);
+typedef int (*PropEnumGetFunc)(void *data);
+typedef void (*PropEnumSetFunc)(void *data, int value);
+typedef void* (*PropPointerGetFunc)(void *data);
+typedef void (*PropPointerSetFunc)(void *data, void *value);
+typedef struct StructRNA* (*PropPointerTypeFunc)(void *data);
+typedef void (*PropCollectionBeginFunc)(struct CollectionPropertyIterator *iter, void *data);
+typedef void (*PropCollectionNextFunc)(struct CollectionPropertyIterator *iter);
+typedef void (*PropCollectionEndFunc)(struct CollectionPropertyIterator *iter);
+typedef void* (*PropCollectionGetFunc)(struct CollectionPropertyIterator *iter);
+typedef struct StructRNA* (*PropCollectionTypeFunc)(struct CollectionPropertyIterator *iter);
+typedef int (*PropCollectionLengthFunc)(void *data);
+typedef void* (*PropCollectionLookupIntFunc)(void *data, int key, struct StructRNA **type);
+typedef void* (*PropCollectionLookupStringFunc)(void *data, const char *key, struct StructRNA **type);
+
+typedef enum PropertyType {
+       PROP_BOOLEAN = 0,
+       PROP_INT = 1,
+       PROP_FLOAT = 2,
+       PROP_STRING = 3,
+       PROP_ENUM = 4,
+       PROP_POINTER = 5,
+       PROP_COLLECTION = 6
+} PropertyType;
+
+typedef enum PropertySubType {
+       PROP_NONE = 0,
+       PROP_UNSIGNED = 1,
+       PROP_FILEPATH = 2,
+       PROP_COLOR = 3,
+       PROP_VECTOR = 4,
+       PROP_MATRIX = 5,
+       PROP_ROTATION = 6
+} PropertySubType;
+
+typedef enum PropertyFlag {
+       PROP_EDITABLE = 1,
+       PROP_EVALUATEABLE = 2
+} PropertyFlag;
+
+typedef struct CollectionPropertyIterator {
+       void *internal;
+       int valid;
+} CollectionPropertyIterator;
+
+typedef struct PropertyEnumItem {
+       int value;
+       const char *cname;
+       const char *name;
+} PropertyEnumItem;
+
+typedef struct PropertyRNA {
+       struct PropertyRNA *next, *prev;
+
+       /* C code name */
+       const char *cname;
+       /* various options */
+       int flag;
+
+       /* user readable name */
+       const char *name;
+       /* single line description, displayed in the tooltip for example */
+       const char *description;
+
+       /* property type as it appears to the outside */
+       PropertyType type;
+       /* subtype, 'interpretation' of the property */
+       PropertySubType subtype;
+       /* if an array this is > 0, specifying the length */
+       unsigned int arraylength;
+       
+       /* callback for notifys on change */
+       PropNotifyFunc notify;
+} PropertyRNA;
+
+/* information specific to the property type */
+typedef struct BooleanPropertyRNA {
+       PropertyRNA property;
+
+       PropBooleanGetFunc get;
+       PropBooleanSetFunc set;
+
+       PropBooleanArrayGetFunc getarray;
+       PropBooleanArraySetFunc setarray;
+
+       int defaultvalue;
+       const int *defaultarray;
+} BooleanPropertyRNA;
+
+typedef struct IntPropertyRNA {
+       PropertyRNA property;
+
+       PropIntGetFunc get;
+       PropIntSetFunc set;
+
+       PropIntArrayGetFunc getarray;
+       PropIntArraySetFunc setarray;
+
+       int softmin, softmax;
+       int hardmin, hardmax;
+       int step;
+
+       int defaultvalue;
+       const int *defaultarray;
+} IntPropertyRNA;
+
+typedef struct FloatPropertyRNA {
+       PropertyRNA property;
+
+       PropFloatGetFunc get;
+       PropFloatSetFunc set;
+
+       PropFloatArrayGetFunc getarray;
+       PropFloatArraySetFunc setarray;
+
+       float softmin, softmax;
+       float hardmin, hardmax;
+       float step, precision;
+
+       float defaultvalue;
+       const float *defaultarray;
+} FloatPropertyRNA;
+
+typedef struct StringPropertyRNA {
+       PropertyRNA property;
+
+       PropStringGetFunc get;
+       PropStringLengthFunc length;
+       PropStringSetFunc set;
+
+       int maxlength;  /* includes string terminator! */
+
+       const char *defaultvalue;
+} StringPropertyRNA;
+
+typedef struct EnumPropertyRNA {
+       PropertyRNA property;
+
+       PropEnumGetFunc get;
+       PropEnumSetFunc set;
+
+       const PropertyEnumItem *item;
+       int totitem;
+
+       int defaultvalue;
+} EnumPropertyRNA;
+
+typedef struct PointerPropertyRNA {
+       PropertyRNA property;
+
+       PropPointerGetFunc get;
+       PropPointerSetFunc set;
+       PropPointerTypeFunc type;       /* optional */
+
+       struct StructRNA *structtype;
+} PointerPropertyRNA;
+
+typedef struct CollectionPropertyRNA {
+       PropertyRNA property;
+
+       PropCollectionBeginFunc begin;
+       PropCollectionNextFunc next;
+       PropCollectionEndFunc end;                                              /* optional */
+       PropCollectionGetFunc get;
+       PropCollectionTypeFunc type;                                    /* optional */
+       PropCollectionLengthFunc length;                                /* optional */
+       PropCollectionLookupIntFunc lookupint;                  /* optional */
+       PropCollectionLookupStringFunc lookupstring;    /* optional */
+
+       struct StructRNA *structtype;
+} CollectionPropertyRNA;
+
+typedef struct StructRNA {
+       struct StructRNA *next, *prev;
+
+       /* C code name */
+       const char *cname;
+       /* various options */
+       int flag;
+
+       /* user readable name */
+       const char *name;
+
+       /* property that defines the name */
+       PropertyRNA *nameproperty;
+
+       /* properties of this struct */
+       ListBase properties; 
+} StructRNA;
+
+typedef struct BlenderRNA {
+       /* structs */
+       ListBase structs;
+} BlenderRNA;
+
+#endif /* RNA_TYPES */
+
diff --git a/source/blender/makesrna/SConscript b/source/blender/makesrna/SConscript
new file mode 100644 (file)
index 0000000..a580072
--- /dev/null
@@ -0,0 +1,11 @@
+#!/usr/bin/python
+Import ('env')
+
+objs = []
+
+o = SConscript('intern/SConscript')
+objs += o
+
+incs = '#/intern/guardedalloc ../blenkernel ../blenlib ../makesdna intern .'
+
+env.BlenderLib ( 'bf_rna', objs, Split(incs), [], libtype=['common','intern'], priority = [95, 95] )
diff --git a/source/blender/makesrna/intern/Makefile b/source/blender/makesrna/intern/Makefile
new file mode 100644 (file)
index 0000000..475e394
--- /dev/null
@@ -0,0 +1,79 @@
+#
+# $Id: Makefile 13161 2008-01-07 19:13:47Z hos $
+#
+# ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# Contributor(s): Blender Foundation (2008).
+#
+# ***** END GPL LICENSE BLOCK *****
+#
+
+LIBNAME = rna
+DIR = $(OCGDIR)/blender/makesrna
+CSRCS = RNA.c $(wildcard rna_*.c)
+
+include nan_compile.mk
+
+CFLAGS += $(LEVEL_1_C_WARNINGS)
+
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+CPPFLAGS += -I../../blenlib
+CPPFLAGS += -I../../blenkernel
+CPPFLAGS += -I../../makesdna
+CPPFLAGS += -I..
+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.
+       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
+
+clean::
+       @$(RM) $(DIR)/makesrna* $(DIR)/RNA.c
+       @$(RM) $(DIR)/debug/makesrna* $(DIR)/debug/RNA.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.
+
+RNAOBJS = $(filter-out %RNA.o, $(OBJS))
+
+$(DIR)/$(DEBUG_DIR)makesrna: $(RNAOBJS) $(DIR)/$(DEBUG_DIR)makesrna.o $(OCGDIR)/blender/makesdna/$(DEBUG_DIR)libdna.a $(NAN_GUARDEDALLOC)/lib/libguardedalloc.a
+       $(CC) $(LDFLAGS) -o $@ $(WINLIBS) $^
+
+$(DIR)/$(DEBUG_DIR)RNA.c: $(DIR)/$(DEBUG_DIR)makesrna
+    ifeq ($(OS),windows)
+       $(SRCHOME)/tools/cygwin/cl_wrapper.pl - $(DIR)/$(DEBUG_DIR)makesrna \
+           $(DIR)/$(DEBUG_DIR)RNA.c
+    else
+       $(DIR)/$(DEBUG_DIR)makesrna $(DIR)/$(DEBUG_DIR)RNA.c
+    endif
+
+$(DIR)/$(DEBUG_DIR)makesrna.o: makesrna.c $(wildcard rna_*.c)
+       $(CC) -c $(CFLAGS) $(CPPFLAGS) makesrna.c -o $@
+
diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript
new file mode 100644 (file)
index 0000000..1dfc5df
--- /dev/null
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+import sys
+import os
+
+Import ('env')
+cflags = ''
+defines = []
+root_build_dir=env['BF_BUILDDIR']
+
+source_files = env.Glob('*.c')
+
+# making rna_access.c part of both makesrna and blender seems to
+# give conflict, how to solve?
+source_files.remove('rna_access.c')
+
+makesrna_tool = env.Copy()
+rna = env.Copy()
+makesrna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesrna/\\"" ')
+
+makesrna_tool.Append (CPPPATH = ['#/intern/guardedalloc',
+                                 '../../makesdna',
+                                 '../../makesrna'])
+
+if env['OURPLATFORM'] == 'linuxcross':
+    makesrna_tool.Replace(CC='gcc')
+    makesrna_tool.Replace(AR='ar')
+    makesrna_tool.Replace(LINK='gcc')
+
+if sys.platform != 'cygwin':
+    makesrna_tool.Append (CCFLAGS = cflags)
+makesrna_tool.Append (CPPDEFINES = defines)
+makesrna_tool.Append (LIBPATH = '#'+root_build_dir+'/lib')
+if env['BF_PROFILE']:
+       makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
+
+if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep:
+    makesrna = makesrna_tool.Program (target = root_build_dir+'/makesrna', source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
+else:
+    makesrna = makesrna_tool.Program (target = '#'+root_build_dir+'/makesrna', source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
+
+rna_dict = rna.Dictionary()
+rna.Depends ('rna.c', makesrna)
+if env['OURPLATFORM'] != 'linuxcross':
+    rna.Command ('rna.c', '', root_build_dir+os.sep+"makesrna $TARGET")
+else:
+    rna.Command ('rna.c', '', root_build_dir+os.sep+"makesrna.exe $TARGET")
+obj = ['intern/rna.c', 'intern/rna_access.c']
+Return ('obj')
+
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
new file mode 100644 (file)
index 0000000..2ac287b
--- /dev/null
@@ -0,0 +1,780 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <float.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#include "rna_internal.h"
+
+#define RNA_VERSION_DATE "$Id$"
+
+#ifdef _WIN32
+#ifndef snprintf
+#define snprintf _snprintf
+#endif
+#endif
+
+/* TODO
+ * - better crash checks for autogenerated functions
+ * - missing warnings for makesdna/rna scons compile?
+ */
+
+/* Preprocessing */
+
+static void rna_print_c_string(FILE *f, const char *str)
+{
+       static char *escape[] = {"\''", "\"\"", "\??", "\\\\","\aa", "\bb", "\ff", "\nn", "\rr", "\tt", "\vv", NULL};
+       int i, j;
+
+       fprintf(f, "\"");
+       for(i=0; str[i]; i++) {
+               for(j=0; escape[j]; j++)
+                       if(str[i] == escape[j][0])
+                               break;
+
+               if(escape[j]) fprintf(f, "\\%c", escape[j][1]);
+               else fprintf(f, "%c", str[i]);
+       }
+       fprintf(f, "\"");
+}
+
+static char *rna_alloc_function_name(const char *structname, const char *propname, const char *type)
+{
+       AllocDefRNA *alloc;
+       char buffer[2048];
+       char *result;
+
+       snprintf(buffer, sizeof(buffer), "rna_%s_%s_%s", structname, propname, type);
+       result= MEM_callocN(sizeof(char)*strlen(buffer)+1, "rna_alloc_function_name");
+       strcpy(result, buffer);
+
+       alloc= MEM_callocN(sizeof(AllocDefRNA), "AllocDefRNA");
+       alloc->mem= result;
+       rna_addtail(&DefRNA.allocs, alloc);
+
+       return result;
+}
+
+static const char *rna_type_type(PropertyRNA *prop)
+{
+       switch(prop->type) {
+               case PROP_BOOLEAN:
+               case PROP_INT:
+               case PROP_ENUM:
+                       return "int";
+               case PROP_FLOAT:
+                       return "float";
+               case PROP_STRING:
+                       return "char*";
+               default:
+                       return "void*";
+       }
+}
+
+static char *rna_def_property_get_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
+{
+       char *func;
+
+       if(!dp->dnastructname || !dp->dnaname) {
+               fprintf(stderr, "rna_def_property_get_func: %s has no valid dna info.\n", prop->cname);
+               DefRNA.error= 1;
+               return NULL;
+       }
+
+       if(prop->type == PROP_STRING && ((StringPropertyRNA*)prop)->maxlength == 0) {
+               fprintf(stderr, "rna_def_property_get_func: string %s has max length 0.\n", prop->cname);
+               DefRNA.error= 1;
+               return NULL;
+       }
+
+       func= rna_alloc_function_name(dp->strct->cname, prop->cname, "get");
+
+       switch(prop->type) {
+               case PROP_STRING: {
+                       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+                       fprintf(f, "static void %s(void *data, char *value)\n", func);
+                       fprintf(f, "{\n");
+                       fprintf(f, "    BLI_strncpy(value, ((%s*)data)->%s, %d);\n", dp->dnastructname, dp->dnaname, sprop->maxlength);
+                       fprintf(f, "}\n\n");
+                       break;
+               }
+               default:
+                       if(prop->arraylength) {
+                               fprintf(f, "static %s %s(void *data, int index)\n", rna_type_type(prop), func);
+                               fprintf(f, "{\n");
+                               if(prop->type == PROP_BOOLEAN && dp->booleanbit && dp->dnaarraylength==1)
+                                       fprintf(f, "    return ((((%s*)data)->%s & (%d<<index)) != 0);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                               else if(prop->type == PROP_BOOLEAN && dp->booleanbit)
+                                       fprintf(f, "    return ((((%s*)data)->%s[index] & %d) != 0);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                               else
+                                       fprintf(f, "    return (%s)(((%s*)data)->%s[index]);\n", rna_type_type(prop), dp->dnastructname, dp->dnaname);
+                               fprintf(f, "}\n\n");
+                       }
+                       else {
+                               fprintf(f, "static %s %s(void *data)\n", rna_type_type(prop), func);
+                               fprintf(f, "{\n");
+                               if(prop->type == PROP_BOOLEAN && dp->booleanbit)
+                                       fprintf(f, "    return (((((%s*)data)->%s) & %d) != 0);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                               else
+                                       fprintf(f, "    return (%s)(((%s*)data)->%s);\n", rna_type_type(prop), dp->dnastructname, dp->dnaname);
+                               fprintf(f, "}\n\n");
+                       }
+                       break;
+       }
+
+       return func;
+}
+
+static const char *rna_function_string(void *func)
+{
+       return (func)? (const char*)func: "NULL";
+}
+
+static void rna_float_print(FILE *f, float num)
+{
+       if(num == -FLT_MAX) fprintf(f, "-FLT_MAX");
+       else if(num == FLT_MAX) fprintf(f, "FLT_MAX");
+       else if((int)num == num) fprintf(f, "%.1ff", num);
+       else fprintf(f, "%.10ff", num);
+}
+
+static void rna_clamp_value(FILE *f, PropertyRNA *prop)
+{
+       if(prop->type == PROP_INT) {
+               IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+
+               if(iprop->hardmin != INT_MIN || iprop->hardmax != INT_MAX)
+                       fprintf(f, "    CLAMP(value, %d, %d);\n", iprop->hardmin, iprop->hardmax);
+       }
+       else if(prop->type == PROP_FLOAT) {
+               FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+
+               if(fprop->hardmin != -FLT_MAX || fprop->hardmax != FLT_MAX) {
+                       fprintf(f, "    CLAMP(value, ");
+                       rna_float_print(f, fprop->hardmin); fprintf(f, ", ");
+                       rna_float_print(f, fprop->hardmax); fprintf(f, ");\n");
+               }
+       }
+}
+
+static char *rna_def_property_set_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
+{
+       char *func;
+
+       if(!dp->dnastructname || !dp->dnaname) {
+               fprintf(stderr, "rna_def_property_set_func: %s has no valid dna info.\n", prop->cname);
+               DefRNA.error= 1;
+               return NULL;
+       }
+
+       func= rna_alloc_function_name(dp->strct->cname, prop->cname, "set");
+
+       switch(prop->type) {
+               case PROP_STRING: {
+                       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+                       fprintf(f, "static void %s(void *data, const char *value)\n", func);
+                       fprintf(f, "{\n");
+                       fprintf(f, "    BLI_strncpy(((%s*)data)->%s, value, %d);\n", dp->dnastructname, dp->dnaname, sprop->maxlength);
+                       fprintf(f, "}\n\n");
+                       break;
+               }
+               default:
+                       if(prop->arraylength) {
+                               fprintf(f, "static void %s(void *data, int index, %s value)\n", func, rna_type_type(prop));
+                               fprintf(f, "{\n");
+                               if(prop->type == PROP_BOOLEAN && dp->booleanbit && dp->dnaarraylength==1) {
+                                       fprintf(f, "    if(value) ((%s*)data)->%s |= (%d<<index);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                                       fprintf(f, "    else ((%s*)data)->%s &= ~(%d<<index);\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                               }
+                               else if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
+                                       fprintf(f, "    if(value) ((%s*)data)->%s[index] |= %d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                                       fprintf(f, "    else ((%s*)data)->%s[index] &= ~%d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                               }
+                               else {
+                                       rna_clamp_value(f, prop);
+                                       fprintf(f, "    ((%s*)data)->%s[index]= value;\n", dp->dnastructname, dp->dnaname);
+                               }
+                               fprintf(f, "}\n\n");
+                       }
+                       else {
+                               fprintf(f, "static void %s(void *data, %s value)\n", func, rna_type_type(prop));
+                               fprintf(f, "{\n");
+                               if(prop->type == PROP_BOOLEAN && dp->booleanbit) {
+                                       fprintf(f, "    if(value) ((%s*)data)->%s |= %d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                                       fprintf(f, "    else ((%s*)data)->%s &= ~%d;\n", dp->dnastructname, dp->dnaname, dp->booleanbit);
+                               }
+                               else {
+                                       rna_clamp_value(f, prop);
+                                       fprintf(f, "    ((%s*)data)->%s= value;\n", dp->dnastructname, dp->dnaname);
+                               }
+                               fprintf(f, "}\n\n");
+                       }
+                       break;
+       }
+
+       return func;
+}
+
+static char *rna_def_property_length_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
+{
+       char *func;
+
+       if(!dp->dnastructname || !dp->dnaname) {
+               fprintf(stderr, "rna_def_property_length_func: %s has no valid dna info.\n", prop->cname);
+               DefRNA.error= 1;
+               return NULL;
+       }
+
+       func= rna_alloc_function_name(dp->strct->cname, prop->cname, "length");
+
+       fprintf(f, "static int %s(void *data)\n", func);
+       fprintf(f, "{\n");
+       fprintf(f, "    return strlen(((%s*)data)->%s);\n", dp->dnastructname, dp->dnaname);
+       fprintf(f, "}\n\n");
+
+       return func;
+}
+
+static char *rna_def_property_begin_func(FILE *f, PropertyRNA *prop, PropertyDefRNA *dp)
+{
+       char *func;
+
+       if(!dp->dnastructname || !dp->dnaname) {
+               fprintf(stderr, "rna_def_property_begin_func: %s has no valid dna info.\n", prop->cname);
+               DefRNA.error= 1;
+               return NULL;
+       }
+
+       func= rna_alloc_function_name(dp->strct->cname, prop->cname, "begin");
+
+       fprintf(f, "static void %s(CollectionPropertyIterator *iter, void *data)\n", func);
+       fprintf(f, "{\n");
+       fprintf(f, "    rna_iterator_listbase_begin(iter, &((%s*)data)->%s);\n", dp->dnastructname, dp->dnaname);
+       fprintf(f, "}\n\n");
+
+       return func;
+}
+
+static void rna_def_property_funcs(FILE *f, PropertyDefRNA *dp)
+{
+       PropertyRNA *prop;
+
+       prop= dp->prop;
+
+       switch(prop->type) {
+               case PROP_BOOLEAN: {
+                       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+
+                       if(!prop->arraylength) {
+                               if(!bprop->get) bprop->get= (void*)rna_def_property_get_func(f, prop, dp);
+                               if(!bprop->set) bprop->set= (void*)rna_def_property_set_func(f, prop, dp);
+                       }
+                       else {
+                               if(!bprop->getarray) bprop->getarray= (void*)rna_def_property_get_func(f, prop, dp);
+                               if(!bprop->setarray) bprop->setarray= (void*)rna_def_property_set_func(f, prop, dp);
+                       }
+                       break;
+               }
+               case PROP_INT: {
+                       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+
+                       if(!prop->arraylength) {
+                               if(!iprop->get) iprop->get= (void*)rna_def_property_get_func(f, prop, dp);
+                               if(!iprop->set) iprop->set= (void*)rna_def_property_set_func(f, prop, dp);
+                       }
+                       else {
+                               if(!iprop->getarray) iprop->getarray= (void*)rna_def_property_get_func(f, prop, dp);
+                               if(!iprop->setarray) iprop->setarray= (void*)rna_def_property_set_func(f, prop, dp);
+                       }
+                       break;
+               }
+               case PROP_FLOAT: {
+                       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+
+                       if(!prop->arraylength) {
+                               if(!fprop->get) fprop->get= (void*)rna_def_property_get_func(f, prop, dp);
+                               if(!fprop->set) fprop->set= (void*)rna_def_property_set_func(f, prop, dp);
+                       }
+                       else {
+                               if(!fprop->getarray) fprop->getarray= (void*)rna_def_property_get_func(f, prop, dp);
+                               if(!fprop->setarray) fprop->setarray= (void*)rna_def_property_set_func(f, prop, dp);
+                       }
+                       break;
+               }
+               case PROP_ENUM: {
+                       EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+
+                       if(!eprop->get) eprop->get= (void*)rna_def_property_get_func(f, prop, dp);
+                       if(!eprop->set) eprop->set= (void*)rna_def_property_set_func(f, prop, dp);
+                       break;
+               }
+               case PROP_STRING: {
+                       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+
+                       if(!sprop->get) sprop->get= (void*)rna_def_property_get_func(f, prop, dp);
+                       if(!sprop->length) sprop->length= (void*)rna_def_property_length_func(f, prop, dp);
+                       if(!sprop->set) sprop->set= (void*)rna_def_property_set_func(f, prop, dp);
+                       break;
+               }
+               case PROP_POINTER: {
+                       PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+
+                       if(!pprop->get) pprop->get= (void*)rna_def_property_get_func(f, prop, dp);
+                       if(!pprop->set) pprop->set= (void*)rna_def_property_set_func(f, prop, dp);
+                       break;
+               }
+               case PROP_COLLECTION: {
+                       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+                       if(dp->dnatype && strcmp(dp->dnatype, "ListBase")==0)
+                               if(!cprop->begin)
+                                       cprop->begin= (void*)rna_def_property_begin_func(f, prop, dp);
+                       break;
+               }
+       }
+}
+
+static const char *rna_find_type(const char *type)
+{
+       StructDefRNA *ds;
+
+       for(ds=DefRNA.structs.first; ds; ds=ds->next)
+               if(ds->dnaname && strcmp(ds->dnaname, type)==0)
+                       return ds->strct->cname;
+       
+       return NULL;
+}
+
+static void rna_auto_types()
+{
+       StructDefRNA *ds;
+       PropertyDefRNA *dp;
+
+       for(ds=DefRNA.structs.first; ds; ds=ds->next) {
+               for(dp=ds->properties.first; dp; dp=dp->next) {
+                       if(dp->dnatype) {
+                               if(dp->prop->type == PROP_POINTER) {
+                                       PointerPropertyRNA *pprop= (PointerPropertyRNA*)dp->prop;
+
+                                       if(!pprop->structtype && !pprop->type)
+                                               pprop->structtype= (StructRNA*)rna_find_type(dp->dnatype);
+                               }
+                               else if(dp->prop->type== PROP_COLLECTION) {
+                                       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)dp->prop;
+
+                                       if(!cprop->structtype && !cprop->type && strcmp(dp->dnatype, "ListBase")==0)
+                                               cprop->structtype= (StructRNA*)rna_find_type(dp->dnatype);
+                               }
+                       }
+               }
+       }
+}
+
+static void rna_auto_functions(FILE *f)
+{
+       StructDefRNA *ds;
+       PropertyDefRNA *dp;
+
+       fprintf(f, "/* Autogenerated Functions */\n\n");
+
+       for(ds=DefRNA.structs.first; ds; ds=ds->next)
+               for(dp=ds->properties.first; dp; dp=dp->next)
+                       rna_def_property_funcs(f, dp);
+}
+
+static const char *rna_property_structname(PropertyType type)
+{
+       switch(type) {
+               case PROP_BOOLEAN: return "BooleanPropertyRNA";
+               case PROP_INT: return "IntPropertyRNA";
+               case PROP_FLOAT: return "FloatPropertyRNA";
+               case PROP_STRING: return "StringPropertyRNA";
+               case PROP_ENUM: return "EnumPropertyRNA";
+               case PROP_POINTER: return "PointerPropertyRNA";
+               case PROP_COLLECTION: return "CollectionPropertyRNA";
+               default: return "UnknownPropertyRNA";
+       }
+}
+
+static const char *rna_property_typename(PropertyType type)
+{
+       switch(type) {
+               case PROP_BOOLEAN: return "PROP_BOOLEAN";
+               case PROP_INT: return "PROP_INT";
+               case PROP_FLOAT: return "PROP_FLOAT";
+               case PROP_STRING: return "PROP_STRING";
+               case PROP_ENUM: return "PROP_ENUM";
+               case PROP_POINTER: return "PROP_POINTER";
+               case PROP_COLLECTION: return "PROP_COLLECTION";
+               default: return "PROP_UNKNOWN";
+       }
+}
+
+static const char *rna_property_subtypename(PropertyType type)
+{
+       switch(type) {
+               case PROP_NONE: return "PROP_NONE";
+               case PROP_UNSIGNED: return "PROP_UNSIGNED";
+               case PROP_FILEPATH: return "PROP_FILEPATH";
+               case PROP_COLOR: return "PROP_COLOR";
+               case PROP_VECTOR: return "PROP_VECTOR";
+               case PROP_MATRIX: return "PROP_MATRIX";
+               default: return "PROP_UNKNOWN";
+       }
+}
+
+static void rna_generate_prototypes(BlenderRNA *brna, FILE *f)
+{
+       StructRNA *strct;
+
+       for(strct=brna->structs.first; strct; strct=strct->next)
+               fprintf(f, "StructRNA RNA_%s;\n", strct->cname);
+       fprintf(f, "\n");
+
+       fprintf(f, "BlenderRNA BLENDER_RNA = {");
+
+       strct= brna->structs.first;
+       if(strct) fprintf(f, "{&RNA_%s, ", strct->cname);
+       else fprintf(f, "{NULL, ");
+
+       strct= brna->structs.last;
+       if(strct) fprintf(f, "&RNA_%s}", strct->cname);
+       else fprintf(f, "NULL}");
+
+       fprintf(f, "};\n\n");
+}
+
+static void rna_generate_struct(BlenderRNA *brna, StructRNA *strct, FILE *f)
+{
+       PropertyRNA *prop;
+
+       fprintf(f, "/* %s */\n", strct->name);
+
+       if(strct->properties.first)
+               fprintf(f, "\n");
+
+       for(prop=strct->properties.first; prop; prop=prop->next)
+               fprintf(f, "static %s rna_%s_%s;\n", rna_property_structname(prop->type), strct->cname, prop->cname);
+       fprintf(f, "\n");
+
+       for(prop=strct->properties.first; prop; prop=prop->next) {
+               switch(prop->type) {
+                       case PROP_ENUM: {
+                               EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+                               int i;
+
+                               if(eprop->item) {
+                                       fprintf(f, "static PropertyEnumItem rna_%s_%s_items[%d] = {", strct->cname, prop->cname, eprop->totitem);
+
+                                       for(i=0; i<eprop->totitem; i++) {
+                                               fprintf(f, "{%d, ", eprop->item[i].value);
+                                               rna_print_c_string(f, eprop->item[i].cname); fprintf(f, ", ");
+                                               rna_print_c_string(f, eprop->item[i].name); fprintf(f, "}");
+                                               if(i != eprop->totitem-1)
+                                                       fprintf(f, ", ");
+                                       }
+
+                                       fprintf(f, "};\n\n");
+                               }
+                               break;
+                       }
+                       case PROP_BOOLEAN: {
+                               BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+                               int i;
+
+                               if(bprop->defaultarray) {
+                                       fprintf(f, "static int rna_%s_%s_default[%d] = {", strct->cname, prop->cname, prop->arraylength);
+
+                                       for(i=0; i<prop->arraylength; i++) {
+                                               fprintf(f, "%d", bprop->defaultarray[i]);
+                                               if(i != prop->arraylength-1)
+                                                       fprintf(f, ", ");
+                                       }
+
+                                       fprintf(f, "};\n\n");
+                               }
+                               break;
+                       }
+                       case PROP_INT: {
+                               IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+                               int i;
+
+                               if(iprop->defaultarray) {
+                                       fprintf(f, "static int rna_%s_%s_default[%d] = {", strct->cname, prop->cname, prop->arraylength);
+
+                                       for(i=0; i<prop->arraylength; i++) {
+                                               fprintf(f, "%d", iprop->defaultarray[i]);
+                                               if(i != prop->arraylength-1)
+                                                       fprintf(f, ", ");
+                                       }
+
+                                       fprintf(f, "};\n\n");
+                               }
+                               break;
+                       }
+                       case PROP_FLOAT: {
+                               FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+                               int i;
+
+                               if(fprop->defaultarray) {
+                                       fprintf(f, "static float rna_%s_%s_default[%d] = {", strct->cname, prop->cname, prop->arraylength);
+
+                                       for(i=0; i<prop->arraylength; i++) {
+                                               rna_float_print(f, fprop->defaultarray[i]);
+                                               if(i != prop->arraylength-1)
+                                                       fprintf(f, ", ");
+                                       }
+
+                                       fprintf(f, "};\n\n");
+                               }
+                               break;
+                       }
+                       default:
+                               break;
+               }
+
+               fprintf(f, "static %s rna_%s_%s = {\n", rna_property_structname(prop->type), strct->cname, prop->cname);
+
+               if(prop->next) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", strct->cname, prop->next->cname);
+               else fprintf(f, "\t{NULL, ");
+               if(prop->prev) fprintf(f, "(PropertyRNA*)&rna_%s_%s,\n", strct->cname, prop->prev->cname);
+               else fprintf(f, "NULL,\n");
+               fprintf(f, "\t"); rna_print_c_string(f, prop->cname);
+               fprintf(f, ", %d, ", prop->flag);
+               rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
+               rna_print_c_string(f, prop->description); fprintf(f, ",\n");
+               fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), prop->arraylength);
+               fprintf(f, "\t%s},\n", rna_function_string(prop->notify));
+
+               switch(prop->type) {
+                       case PROP_BOOLEAN: {
+                               BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+                               fprintf(f, "\t%s, %s, %s, %s, %d, ", rna_function_string(bprop->get), rna_function_string(bprop->set), rna_function_string(bprop->getarray), rna_function_string(bprop->setarray), bprop->defaultvalue);
+                               if(bprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", strct->name, prop->cname);
+                               else fprintf(f, "NULL\n");
+                               break;
+                       }
+                       case PROP_INT: {
+                               IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+                               fprintf(f, "\t%s, %s, %s, %s, %d, %d, %d, %d, %d,\n\t%d, \n", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), iprop->softmin, iprop->softmax, iprop->hardmin, iprop->hardmax, iprop->step, iprop->defaultvalue);
+                               if(iprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", strct->name, prop->cname);
+                               else fprintf(f, "NULL\n");
+                               break;
+                       }
+                       case PROP_FLOAT: {
+                               FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+                               fprintf(f, "\t%s, %s, %s, %s, ", rna_function_string(fprop->get), rna_function_string(fprop->set), rna_function_string(fprop->getarray), rna_function_string(fprop->setarray));
+                               rna_float_print(f, fprop->softmin); fprintf(f, ", ");
+                               rna_float_print(f, fprop->softmax); fprintf(f, ", ");
+                               rna_float_print(f, fprop->hardmin); fprintf(f, ", ");
+                               rna_float_print(f, fprop->hardmax); fprintf(f, ", ");
+                               rna_float_print(f, fprop->step); fprintf(f, ", ");
+                               rna_float_print(f, fprop->precision); fprintf(f, ", ");
+                               rna_float_print(f, fprop->defaultvalue); fprintf(f, ", ");
+                               if(fprop->defaultarray) fprintf(f, "rna_%s_%s_default\n", strct->name, prop->cname);
+                               else fprintf(f, "NULL\n");
+                               break;
+                       }
+                       case PROP_STRING: {
+                               StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+                               fprintf(f, "\t%s, %s, %s, %d, ", rna_function_string(sprop->get), rna_function_string(sprop->length), rna_function_string(sprop->set), sprop->maxlength);
+                               rna_print_c_string(f, sprop->defaultvalue); fprintf(f, "\n");
+                               break;
+                       }
+                       case PROP_ENUM: {
+                               EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+                               fprintf(f, "\t%s, %s, rna_%s_%s_items, %d, %d\n", rna_function_string(eprop->get), rna_function_string(eprop->set), strct->cname, prop->cname, eprop->totitem, eprop->defaultvalue);
+                               break;
+                       }
+                       case PROP_POINTER: {
+                               PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+                               fprintf(f, "\t%s, %s, %s, ", rna_function_string(pprop->get), rna_function_string(pprop->set), rna_function_string(pprop->type));
+                               if(pprop->structtype) fprintf(f, "&RNA_%s\n", (char*)pprop->structtype);
+                               else fprintf(f, "NULL\n");
+                               break;
+                       }
+                       case PROP_COLLECTION: {
+                               CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+                               fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->type), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring));
+                               if(cprop->structtype) fprintf(f, "&RNA_%s\n", (char*)cprop->structtype);
+                               else fprintf(f, "NULL\n");
+                               break;
+                       }
+               }
+
+               fprintf(f, "};\n\n");
+       }
+
+       fprintf(f, "StructRNA RNA_%s = {\n", strct->cname);
+
+       if(strct->next) fprintf(f, "\t&RNA_%s, ", strct->next->cname);
+       else fprintf(f, "\tNULL, ");
+       if(strct->prev) fprintf(f, "&RNA_%s,\n", strct->prev->cname);
+       else fprintf(f, "NULL,\n");
+
+       fprintf(f, "\t");
+       rna_print_c_string(f, strct->cname);
+       fprintf(f, ", %d, ", strct->flag);
+       rna_print_c_string(f, strct->name);
+       fprintf(f, ",\n");
+
+       prop= strct->nameproperty;
+       if(prop) fprintf(f, "\t(PropertyRNA*)&rna_%s_%s,\n", strct->cname, prop->cname);
+       else fprintf(f, "\tNULL,\n");
+
+       prop= strct->properties.first;
+       if(prop) fprintf(f, "\t{(PropertyRNA*)&rna_%s_%s, ", strct->cname, prop->cname);
+       else fprintf(f, "\t{NULL, ");
+
+       prop= strct->properties.last;
+       if(prop) fprintf(f, "(PropertyRNA*)&rna_%s_%s}\n", strct->cname, prop->cname);
+       else fprintf(f, "NULL}\n");
+
+       fprintf(f, "};\n");
+
+       fprintf(f, "\n");
+}
+
+typedef struct RNAProcessItem {
+       char *filename;
+       void (*define)(BlenderRNA *brna);
+} RNAProcessItem;
+
+RNAProcessItem PROCESS_ITEMS[]= {
+       {"rna_object.c", RNA_def_object},
+       {"rna_scene.c", RNA_def_scene},
+       {NULL, NULL}};
+
+static int rna_preprocess(char *basedirectory, FILE *f)
+{
+       BlenderRNA *brna;
+       StructRNA *strct;
+       int i, status;
+       
+       fprintf(f, "\n/* Automatically generated struct definitions for the Data API.\n"
+                       "   Do not edit manually, changes will be overwritten */\n\n"
+                       "#define RNA_RUNTIME\n\n");
+
+       brna= RNA_create();
+
+       fprintf(f, "#include <float.h>\n");
+       fprintf(f, "#include <limits.h>\n");
+       fprintf(f, "#include <string.h>\n\n");
+
+       fprintf(f, "#include \"BLI_blenlib.h\"\n\n");
+
+       fprintf(f, "#include \"BKE_utildefines.h\"\n\n");
+
+       fprintf(f, "#include \"RNA_define.h\"\n\n");
+       fprintf(f, "#include \"RNA_types.h\"\n\n");
+
+       fprintf(f, "#include \"rna_internal.h\"\n\n");
+       for(i=0; PROCESS_ITEMS[i].define; i++)
+               fprintf(f, "#include \"%s\"\n", PROCESS_ITEMS[i].filename);
+       fprintf(f, "\n");
+
+       for(i=0; PROCESS_ITEMS[i].define; i++)
+               PROCESS_ITEMS[i].define(brna);
+       rna_auto_types();
+       
+       rna_generate_prototypes(brna, f);
+       rna_auto_functions(f);
+
+       for(strct=brna->structs.first; strct; strct=strct->next)
+               rna_generate_struct(brna, strct, f);
+       
+       status= DefRNA.error;
+
+       RNA_define_free(brna);
+       RNA_free(brna);
+
+       return status;
+}
+
+static void make_bad_file(char *file)
+{
+       FILE *fp= fopen(file, "w");
+       fprintf(fp, "ERROR! Cannot make correct RNA.c file, STUPID!\n");
+       fclose(fp);
+}
+
+#ifndef BASE_HEADER
+#define BASE_HEADER "../"
+#endif
+
+int main(int argc, char **argv)
+{
+       FILE *file;
+       int return_status = 0;
+       extern int totblock;
+
+       if (argc!=2 && argc!=3) {
+               printf("Usage: %s outfile.c [base directory]\n", argv[0]);
+               return_status = 1;
+       }
+       else {
+               file = fopen(argv[1], "w");
+
+               if (!file) {
+                       printf ("Unable to open file: %s\n", argv[1]);
+                       return_status = 1;
+               }
+               else {
+                       char baseDirectory[256];
+
+                       printf("Running makesrna, program versions %s\n",  RNA_VERSION_DATE);
+
+                       if (argc==3)
+                               strcpy(baseDirectory, argv[2]);
+                       else
+                               strcpy(baseDirectory, BASE_HEADER);
+
+                       return_status= (rna_preprocess(baseDirectory, file));
+                       fclose(file);
+
+                       if(return_status) {
+                               /* error */
+                               make_bad_file(argv[1]);
+                               return_status = 1;
+                       }
+               }
+       }
+
+       if(totblock!=0) {
+               printf("Error Totblock: %d\n",totblock);
+               MEM_printmemlist();
+       }
+
+       return return_status;
+}
+
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
new file mode 100644 (file)
index 0000000..af4a4b4
--- /dev/null
@@ -0,0 +1,411 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+#include "RNA_types.h"
+
+/* Accessors */
+
+void RNA_property_notify(PropertyRNA *prop, struct bContext *C, void *data)
+{
+       if(prop->notify)
+               prop->notify(C, data);
+}
+
+int RNA_property_editable(PropertyRNA *prop, struct bContext *C, void *data)
+{
+       return (prop->flag & PROP_EDITABLE);
+}
+
+int RNA_property_evaluatable(PropertyRNA *prop, struct bContext *C, void *data)
+{
+       return (prop->flag & PROP_EVALUATEABLE);
+}
+
+int RNA_property_boolean_get(PropertyRNA *prop, void *data)
+{
+       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+
+       return bprop->get(data);
+}
+
+void RNA_property_boolean_set(PropertyRNA *prop, void *data, int value)
+{
+       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+
+       bprop->set(data, value);
+}
+
+int RNA_property_boolean_get_array(PropertyRNA *prop, void *data, int index)
+{
+       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+
+       return bprop->getarray(data, index);
+}
+
+void RNA_property_boolean_set_array(PropertyRNA *prop, void *data, int index, int value)
+{
+       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+
+       bprop->setarray(data, index, value);
+}
+
+int RNA_property_int_get(PropertyRNA *prop, void *data)
+{
+       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+
+       return iprop->get(data);
+}
+
+void RNA_property_int_set(PropertyRNA *prop, void *data, int value)
+{
+       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+
+       iprop->set(data, value);
+}
+
+int RNA_property_int_get_array(PropertyRNA *prop, void *data, int index)
+{
+       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+
+       return iprop->getarray(data, index);
+}
+
+void RNA_property_int_set_array(PropertyRNA *prop, void *data, int index, int value)
+{
+       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+
+       iprop->setarray(data, index, value);
+}
+
+float RNA_property_float_get(PropertyRNA *prop, void *data)
+{
+       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+
+       return fprop->get(data);
+}
+
+void RNA_property_float_set(PropertyRNA *prop, void *data, float value)
+{
+       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+
+       fprop->set(data, value);
+}
+
+float RNA_property_float_get_array(PropertyRNA *prop, void *data, int index)
+{
+       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+
+       return fprop->getarray(data, index);
+}
+
+void RNA_property_float_set_array(PropertyRNA *prop, void *data, int index, float value)
+{
+       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+
+       fprop->setarray(data, index, value);
+}
+
+void RNA_property_string_get(PropertyRNA *prop, void *data, char *value)
+{
+       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+
+       sprop->get(data, value);
+}
+
+int RNA_property_string_length(PropertyRNA *prop, void *data)
+{
+       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+
+       return sprop->length(data);
+}
+
+void RNA_property_string_set(PropertyRNA *prop, void *data, const char *value)
+{
+       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+
+       sprop->set(data, value);
+}
+
+int RNA_property_enum_get(PropertyRNA *prop, void *data)
+{
+       EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+
+       return eprop->get(data);
+}
+
+void RNA_property_enum_set(PropertyRNA *prop, void *data, int value)
+{
+       EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+
+       eprop->set(data, value);
+}
+
+void *RNA_property_pointer_get(PropertyRNA *prop, void *data)
+{
+       PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+
+       return pprop->get(data);
+}
+
+void RNA_property_pointer_set(PropertyRNA *prop, void *data, void *value)
+{
+       PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+
+       pprop->set(data, value);
+}
+
+StructRNA *RNA_property_pointer_type(PropertyRNA *prop, void *data)
+{
+       PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+
+       if(pprop->type)
+               return pprop->type(data);
+       
+       return pprop->structtype;
+}
+
+void RNA_property_collection_begin(PropertyRNA *prop, struct CollectionPropertyIterator *iter, void *data)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+       cprop->begin(iter, data);
+}
+
+void RNA_property_collection_next(PropertyRNA *prop, struct CollectionPropertyIterator *iter)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+       cprop->next(iter);
+}
+
+void RNA_property_collection_end(PropertyRNA *prop, struct CollectionPropertyIterator *iter)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+       if(cprop->end)
+               cprop->end(iter);
+}
+
+void *RNA_property_collection_get(PropertyRNA *prop, struct CollectionPropertyIterator *iter)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+       return cprop->get(iter);
+}
+
+StructRNA *RNA_property_collection_type(PropertyRNA *prop, struct CollectionPropertyIterator *iter)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+       if(cprop->type)
+               return cprop->type(iter);
+       
+       return cprop->structtype;
+}
+
+int RNA_property_collection_length(PropertyRNA *prop, void *data)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+       if(cprop->length) {
+               return cprop->length(data);
+       }
+       else {
+               CollectionPropertyIterator iter;
+               int length= 0;
+
+               for(cprop->begin(&iter, data); iter.valid; cprop->next(&iter))
+                       length++;
+
+               if(cprop->end)
+                       cprop->end(&iter);
+
+               return length;
+       }
+}
+
+void *RNA_property_collection_lookup_int(PropertyRNA *prop, void *data, int key, StructRNA **type)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+       void *value;
+
+       if(cprop->lookupint) {
+               value= cprop->lookupint(data, key, type);
+
+               if(value && type && !*type)
+                       *type= cprop->structtype;
+
+               return value;
+       }
+       else {
+               CollectionPropertyIterator iter;
+               int i= 0;
+               void *value;
+
+               for(cprop->begin(&iter, data); iter.valid; cprop->next(&iter), i++)
+                       if(i == key)
+                               break;
+
+               if(iter.valid) {
+                       value= cprop->get(&iter);
+                       if(type) *type= RNA_property_collection_type(prop, &iter);
+               }
+               else {
+                       value= NULL;
+                       if(type) *type= NULL;
+               }
+
+               if(cprop->end)
+                       cprop->end(&iter);
+
+               return value;
+       }
+}
+
+void *RNA_property_collection_lookup_string(PropertyRNA *prop, void *data, const char *key, StructRNA **type)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+       void *value;
+
+       if(cprop->lookupstring) {
+               value= cprop->lookupstring(data, key, type);
+
+               if(value && type && !*type)
+                       *type= cprop->structtype;
+
+               return value;
+       }
+       else {
+               CollectionPropertyIterator iter;
+               StructRNA *itertype= NULL;
+               StringPropertyRNA *sprop;
+               void *value= NULL;
+               char name[256], *nameptr;
+               int length, alloc, found= 0;
+
+               for(cprop->begin(&iter, data); iter.valid && !found; cprop->next(&iter)) {
+                       itertype= RNA_property_collection_type(prop, &iter);
+
+                       if(itertype->nameproperty) {
+                               value= cprop->get(&iter);
+
+                               if(value) {
+                                       sprop= (StringPropertyRNA*)itertype->nameproperty;
+                                       length= sprop->length(value);
+
+                                       if(sizeof(name)-1 < length) {
+                                               nameptr= name;
+                                               alloc= 0;
+                                       }
+                                       else {
+                                               nameptr= MEM_mallocN(sizeof(char)*length+1, "RNA_lookup_string");
+                                               alloc= 1;
+                                       }
+
+                                       sprop->get(value, nameptr);
+
+                                       if(strcmp(nameptr, key) == 0)
+                                               found= 1;
+
+                                       if(alloc)
+                                               MEM_freeN(nameptr);
+                               }
+                       }
+               }
+
+               if(found && type)
+                       *type= itertype;
+
+               if(cprop->end)
+                       cprop->end(&iter);
+
+               return value;
+       }
+       
+       return NULL;
+}
+
+/* Standard iterator functions */
+
+void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb)
+{
+       iter->internal= lb->first;
+       iter->valid= (iter->internal != NULL);
+}
+
+void rna_iterator_listbase_next(CollectionPropertyIterator *iter)
+{
+       iter->internal= ((Link*)iter->internal)->next;
+       iter->valid= (iter->internal != NULL);
+}
+
+void *rna_iterator_listbase_get(CollectionPropertyIterator *iter)
+{
+       return iter->internal;
+}
+
+typedef struct ArrayIterator {
+       char *ptr;
+       char *endptr;
+       int itemsize;
+} ArrayIterator;
+
+void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length)
+{
+       ArrayIterator *internal;
+
+       internal= MEM_callocN(sizeof(ArrayIterator), "ArrayIterator");
+       internal->ptr= ptr;
+       internal->endptr= ptr+length*itemsize;
+
+       iter->internal= internal;
+       iter->valid= (internal->ptr != internal->endptr);
+}
+
+void rna_iterator_array_next(CollectionPropertyIterator *iter)
+{
+       ArrayIterator *internal= iter->internal;
+
+       internal->ptr += internal->itemsize;
+       iter->valid= (internal->ptr != internal->endptr);
+}
+
+void *rna_iterator_array_get(CollectionPropertyIterator *iter)
+{
+       ArrayIterator *internal= iter->internal;
+
+       return internal->ptr;
+}
+
+void rna_iterator_array_end(CollectionPropertyIterator *iter)
+{
+       MEM_freeN(iter->internal);
+}
+
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
new file mode 100644 (file)
index 0000000..b3399df
--- /dev/null
@@ -0,0 +1,847 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <float.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_genfile.h"
+#include "DNA_sdna_types.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#include "rna_internal.h"
+
+/* Global used during defining */
+
+BlenderDefRNA DefRNA;
+
+/* Duplicated code since we can't link in blenkernel or blenlib */
+
+#define MIN2(x,y) ((x)<(y)? (x): (y))
+#define MAX2(x,y) ((x)>(y)? (x): (y))
+
+void rna_addtail(ListBase *listbase, void *vlink)
+{
+       Link *link= vlink;
+
+       link->next = NULL;
+       link->prev = listbase->last;
+
+       if (listbase->last) ((Link *)listbase->last)->next = link;
+       if (listbase->first == 0) listbase->first = link;
+       listbase->last = link;
+}
+
+void rna_freelistN(ListBase *listbase)
+{
+       Link *link, *next;
+       
+       for(link=listbase->first; link; link=next) {
+               next= link->next;
+               MEM_freeN(link);
+       }
+       
+       listbase->first= listbase->last= NULL;
+}
+
+/* DNA utility function for looking up members */
+
+typedef struct DNAStructMember {
+       char *type;
+       char *name;
+       int arraylength;
+} DNAStructMember;
+
+static int rna_member_cmp(const char *name, const char *oname)
+{
+       int a=0;
+       
+       /* compare without pointer or array part */
+       while(name[0]=='*')
+               name++;
+       while(oname[0]=='*')
+               oname++;
+       
+       while(1) {
+               if(name[a]=='[' && oname[a]==0) return 1;
+               if(name[a]==0) break;
+               if(name[a] != oname[a]) return 0;
+               a++;
+       }
+       if(name[a]==0 && oname[a] == '.') return 2;
+       if(name[a]==0 && oname[a] == '-' && oname[a+1] == '>') return 3;
+
+       return (name[a] == oname[a]);
+}
+
+static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *membername, DNAStructMember *smember)
+{
+       char *dnaname;
+       short *sp;
+       int a, structnr, totmember, cmp;
+
+       structnr= DNA_struct_find_nr(sdna, structname);
+       if(structnr == -1)
+               return 0;
+
+       sp= sdna->structs[structnr];
+       totmember= sp[1];
+       sp+= 2;
+
+       for(a=0; a<totmember; a++, sp+=2) {
+               dnaname= sdna->names[sp[1]];
+
+               cmp= rna_member_cmp(dnaname, membername);
+
+               if(cmp == 1) {
+                       smember->type= sdna->types[sp[0]];
+                       smember->name= dnaname;
+                       smember->arraylength= DNA_elem_array_size(smember->name, strlen(smember->name));
+                       return 1;
+               }
+               else if(cmp == 2) {
+                       membername= strstr(membername, ".") + strlen(".");
+                       return rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
+               }
+               else if(cmp == 3) {
+                       membername= strstr(membername, "->") + strlen("->");
+                       return rna_find_sdna_member(sdna, sdna->types[sp[0]], membername, smember);
+               }
+       }
+
+       return 0;
+}
+
+/* Blender Data Definition */
+
+BlenderRNA *RNA_create()
+{
+       BlenderRNA *brna;
+
+       brna= MEM_callocN(sizeof(BlenderRNA), "BlenderRNA");
+
+       DefRNA.sdna= DNA_sdna_from_data(DNAstr,  DNAlen, 0);
+       DefRNA.structs.first= DefRNA.structs.last= NULL;
+       DefRNA.error= 0;
+
+       return brna;
+}
+
+void RNA_define_free(BlenderRNA *brna)
+{
+       StructDefRNA *strct;
+       AllocDefRNA *alloc;
+
+       for(alloc=DefRNA.allocs.first; alloc; alloc=alloc->next)
+               MEM_freeN(alloc->mem);
+       rna_freelistN(&DefRNA.allocs);
+
+       for(strct=DefRNA.structs.first; strct; strct=strct->next)
+               rna_freelistN(&strct->properties);
+
+       rna_freelistN(&DefRNA.structs);
+
+       if(DefRNA.sdna) {
+               DNA_sdna_free(DefRNA.sdna);
+               DefRNA.sdna= NULL;
+       }
+
+       DefRNA.error= 0;
+}
+
+void RNA_free(BlenderRNA *brna)
+{
+       StructRNA *strct;
+
+       RNA_define_free(brna);
+
+       for(strct=brna->structs.first; strct; strct=strct->next)
+               rna_freelistN(&strct->properties);
+
+       rna_freelistN(&brna->structs);
+       
+       MEM_freeN(brna);
+}
+
+/* Struct Definition */
+
+StructRNA *RNA_def_struct(BlenderRNA *brna, const char *cname, const char *name)
+{
+       StructRNA *strct;
+       StructDefRNA *ds;
+
+       ds= MEM_callocN(sizeof(StructDefRNA), "StructDefRNA");
+       rna_addtail(&DefRNA.structs, ds);
+
+       strct= MEM_callocN(sizeof(StructRNA), "StructRNA");
+       strct->cname= cname;
+       strct->name= name;
+
+       ds->strct= strct;
+
+       rna_addtail(&brna->structs, strct);
+
+       RNA_def_struct_sdna(strct, strct->cname);
+
+       return strct;
+}
+
+void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
+{
+       StructDefRNA *ds= DefRNA.structs.last;
+
+       if(!DNA_struct_find_nr(DefRNA.sdna, structname)) {
+               if(!DefRNA.silent) {
+                       fprintf(stderr, "RNA_def_struct_sdna: %s not found.\n", structname);
+                       DefRNA.error= 1;
+               }
+               return;
+       }
+
+       ds->dnaname= structname;
+}
+
+void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
+{
+       if(prop->type != PROP_STRING) {
+               fprintf(stderr, "RNA_def_struct_name_property: must be a string property.\n");
+               DefRNA.error= 1;
+       }
+       else
+               srna->nameproperty= prop;
+}
+
+/* Property Definition */
+
+PropertyRNA *RNA_def_property(StructRNA *strct, const char *cname, int type, int subtype)
+{
+       StructDefRNA *ds;
+       PropertyDefRNA *dp;
+       PropertyRNA *prop;
+
+       ds= DefRNA.structs.last;
+       dp= MEM_callocN(sizeof(PropertyDefRNA), "PropertyDefRNA");
+       rna_addtail(&ds->properties, dp);
+
+       switch(type) {
+               case PROP_BOOLEAN:
+                       prop= MEM_callocN(sizeof(BooleanPropertyRNA), "BooleanPropertyRNA");
+                       break;
+               case PROP_INT: {
+                       IntPropertyRNA *iprop;
+                       iprop= MEM_callocN(sizeof(IntPropertyRNA), "IntPropertyRNA");
+                       prop= &iprop->property;
+
+                       iprop->hardmin= (subtype == PROP_UNSIGNED)? 0: INT_MIN;
+                       iprop->hardmax= INT_MAX;
+
+                       iprop->softmin= (subtype == PROP_UNSIGNED)? 0: -10000; /* rather arbitrary .. */
+                       iprop->softmax= 10000;
+                       break;
+               }
+               case PROP_FLOAT: {
+                       FloatPropertyRNA *fprop;
+                       fprop= MEM_callocN(sizeof(FloatPropertyRNA), "FloatPropertyRNA");
+                       prop= &fprop->property;
+
+                       fprop->hardmin= (subtype == PROP_UNSIGNED)? 0: -FLT_MAX;
+                       fprop->hardmax= FLT_MAX;
+
+                       fprop->softmin= (subtype == PROP_UNSIGNED)? 0: -10000; /* rather arbitrary .. */
+                       fprop->softmax= 10000;
+                       break;
+               }
+               case PROP_STRING: {
+                       StringPropertyRNA *sprop;
+                       sprop= MEM_callocN(sizeof(StringPropertyRNA), "StringPropertyRNA");
+                       prop= &sprop->property;
+
+                       sprop->defaultvalue= "";
+                       sprop->maxlength= 0;
+                       break;
+               }
+               case PROP_ENUM:
+                       prop= MEM_callocN(sizeof(EnumPropertyRNA), "EnumPropertyRNA");
+                       break;
+               case PROP_POINTER:
+                       prop= MEM_callocN(sizeof(PointerPropertyRNA), "PointerPropertyRNA");
+                       break;
+               case PROP_COLLECTION:
+                       prop= MEM_callocN(sizeof(CollectionPropertyRNA), "CollectionPropertyRNA");
+                       break;
+               default:
+                       fprintf(stderr, "RNA_def_property: invalid property type.\n");
+                       DefRNA.error= 1;
+                       return NULL;
+       }
+
+       dp->strct= strct;
+       dp->prop= prop;
+
+       prop->cname= cname;
+       prop->type= type;
+       prop->subtype= subtype;
+       prop->name= cname;
+       prop->description= "";
+       prop->flag= PROP_EDITABLE|PROP_EVALUATEABLE;
+
+       switch(type) {
+               case PROP_BOOLEAN:
+                       DefRNA.silent= 1;
+                       RNA_def_property_boolean_sdna(prop, strct->cname, cname, 0);
+                       DefRNA.silent= 0;
+                       break;
+               case PROP_INT: {
+                       DefRNA.silent= 1;
+                       RNA_def_property_int_sdna(prop, strct->cname, cname);
+                       DefRNA.silent= 0;
+                       break;
+               }
+               case PROP_FLOAT: {
+                       DefRNA.silent= 1;
+                       RNA_def_property_float_sdna(prop, strct->cname, cname);
+                       DefRNA.silent= 0;
+                       break;
+               }
+               case PROP_STRING: {
+                       DefRNA.silent= 1;
+                       RNA_def_property_string_sdna(prop, strct->cname, cname);
+                       DefRNA.silent= 0;
+                       break;
+               }
+               case PROP_ENUM:
+                       DefRNA.silent= 1;
+                       RNA_def_property_enum_sdna(prop, strct->cname, cname);
+                       DefRNA.silent= 0;
+                       break;
+               case PROP_POINTER:
+                       DefRNA.silent= 1;
+                       RNA_def_property_pointer_sdna(prop, strct->cname, cname);
+                       DefRNA.silent= 0;
+                       break;
+               case PROP_COLLECTION:
+                       DefRNA.silent= 1;
+                       RNA_def_property_collection_sdna(prop, strct->cname, cname);
+                       DefRNA.silent= 0;
+                       break;
+       }
+
+       rna_addtail(&strct->properties, prop);
+
+       return prop;
+}
+
+void RNA_def_property_access(PropertyRNA *prop, int editable, int evaluatable)
+{
+       if(editable) prop->flag |= PROP_EDITABLE;
+       else prop->flag &= ~PROP_EDITABLE;
+
+       if(evaluatable) prop->flag |= PROP_EVALUATEABLE;
+       else prop->flag &= ~PROP_EVALUATEABLE;
+}
+
+void RNA_def_property_array(PropertyRNA *prop, int arraylength)
+{
+       switch(prop->type) {
+               case PROP_BOOLEAN:
+               case PROP_INT:
+               case PROP_FLOAT:
+                       prop->arraylength= arraylength;
+                       break;
+               default:
+                       fprintf(stderr, "RNA_def_property_array: only boolean/int/float can be array.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
+{
+       prop->name= name;
+       prop->description= description;
+}
+
+void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, double precision)
+{
+       switch(prop->type) {
+               case PROP_INT: {
+                       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+                       iprop->softmin= (int)min;
+                       iprop->softmax= (int)max;
+                       iprop->step= (int)step;
+                       break;
+               }
+               case PROP_FLOAT: {
+                       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+                       fprop->softmin= (float)min;
+                       fprop->softmax= (float)max;
+                       fprop->step= (float)step;
+                       fprop->precision= (float)precision;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_ui_range: invalid type for ui range.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_range(PropertyRNA *prop, double min, double max)
+{
+       switch(prop->type) {
+               case PROP_INT: {
+                       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+                       iprop->hardmin= (int)min;
+                       iprop->hardmax= (int)max;
+                       iprop->softmin= MAX2(min, iprop->hardmin);
+                       iprop->softmax= MIN2(max, iprop->hardmax);
+                       break;
+               }
+               case PROP_FLOAT: {
+                       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+                       fprop->hardmin= (float)min;
+                       fprop->hardmax= (float)max;
+                       fprop->softmin= MAX2(min, fprop->hardmin);
+                       fprop->softmax= MIN2(max, fprop->hardmax);
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_range: invalid type for range.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
+{
+       switch(prop->type) {
+               case PROP_POINTER: {
+                       PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+                       pprop->structtype = (StructRNA*)type;
+                       break;
+               }
+               case PROP_COLLECTION: {
+                       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+                       cprop->structtype = (StructRNA*)type;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_struct_type: invalid type for struct type.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_enum_items(PropertyRNA *prop, const PropertyEnumItem *item)
+{
+       int i;
+
+       switch(prop->type) {
+               case PROP_ENUM: {
+                       EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+                       eprop->item= item;
+                       eprop->totitem= 0;
+                       for(i=0; item[i].cname; i++)
+                               eprop->totitem++;
+
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_struct_type: invalid type for struct type.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
+{
+       switch(prop->type) {
+               case PROP_STRING: {
+                       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+                       sprop->maxlength= maxlength;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_string_maxlength: type is not string.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_boolean_default(PropertyRNA *prop, int value)
+{
+       switch(prop->type) {
+               case PROP_BOOLEAN: {
+                       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+                       bprop->defaultvalue= value;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_boolean_default: type is not boolean.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_boolean_array_default(PropertyRNA *prop, const int *array)
+{
+       switch(prop->type) {
+               case PROP_BOOLEAN: {
+                       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+                       bprop->defaultarray= array;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_boolean_default: type is not boolean.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_int_default(PropertyRNA *prop, int value)
+{
+       switch(prop->type) {
+               case PROP_INT: {
+                       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+                       iprop->defaultvalue= value;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_int_default: type is not int.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_int_array_default(PropertyRNA *prop, const int *array)
+{
+       switch(prop->type) {
+               case PROP_INT: {
+                       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+                       iprop->defaultarray= array;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_int_default: type is not int.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_float_default(PropertyRNA *prop, float value)
+{
+       switch(prop->type) {
+               case PROP_FLOAT: {
+                       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+                       fprop->defaultvalue= value;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_float_default: type is not float.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_float_array_default(PropertyRNA *prop, const float *array)
+{
+       switch(prop->type) {
+               case PROP_FLOAT: {
+                       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+                       fprop->defaultarray= array;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_float_default: type is not float.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_string_default(PropertyRNA *prop, const char *value)
+{
+       switch(prop->type) {
+               case PROP_STRING: {
+                       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+                       sprop->defaultvalue= value;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_string_default: type is not string.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+void RNA_def_property_enum_default(PropertyRNA *prop, int value)
+{
+       switch(prop->type) {
+               case PROP_ENUM: {
+                       EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+                       eprop->defaultvalue= value;
+                       break;
+               }
+               default:
+                       fprintf(stderr, "RNA_def_property_enum_default: type is not enum.\n");
+                       DefRNA.error= 1;
+                       break;
+       }
+}
+
+/* SDNA */
+
+static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *structname, const char *propname)
+{
+       DNAStructMember smember;
+       StructDefRNA *ds= DefRNA.structs.last;
+       PropertyDefRNA *dp= ds->properties.last;
+
+       if(!structname)
+               structname= ds->dnaname;
+       if(!propname)
+               propname= prop->cname;
+
+       if(!rna_find_sdna_member(DefRNA.sdna, structname, propname, &smember)) {
+               if(!DefRNA.silent) {
+                       fprintf(stderr, "rna_def_property_sdna: %s.%s not found.\n", structname, propname);
+                       DefRNA.error= 1;
+               }
+               return NULL;
+       }
+
+       if(smember.arraylength > 1)
+               prop->arraylength= smember.arraylength;
+       else
+               prop->arraylength= 0;
+       
+       dp->dnastructname= structname;
+       dp->dnaname= propname;
+       dp->dnatype= smember.type;
+       dp->dnaarraylength= smember.arraylength;
+
+       return dp;
+}
+
+void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit)
+{
+       PropertyDefRNA *dp;
+       
+       if((dp=rna_def_property_sdna(prop, structname, propname)))
+               dp->booleanbit= bit;
+}
+
+void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
+{
+       PropertyDefRNA *dp;
+       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+       
+       if((dp= rna_def_property_sdna(prop, structname, propname))) {
+               /* SDNA doesn't pass us unsigned unfortunately .. */
+               if(strcmp(dp->dnatype, "char") == 0) {
+                       iprop->hardmin= iprop->softmin= CHAR_MIN;
+                       iprop->hardmax= iprop->softmax= CHAR_MAX;
+               }
+               else if(strcmp(dp->dnatype, "short") == 0) {
+                       iprop->hardmin= iprop->softmin= SHRT_MIN;
+                       iprop->hardmax= iprop->softmax= SHRT_MAX;
+               }
+               else if(strcmp(dp->dnatype, "int") == 0) {
+                       iprop->hardmin= INT_MIN;
+                       iprop->hardmax= INT_MAX;
+
+                       iprop->softmin= -10000; /* rather arbitrary .. */
+                       iprop->softmax= 10000;
+               }
+
+               if(prop->subtype == PROP_UNSIGNED)
+                       iprop->hardmin= iprop->softmin= 0;
+       }
+}
+
+void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
+{
+       rna_def_property_sdna(prop, structname, propname);
+}
+
+void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
+{
+       PropertyDefRNA *dp;
+       
+       if((dp=rna_def_property_sdna(prop, structname, propname))) {
+               if(prop->arraylength) {
+                       prop->arraylength= 0;
+                       if(!DefRNA.silent) {
+                               fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, array not supported for enum type.\n", structname, propname);
+                               DefRNA.error= 1;
+                       }
+               }
+       }
+}
+
+void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
+{
+       PropertyDefRNA *dp;
+       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+
+       if((dp=rna_def_property_sdna(prop, structname, propname))) {
+               if(prop->arraylength) {
+                       sprop->maxlength= prop->arraylength;
+                       prop->arraylength= 0;
+               }
+       }
+}
+
+void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
+{
+       PropertyDefRNA *dp;
+       
+       if((dp=rna_def_property_sdna(prop, structname, propname))) {
+               if(prop->arraylength) {
+                       prop->arraylength= 0;
+                       if(!DefRNA.silent) {
+                               fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, array not supported for pointer type.\n", structname, propname);
+                               DefRNA.error= 1;
+                       }
+               }
+       }
+}
+
+void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname)
+{
+       PropertyDefRNA *dp;
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+       
+       if((dp=rna_def_property_sdna(prop, structname, propname))) {
+               if(prop->arraylength) {
+                       prop->arraylength= 0;
+
+                       if(!DefRNA.silent) {
+                               fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, array not supported for collection type.\n", structname, propname);
+                               DefRNA.error= 1;
+                       }
+               }
+
+               if(strcmp(dp->dnatype, "ListBase") == 0) {
+                       cprop->next= (PropCollectionNextFunc)"rna_iterator_listbase_next";
+                       cprop->get= (PropCollectionGetFunc)"rna_iterator_listbase_get";
+               }
+       }
+}
+
+/* Functions */
+
+void RNA_def_property_notify_func(PropertyRNA *prop, char *notify)
+{
+       if(notify) prop->notify= (PropNotifyFunc)notify;
+}
+
+void RNA_def_property_boolean_funcs(PropertyRNA *prop, char *get, char *set)
+{
+       BooleanPropertyRNA *bprop= (BooleanPropertyRNA*)prop;
+
+       if(prop->arraylength) {
+               if(get) bprop->getarray= (PropBooleanArrayGetFunc)get;
+               if(set) bprop->setarray= (PropBooleanArraySetFunc)set;
+       }
+       else {
+               if(get) bprop->get= (PropBooleanGetFunc)get;
+               if(set) bprop->set= (PropBooleanSetFunc)set;
+       }
+}
+
+void RNA_def_property_int_funcs(PropertyRNA *prop, char *get, char *set)
+{
+       IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
+
+       if(prop->arraylength) {
+               if(get) iprop->getarray= (PropIntArrayGetFunc)get;
+               if(set) iprop->setarray= (PropIntArraySetFunc)set;
+       }
+       else {
+               if(get) iprop->get= (PropIntGetFunc)get;
+               if(set) iprop->set= (PropIntSetFunc)set;
+       }
+}
+
+void RNA_def_property_float_funcs(PropertyRNA *prop, char *get, char *set)
+{
+       FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
+
+       if(prop->arraylength) {
+               if(get) fprop->getarray= (PropFloatArrayGetFunc)get;
+               if(set) fprop->setarray= (PropFloatArraySetFunc)set;
+       }
+       else {
+               if(get) fprop->get= (PropFloatGetFunc)get;
+               if(set) fprop->set= (PropFloatSetFunc)set;
+       }
+}
+
+void RNA_def_property_enum_funcs(PropertyRNA *prop, char *get, char *set)
+{
+       EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
+
+       if(get) eprop->get= (PropEnumGetFunc)get;
+       if(set) eprop->set= (PropEnumSetFunc)set;
+}
+
+void RNA_def_property_string_funcs(PropertyRNA *prop, char *get, char *length, char *set)
+{
+       StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
+
+       if(get) sprop->get= (PropStringGetFunc)get;
+       if(length) sprop->length= (PropStringLengthFunc)length;
+       if(set) sprop->set= (PropStringSetFunc)set;
+}
+
+void RNA_def_property_pointer_funcs(PropertyRNA *prop, char *get, char *type, char *set)
+{
+       PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop;
+
+       if(get) pprop->get= (PropPointerGetFunc)get;
+       if(type) pprop->type= (PropPointerTypeFunc)type;
+       if(set) pprop->set= (PropPointerSetFunc)set;
+}
+
+void RNA_def_property_collection_funcs(PropertyRNA *prop, char *begin, char *next, char *end, char *get, char *type, char *length, char *lookupint, char *lookupstring)
+{
+       CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
+
+       if(begin) cprop->begin= (PropCollectionBeginFunc)begin;
+       if(next) cprop->next= (PropCollectionNextFunc)next;
+       if(end) cprop->end= (PropCollectionEndFunc)end;
+       if(get) cprop->get= (PropCollectionGetFunc)get;
+       if(type) cprop->type= (PropCollectionTypeFunc)type;
+       if(length) cprop->length= (PropCollectionLengthFunc)length;
+       if(lookupint) cprop->lookupint= (PropCollectionLookupIntFunc)lookupint;
+       if(lookupstring) cprop->lookupstring= (PropCollectionLookupStringFunc)lookupstring;
+}
+
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
new file mode 100644 (file)
index 0000000..7c2cb8e
--- /dev/null
@@ -0,0 +1,94 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef RNA_INTERNAL_H
+#define RNA_INTERNAL_H
+
+struct StructRNA;
+struct PropertyRNA;
+struct SDNA;
+struct ListBase;
+
+/* Data structures used during define */
+
+typedef struct PropertyDefRNA {
+       struct PropertyDefRNA *next, *prev;
+
+       struct StructRNA *strct;
+       struct PropertyRNA *prop;
+
+       const char *dnastructname;
+       const char *dnaname;
+       const char *dnatype;
+       int dnaarraylength;
+
+       int booleanbit;
+} PropertyDefRNA;
+
+typedef struct StructDefRNA {
+       struct StructDefRNA *next, *prev;
+
+       struct StructRNA *strct;
+
+       const char *dnaname;
+       ListBase properties;
+} StructDefRNA;
+
+typedef struct AllocDefRNA {
+       struct AllocDefRNA *next, *prev;
+       void *mem;
+} AllocDefRNA;
+
+typedef struct BlenderDefRNA {
+       struct SDNA *sdna;
+       ListBase structs;
+       ListBase allocs;
+       int error, silent;
+} BlenderDefRNA;
+
+extern BlenderDefRNA DefRNA;
+
+/* Define functions for all types */
+
+void RNA_def_object(struct BlenderRNA *brna);
+void RNA_def_scene(struct BlenderRNA *brna);
+
+/* Standard iterator functions */
+
+void rna_iterator_listbase_begin(struct CollectionPropertyIterator *iter, struct ListBase *lb);
+void rna_iterator_listbase_next(struct CollectionPropertyIterator *iter);
+void *rna_iterator_listbase_get(struct CollectionPropertyIterator *iter);
+
+void rna_iterator_array_begin(struct CollectionPropertyIterator *iter, void *ptr, int itemsize, int length);
+void rna_iterator_array_next(struct CollectionPropertyIterator *iter);
+void *rna_iterator_array_get(struct CollectionPropertyIterator *iter);
+void rna_iterator_array_end(struct CollectionPropertyIterator *iter);
+
+/* Duplicated code since we can't link in blenlib */
+
+void rna_addtail(struct ListBase *listbase, void *vlink);
+void rna_freelistN(struct ListBase *listbase);
+
+#endif /* RNA_INTERNAL_H */
+
similarity index 56%
rename from source/blender/blenloader/BLO_genfile.h
rename to source/blender/makesrna/intern/rna_object.c
index 2f5ab21cef02383f1da87b847d31ebc42401e92c..ac1320a52db079d2e8a4a2491d61d7b065038787 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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.
+ * Contributor(s): Blender Foundation (2008).
  *
  * ***** END GPL LICENSE BLOCK *****
- * external genfile function prototypes
  */
 
-#ifndef BLO_GENFILE_H
-#define BLO_GENFILE_H
+#include <stdlib.h>
+
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#include "DNA_object_types.h"
+
+#ifdef RNA_RUNTIME
+
+#else
+
+void RNA_def_object(BlenderRNA *brna)
+{
+       StructRNA *strct;
+       PropertyRNA *prop;
+       
+       strct= RNA_def_struct(brna, "Object", "Object");
+
+       prop= RNA_def_property(strct, "name", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_sdna(prop, "ID", "name");
+       RNA_def_property_ui_text(prop, "Name", "Object ID name.");
+       RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
+
+       RNA_def_struct_name_property(strct, prop);
+}
 
 #endif
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
new file mode 100644 (file)
index 0000000..c26c73f
--- /dev/null
@@ -0,0 +1,115 @@
+/**
+ * $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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * Contributor(s): Blender Foundation (2008).
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdlib.h>
+
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#include "DNA_scene_types.h"
+
+#ifdef RNA_RUNTIME
+
+#include "BKE_global.h"
+
+void *rna_Scene_objects_get(CollectionPropertyIterator *iter)
+{
+       /* we are actually iterating a Base list, so override get */
+       return ((Base*)iter->internal)->object;
+}
+
+/* name functions that ignore the first two ID characters */
+static void rna_ID_name_get(void *data, char *value)
+{
+       BLI_strncpy(value, ((ID*)data)->name+2, sizeof(((ID*)data)->name)-2);
+}
+
+static int rna_ID_name_length(void *data)
+{
+       return strlen(((ID*)data)->name+2);
+}
+
+static void rna_ID_name_set(void *data, const char *value)
+{
+       BLI_strncpy(((ID*)data)->name+2, value, sizeof(((ID*)data)->name)-2);
+}
+
+#else
+
+void RNA_def_scene(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+       static PropertyEnumItem prop_mode_items[] = {{PROP_SMOOTH, "SMOOTH", "Smooth"}, {PROP_SPHERE, "SPHERE", "Sphere"}, {PROP_ROOT, "ROOT", "Root"}, {PROP_SHARP, "SHARP", "Sharp"}, {PROP_LIN, "LINEAR", "Linear"}, {PROP_CONST, "CONSTANT", "Constant"}, {PROP_RANDOM, "RANDOM", "Random"}, {0, NULL, NULL}};
+       static PropertyEnumItem unwrapper_items[] = {{0, "CONFORMAL", "Conformal"}, {1, "ANGLEBASED", "Angle Based"},  {0, NULL, NULL}};
+       
+       srna= RNA_def_struct(brna, "Scene", "Scene");
+
+       prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_sdna(prop, "ID", "name");
+       RNA_def_property_ui_text(prop, "Name", "Object ID name.");
+       RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set");
+
+       RNA_def_struct_name_property(srna, prop);
+
+       prop= RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
+       RNA_def_property_ui_text(prop, "Active Camera", "Active camera used for rendering the scene.");
+
+       prop= RNA_def_property(srna, "cursor", PROP_FLOAT, PROP_VECTOR);
+       RNA_def_property_ui_text(prop, "Cursor Location", "3D cursor location.");
+       RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
+
+       prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
+       RNA_def_property_collection_sdna(prop, NULL, "base");
+       RNA_def_property_struct_type(prop, "Object");
+       RNA_def_property_ui_text(prop, "Objects", "Objects in the scene.");
+       RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Scene_objects_get", 0, 0, 0, 0);
+
+       prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "lay", 1);
+       RNA_def_property_array(prop, 20);
+       RNA_def_property_ui_text(prop, "Visible Layers", "Layers visible when rendering the scene.");
+
+       prop= RNA_def_property(srna, "prop_mode", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_mode_items);
+       RNA_def_property_ui_text(prop, "Proportional Mode", "Proportional edit mode.");
+
+       prop= RNA_def_property(srna, "current_frame", PROP_INT, PROP_NONE);
+       RNA_def_property_int_sdna(prop, NULL, "r.cfra");
+       RNA_def_property_range(prop, MINFRAME, MAXFRAME);
+       RNA_def_property_ui_text(prop, "Current Frame", "Current frame.");
+       RNA_def_property_access(prop, PROP_EDITABLE, 0);
+
+       prop= RNA_def_property(srna, "stamp_note", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_sdna(prop, NULL, "r.stamp_udata");
+       RNA_def_property_ui_text(prop, "Stamp Note", "User define note for the render stamping.");
+
+       prop= RNA_def_property(srna, "unwrapper", PROP_ENUM, PROP_NONE);
+       RNA_def_property_string_sdna(prop, NULL, "toolsettings->unwrapper");
+       RNA_def_property_enum_items(prop, unwrapper_items);
+       RNA_def_property_ui_text(prop, "Unwrapper", "Unwrap algorithm used by the Unwrap tool.");
+}
+
+#endif
+