Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-01 02:50:02 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-01 02:50:02 +0300
commit7f24dbe5fc5a00ee161717070deb6baf4af8e83e (patch)
tree3d62a641123bdd8c61e9d2bf5b40203befac2597 /source/blender/makesrna
parentb589489ef8d56976165fb88ebf7b59dbc417d443 (diff)
RNA / Data API
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.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/Makefile31
-rw-r--r--source/blender/makesrna/RNA_access.h75
-rw-r--r--source/blender/makesrna/RNA_define.h96
-rw-r--r--source/blender/makesrna/RNA_types.h247
-rw-r--r--source/blender/makesrna/SConscript11
-rw-r--r--source/blender/makesrna/intern/Makefile79
-rw-r--r--source/blender/makesrna/intern/SConscript49
-rw-r--r--source/blender/makesrna/intern/makesrna.c780
-rw-r--r--source/blender/makesrna/intern/rna_access.c411
-rw-r--r--source/blender/makesrna/intern/rna_define.c847
-rw-r--r--source/blender/makesrna/intern/rna_internal.h94
-rw-r--r--source/blender/makesrna/intern/rna_object.c52
-rw-r--r--source/blender/makesrna/intern/rna_scene.c115
13 files changed, 2887 insertions, 0 deletions
diff --git a/source/blender/makesrna/Makefile b/source/blender/makesrna/Makefile
new file mode 100644
index 00000000000..bed3e85550d
--- /dev/null
+++ b/source/blender/makesrna/Makefile
@@ -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
index 00000000000..828bcff82b1
--- /dev/null
+++ b/source/blender/makesrna/RNA_access.h
@@ -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
index 00000000000..0eb96da4d1f
--- /dev/null
+++ b/source/blender/makesrna/RNA_define.h
@@ -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
index 00000000000..9faa8b2fd8e
--- /dev/null
+++ b/source/blender/makesrna/RNA_types.h
@@ -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
index 00000000000..a580072895a
--- /dev/null
+++ b/source/blender/makesrna/SConscript
@@ -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
index 00000000000..475e3944397
--- /dev/null
+++ b/source/blender/makesrna/intern/Makefile
@@ -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
index 00000000000..1dfc5df4202
--- /dev/null
+++ b/source/blender/makesrna/intern/SConscript
@@ -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
index 00000000000..2ac287bfce2
--- /dev/null
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -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
index 00000000000..af4a4b47cb3
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -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
index 00000000000..b3399df67ab
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -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
index 00000000000..7c2cb8e36be
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -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 */
+
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
new file mode 100644
index 00000000000..ac1320a52db
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -0,0 +1,52 @@
+/**
+ * $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_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
index 00000000000..c26c73f011d
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -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
+