Extended functions not usable in the wrappers?
Kustaa Nyholm <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <[email protected]> |
I'm trying to use occjava swig .i defs with OCC/OpenCascade 7.3.0.
(it is intended to be used with the OCE/OpenCascade version some or other).
To solve an issue that results in bunch of errors like this:
error: cannot cast from type 'Handle_Poly_Triangulation' (aka 'handle<Poly_Triangulation>') to pointer type 'Standard_Transient *'
I want to add following to the handle class:
// file Standard_Header.hxx
operator Standard_Transient* ()
{
return static_cast<Standard_Transient*>(entity);
}
and when I do that, all/most of those errors disappear.
This should be fine because all handles in this framework (OpenCascade)
derive from the handle class, but the occjava SWIG defs don't bother to make
this explicit, hence this 'hack'. At least this is my understanding
I could be wrong, flying with gut feeling here.
But I don't want to patch the Standard_Header.hxx file in which 'class handle' lives,
cause that is part of the OCC distribution.
So I thought I could just do following and remove above hack from the header:
// file OccJava.i
class handle {
handle()=0;
};
%ignore operator Standard_Transient*();
%extend handle
{
operator Standard_Transient* ()
{
return static_cast<Standard_Transient*>(this);
}
};
This produces no warnings but I'm back at the 'cannot cast' error.
Am I doing something wrong?
Is this approach not valid?
What are my other options?
wbr Kusti