Re: $typemap and variable names
William S Fulton <[email protected]> Sun, 20 Jun 2021 11:25:39 +0100
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CANGqftDA0BasNKB9QY99+PAc0xDcSprm91E7de=pxmcc1Y_YiQ@mail.gmail.com> |
Hi Lindley This is quite hard to follow what you are doing. From what I can make out the expansion of $javainput in 'javain' is okay. It should work the same as $input in the 'in' typemap and I can't see a difference in behaviour. The techniques to handle template types in map<K, V> can be seen in Lib/java/std_map.i. Perhaps that will help you. If not, perhaps give a full example of std:map that you want to customise. William On Tue, 27 Apr 2021 at 18:40, Lindley French <[email protected]> wrote: > Im trying to write a typemap involving subtypes. Specifically, for > map<K,V>. > > The problem is that when I reference $typemap(javain, K) within > %typemap(javain) map<K,V>, the value of $javainput is the same variable > name in the inner and outer typemaps, even though it has different types. > > In the 'in' typemap I was able to handle this with scoping to create a > shadow. I can do the same in Java with an anonymous class. But that’s > super-verbose, and since the javain typemap is an expression rather than a > block, I'm not sure how to format it so it's readable. A Java lambda > would be much cleaner, but they don't allow shadowing. > > According to > http://www.swig.org/Doc3.0/SWIGDocumentation.html#Typemaps_special_macro_typemap, > "The special variables within the matched typemap are expanded into those > for the matched typemap type, not the typemap within which the macro is > called." But this doesn't appear to apply to $javainput. I thought > that $typemap(javain, KeyType& key) might set $javainput to "key", but it > doesn't, unfortunately. > > Is it possible to reassign the javainput variable temporarily, or use a > special syntax that tells swig to rename it for me in $typemap lookups? > _______________________________________________ > Swig-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/swig-user > _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user