Re: How do I found out which .i rule/pattern generates a specific (illegal) C++ code fragment?
William S Fulton <[email protected]>
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftBF+wNVxaHe5LfE8PM1hD5csP5xmwvx2WBL8_Sy36EkQQ@mail.gmail.com> |
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 On Sat, 25 Jul 2020 at 08:35, Kustaa Nyholm <[email protected]> wrote: > > > > Further details, maybe my *question* was actually wrong! > > There seems to be actually 12 occurrences of the same code/pattern in the > generated file but only the > one I referred to in the original question causes compile error. > > > > > For example this is ok: > > // From SWIG generated wrapper > SWIGEXPORT jlong JNICALL > Java_org_jcae_opencascade_jni_OccJavaJNI_BRepBuilderAPI_1MakeShape_1shape(JNIEnv > *jenv, jclass jcls, jlong jarg1, jobject jarg1_) { > ... > TopoDS_Shape *result = 0 ; > ... > result = (TopoDS_Shape *) &((BRepBuilderAPI_MakeShape const > *)arg1)->Shape(); > > > // This is the OpenCascade C++ declaration (AFAIU): > class BRepBuilderAPI_MakeShape { > .... > virtual const TopoDS_Shape & Shape () > > > > > > But this results in 'taking the address of a temporary object of type' > error: > > // From SWIG generated wrapper > > SWIGEXPORT jlong JNICALL > Java_org_jcae_opencascade_jni_OccJavaJNI_BRepBuilderAPI_1ModifyShape_1modifiedShape(JNIEnv > *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jlong jarg2, jobject > jarg2_) { > ... > TopoDS_Shape *result = 0 ; > ... > result = (TopoDS_Shape *) &((BRepBuilderAPI_ModifyShape const > *)arg1)->ModifiedShape((TopoDS_Shape const &)*arg2); > > // This is the OpenCascade C++ declaration (AFAIU): > class BRepBuilderAPI_ModifyShape { > ... > virtual TopoDS_Shape ModifiedShape (const TopoDS_Shape &S) > const > > > > The difference that I see on the C++/OCC side is the 'const' in the return > type. > > > If that is the problem how can I fix this in the '.i' files without > touching OCC sources. > (I suspect the missing 'const' is really a bug or omission but it is what > it is). > > > wbr Kusti > > > > > > > > > > _______________________________________________ > > Swig-user mailing list > > [email protected] > > https://lists.sourceforge.net/lists/listinfo/swig-user > > > > _______________________________________________ > Swig-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/swig-user > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user