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-14 17:34:19 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-14 17:34:19 +0300
commit4a8e571e8d3b5a4f8d223d40594b1be96206a141 (patch)
treea0e33bd30f37f316a43ef4630ea1d5649cd21fe4 /source/blender/makesrna/intern/rna_rna.c
parent8ba404b0d7d5fb1de1cf93a794587fed85c9d727 (diff)
RNA
* Added accessor functions for structs and properties instead of direct access, in preparation of wrapping ID properties. * Added more error prints for wrong defines. * Wrap RNA data structures with RNA. * Disable dependency code for now to avoid confusion.
Diffstat (limited to 'source/blender/makesrna/intern/rna_rna.c')
-rw-r--r--source/blender/makesrna/intern/rna_rna.c310
1 files changed, 310 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
new file mode 100644
index 00000000000..dc3d2486126
--- /dev/null
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -0,0 +1,310 @@
+/**
+ * $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_access.h"
+#include "RNA_define.h"
+#include "RNA_types.h"
+
+#ifdef RNA_RUNTIME
+
+/* Struct */
+
+static void rna_StructRNA_cname_get(PointerRNA *ptr, char *value)
+{
+ strcpy(value, ((StructRNA*)ptr->data)->cname);
+}
+
+static int rna_StructRNA_cname_length(PointerRNA *ptr)
+{
+ return strlen(((StructRNA*)ptr->data)->cname);
+}
+
+static void rna_StructRNA_name_get(PointerRNA *ptr, char *value)
+{
+ strcpy(value, ((StructRNA*)ptr->data)->name);
+}
+
+static int rna_StructRNA_name_length(PointerRNA *ptr)
+{
+ return strlen(((StructRNA*)ptr->data)->name);
+}
+
+static void *rna_StructRNA_name_property_get(PointerRNA *ptr)
+{
+ return ((StructRNA*)ptr->data)->nameproperty;
+}
+
+static void *rna_StructRNA_iterator_property_get(PointerRNA *ptr)
+{
+ return ((StructRNA*)ptr->data)->iteratorproperty;
+}
+
+static void rna_StructRNA_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ rna_iterator_listbase_begin(iter, &((StructRNA*)ptr->data)->properties);
+}
+
+static void rna_StructRNA_properties_next(CollectionPropertyIterator *iter)
+{
+ rna_iterator_listbase_next(iter);
+}
+
+static void *rna_StructRNA_properties_get(CollectionPropertyIterator *iter)
+{
+ return rna_iterator_listbase_get(iter);
+}
+
+static StructRNA *rna_StructRNA_properties_type(CollectionPropertyIterator *iter)
+{
+ PropertyRNA *prop= iter->internal;
+
+ switch(prop->type) {
+ case PROP_BOOLEAN: return &RNA_BooleanPropertyRNA;
+ case PROP_INT: return &RNA_IntPropertyRNA;
+ case PROP_FLOAT: return &RNA_FloatPropertyRNA;
+ case PROP_STRING: return &RNA_StringPropertyRNA;
+ case PROP_ENUM: return &RNA_EnumPropertyRNA;
+ case PROP_POINTER: return &RNA_PointerPropertyRNA;
+ case PROP_COLLECTION: return &RNA_CollectionPropertyRNA;
+ default: return NULL;
+ }
+}
+
+static void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ PointerRNA newptr;
+
+ /* we create a new with the type as the data */
+ newptr.type= &RNA_StructRNA;
+ newptr.data= ptr->type;
+
+ if(ptr->type->flag & STRUCT_ID) {
+ newptr.id.type= ptr->type;
+ newptr.id.data= ptr->data;
+ }
+ else {
+ newptr.id.type= NULL;
+ newptr.id.data= NULL;
+ }
+
+ rna_StructRNA_properties_begin(iter, &newptr);
+}
+
+static void rna_builtin_properties_next(CollectionPropertyIterator *iter)
+{
+ rna_StructRNA_properties_next(iter);
+}
+
+static void *rna_builtin_properties_get(CollectionPropertyIterator *iter)
+{
+ return rna_StructRNA_properties_get(iter);
+}
+
+static StructRNA *rna_builtin_properties_type(CollectionPropertyIterator *iter)
+{
+ return rna_StructRNA_properties_type(iter);
+}
+
+static void *rna_builtin_type_get(PointerRNA *ptr)
+{
+ return ptr->type;
+}
+
+/* Property */
+
+static void rna_PropertyRNA_cname_get(PointerRNA *ptr, char *value)
+{
+ strcpy(value, ((PropertyRNA*)ptr->data)->cname);
+}
+
+static int rna_PropertyRNA_cname_length(PointerRNA *ptr)
+{
+ return strlen(((PropertyRNA*)ptr->data)->cname);
+}
+
+static void rna_PropertyRNA_name_get(PointerRNA *ptr, char *value)
+{
+ strcpy(value, ((PropertyRNA*)ptr->data)->name);
+}
+
+static int rna_PropertyRNA_name_length(PointerRNA *ptr)
+{
+ return strlen(((PropertyRNA*)ptr->data)->name);
+}
+
+static void rna_PropertyRNA_description_get(PointerRNA *ptr, char *value)
+{
+ strcpy(value, ((PropertyRNA*)ptr->data)->description);
+}
+
+static int rna_PropertyRNA_description_length(PointerRNA *ptr)
+{
+ return strlen(((PropertyRNA*)ptr->data)->description);
+}
+
+static int rna_PropertyRNA_type_get(PointerRNA *ptr)
+{
+ return ((PropertyRNA*)ptr->data)->type;
+}
+
+static int rna_PropertyRNA_subtype_get(PointerRNA *ptr)
+{
+ return ((PropertyRNA*)ptr->data)->subtype;
+}
+
+static int rna_PropertyRNA_array_length_get(PointerRNA *ptr)
+{
+ return ((PropertyRNA*)ptr->data)->arraylength;
+}
+
+#else
+
+static void rna_def_property(StructRNA *srna)
+{
+ PropertyRNA *prop;
+ static PropertyEnumItem type_items[] = {
+ {PROP_BOOLEAN, "BOOLEAN", "Boolean"},
+ {PROP_INT, "INT", "Integer"},
+ {PROP_FLOAT, "FLOAT", "Float"},
+ {PROP_STRING, "STRING", "String"},
+ {PROP_ENUM, "ENUM", "Enumeration"},
+ {PROP_POINTER, "POINTER", "Pointer"},
+ {PROP_COLLECTION, "COLLECTION", "Collection"},
+ {0, NULL, NULL}};
+ static PropertyEnumItem subtype_items[] = {
+ {PROP_NONE, "NONE", "None"},
+ {PROP_UNSIGNED, "UNSIGNED", "Unsigned Number"},
+ {PROP_FILEPATH, "FILEPATH", "File Path"},
+ {PROP_COLOR, "COLOR", "Color"},
+ {PROP_VECTOR, "VECTOR", "Vector"},
+ {PROP_MATRIX, "MATRIX", "Matrix"},
+ {PROP_ROTATION, "ROTATION", "Rotation"},
+ {0, NULL, NULL}};
+
+ prop= RNA_def_property(srna, "cname", PROP_STRING, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_PropertyRNA_cname_get", "rna_PropertyRNA_cname_length", NULL);
+
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_PropertyRNA_name_get", "rna_PropertyRNA_name_length", NULL);
+ RNA_def_struct_name_property(srna, prop);
+
+ prop= RNA_def_property(srna, "description", PROP_STRING, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_PropertyRNA_description_get", "rna_PropertyRNA_description_length", NULL);
+
+ prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_enum_items(prop, type_items);
+ RNA_def_property_enum_funcs(prop, "rna_PropertyRNA_type_get", NULL);
+
+ prop= RNA_def_property(srna, "subtype", PROP_ENUM, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_enum_items(prop, subtype_items);
+ RNA_def_property_enum_funcs(prop, "rna_PropertyRNA_subtype_get", NULL);
+
+ prop= RNA_def_property(srna, "array_length", PROP_INT, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_int_funcs(prop, "rna_PropertyRNA_array_length_get", NULL);
+}
+
+void RNA_def_rna(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ /* StructRNA */
+ srna= RNA_def_struct(brna, "StructRNA", "Struct RNA");
+
+ prop= RNA_def_property(srna, "cname", PROP_STRING, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_StructRNA_cname_get", "rna_StructRNA_cname_length", NULL);
+
+ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_StructRNA_name_get", "rna_StructRNA_name_length", NULL);
+ RNA_def_struct_name_property(srna, prop);
+
+ prop= RNA_def_property(srna, "name_property", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_struct_type(prop, "StringPropertyRNA");
+ RNA_def_property_pointer_funcs(prop, "rna_StructRNA_name_property_get", NULL, NULL);
+
+ prop= RNA_def_property(srna, "iterator_property", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_struct_type(prop, "CollectionPropertyRNA");
+ RNA_def_property_pointer_funcs(prop, "rna_StructRNA_iterator_property_get", NULL, NULL);
+
+ prop= RNA_def_property(srna, "properties", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
+ RNA_def_property_collection_funcs(prop, "rna_StructRNA_properties_begin", "rna_StructRNA_properties_next", 0, "rna_StructRNA_properties_get", "rna_StructRNA_properties_type", 0, 0, 0);
+
+ /* BooleanPropertyRNA */
+ srna= RNA_def_struct(brna, "BooleanPropertyRNA", "Boolean Property");
+ rna_def_property(srna);
+
+ /* IntPropertyRNA */
+ srna= RNA_def_struct(brna, "IntPropertyRNA", "Int Property");
+ rna_def_property(srna);
+
+ /* FloatPropertyRNA */
+ srna= RNA_def_struct(brna, "FloatPropertyRNA", "Float Property");
+ rna_def_property(srna);
+
+ /* StringPropertyRNA */
+ srna= RNA_def_struct(brna, "StringPropertyRNA", "String Property");
+ rna_def_property(srna);
+
+ /* EnumPropertyRNA */
+ srna= RNA_def_struct(brna, "EnumPropertyRNA", "Enum Property");
+ rna_def_property(srna);
+
+ /* PointerPropertyRNA */
+ srna= RNA_def_struct(brna, "PointerPropertyRNA", "Pointer Property");
+ rna_def_property(srna);
+
+ /* CollectionPropertyRNA */
+ srna= RNA_def_struct(brna, "CollectionPropertyRNA", "Collection Property");
+ rna_def_property(srna);
+}
+
+void rna_def_builtin_properties(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop= RNA_def_property(srna, "rna_properties", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE|PROP_BUILTIN);
+ RNA_def_property_collection_funcs(prop, "rna_builtin_properties_begin", "rna_builtin_properties_next", 0, "rna_builtin_properties_get", "rna_builtin_properties_type", 0, 0, 0);
+
+ prop= RNA_def_property(srna, "rna_type", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_NOT_EDITABLE|PROP_BUILTIN);
+ RNA_def_property_struct_type(prop, "StructRNA");
+ RNA_def_property_pointer_funcs(prop, "rna_builtin_type_get", NULL, NULL);
+}
+
+#endif
+