2.5/RNA:
authorNicholas Bishop <nicholasbishop@gmail.com>
Sun, 16 Aug 2009 14:43:08 +0000 (14:43 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Sun, 16 Aug 2009 14:43:08 +0000 (14:43 +0000)
* Added Context access to RNA_property_as_string. This is needed for doing a Python call to the object mode set operator, which has a dynamic enum property that needs context.

source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_regions.c
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_access.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_operators.c

index 6f438edc9662cd863b16fe12b55375f47a666266..e3518b446ba17b805df42fc8425285e7790693d4 100644 (file)
@@ -974,7 +974,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data,
                        char *str;
                        opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
 
-                       str= WM_operator_pystring(but->optype, opptr, 0);
+                       str= WM_operator_pystring(C, but->optype, opptr, 0);
 
                        WM_clipboard_text_set(str, 0);
 
index b59db0556471ff2d8555b1fa8f3b8498c6772983..bf9217155247d1836eb9e440f467561f756b01d3 100644 (file)
@@ -396,7 +396,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                char *str;
                opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */
 
-               str= WM_operator_pystring(but->optype, opptr, 0);
+               str= WM_operator_pystring(C, but->optype, opptr, 0);
 
                /* operator info */
                BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str);
index 7dd7e3714a43d78992f700b4d7e44205a63dc2a7..95c46515204e41d73e67bced1cc425431dbcd3bf 100644 (file)
@@ -767,7 +767,7 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name);
 int RNA_property_is_set(PointerRNA *ptr, const char *name);
 
 /* python compatible string representation of this property, (must be freed!) */
-char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop);
+char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop);
 char *RNA_pointer_as_string(PointerRNA *ptr);
 
 /* Function */
index 9db4210c9ccc50bd7f45a4753daf31bcc1a1beea..0ddbfb46f81ed65dd1df3a5649db28e46840ba6d 100644 (file)
@@ -2647,7 +2647,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr)
                        BLI_dynstr_append(dynstr, ", ");
                first_time= 0;
                
-               cstring = RNA_property_as_string(ptr, prop);
+               cstring = RNA_property_as_string(NULL, ptr, prop);
                BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
                MEM_freeN(cstring);
        }
@@ -2661,7 +2661,7 @@ char *RNA_pointer_as_string(PointerRNA *ptr)
        return cstring;
 }
 
-char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
+char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
 {
        int type = RNA_property_type(prop);
        int len = RNA_property_array_length(prop);
@@ -2730,7 +2730,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
                const char *identifier;
                int val = RNA_property_enum_get(ptr, prop);
 
-               if(RNA_property_enum_identifier(NULL, ptr, prop, val, &identifier)) {
+               if(RNA_property_enum_identifier(C, ptr, prop, val, &identifier)) {
                        BLI_dynstr_appendf(dynstr, "'%s'", identifier);
                }
                else {
index decd855eae06685c960cbc6b63b02488841f21c4..0f5558382c4b50f3cca26f0367ae35d0945e5681 100644 (file)
@@ -172,7 +172,7 @@ void                WM_operator_properties_free(struct PointerRNA *ptr);
 void           WM_operator_properties_filesel(struct wmOperatorType *ot, int filter);
 
                /* operator as a python command (resultuing string must be free'd) */
-char           *WM_operator_pystring(struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args);
+char           *WM_operator_pystring(struct bContext *C, struct wmOperatorType *ot, struct PointerRNA *opptr, int all_args);
 void           WM_operator_bl_idname(char *to, const char *from);
 void           WM_operator_py_idname(char *to, const char *from);
 
index 406541d62ba3f3e0004689893e4ec8d297f1c43b..85f8a64782629672940318c2c818792b7a639eb2 100644 (file)
@@ -103,7 +103,7 @@ void wm_operator_register(bContext *C, wmOperator *op)
        
        
        /* Report the string representation of the operator */
-       buf = WM_operator_pystring(op->type, op->ptr, 1);
+       buf = WM_operator_pystring(C, op->type, op->ptr, 1);
        BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf);
        MEM_freeN(buf);
        
index dbb4086c541deafa2018a200b5e6606540da9421..05be825b3bd806172f30d5cd2eff7b9bf48206f3 100644 (file)
@@ -370,7 +370,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, wmOperatorType *ot, P
 
 static void wm_operator_print(wmOperator *op)
 {
-       char *buf = WM_operator_pystring(op->type, op->ptr, 1);
+       char *buf = WM_operator_pystring(NULL, op->type, op->ptr, 1);
        printf("%s\n", buf);
        MEM_freeN(buf);
 }
index 41613d0ab78131a849b2cd9dfd8c438a1e0b3fba..dd4728d97affd2fb785599e8a4f39896b83a48c6 100644 (file)
@@ -345,7 +345,7 @@ void WM_operator_bl_idname(char *to, const char *from)
  * When calling from an existing wmOperator do.
  * WM_operator_pystring(op->type, op->ptr);
  */
-char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args)
+char *WM_operator_pystring(bContext *C, wmOperatorType *ot, PointerRNA *opptr, int all_args)
 {
        const char *arg_name= NULL;
        char idname_py[OP_MAX_TYPENAME];
@@ -378,7 +378,7 @@ char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args)
 
                if (strcmp(arg_name, "rna_type")==0) continue;
 
-               buf= RNA_property_as_string(opptr, prop);
+               buf= RNA_property_as_string(C, opptr, prop);
                
                ok= 1;
 
@@ -388,7 +388,7 @@ char *WM_operator_pystring(wmOperatorType *ot, PointerRNA *opptr, int all_args)
                        prop_default= RNA_struct_find_property(&opptr_default, arg_name);
 
                        if(prop_default) {
-                               buf_default= RNA_property_as_string(&opptr_default, prop_default);
+                               buf_default= RNA_property_as_string(C, &opptr_default, prop_default);
 
                                if(strcmp(buf, buf_default)==0)
                                        ok= 0; /* values match, dont bother printing */