Lines 67-74
extern "C"
Link Here
|
67 |
PyObject *prop_set; |
67 |
PyObject *prop_set; |
68 |
PyObject *prop_del; |
68 |
PyObject *prop_del; |
69 |
PyObject *prop_doc; |
69 |
PyObject *prop_doc; |
|
|
70 |
int getter_doc; |
70 |
} propertyobject; |
71 |
} propertyobject; |
71 |
|
72 |
|
|
|
73 |
// Copied from Python source and removed the part for setting docstring, |
74 |
// since we don't have a setter for __doc__ and trying to set it will |
75 |
// cause the init fail. |
76 |
static int property_init(PyObject *self, PyObject *args, PyObject *kwds) |
77 |
{ |
78 |
PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL; |
79 |
static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0}; |
80 |
propertyobject *prop = (propertyobject *)self; |
81 |
|
82 |
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property", |
83 |
kwlist, &get, &set, &del, &doc)) |
84 |
return -1; |
85 |
|
86 |
if (get == Py_None) |
87 |
get = NULL; |
88 |
if (set == Py_None) |
89 |
set = NULL; |
90 |
if (del == Py_None) |
91 |
del = NULL; |
92 |
|
93 |
Py_XINCREF(get); |
94 |
Py_XINCREF(set); |
95 |
Py_XINCREF(del); |
96 |
Py_XINCREF(doc); |
97 |
|
98 |
prop->prop_get = get; |
99 |
prop->prop_set = set; |
100 |
prop->prop_del = del; |
101 |
prop->prop_doc = doc; |
102 |
prop->getter_doc = 0; |
103 |
|
104 |
return 0; |
105 |
} |
106 |
|
107 |
|
72 |
static PyObject * |
108 |
static PyObject * |
73 |
static_data_descr_get(PyObject *self, PyObject * /*obj*/, PyObject * /*type*/) |
109 |
static_data_descr_get(PyObject *self, PyObject * /*obj*/, PyObject * /*type*/) |
74 |
{ |
110 |
{ |
Lines 109-115
static PyTypeObject static_data_object =
Link Here
|
109 |
PyObject_HEAD_INIT(0)//&PyType_Type) |
145 |
PyObject_HEAD_INIT(0)//&PyType_Type) |
110 |
0, |
146 |
0, |
111 |
"Boost.Python.StaticProperty", |
147 |
"Boost.Python.StaticProperty", |
112 |
PyType_Type.tp_basicsize, |
148 |
sizeof(propertyobject), |
113 |
0, |
149 |
0, |
114 |
0, /* tp_dealloc */ |
150 |
0, /* tp_dealloc */ |
115 |
0, /* tp_print */ |
151 |
0, /* tp_print */ |
Lines 143-149
static PyTypeObject static_data_object =
Link Here
|
143 |
static_data_descr_get, /* tp_descr_get */ |
179 |
static_data_descr_get, /* tp_descr_get */ |
144 |
static_data_descr_set, /* tp_descr_set */ |
180 |
static_data_descr_set, /* tp_descr_set */ |
145 |
0, /* tp_dictoffset */ |
181 |
0, /* tp_dictoffset */ |
146 |
0, /* tp_init */ |
182 |
property_init, /* tp_init */ |
147 |
0, /* tp_alloc */ |
183 |
0, /* tp_alloc */ |
148 |
0, // filled in with type_new /* tp_new */ |
184 |
0, // filled in with type_new /* tp_new */ |
149 |
0, // filled in with __PyObject_GC_Del /* tp_free */ |
185 |
0, // filled in with __PyObject_GC_Del /* tp_free */ |