PyAPI: extend save/load handlers, optionally take a filepath argument
Add a filepath argument to load/save pre/post.
Also add save_post_failed and load_post_failed handlers so it's always
possible to for the pre handlers to run a matching post action.
This makes it possible to know the filepath of the blend file mean
loaded/saved as well as supporting running an action when load/save
operations fail.
When loading and saving the startup-file, the path argument is set to
an empty string.
Details:
New RNA types were added to support storing primitive values in
PointerRNA. Primitive{String/Int/Float/Boolean}RNA. These will likely
only be used in some limited cases, in the case of BKE_callback_exec it
allows strings to be included as part of the PointerRNA **pointers
argument.
Ref !104769.
This commit is contained in:
@@ -7407,6 +7407,27 @@ PyObject *pyrna_struct_CreatePyObject(PointerRNA *ptr)
|
||||
return (PyObject *)pyrna;
|
||||
}
|
||||
|
||||
PyObject *pyrna_struct_CreatePyObject_with_primitive_support(PointerRNA *ptr)
|
||||
{
|
||||
if (ptr->type == &RNA_PrimitiveString) {
|
||||
const PrimitiveStringRNA *data = ptr->data;
|
||||
return PyC_UnicodeFromBytes(data->value);
|
||||
}
|
||||
if (ptr->type == &RNA_PrimitiveInt) {
|
||||
const PrimitiveIntRNA *data = ptr->data;
|
||||
return PyLong_FromLong(data->value);
|
||||
}
|
||||
if (ptr->type == &RNA_PrimitiveFloat) {
|
||||
const PrimitiveFloatRNA *data = ptr->data;
|
||||
return PyFloat_FromDouble(data->value);
|
||||
}
|
||||
if (ptr->type == &RNA_PrimitiveBoolean) {
|
||||
const PrimitiveBooleanRNA *data = ptr->data;
|
||||
return PyBool_FromLong(data->value);
|
||||
}
|
||||
return pyrna_struct_CreatePyObject(ptr);
|
||||
}
|
||||
|
||||
PyObject *pyrna_prop_CreatePyObject(PointerRNA *ptr, PropertyRNA *prop)
|
||||
{
|
||||
BPy_PropertyRNA *pyrna;
|
||||
|
||||
Reference in New Issue
Block a user