|
From: William S F. <ws...@fu...> - 2010-03-15 20:26:58
|
James17 wrote: > Hi all, > > I am wrapping a very large library of which I do not own the header files. > There are some circumstances where I would like to apply an "output_helper" > on functions that would otherwise return void. I've looked around and found > the following: > > %typemap(argout, fragment="output_helper") > > This will return the reference argument passed as a return value (instead of > void). Unfortunately, the above does not guarantee the following: > > 1. That the typemap applies only to functions that return void > 2. That it applies to a specific class and method (we may want to toggle > this on/off in some circumstances - maybe in cases where there is more than > one non-const reference argument) You can't use argout (an input typemap targeting an input type) and the output. Typemaps apply to *types* and the input types are not related to the output types. You need to write a helper function and wrap that for the kind of things you are looking for. > > So more generally, I'm asking: > > 1. How can I tell a typemap to only apply to a function that returns void? %typemap(out) void "...fill me in..." > 2. How can I tell a typemap to only apply to a specific class and method? %typemap(out) void Foo::bar ".. fill me in.." > 3. (slightly related): Where can I find documentation on all possible > typemap modifiers? The typemaps documentation only briefly mentions it > (%typemap(method [, modifiers]) typelist code ;) but does not provide an > index of available keywords and what the keywords do. There isn't one place to find these I'm afraid. Each typemap method (like in, out, argout) can support different modifiers and specific modifiers are documented with the typemaps. There are a few global modifiers, but you should find them all in Typemaps.html. "fragment" is one that isn't documented though. I'd like to beef up the documentation in this area, so if you find any others, let me know. If you are going to be using typemaps, I suggest you try out version 2.0 which is currently only in subversion... the documentation in Typemaps.html is improved and this version supports a few very useful typemaps debugging commandline options (-debug-tmsearch and -debug-tmused). William |