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:
authorElia Sarti <vekoon@gmail.com>2009-07-01 23:56:50 +0400
committerElia Sarti <vekoon@gmail.com>2009-07-01 23:56:50 +0400
commit594c8802d748dc0701af491e8a2c590f2d2e0038 (patch)
treec9c4d99655248198dea7240323a76993d00a181a
parent1a86cd6dcda1b6bca338d096b6a4b332d0b39822 (diff)
Added support for collection parameters also for RNA_function_call_direct family of functions. The syntax for passing collection parameters is similar to passing pointers where you pass first the RNA type and then the ListBase representing the collection. The format specifier is "C" instead of "O", e.g.
RNA_function_call_direct_lookup(C, reports, ptr, "do_something", "sC", "some string value", &RNA_SomeItemType, listbase); Note that from python you could in theory pass collections of items each of a different type while using this API you can't. I don't think this should be a problem as RNA supports collections this way anyway (i.e. where items are all of the same type or inherit from the same base type). Also a small fix for pointer parameters.
-rw-r--r--source/blender/makesrna/intern/rna_access.c60
1 files changed, 49 insertions, 11 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 9ebb778707c..cc8704dc350 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -3050,23 +3050,46 @@ static int rna_function_parameter_parse(PointerRNA *ptr, PropertyRNA *prop, Prop
if(prop->flag & PROP_RNAPTR) {
*((PointerRNA*)dest)= *((PointerRNA*)src);
+ break;
+ }
+
+ if (ptype!=srna && !RNA_struct_is_a(srna, ptype)) {
+ fprintf(stderr, "%s.%s: wrong type for parameter %s, an object of type %s was expected, passed an object of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna));
+ return -1;
}
- else if (ptype!=srna) {
- if (!RNA_struct_is_a(srna, ptype)) {
- fprintf(stderr, "%s.%s: wrong type for parameter %s, an object of type %s was expected, passed an object of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(ptype));
- return -1;
- }
-
- *((void**)dest)= *((void**)src);
- }
+
+ *((void**)dest)= *((void**)src);
break;
}
case PROP_COLLECTION:
{
- /* XXX collections are not supported yet */
- fprintf(stderr, "%s.%s: for parameter %s, collections are not supported yet\n", tid, fid, pid);
- return -1;
+ StructRNA *ptype;
+ ListBase *lb, *clb;
+ Link *link;
+ CollectionPointerLink *clink;
+
+ if (ftype!='C') {
+ fprintf(stderr, "%s.%s: wrong type for parameter %s, a collection was expected\n", tid, fid, pid);
+ return -1;
+ }
+
+ lb= (ListBase *)src;
+ clb= (ListBase *)dest;
+ ptype= RNA_property_pointer_type(ptr, prop);
+
+ if (ptype!=srna && !RNA_struct_is_a(srna, ptype)) {
+ fprintf(stderr, "%s.%s: wrong type for parameter %s, a collection of objects of type %s was expected, passed a collection of objects of type %s\n", tid, fid, pid, RNA_struct_identifier(ptype), RNA_struct_identifier(srna));
+ return -1;
+ }
+
+ for (link= lb->first; link; link= link->next) {
+ clink= MEM_callocN(sizeof(CollectionPointerLink), "CCollectionPointerLink");
+ RNA_pointer_create(NULL, srna, link, &clink->ptr);
+ BLI_addtail(clb, clink);
+ }
+
+ break;
}
default:
{
@@ -3164,6 +3187,13 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt
err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, iter.data, &arg, srna, tid, fid, pid);
break;
}
+ case PROP_COLLECTION:
+ {
+ StructRNA *srna= va_arg(args, StructRNA*);
+ ListBase *arg= va_arg(args, ListBase*);
+ err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, iter.data, &arg, srna, tid, fid, pid);
+ break;
+ }
default:
{
/* handle errors */
@@ -3221,6 +3251,13 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt
err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, arg, retdata, srna, tid, fid, pid);
break;
}
+ case PROP_COLLECTION:
+ {
+ StructRNA *srna= va_arg(args, StructRNA*);
+ ListBase **arg= va_arg(args, ListBase**);
+ err= rna_function_parameter_parse(&funcptr, parm, type, ftype, len, arg, retdata, srna, tid, fid, pid);
+ break;
+ }
default:
{
/* handle errors */
@@ -3249,3 +3286,4 @@ int RNA_function_call_direct_va_lookup(bContext *C, ReportList *reports, Pointer
return 0;
}
+