void RNA_struct_property_unset(PointerRNA *ptr, const char *identifier);
/* python compatible string representation of this property, (must be freed!) */
-char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index);
+char *RNA_property_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length);
char *RNA_pointer_as_string(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop);
char *RNA_pointer_as_string_keywords_ex(struct bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
const short skip_optional_value, const short all_args,
+ const int max_prop_length,
PropertyRNA *iterprop);
char *RNA_pointer_as_string_keywords(struct bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
- const short skip_optional_value, const short all_args);
+ const short skip_optional_value, const short all_args,
+ const int max_prop_length);
char *RNA_function_as_string_keywords(struct bContext *C, FunctionRNA *func, PointerRNA *ptr_default,
- const short as_function, const short all_args);
+ const short as_function, const short all_args,
+ const int max_prop_length);
/* Function */
BLI_dynstr_append(dynstr, ", ");
first_time = 0;
- cstring = RNA_property_as_string(C, ptr, prop, -1);
+ cstring = RNA_property_as_string(C, ptr, prop, -1, INT_MAX);
BLI_dynstr_appendf(dynstr, "\"%s\":%s", propname, cstring);
MEM_freeN(cstring);
}
/* context and ptr_default can be NULL */
char *RNA_pointer_as_string_keywords_ex(bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
const short as_function, const short all_args,
+ const int max_prop_length,
PropertyRNA *iterprop)
{
const char *arg_name = NULL;
}
}
else {
- buf = RNA_property_as_string(C, ptr, prop, -1);
+ buf = RNA_property_as_string(C, ptr, prop, -1, max_prop_length);
}
ok = TRUE;
prop_default = RNA_struct_find_property(ptr_default, arg_name);
if (prop_default) {
- buf_default = RNA_property_as_string(C, ptr_default, prop_default, -1);
+ buf_default = RNA_property_as_string(C, ptr_default, prop_default, -1, max_prop_length);
if (strcmp(buf, buf_default) == 0)
ok = FALSE; /* values match, don't bother printing */
}
char *RNA_pointer_as_string_keywords(bContext *C, PointerRNA *ptr, PointerRNA *ptr_default,
- const short as_function, const short all_args)
+ const short as_function, const short all_args,
+ const int max_prop_length)
{
PropertyRNA *iterprop;
iterprop = RNA_struct_iterator_property(ptr->type);
return RNA_pointer_as_string_keywords_ex(C, ptr, ptr_default, as_function, all_args,
- iterprop);
+ max_prop_length, iterprop);
}
char *RNA_function_as_string_keywords(bContext *C, FunctionRNA *func, PointerRNA *ptr_default,
- const short as_function, const short all_args)
+ const short as_function, const short all_args,
+ const int max_prop_length)
{
PointerRNA funcptr;
PropertyRNA *iterprop;
RNA_struct_iterator_property(funcptr.type);
return RNA_pointer_as_string_keywords_ex(C, &funcptr, ptr_default, as_function, all_args,
- iterprop);
+ max_prop_length, iterprop);
}
static const char *bool_as_py_string(const int var)
return var ? "True" : "False";
}
-char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index)
+char *RNA_property_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop, int index, int max_prop_length)
{
int type = RNA_property_type(prop);
int len = RNA_property_array_length(ptr, prop);
}
case PROP_COLLECTION:
{
- int first_time = 1;
+ int i = 0;
CollectionPropertyIterator collect_iter;
BLI_dynstr_append(dynstr, "[");
- for (RNA_property_collection_begin(ptr, prop, &collect_iter); collect_iter.valid;
- RNA_property_collection_next(&collect_iter))
+ for (RNA_property_collection_begin(ptr, prop, &collect_iter);
+ (i < max_prop_length) && collect_iter.valid;
+ RNA_property_collection_next(&collect_iter), i++)
{
PointerRNA itemptr = collect_iter.ptr;
- if (first_time == 0)
+ if (i != 0)
BLI_dynstr_append(dynstr, ", ");
- first_time = 0;
/* now get every prop of the collection */
cstring = RNA_pointer_as_string(C, ptr, prop, &itemptr);
char *cstring;
char *cstring_args;
+ /* arbitrary, but can get huge string with stroke painting otherwise */
+ int max_prop_length = 10;
+
/* only to get the orginal props for comparisons */
PointerRNA opptr_default;
WM_operator_py_idname(idname_py, ot->idname);
BLI_dynstr_appendf(dynstr, "bpy.ops.%s(", idname_py);
- cstring_args = RNA_pointer_as_string_keywords(C, opptr, &opptr_default, FALSE, all_args);
+ cstring_args = RNA_pointer_as_string_keywords(C, opptr, &opptr_default, FALSE,
+ all_args, max_prop_length);
BLI_dynstr_append(dynstr, cstring_args);
MEM_freeN(cstring_args);
return NULL;
}
- rhs = RNA_property_as_string(C, ptr, prop, index);
+ rhs = RNA_property_as_string(C, ptr, prop, index, INT_MAX);
if (!rhs) {
MEM_freeN(lhs);
return NULL;