|
@@ -149,83 +149,6 @@ PyTypeObject Nature_Type = {
|
|
|
|
|
|
/*-----------------------BPy_Nature instance definitions ----------------------------------*/
|
|
|
|
|
|
-static PyLongObject _Nature_POINT = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 0)
|
|
|
- { Nature::POINT }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_S_VERTEX = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::S_VERTEX }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_VIEW_VERTEX = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::VIEW_VERTEX }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_NON_T_VERTEX = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::NON_T_VERTEX }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_T_VERTEX = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::T_VERTEX }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_CUSP = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::CUSP }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_NO_FEATURE = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 0)
|
|
|
- { Nature::NO_FEATURE }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_SILHOUETTE = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::SILHOUETTE }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_BORDER = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::BORDER }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_CREASE = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::CREASE }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_RIDGE = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::RIDGE }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_VALLEY = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::VALLEY }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_SUGGESTIVE_CONTOUR = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::SUGGESTIVE_CONTOUR }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_MATERIAL_BOUNDARY = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::MATERIAL_BOUNDARY }
|
|
|
-};
|
|
|
-static PyLongObject _Nature_EDGE_MARK = {
|
|
|
- PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
|
|
- { Nature::EDGE_MARK }
|
|
|
-};
|
|
|
-
|
|
|
-#define BPy_Nature_POINT ((PyObject *)&_Nature_POINT)
|
|
|
-#define BPy_Nature_S_VERTEX ((PyObject *)&_Nature_S_VERTEX)
|
|
|
-#define BPy_Nature_VIEW_VERTEX ((PyObject *)&_Nature_VIEW_VERTEX)
|
|
|
-#define BPy_Nature_NON_T_VERTEX ((PyObject *)&_Nature_NON_T_VERTEX)
|
|
|
-#define BPy_Nature_T_VERTEX ((PyObject *)&_Nature_T_VERTEX)
|
|
|
-#define BPy_Nature_CUSP ((PyObject *)&_Nature_CUSP)
|
|
|
-#define BPy_Nature_NO_FEATURE ((PyObject *)&_Nature_NO_FEATURE)
|
|
|
-#define BPy_Nature_SILHOUETTE ((PyObject *)&_Nature_SILHOUETTE)
|
|
|
-#define BPy_Nature_BORDER ((PyObject *)&_Nature_BORDER)
|
|
|
-#define BPy_Nature_CREASE ((PyObject *)&_Nature_CREASE)
|
|
|
-#define BPy_Nature_RIDGE ((PyObject *)&_Nature_RIDGE)
|
|
|
-#define BPy_Nature_VALLEY ((PyObject *)&_Nature_VALLEY)
|
|
|
-#define BPy_Nature_SUGGESTIVE_CONTOUR ((PyObject *)&_Nature_SUGGESTIVE_CONTOUR)
|
|
|
-#define BPy_Nature_MATERIAL_BOUNDARY ((PyObject *)&_Nature_MATERIAL_BOUNDARY)
|
|
|
-#define BPy_Nature_EDGE_MARK ((PyObject *)&_Nature_EDGE_MARK)
|
|
|
-
|
|
|
//-------------------MODULE INITIALIZATION--------------------------------
|
|
|
int Nature_Init(PyObject *module)
|
|
|
{
|
|
@@ -237,24 +160,29 @@ int Nature_Init(PyObject *module)
|
|
|
Py_INCREF(&Nature_Type);
|
|
|
PyModule_AddObject(module, "Nature", (PyObject *)&Nature_Type);
|
|
|
|
|
|
+#define ADD_TYPE_CONST(id) \
|
|
|
+ PyLong_subtype_add_to_dict(Nature_Type.tp_dict, &Nature_Type, STRINGIFY(id), Nature::id)
|
|
|
+
|
|
|
// VertexNature
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "POINT", BPy_Nature_POINT);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "S_VERTEX", BPy_Nature_S_VERTEX);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "VIEW_VERTEX", BPy_Nature_VIEW_VERTEX);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "NON_T_VERTEX", BPy_Nature_NON_T_VERTEX);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "T_VERTEX", BPy_Nature_T_VERTEX);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "CUSP", BPy_Nature_CUSP);
|
|
|
+ ADD_TYPE_CONST(POINT);
|
|
|
+ ADD_TYPE_CONST(S_VERTEX);
|
|
|
+ ADD_TYPE_CONST(VIEW_VERTEX);
|
|
|
+ ADD_TYPE_CONST(NON_T_VERTEX);
|
|
|
+ ADD_TYPE_CONST(T_VERTEX);
|
|
|
+ ADD_TYPE_CONST(CUSP);
|
|
|
|
|
|
// EdgeNature
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "NO_FEATURE", BPy_Nature_NO_FEATURE);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "SILHOUETTE", BPy_Nature_SILHOUETTE);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "BORDER", BPy_Nature_BORDER);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "CREASE", BPy_Nature_CREASE);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "RIDGE", BPy_Nature_RIDGE);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "VALLEY", BPy_Nature_VALLEY);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", BPy_Nature_SUGGESTIVE_CONTOUR);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "MATERIAL_BOUNDARY", BPy_Nature_MATERIAL_BOUNDARY);
|
|
|
- PyDict_SetItemString(Nature_Type.tp_dict, "EDGE_MARK", BPy_Nature_EDGE_MARK);
|
|
|
+ ADD_TYPE_CONST(NO_FEATURE);
|
|
|
+ ADD_TYPE_CONST(SILHOUETTE);
|
|
|
+ ADD_TYPE_CONST(BORDER);
|
|
|
+ ADD_TYPE_CONST(CREASE);
|
|
|
+ ADD_TYPE_CONST(RIDGE);
|
|
|
+ ADD_TYPE_CONST(VALLEY);
|
|
|
+ ADD_TYPE_CONST(SUGGESTIVE_CONTOUR);
|
|
|
+ ADD_TYPE_CONST(MATERIAL_BOUNDARY);
|
|
|
+ ADD_TYPE_CONST(EDGE_MARK);
|
|
|
+
|
|
|
+#undef ADD_TYPE_CONST
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -294,9 +222,7 @@ static PyObject *BPy_Nature_bitwise(PyObject *a, int op, PyObject *b)
|
|
|
if (v == 0)
|
|
|
result = PyObject_NewVar(BPy_Nature, &Nature_Type, 0);
|
|
|
else {
|
|
|
- result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1);
|
|
|
- if (result)
|
|
|
- result->i.ob_digit[0] = v;
|
|
|
+ result = (BPy_Nature *)PyLong_subtype_new(&Nature_Type, v);
|
|
|
}
|
|
|
return (PyObject *)result;
|
|
|
}
|