From 16fe92f86828d6ccec90ad4d8a1995afaf616964 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 16 Mar 2009 15:54:43 +0000 Subject: 2.5 PyAPI Support for subclassing blenders operator, to be registered as a new operator. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Still need to... * add constants like Operator.FINISHED * wrap context (with rna?) * poll() cant work right now because there is no way to access the operatorType that holds the python class. * Only float, int and bool properties can be added so far. working example operator. http://wiki.blender.org/index.php/BlenderDev/Blender2.5/WinterCamp/TechnicalDesign#Operator_Example_Code --- source/blender/python/intern/bpy_interface.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/python/intern/bpy_interface.c') diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index fc43d7e5537..54f7bb55cc0 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -57,6 +57,22 @@ static PyObject *CreateGlobalDictionary( bContext *C ) PyDict_SetItemString( dict, "__bpy_context__", item ); Py_DECREF(item); + + // XXX - put somewhere more logical + { + PyMethodDef *ml; + static PyMethodDef bpy_prop_meths[] = { + {"FloatProperty", BPy_FloatProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"IntProperty", BPy_IntProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {"BoolProperty", BPy_BoolProperty, METH_VARARGS|METH_KEYWORDS, ""}, + {NULL, NULL, 0, NULL} + }; + + for(ml = &bpy_prop_meths; ml->ml_name; ml++) { + PyDict_SetItemString( dict, ml->ml_name, PyCFunction_New(ml, NULL)); + } + } + return dict; } -- cgit v1.2.3