"Tom" <NoSpam at NoSpam.com> wrote in message news:T8HG6.20396$HF.4234648 at news4.rdc1.on.home.com... > > In args[0] you have a PyObject*. > If the PyObject is actually one of your PyAtoms, you can cast it as such. > (PyAtom inherits - I'm assuming - from cxx::PythonExtension<> which inherits > from PyObject.) > Unfortunately, we can't do a safe 'dynamic_cast' because the inheritance of > PyObject is non-virtual, so we'll do it the C way: > assert( thePyObject->ob_type == PyAtom::type_object() ); // or throw. > PyAtom* pPyAtom = static_cast< PyAtom* >( thePyObject ); > > I think this is right, but no guarantees. Tell me if I'm wrong. > It was close enough to lead me to something that works: Py::Object PyBond::GetNbrAtom(const Py::Tuple& args){ PyObject *pyObj=args[0].ptr(); if( pyObj->ob_type != PyAtom::type_object() ){ throw Py::ValueError("argument must be a PyAtom"); } PyAtom *a = static_cast<PyAtom *>(pyObj); Thanks for the pointer! -greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4