Hey All,
    I was working on a project a few months ago where I
was wrapping a lib ( using Boost.Python ) that inherited
from classes that were already wrapped ( using SIP ).
Boost.Python however couldn't find the base classes.  I
hacked something up ( that I'm not very proud of ) in class.cpp :

   type_handle get_class(type_info id)
    {
        type_handle result(query_class(id));

        if (result.get() == 0)
        {
          PyObject* globals = PyEval_GetGlobals() ;
          PyObject* key = object( id.name() ).ptr() ;
          PyObject* obj = PyDict_GetItem( globals, key );
          if( obj ){
            return type_handle( obj->ob_type );
          }else{
            object report("extension class wrapper for base class ");
            report = report + id.name() + " has not been created yet";
            PyErr_SetObject(PyExc_RuntimeError, report.ptr());
            throw_error_already_set();
          }
        }
        return result;
    }


Surely there has to be a better way.  Does anyone have a
better solution than this?

This was also followed by metaclass and layout conflicts,
but that's another issue I think.

To give a little background I was trying to wrap a lib that
inherits from Qt and I really would prefer to use the
bindings from PyQt rather than re-wrap ( which also seems
more difficult than I thought it would be ).
Thanks,
Alex.
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to