Re: cross-project inheritance question
William S Fulton <[email protected]> Thu, 13 Oct 2022 21:07:18 +0100
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftBf=ROKnnY2pshXsiOZoRhgAS2W7ndKtRHyT5xfAK=Kyw@mail.gmail.com> |
Have a look at %import which imports type information, but doesn't wrap the types. There is a python example shipped with SWIG in the Examples/python/import directory. William On Thu, 13 Oct 2022 at 20:42, Langer, Stephen A. (Fed) via Swig-user < [email protected]> wrote: > Hi -- > > I have two projects, A and B. Both are a mix of C++ and Python, with swig4 > interfaces. Project A defines some classes that are used in project B, > both by importing python modules and by C++ #includes. A C++ class in B > (BClass) is derived from a C++ class in A (AClass). Both classes have > swig-generated Python equivalents. > > In Python, I want to pass a wrapped instance of the derived class (in B) > to a wrapped function in A that expects an AClass* argument. But the > wrapper for A is rejecting the argument because it doesn't know that BClass > is derived from A's AClass. How can I tell swig about the inheritance? > I've tried declaring AClass as "extern" in B's swig file, and also > duplicating AClass in the file, but those don't seem to work. > > Should I add a typemap to A so that the function doesn't check its > argument type, and just call SWIG_ConvertPtr manually? > > Thanks, > Steve > > > > _______________________________________________ > 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