1 #include "BPy_UnaryFunction0DEdgeNature.h"
3 #include "../BPy_Convert.h"
4 #include "../Iterator/BPy_Interface0DIterator.h"
6 #include "UnaryFunction0D_Nature_EdgeNature/BPy_CurveNatureF0D.h"
12 ///////////////////////////////////////////////////////////////////////////////////////////
14 /*--------------- Python API function prototypes for UnaryFunction0DEdgeNature instance -----------*/
15 static int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature* self, PyObject *args, PyObject *kwds);
16 static void UnaryFunction0DEdgeNature___dealloc__(BPy_UnaryFunction0DEdgeNature* self);
17 static PyObject * UnaryFunction0DEdgeNature___repr__(BPy_UnaryFunction0DEdgeNature* self);
19 static PyObject * UnaryFunction0DEdgeNature_getName( BPy_UnaryFunction0DEdgeNature *self);
20 static PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds);
22 /*----------------------UnaryFunction0DEdgeNature instance definitions ----------------------------*/
23 static PyMethodDef BPy_UnaryFunction0DEdgeNature_methods[] = {
24 {"getName", ( PyCFunction ) UnaryFunction0DEdgeNature_getName, METH_NOARGS, "() Returns the string of the name of the unary 0D function."},
28 /*-----------------------BPy_UnaryFunction0DEdgeNature type definition ------------------------------*/
30 PyTypeObject UnaryFunction0DEdgeNature_Type = {
31 PyVarObject_HEAD_INIT(NULL, 0)
32 "UnaryFunction0DEdgeNature", /* tp_name */
33 sizeof(BPy_UnaryFunction0DEdgeNature), /* tp_basicsize */
35 (destructor)UnaryFunction0DEdgeNature___dealloc__, /* tp_dealloc */
40 (reprfunc)UnaryFunction0DEdgeNature___repr__, /* tp_repr */
42 0, /* tp_as_sequence */
43 0, /* tp_as_mapping */
45 (ternaryfunc)UnaryFunction0DEdgeNature___call__, /* tp_call */
50 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
51 "UnaryFunction0DEdgeNature objects", /* tp_doc */
54 0, /* tp_richcompare */
55 0, /* tp_weaklistoffset */
58 BPy_UnaryFunction0DEdgeNature_methods, /* tp_methods */
61 &UnaryFunction0D_Type, /* tp_base */
65 0, /* tp_dictoffset */
66 (initproc)UnaryFunction0DEdgeNature___init__, /* tp_init */
71 //-------------------MODULE INITIALIZATION--------------------------------
73 int UnaryFunction0DEdgeNature_Init( PyObject *module ) {
78 if( PyType_Ready( &UnaryFunction0DEdgeNature_Type ) < 0 )
80 Py_INCREF( &UnaryFunction0DEdgeNature_Type );
81 PyModule_AddObject(module, "UnaryFunction0DEdgeNature", (PyObject *)&UnaryFunction0DEdgeNature_Type);
83 if( PyType_Ready( &CurveNatureF0D_Type ) < 0 )
85 Py_INCREF( &CurveNatureF0D_Type );
86 PyModule_AddObject(module, "CurveNatureF0D", (PyObject *)&CurveNatureF0D_Type);
91 //------------------------INSTANCE METHODS ----------------------------------
93 int UnaryFunction0DEdgeNature___init__(BPy_UnaryFunction0DEdgeNature* self, PyObject *args, PyObject *kwds)
95 if ( !PyArg_ParseTuple(args, "") )
97 self->uf0D_edgenature = new UnaryFunction0D<Nature::EdgeNature>();
98 self->uf0D_edgenature->py_uf0D = (PyObject *)self;
102 void UnaryFunction0DEdgeNature___dealloc__(BPy_UnaryFunction0DEdgeNature* self)
104 if (self->uf0D_edgenature)
105 delete self->uf0D_edgenature;
106 UnaryFunction0D_Type.tp_dealloc((PyObject*)self);
110 PyObject * UnaryFunction0DEdgeNature___repr__(BPy_UnaryFunction0DEdgeNature* self)
112 return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_edgenature->getName().c_str(), self->uf0D_edgenature );
115 PyObject * UnaryFunction0DEdgeNature_getName( BPy_UnaryFunction0DEdgeNature *self )
117 return PyUnicode_FromFormat( self->uf0D_edgenature->getName().c_str() );
120 PyObject * UnaryFunction0DEdgeNature___call__( BPy_UnaryFunction0DEdgeNature *self, PyObject *args, PyObject *kwds)
125 PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported");
128 if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj))
131 if( typeid(*(self->uf0D_edgenature)) == typeid(UnaryFunction0D<Nature::EdgeNature>) ) {
132 PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
135 if (self->uf0D_edgenature->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) {
136 if (!PyErr_Occurred()) {
137 string msg(self->uf0D_edgenature->getName() + " __call__ method failed");
138 PyErr_SetString(PyExc_RuntimeError, msg.c_str());
142 return BPy_Nature_from_Nature( self->uf0D_edgenature->result );
146 ///////////////////////////////////////////////////////////////////////////////////////////