From: William S F. <ws...@fu...> - 2006-09-22 22:36:08
|
Nitro wrote: >> I'd like to have this feature. I would say that doing this using *any* >> name is better than nothing. At least when the type is returned by a >> function you get back something you can use, rather than the mostly >> useless bare PySwigObject I'm always seeing for unwrapped templates. >> Even doing the equivalent of %template(), with *no* name, would be quite >> useful for std::vector and many other templates; at least it allows >> passing (in Python) a list or tuple, and receiving one from functions >> that >> return by value or const ref. > > I definately agree here, especially on the %template() comment. I also > thought a bit how to realize this. > > The whole problem of generating names resembles a lot of the %rename > "troubles". Marcelo implemented some kind of regex mechanism for that. > While allowing for more flexibility, I think one could go even one step > further. Ideally, the user could plugin his own "functions" into swig for > doing this. These functions could be something like a simple language to > manipulate strings. It could go further and allow to write arbitrary > python functions for instance. The basic concept here could be wrapping > swig with itself :-) Sounds scary, but it probably would make sense. The > cases I figured out so far would be %renaming and automatic template > names. Maybe there are lots of other areas where this customization could > be of use. > I see that this feature might make swig slower if users rely on it a lot, > but it's still faster than the current 2 pass algorithm I am applying > (generating XML with swig, parsing it, generating some swig %things and > running swig again). > > Comments? > This is not really a discussion for swig-user though, so I've posted to swig-devel instead. I think more effort should be placed on providing tools to translate the XML output into generating the manually customised code rather than overcomplicating SWIG. It is a bit like wanting to extend the C++ language with some esoteric features to do things that can be done with a code generator instead. Like C++, I think SWIG has too many weird features and the feature creep should be curtailed otherwise you'll end up with a 'write-only' language like perl. Well that is my opinion since you asked :) Having said that it would be nice to have an automatic %template instantiation and I'd be all for simple elegant solutions, but failing that, I'd leave it as a manual process. Anyone is welcome to have a go at implementing a %template() solution, but I've got other priorities. William |
From: William S F. <ws...@fu...> - 2006-09-25 21:20:37
|
Nitro wrote: > Am 23.09.2006, 00:33 Uhr, schrieb William S Fulton > <ws...@fu...>: > >> I think more effort should be placed on providing tools to translate the >> XML output into generating the manually customised code rather than >> overcomplicating SWIG. It is a bit like wanting to extend the C++ >> language with some esoteric features to do things that can be done with >> a code generator instead. Like C++, I think SWIG has too many weird >> features and the feature creep should be curtailed otherwise you'll end >> up with a 'write-only' language like perl. Well that is my opinion since >> you asked :) > > I definately see your point and agree. Swig really has a lot of > "esoteric" features which leads to a lot of possible combinations > between them. So I guess testing takes up a lot of time. And you're > right about the 'write-only' language, too. > There's just one major point that I don't like about the xml approach. > It's very very slow. Usually a single swig run in our project requires > 30-60 seconds. We have more than 5 runs of this for a complete build. > Some swig modules depend on others, so if you change the one where all > others are dependent on, you are forced to do a complete rebuild. > Now the XML step doubles this time, because we need to run swig twice. > Some of the XML files it generates are >100 MB, so it takes a > considerable amount of time to parse them. This all makes the swig build > very slow. Have you looked at using -xmllite to reduce generated output? William |
From: Josh C. <jc...@nc...> - 2006-09-25 13:51:52
|
On Fri, 22 Sep 2006, William S Fulton wrote: > Having said that it would be nice to have an automatic %template > instantiation and I'd be all for simple elegant solutions, but failing > that, I'd leave it as a manual process. Anyone is welcome to have a go > at implementing a %template() solution, but I've got other priorities. One further thought: a warning would help a lot, so we could know about template return values and parameters that are not being wrapped and have a list of what to do manually. Josh |