Skip to content

Commit 62e0685

Browse files
committed
Test and document imfuncname special variable expansion
1 parent e25911b commit 62e0685

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

CHANGES.current

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
77
Version 4.1.0 (in progress)
88
===========================
99

10+
2022-05-30: LindleyF
11+
[Java] #2042 Add new special variable expansion: $imfuncname.
12+
Expands to the function name called in the intermediary class.
13+
1014
2022-02-02: olly
1115
[Ruby] https://sourceforge.net/p/swig/bugs/1136/ Fix remove of prefix
1216
from method name to only remove it at the start.

Doc/Manual/Java.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6441,7 +6441,8 @@ <H3><a name="Java_special_variables">27.9.7 Java special variables</a></H3>
64416441

64426442
<p>
64436443
<b><tt>$imfuncname</tt></b><br>
6444-
This special variable expands to the name of the function on the $imclassname that will be used in $jnicall.
6444+
This special variable expands to the name of the function in the intermediary class that will be used in $jnicall.
6445+
Like, $jnicall, this special variable is only expanded in the "javaout" typemap.
64456446
</p>
64466447

64476448
<p>

Examples/test-suite/java/java_typemaps_proxy_runme.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ public static void main(String argv[]) {
7676
java_typemaps_proxyJNI.Without_member_method(nullPtr, nullPtr);
7777
java_typemaps_proxyJNI.delete_Without(nullPtr);
7878
java_typemaps_proxyJNI.global_method_without(nullPtr);
79+
80+
// $imfuncname substitution
81+
ProxyA pa = new ProxyA();
82+
if (pa.imfuncname_test() != 123)
83+
throw new RuntimeException("imfuncname_test is not 123");
84+
if (ProxyA.imfuncname_static_test() != 234)
85+
throw new RuntimeException("imfuncname_test is not 234");
86+
if (java_typemaps_proxy.imfuncname_global_test() != 345)
87+
throw new RuntimeException("imfuncname_test is not 345");
7988
}
8089
}
8190

Examples/test-suite/java_typemaps_proxy.i

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,20 @@ void global_method_constwithout(const ConstWithout *p) {}
127127
%}
128128

129129

130+
// $imfuncname substitution
131+
%typemap(javaout) int imfuncname_test {
132+
return $moduleJNI.$imfuncname(swigCPtr, this) + 123;
133+
}
134+
%typemap(javaout) int imfuncname_static_test {
135+
return $moduleJNI.$imfuncname() + 234;
136+
}
137+
%typemap(javaout) int imfuncname_global_test {
138+
return $moduleJNI.$imfuncname() + 345;
139+
}
140+
%inline %{
141+
struct ProxyA {
142+
int imfuncname_test() { return 0; }
143+
static int imfuncname_static_test() { return 0; }
144+
};
145+
int imfuncname_global_test() { return 0; }
146+
%}

0 commit comments

Comments
 (0)