static void py_struct_seq_getset_init(void) { /* tricky dynamic members, not to py-spec! */ PyGetSetDef *getset; for(getset= bpy_app_getsets; getset->name; getset++) { PyDict_SetItemString(BlenderAppType.tp_dict, getset->name, PyDescr_NewGetSet(&BlenderAppType, getset)); } }
PyObject* wrap_property_helper(PyTypeObject* type,const char* name,getter get_wrapper,setter set_wrapper,void* getset) { // Make a PyGetSetDef PyGetSetDef* def = (PyGetSetDef*)malloc(sizeof(PyGetSetDef)); memset(def,0,sizeof(PyGetSetDef)); def->name = const_cast_(name); def->get = get_wrapper; def->set = set_wrapper; def->closure = getset; // Allocate descriptor PyObject* descr = PyDescr_NewGetSet(type,def); if (!descr) throw_python_error(); return descr; }
static void PyType_AddGetSet(PyTypeObject *type, PyGetSetDef *getset) { PyObject *dict; int i; if (type->tp_dict == NULL) type->tp_dict = PyDict_New(); dict = type->tp_dict; for (i = 0; getset[i].name; i++) { PyObject *descr; descr = PyDescr_NewGetSet(type, &getset[i]); PyDict_SetItemString(dict, getset[i].name, descr); } }