Missing code updates in the previous commit.
Also improved __repr__() so that the .getName() is no longer necessary in user-defined Function0D and Function1D subclasses.
This commit is contained in:
@@ -13,19 +13,19 @@ extern "C" {
|
||||
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
|
||||
int UnaryFunction0DVectorViewShape_Init( PyObject *module ) {
|
||||
int UnaryFunction0DVectorViewShape_Init(PyObject *module) {
|
||||
|
||||
if( module == NULL )
|
||||
if (module == NULL)
|
||||
return -1;
|
||||
|
||||
if( PyType_Ready( &UnaryFunction0DVectorViewShape_Type ) < 0 )
|
||||
if (PyType_Ready(&UnaryFunction0DVectorViewShape_Type) < 0)
|
||||
return -1;
|
||||
Py_INCREF( &UnaryFunction0DVectorViewShape_Type );
|
||||
Py_INCREF(&UnaryFunction0DVectorViewShape_Type);
|
||||
PyModule_AddObject(module, "UnaryFunction0DVectorViewShape", (PyObject *)&UnaryFunction0DVectorViewShape_Type);
|
||||
|
||||
if( PyType_Ready( &GetOccludersF0D_Type ) < 0 )
|
||||
if (PyType_Ready(&GetOccludersF0D_Type) < 0)
|
||||
return -1;
|
||||
Py_INCREF( &GetOccludersF0D_Type );
|
||||
Py_INCREF(&GetOccludersF0D_Type);
|
||||
PyModule_AddObject(module, "GetOccludersF0D", (PyObject *)&GetOccludersF0D_Type);
|
||||
|
||||
return 0;
|
||||
@@ -46,8 +46,10 @@ static char UnaryFunction0DVectorViewShape___doc__[] =
|
||||
|
||||
static int UnaryFunction0DVectorViewShape___init__(BPy_UnaryFunction0DVectorViewShape* self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
if ( !PyArg_ParseTuple(args, "") )
|
||||
return -1;
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
return -1;
|
||||
self->uf0D_vectorviewshape = new UnaryFunction0D< std::vector<ViewShape*> >();
|
||||
self->uf0D_vectorviewshape->py_uf0D = (PyObject *)self;
|
||||
return 0;
|
||||
@@ -62,38 +64,22 @@ static void UnaryFunction0DVectorViewShape___dealloc__(BPy_UnaryFunction0DVector
|
||||
|
||||
static PyObject * UnaryFunction0DVectorViewShape___repr__(BPy_UnaryFunction0DVectorViewShape* self)
|
||||
{
|
||||
return PyUnicode_FromFormat("type: %s - address: %p", self->uf0D_vectorviewshape->getName().c_str(), self->uf0D_vectorviewshape );
|
||||
return PyUnicode_FromFormat("type: %s - address: %p", Py_TYPE(self)->tp_name, self->uf0D_vectorviewshape);
|
||||
}
|
||||
|
||||
static char UnaryFunction0DVectorViewShape_getName___doc__[] =
|
||||
".. method:: getName()\n"
|
||||
"\n"
|
||||
" Returns the name of the unary 0D predicate.\n"
|
||||
"\n"
|
||||
" :return: The name of the unary 0D predicate.\n"
|
||||
" :rtype: str\n";
|
||||
|
||||
static PyObject * UnaryFunction0DVectorViewShape_getName( BPy_UnaryFunction0DVectorViewShape *self )
|
||||
{
|
||||
return PyUnicode_FromString( self->uf0D_vectorviewshape->getName().c_str() );
|
||||
}
|
||||
|
||||
static PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds)
|
||||
static PyObject * UnaryFunction0DVectorViewShape___call__(BPy_UnaryFunction0DVectorViewShape *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {"it", NULL};
|
||||
PyObject *obj;
|
||||
|
||||
if( kwds != NULL ) {
|
||||
PyErr_SetString(PyExc_TypeError, "keyword argument(s) not supported");
|
||||
return NULL;
|
||||
}
|
||||
if(!PyArg_ParseTuple(args, "O!", &Interface0DIterator_Type, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &obj))
|
||||
return NULL;
|
||||
|
||||
if( typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D< std::vector<ViewShape*> >) ) {
|
||||
if (typeid(*(self->uf0D_vectorviewshape)) == typeid(UnaryFunction0D< std::vector<ViewShape*> >)) {
|
||||
PyErr_SetString(PyExc_TypeError, "__call__ method not properly overridden");
|
||||
return NULL;
|
||||
}
|
||||
if (self->uf0D_vectorviewshape->operator()(*( ((BPy_Interface0DIterator *) obj)->if0D_it )) < 0) {
|
||||
if (self->uf0D_vectorviewshape->operator()(*(((BPy_Interface0DIterator *)obj)->if0D_it)) < 0) {
|
||||
if (!PyErr_Occurred()) {
|
||||
string class_name(Py_TYPE(self)->tp_name);
|
||||
PyErr_SetString(PyExc_RuntimeError, (class_name + " __call__ method failed").c_str());
|
||||
@@ -102,7 +88,7 @@ static PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVe
|
||||
}
|
||||
PyObject *list = PyList_New(0);
|
||||
PyObject *item;
|
||||
for( unsigned int i = 0; i < self->uf0D_vectorviewshape->result.size(); i++) {
|
||||
for(unsigned int i = 0; i < self->uf0D_vectorviewshape->result.size(); i++) {
|
||||
ViewShape *v = self->uf0D_vectorviewshape->result[i];
|
||||
if (v) {
|
||||
item = BPy_ViewShape_from_ViewShape(*v);
|
||||
@@ -116,9 +102,7 @@ static PyObject * UnaryFunction0DVectorViewShape___call__( BPy_UnaryFunction0DVe
|
||||
return list;
|
||||
}
|
||||
|
||||
/*----------------------UnaryFunction0DVectorViewShape instance definitions ----------------------------*/
|
||||
static PyMethodDef BPy_UnaryFunction0DVectorViewShape_methods[] = {
|
||||
{"getName", ( PyCFunction ) UnaryFunction0DVectorViewShape_getName, METH_NOARGS, UnaryFunction0DVectorViewShape_getName___doc__},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user