DescriptionThis patch adds support in bpy.props for getter/setter callback functions. We already have update callbacks, but generic get/set functions can come in handy in some cases where the functionality is too complex to use a single value.
The current C callback functions are too simple allow a straightforward implementation, in particular they don't receive the PropertyRNA pointer itself as an argument, which means the callback cannot directly access the PropertyRNA's py_data pointers which store the python function objects. For this reason a second runtime variant of these callbacks has been added. It is only used for runtime callbacks and not in makesrna, but otherwise works the same way.
A few possible improvements:
* BPy_EnumProperty: Could use generic property py_data slot for the enum item callback. Would be one unused pointer for non-enum properties, but a bit simpler.
* BPy_EnumProperty: Integrate enum item function argument check into general bpy_prop_callback_check.
* enum get/set callbacks only work with integer values for now. Using string identifiers would be better, for that the extended callback variants must be modified for runtime enum callbacks. No access to the items list in get/set itself (no context).
Patch Set 1 #
Total comments: 15
MessagesTotal messages: 4
|