Revision: 21292
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21292
Author: vekoon
Date: 2009-07-01 21:56:50 +0200 (Wed, 01 Jul 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
Modified:
branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
2009-07-01 18:23:11 UTC (rev 21291)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
2009-07-01 19:56:50 UTC (rev 21292)
@@ -3050,23 +3050,46 @@
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 @@
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 @@
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 @@
return 0;
}
+
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs