From: Joel A. <j.a...@gm...> - 2015-10-30 14:29:39
|
Sure, it's possible to do like that, but it would require us to maintain a separate Foo.i file, which we want to avoid. To avoid code duplication of hundreds of functions, we always try to "%import" the C++ header file directly, which has "#ifdef SWIG" for SWIG-specific things. Best regards, Joel 2015-10-30 14:53 GMT+01:00 Andrew Haining < and...@di...>: > I might have misunderstood but you can expose methods of Bar on Foo > objects without wrapping Bar like so: > > Foo.cpp > > template<typename Derived> > > class Bar > > { > > public: > > void barMethod() {} > > }; > > > > class Foo : public Bar<Foo> > > { > > public: > > void fooMethod() {} > > }; > > > > Foo.i > > class Foo > > { > > public: > > void fooMethod(); > > void barMethod(); > > }; > > > > *From:* Joel Andersson [mailto:j.a...@gm...] > *Sent:* 30 October 2015 10:10 > *To:* swig-user <swi...@li...> > *Subject:* [Swig-user] Inline templated proxy classes when doing static > polymorphism? > > > > Hi, > > > > Static polymorphism is a useful idiom in C++, e.g. > > template<typename Derived> > > class Bar { > > ... > > }; > > > > class Foo : public Bar<Foo> { > > ... > > }; > > > > When I wrap this with SWIG, I have to create proxy classes both for > Bar<Foo> (using the %template command) and Foo. > > > > Is there some way to avoid the creation of a proxy class for Bar<Foo> and > simply copy all of its functions into Foo? That would make the generated > public API much cleaner. > > > > Best regards, > > Joel > > > > > > > ______________________________________________________________________ > This email has been scanned by the Symantec Email Security.cloud service. > For more information please visit http://www.symanteccloud.com > ______________________________________________________________________ > > > > *Digital Barriers e-Mail Confidentiality and Disclaimer* > > > > This message contains confidential information and is intended only for > the individual named. Please notify the sender immediately by e-mail if you > have received this e-mail by mistake and delete this e-mail from your > system. E-mail transmission cannot be guaranteed to be secure or error-free > as information could be intercepted, corrupted, lost, destroyed, arrive > late or incomplete, or contain viruses. The sender therefore does not > accept liability for any errors or omissions in the contents of this > message, which arise as a result of e-mail transmission. The recipient > should check this email and any attachments for the presence of viruses. > The company accepts no liability for any damage caused by any virus > transmitted by this email. > > > > Digital Barriers plc is a company registered in England and Wales. > Registered number: 7149547. Registered office: Cargo Works, 1-2 Hatfields, > London SE1 9PG, United Kingdom. For further information about Digital > Barriers, please visit www.digitalbarriers.com. > > > > > ______________________________________________________________________ > This email has been scanned by the Symantec Email Security.cloud service. > For more information please visit http://www.symanteccloud.com > ______________________________________________________________________ > -- -- Joel Andersson, PhD Ptge. Busquets 11-13, atico 3 E-08940 Cornella de Llobregat (Barcelona), Spain Home: +34-93-6034011 Mobile: +34-63-4408800 (in Sweden also +46-707-360512) |