[Bf-codereview] Support for Get/Set callbacks in bpy.props (issue 7027056)

lukas.toenne at gmail.com lukas.toenne at gmail.com
Fri Jan 4 19:43:43 CET 2013


Reviewers: bf-codereview_blender.org, ideasman42,

Description:
This 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).

Please review this at https://codereview.appspot.com/7027056/

Affected files:
   source/blender/makesrna/RNA_define.h
   source/blender/makesrna/RNA_types.h
   source/blender/makesrna/intern/makesrna.c
   source/blender/makesrna/intern/rna_access.c
   source/blender/makesrna/intern/rna_define.c
   source/blender/makesrna/intern/rna_internal_types.h
   source/blender/python/intern/bpy_props.c




More information about the Bf-codereview mailing list