From: Josh C. <jc...@nc...> - 2009-05-26 14:13:40
|
On Tue, 26 May 2009, Philipp Kraft wrote: > Maybe I wasn't precise enough. It is not the problem to access A from B with > some function (get_A is a member of B) but to use b as an A in a "quasi duck > typing way". > This works: >>>> ct.print_a(b.get_A()) # but it's ugly and hard to explain to Non-C++ > Python programmers > > This should work: >>>> ct.print_a(b) # Simple to use, but how to do it with SWIG? > > The idea is to have a "HAS A" relationship, and, in some cases an "IS A" > relationship-like behaviour without using inheritance. You could provide typemaps for A& that accept B. Alternatively, if the number of functions is small you could provide overloads that take a B& for wrapping purposes. Josh |