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:
authorCampbell Barton <ideasman42@gmail.com>2010-08-23 09:36:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-23 09:36:21 +0400
commitf956e94d131c55625a03569a7bb19d36d4aac9d3 (patch)
tree307e1f3aff79f65cc8893a701b0e57c5e7159604 /source/blender/makesrna/intern/rna_access.c
parent51c0e9b87c971e443d526eaeb4c35af0660e90c8 (diff)
collection attributes can now be resolved with by rna
this now works... bpy.context.scene.path_resolve("objects.active.location") Also added an option to coerce the property into a native pytype.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r--source/blender/makesrna/intern/rna_access.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 73af75ca960..cdb032b54af 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -2949,7 +2949,7 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr,
PropertyRNA *prop;
PointerRNA curptr, nextptr;
char fixedbuf[256], *token;
- int type, len, intkey;
+ int type, intkey;
prop= NULL;
curptr= *ptr;
@@ -3001,33 +3001,44 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr,
break;
case PROP_COLLECTION:
if(*path) {
- /* resolve the lookup with [] brackets */
- token= rna_path_token(&path, fixedbuf, sizeof(fixedbuf), 1);
-
- if(!token)
- return 0;
-
- len= strlen(token);
+ if(*path == '[') {
+ /* resolve the lookup with [] brackets */
+ token= rna_path_token(&path, fixedbuf, sizeof(fixedbuf), 1);
+
+ if(!token)
+ return 0;
+
+ /* check for "" to see if it is a string */
+ if(rna_token_strip_quotes(token)) {
+ RNA_property_collection_lookup_string(&curptr, prop, token+1, &nextptr);
+ }
+ else {
+ /* otherwise do int lookup */
+ intkey= atoi(token);
+ RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr);
+ }
- /* check for "" to see if it is a string */
- if(rna_token_strip_quotes(token)) {
- RNA_property_collection_lookup_string(&curptr, prop, token+1, &nextptr);
+ if(token != fixedbuf) {
+ MEM_freeN(token);
+ }
}
else {
- /* otherwise do int lookup */
- intkey= atoi(token);
- RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr);
- }
+ PointerRNA c_ptr;
+
+ /* ensure we quit on invalid values */
+ nextptr.data = NULL;
- if(token != fixedbuf)
- MEM_freeN(token);
+ if(RNA_property_collection_type_get(&curptr, prop, &c_ptr)) {
+ nextptr= c_ptr;
+ }
+ }
if(nextptr.data)
curptr= nextptr;
else
return 0;
}
-
+
break;
default:
if (index==NULL)