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-27 01:24:26 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-27 01:24:26 +0300
commite384ad573ac71d065ad27e139039af0b711be8dd (patch)
treee145011cdf8e10cda0e65db32d4fad0fcf4b710e /source/blender/makesrna
parent03f9b732165b9a2bc35d1b7e46411cb69d076d61 (diff)
RNA
* Made auto collection wrapping work for ** arrays. (Mesh.mats, still points to ID since there is no Material yet). * Added sorting of RNA structs/properties before writing.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/SConscript2
-rw-r--r--source/blender/makesrna/intern/makesrna.c61
-rw-r--r--source/blender/makesrna/intern/rna_access.c8
-rw-r--r--source/blender/makesrna/intern/rna_define.c15
-rw-r--r--source/blender/makesrna/intern/rna_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_mesh.c8
6 files changed, 89 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript
index e493e274690..f8d623dfa2b 100644
--- a/source/blender/makesrna/intern/SConscript
+++ b/source/blender/makesrna/intern/SConscript
@@ -3,7 +3,7 @@ import sys
import os
Import ('env')
-cflags = '-Wall'
+cflags = ''
defines = []
root_build_dir=env['BF_BUILDDIR']
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index 2f110b764a5..d9db1121ba2 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -44,6 +44,56 @@
#endif
#endif
+int cmp_struct(const void *a, const void *b)
+{
+ const StructRNA *structa= *(const StructRNA**)a;
+ const StructRNA *structb= *(const StructRNA**)b;
+
+ return strcmp(structa->identifier, structb->identifier);
+}
+
+int cmp_property(const void *a, const void *b)
+{
+ const PropertyRNA *propa= *(const PropertyRNA**)a;
+ const PropertyRNA *propb= *(const PropertyRNA**)b;
+
+ if(strcmp(propa->identifier, "rna_type") == 0) return -1;
+ else if(strcmp(propb->identifier, "rna_type") == 0) return 1;
+
+ if(strcmp(propa->identifier, "name") == 0) return -1;
+ else if(strcmp(propb->identifier, "name") == 0) return 1;
+
+ return strcmp(propa->name, propb->name);
+}
+
+void rna_sortlist(ListBase *listbase, int(*cmp)(const void*, const void*))
+{
+ Link *link;
+ void **array;
+ int a, size;
+
+ if(listbase->first == listbase->last)
+ return;
+
+ for(size=0, link=listbase->first; link; link=link->next)
+ size++;
+
+ array= MEM_mallocN(sizeof(void*)*size, "rna_sortlist");
+ for(a=0, link=listbase->first; link; link=link->next, a++)
+ array[a]= link;
+
+ qsort(array, size, sizeof(void*), cmp);
+
+ listbase->first= listbase->last= NULL;
+ for(a=0; a<size; a++) {
+ link= array[a];
+ link->next= link->prev= NULL;
+ rna_addtail(listbase, link);
+ }
+
+ MEM_freeN(array);
+}
+
/* Preprocessing */
static void rna_print_c_string(FILE *f, const char *str)
@@ -499,6 +549,16 @@ static void rna_auto_functions(FILE *f)
rna_def_property_funcs(f, dp);
}
+static void rna_sort(BlenderRNA *brna)
+{
+ StructRNA *srna;
+
+ rna_sortlist(&brna->structs, cmp_struct);
+
+ for(srna=brna->structs.first; srna; srna=srna->next)
+ rna_sortlist(&srna->properties, cmp_property);
+}
+
static const char *rna_property_structname(PropertyType type)
{
switch(type) {
@@ -830,6 +890,7 @@ static int rna_preprocess(char *basedirectory, FILE *f)
fprintf(f, "\n");
rna_auto_functions(f);
+ rna_sort(brna);
for(srna=brna->structs.first; srna; srna=srna->next)
rna_generate_struct(brna, srna, f);
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 488a4958830..7351ff700e6 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1106,6 +1106,14 @@ void *rna_iterator_array_get(CollectionPropertyIterator *iter)
return internal->ptr;
}
+void *rna_iterator_array_dereference_get(CollectionPropertyIterator *iter)
+{
+ ArrayIterator *internal= iter->internal;
+
+ /* for ** arrays */
+ return *(void**)(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
index 9d9606809f6..63df7252e9e 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -97,6 +97,7 @@ typedef struct DNAStructMember {
char *type;
char *name;
int arraylength;
+ int pointerlevel;
} DNAStructMember;
static int rna_member_cmp(const char *name, const char *oname)
@@ -125,7 +126,7 @@ static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *
{
char *dnaname;
short *sp;
- int a, structnr, totmember, cmp;
+ int a, b, structnr, totmember, cmp;
structnr= DNA_struct_find_nr(sdna, structname);
if(structnr == -1)
@@ -144,6 +145,11 @@ static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *
smember->type= sdna->types[sp[0]];
smember->name= dnaname;
smember->arraylength= DNA_elem_array_size(smember->name, strlen(smember->name));
+
+ smember->pointerlevel= 0;
+ for(b=0; dnaname[b] == '*'; b++)
+ smember->pointerlevel++;
+
return 1;
}
else if(cmp == 2) {
@@ -864,6 +870,7 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *stru
dp->dnaname= propname;
dp->dnatype= smember.type;
dp->dnaarraylength= smember.arraylength;
+ dp->dnapointerlevel= smember.pointerlevel;
return dp;
}
@@ -1077,8 +1084,12 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
dp->dnalengthname= lengthpropname;
cprop->next= (PropCollectionNextFunc)"rna_iterator_array_next";
- cprop->get= (PropCollectionGetFunc)"rna_iterator_array_get";
cprop->end= (PropCollectionEndFunc)"rna_iterator_array_end";
+
+ if(dp->dnapointerlevel >= 2)
+ cprop->get= (PropCollectionGetFunc)"rna_iterator_array_dereference_get";
+ else
+ cprop->get= (PropCollectionGetFunc)"rna_iterator_array_get";
}
}
}
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h
index f5079ac437f..03ef6016c07 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -46,6 +46,7 @@ typedef struct PropertyDefRNA {
const char *dnalengthname;
const char *dnatype;
int dnaarraylength;
+ int dnapointerlevel;
int booleanbit;
} PropertyDefRNA;
@@ -136,6 +137,7 @@ typedef struct ArrayIterator {
void rna_iterator_array_begin(struct CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, IteratorSkipFunc skip);
void rna_iterator_array_next(struct CollectionPropertyIterator *iter);
void *rna_iterator_array_get(struct CollectionPropertyIterator *iter);
+void *rna_iterator_array_dereference_get(struct CollectionPropertyIterator *iter);
void rna_iterator_array_end(struct CollectionPropertyIterator *iter);
/* Duplicated code since we can't link in blenlib */
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c
index 369bd1a5d37..522641318bc 100644
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@ -721,7 +721,7 @@ static void rna_def_mcol(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_MCol_color4_get", "rna_MCol_color4_set", NULL);
RNA_def_property_ui_text(prop, "Color 4", "");
- srna= RNA_def_struct(brna, "MColLayer", NULL, "Mesh Texture Face Layer");
+ srna= RNA_def_struct(brna, "MColLayer", NULL, "Mesh Vertex Color Layer");
RNA_def_struct_sdna(srna, "CustomDataLayer");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
@@ -937,10 +937,10 @@ static void rna_def_mesh(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "mr");
RNA_def_property_ui_text(prop, "Multires", "");
- /*prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
+ prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
- RNA_def_property_struct_type(prop, "Material");
- RNA_def_property_ui_text(prop, "Materials", "");*/
+ RNA_def_property_struct_type(prop, "ID");
+ RNA_def_property_ui_text(prop, "Materials", "");
/*prop= RNA_def_property(srna, "key", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Key", "");*/