Test and document imfuncname special variable expansion

This commit is contained in:
William S Fulton 2022-05-30 19:00:04 +01:00
commit 62e0685df6
4 changed files with 32 additions and 1 deletions

View file

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
2022-05-30: LindleyF
[Java] #2042 Add new special variable expansion: $imfuncname.
Expands to the function name called in the intermediary class.
2022-02-02: olly
[Ruby] https://sourceforge.net/p/swig/bugs/1136/ Fix remove of prefix
from method name to only remove it at the start.

View file

@ -6441,7 +6441,8 @@ unless the jniclassname attribute is specified in the <a href="Java.html#Java_mo
<p>
<b><tt>$imfuncname</tt></b><br>
This special variable expands to the name of the function on the $imclassname that will be used in $jnicall.
This special variable expands to the name of the function in the intermediary class that will be used in $jnicall.
Like, $jnicall, this special variable is only expanded in the "javaout" typemap.
</p>
<p>

View file

@ -76,6 +76,15 @@ public class java_typemaps_proxy_runme {
java_typemaps_proxyJNI.Without_member_method(nullPtr, nullPtr);
java_typemaps_proxyJNI.delete_Without(nullPtr);
java_typemaps_proxyJNI.global_method_without(nullPtr);
// $imfuncname substitution
ProxyA pa = new ProxyA();
if (pa.imfuncname_test() != 123)
throw new RuntimeException("imfuncname_test is not 123");
if (ProxyA.imfuncname_static_test() != 234)
throw new RuntimeException("imfuncname_test is not 234");
if (java_typemaps_proxy.imfuncname_global_test() != 345)
throw new RuntimeException("imfuncname_test is not 345");
}
}

View file

@ -127,3 +127,20 @@ void global_method_constwithout(const ConstWithout *p) {}
%}
// $imfuncname substitution
%typemap(javaout) int imfuncname_test {
return $moduleJNI.$imfuncname(swigCPtr, this) + 123;
}
%typemap(javaout) int imfuncname_static_test {
return $moduleJNI.$imfuncname() + 234;
}
%typemap(javaout) int imfuncname_global_test {
return $moduleJNI.$imfuncname() + 345;
}
%inline %{
struct ProxyA {
int imfuncname_test() { return 0; }
static int imfuncname_static_test() { return 0; }
};
int imfuncname_global_test() { return 0; }
%}