Re: cross-project inheritance question
"Langer, Stephen A. \(Fed\) via Swig-user" <[email protected]> Fri, 14 Oct 2022 15:08:02 +0000
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <[email protected]> |
Hi William -- I have been using %import extensively, within each project, but I can't get it to work when importing the swig file from the other project. I've been using a simplified version of the imported swig file, because I don't want to import all of the class information. The two projects use different values of SWIG_TYPE_TABLE. Would that make A reject a derived class from B? I'll work on a simplified example to see if it does the same thing. -- Steve From: William S Fulton <[email protected]> Date: Thursday, October 13, 2022 at 4:08 PM To: "Langer, Stephen A. (Fed)" <[email protected]> Cc: "[email protected]" <[email protected]> Subject: Re: [Swig-user] cross-project inheritance question 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]<mailto:[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]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/swig-user<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7Ce6652c59a1344773f9cd08daad56a05d%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C638012884840630300%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=WPQzFONNZ0PNOtj4FKcoX3W1W2heMEP2Udfeskijr7g%3D&reserved=0> _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user