From 62e0685df61bd636cb101eb58a27e0e14074b0c2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 30 May 2022 19:00:04 +0100 Subject: [PATCH] Test and document imfuncname special variable expansion --- CHANGES.current | 4 ++++ Doc/Manual/Java.html | 3 ++- .../java/java_typemaps_proxy_runme.java | 9 +++++++++ Examples/test-suite/java_typemaps_proxy.i | 17 +++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 46c567a02..95114d3f6 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -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. diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 03e3c9124..4a4b1750f 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6441,7 +6441,8 @@ unless the jniclassname attribute is specified in the

diff --git a/Examples/test-suite/java/java_typemaps_proxy_runme.java b/Examples/test-suite/java/java_typemaps_proxy_runme.java index 67a083114..0caeb1c65 100644 --- a/Examples/test-suite/java/java_typemaps_proxy_runme.java +++ b/Examples/test-suite/java/java_typemaps_proxy_runme.java @@ -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"); } } diff --git a/Examples/test-suite/java_typemaps_proxy.i b/Examples/test-suite/java_typemaps_proxy.i index 3e9b18335..b20dd385b 100644 --- a/Examples/test-suite/java_typemaps_proxy.i +++ b/Examples/test-suite/java_typemaps_proxy.i @@ -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; } +%}