Re: How do I found out which .i rule/pattern generates a specific (illegal) C++ code fragment?
Kustaa Nyholm <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <[email protected]> |
> On 28 Jul 2020, at 0.53, William S Fulton <[email protected]> wrote: > > Kustaa > > It is very hard to know what is going on if you just post the output. It's like asking someone to diagnose a problem in some C++ code and just show them the assembler output. I suggest you read about the C and SWIG preprocessors to see what is really happening and cut it all down to a minimal bit of code to really understand what is going on. Look for missing definitions and declarations of the relevant types that SWIG actually parses. Post a few lines of standalone cutdown code here for further help. > > William Thanks. It is difficult to know what are the relevant things to post to allow people to help me. Since I made the post I've changed my approach a bit so the original question as presented is not relevant. I've made an other post here: https://sourceforge.net/p/swig/mailman/message/37071246/ I'm not sure that was a good post either, maybe not worth answering. The thing is, the .i files I'm working with worked with a previous release of OCE but now fail with latest OCC. OCE and OCC are very large and the .files are not that minimal either so it is difficult to pin point the problem. Now with my slightly different take on the problem this comes up in the generated code: SWIGEXPORT jlong JNICALL Java_org_jcae_opencascade_jni_OccJavaJNI_Geom_1BSplineCurve_1SWIGUpcast(JNIEnv *jenv, jclass jcls, jlong jarg1) { jlong baseptr = 0; (void)jenv; (void)jcls; *(Handle_Geom_BoundedCurve **)&baseptr = *(Handle_Geom_BSplineCurve **)&jarg1; return baseptr; } and it fails to compile with error: /Users/nyholku/jCAE/occjava2/src-java/org/jcae/opencascade/jni/OccJavaJAVA_wrap.cxx:7870:46: error: assigning to 'Handle_Geom_BoundedCurve *' (aka 'handle<Geom_BoundedCurve> *') from incompatible type 'Handle_Geom_BSplineCurve *' (aka 'handle<Geom_BSplineCurve> *') *(Handle_Geom_BoundedCurve **)&baseptr = *(Handle_Geom_BSplineCurve **)&jarg1; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Of course that fails to compile cause Geom_BoundedCurve and Geom_BSplineCurve are different types even if one is derived from other so handle<> and pointer to handle<) are different. In memory all handles are of course equal so the assignment should work and makes sense cause the handle only contains a pointer to the actual object and because those are related casting to the base type is fine. I could hack (for sake of experiment) something that would make above compile and actually work, but since this is SWIG generated helper/glue code I cannot understand how make SWIG emit that kind of thing. And I suspect that that would be wrong approach as this is probably some missing def somewhere. I've looked for differences in OCE and OCC but nothing seems to be related this general problem (have like 16 of similar errors in this one file). In the .i file the two classes are defined as: class Handle_Geom_BoundedCurve : public Handle_Geom_Curve { Handle_Geom_BoundedCurve()=0; }; class Handle_Geom_BSplineCurve : public Handle_Geom_BoundedCurve { Handle_Geom_BSplineCurve()=0; }; wbr Kusti