<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hey All,<br>
I was working on a project a few months ago where I <br>
was wrapping a lib ( using Boost.Python ) that inherited <br>
from classes that were already wrapped ( using SIP ). <br>
Boost.Python however couldn't find the base classes. I <br>
hacked something up ( that I'm not very proud of ) in class.cpp : <br>
<br>
<meta charset="utf-8">
<pre style="font-size: 12px; white-space: pre-wrap; max-width: 80em; padding-left: 0.7em; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); "> 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;
}
</pre>
Surely there has to be a better way. Does anyone have a <br>
better solution than this?<br>
<br>
This was also followed by metaclass and layout conflicts, <br>
but that's another issue I think.<br>
<br>
To give a little background I was trying to wrap a lib that<br>
inherits from Qt and I really would prefer to use the <br>
bindings from PyQt rather than re-wrap ( which also seems<br>
more difficult than I thought it would be ).<br>
Thanks,<br>
Alex.<br>
</body>
</html>