* 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.
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);
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);
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 */
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);
}
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);
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 {
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);
/* 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);
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);
}
* 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];
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;
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 */