From: Steven H. <snh...@gm...> - 2007-09-30 13:20:29
|
On Sat, 29 Sep 2007, William S Fulton wrote: > Steven Hirsch wrote: >> >> SWIG does a super job of hitting a useful common denominator across all >> languages, but you're getting into an area where it could benefit from more >> "smarts". If the documentation on authoring SWIG language personalities >> was more complete (or comprehensible) I'd take a crack at it myself. As it >> is, the learning curve is too steep. I don't have time to reverse engineer >> a dense, undocumented system of C++ code and macros. >> >> There's a lot of information there, but despite numerous re-readings, I'm >> just not seeing a cohesive picture. Any time I've needed a capability that >> was not intrinsic it generally entails an afternoon of swearing, >> hairpulling and painstaking examination of the generated wrapper code. >> There have been times I've simply given up and resorted to sed or perl post >> processing to fix bindings dynamically after SWIG generates them. > Unfortunately Perl is one of the languages that is not given much attention > due to lack of a maintainer. It is quite a lot to ask of someone to > understand Perl, XS, C/C++ and the SWIG machinery in order to customise the > generated code. However, Steven, it sounds like you understand all of this > bar the SWIG typemaps. If you could give examples of what is generated and > what you'd like to be generated, we'd be able to tell you how to achieve this > and provide the missing piece in the puzzle. The current complexity in the > SWIG typemaps is something that needs addressing, but it is quite possible to > ignore all that complexity and write simple typemaps like in older versions > of SWIG before the UTL became prevalent. Although the documentation is very > large, Perl specific examples of typemaps need putting in. It really wouldn't > be very difficult for anyone familiar with XS and just a bit more SWIG > knowledge. If you could help in this area, it would be great for everyone. The next time something specific comes up, I will post. In the meantime, can someone _please_ start even a hand-waving discussion of the UTL? It looks quite powerful and I'm trusting that there are maintainers who understand it well. In a general sense, most of my problems are rooted in lack of cooperation from the typemap "triggering" system. It seems sensitive to how I hold my mouth, phases of the moon, etc. Most of the times I've resorted to hacking the generated wrapper it's been because a seemingly valid typemap simply is not getting invoked. This is most chronic with Perl/C++ interfaces. A second annoyance is the random refusal of %ignore to, well, ignore things. With complex C++ code, the SWIG parser can trip over constructs that you really would rather have it ignore. When templated classes are involved it can be near impossible to get SWIG to ignore an "immediate" specialization. For example, if I have template <class T> someclass { ... there's no way to tell SWIG to ignore typedef someclass<Foo> OtherClass; The only way ignore will work is on an actual derivation: class OtherClass : public someclass<Foo> { ... I can then say %ignore OtherClass; and _that_ will work. Theoretically, warnings can be turned off for specific classes. I have never actually been able to make this work. To make it shut up about inner classes, I have to suppress the class of warning for everything at the global level - naming the class does not work. The perl documentation is so out-of-date that (last I looked) it fails to mention direct object syntax, i.e. it leads you to believe that you must call a wrapped method foo as: foo( $object, <args>... ) when in fact $object->foo( <args>.. ) is perfectly valid and has been for years! Who was the most recent Perl maintainer? Perhaps we can shame/cajole them into a managed handoff and get their TODO list and thoughts for the future? Steve -- |