$typemap and variable names
Lindley French <[email protected]> Tue, 27 Apr 2021 10:39:41 -0700
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CALwtg07vE69dHstSuntu_gYR11D8+x_Gp1egdWKpGZkczAxfBA@mail.gmail.com> |
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