// BPy_UnaryFunction{0D,1D}: __call__ int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0DIterator& if0D_it) { if (!py_uf0D) { // internal error PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf0D) not initialized"); return -1; } PyObject *obj = (PyObject *)py_uf0D; PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, false); if (!arg) return -1; PyObject *result = PyObject_CallMethod(obj, "__call__", "O", arg); Py_DECREF(arg); if (!result) return -1; if (BPy_UnaryFunction0DDouble_Check(obj)) { ((UnaryFunction0D<double> *)uf0D)->result = PyFloat_AsDouble(result); } else if (BPy_UnaryFunction0DEdgeNature_Check(obj)) { ((UnaryFunction0D<Nature::EdgeNature> *)uf0D)->result = EdgeNature_from_BPy_Nature(result); } else if (BPy_UnaryFunction0DFloat_Check(obj)) { ((UnaryFunction0D<float> *)uf0D)->result = PyFloat_AsDouble(result); } else if (BPy_UnaryFunction0DId_Check(obj)) { ((UnaryFunction0D<Id> *)uf0D)->result = *(((BPy_Id *)result)->id); } else if (BPy_UnaryFunction0DMaterial_Check(obj)) { ((UnaryFunction0D<FrsMaterial> *)uf0D)->result = *(((BPy_FrsMaterial *)result)->m); } else if (BPy_UnaryFunction0DUnsigned_Check(obj)) { ((UnaryFunction0D<unsigned> *)uf0D)->result = PyLong_AsLong(result); } else if (BPy_UnaryFunction0DVec2f_Check(obj)) { Vec2f vec; if (!Vec2f_ptr_from_Vector(result, vec)) return -1; ((UnaryFunction0D<Vec2f> *)uf0D)->result = vec; } else if (BPy_UnaryFunction0DVec3f_Check(obj)) { Vec3f vec; if (!Vec3f_ptr_from_Vector(result, vec)) return -1; ((UnaryFunction0D<Vec3f> *)uf0D)->result = vec; } else if (BPy_UnaryFunction0DVectorViewShape_Check(obj)) { vector<ViewShape*> vec; vec.reserve(PyList_Size(result)); for (int i = 0; i < PyList_Size(result); i++) { ViewShape *b = ((BPy_ViewShape *)PyList_GET_ITEM(result, i))->vs; vec.push_back(b); } ((UnaryFunction0D< vector<ViewShape*> > *)uf0D)->result = vec; } else if (BPy_UnaryFunction0DViewShape_Check(obj)) { ((UnaryFunction0D<ViewShape*> *)uf0D)->result = ((BPy_ViewShape *)result)->vs; } Py_DECREF(result); return 0; }
bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f &vec) { if (Vec3f_ptr_from_Vector(obj, vec)) return true; if (Vec3f_ptr_from_Color(obj, vec)) return true; if (Vec3f_ptr_from_PyList(obj, vec)) return true; if (Vec3f_ptr_from_PyTuple(obj, vec)) return true; return false; }
Vec3f *Vec3f_ptr_from_PyObject(PyObject *obj) { Vec3f *v; if ((v = Vec3f_ptr_from_Vector(obj))) return v; if ((v = Vec3f_ptr_from_Color(obj))) return v; if ((v = Vec3f_ptr_from_PyList(obj))) return v; if ((v = Vec3f_ptr_from_PyTuple(obj))) return v; return NULL; }
int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D& if1D) { if (!py_uf1D) { // internal error PyErr_SetString(PyExc_RuntimeError, "Reference to Python object (py_uf1D) not initialized"); return -1; } PyObject *obj = (PyObject *)py_uf1D; PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D); if (!arg) return -1; PyObject *result = PyObject_CallMethod(obj, "__call__", "O", arg); Py_DECREF(arg); if (!result) return -1; if (BPy_UnaryFunction1DDouble_Check(obj)) { ((UnaryFunction1D<double> *)uf1D)->result = PyFloat_AsDouble(result); } else if (BPy_UnaryFunction1DEdgeNature_Check(obj)) { ((UnaryFunction1D<Nature::EdgeNature> *)uf1D)->result = EdgeNature_from_BPy_Nature(result); } else if (BPy_UnaryFunction1DFloat_Check(obj)) { ((UnaryFunction1D<float> *)uf1D)->result = PyFloat_AsDouble(result); } else if (BPy_UnaryFunction1DUnsigned_Check(obj)) { ((UnaryFunction1D<unsigned> *)uf1D)->result = PyLong_AsLong(result); } else if (BPy_UnaryFunction1DVec2f_Check(obj)) { Vec2f vec; if (!Vec2f_ptr_from_Vector(result, vec)) return -1; ((UnaryFunction1D<Vec2f> *)uf1D)->result = vec; } else if (BPy_UnaryFunction1DVec3f_Check(obj)) { Vec3f vec; if (!Vec3f_ptr_from_Vector(result, vec)) return -1; ((UnaryFunction1D<Vec3f> *)uf1D)->result = vec; } else if (BPy_UnaryFunction1DVectorViewShape_Check(obj)) { vector<ViewShape*> vec; for (int i = 1; i < PyList_Size(result); i++) { ViewShape *b = ((BPy_ViewShape *)PyList_GetItem(result, i))->vs; vec.push_back(b); } ((UnaryFunction1D< vector<ViewShape*> > *)uf1D)->result = vec; } Py_DECREF(result); return 0; }