Merge branch 'imfunc'

* imfunc:
  Add special variable imfuncname expansion for C# and D
  Test and document imfuncname special variable expansion
  Update docs.
  Also expose  in proxyClassFunctionHandler
  Expose  to javaout typemaps.

Conflicts:
	CHANGES.current
This commit is contained in:
William S Fulton 2022-05-30 19:45:28 +01:00
commit 34c219b5f7
11 changed files with 117 additions and 0 deletions

View File

@ -7,6 +7,14 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
2022-05-30: wsfulton
[C#, D] Add new special variable expansion: $imfuncname.
Expands to the function name called in the intermediary class.
2022-05-30: LindleyF
[Java] #2042 Add new special variable expansion: $imfuncname.
Expands to the function name called in the intermediary class.
2022-05-28: jkuebart
[Java] On some versions of Android, specifically Android 6,
detaching the current thread from the JVM after every invocation

View File

@ -550,6 +550,12 @@ This special variable expands to the intermediary class name. For C# this is usu
unless the imclassname attribute is specified in the <a href="CSharp.html#CSharp_module_directive">%module directive</a>.
</p>
<p>
<b><tt>$imfuncname</tt></b><br>
This special variable expands to the name of the function in the intermediary class that will be used in $imcall.
Like, $imcall, this special variable is only expanded in the "csout", "csvarin" and "csvarout" typemaps.
</p>
<p>
The directory <tt>Examples/csharp</tt> has a number of simple examples.
Visual Studio .NET 2003 solution and project files are available for compiling with the Microsoft .NET C#

View File

@ -267,6 +267,12 @@ SomeClass bar() {
</pre></div>
</dd>
<dt><tt>$imfuncname</tt></dt>
<dd><p>
This special variable expands to the name of the function in the intermediary class that will be used in $imcall.
Like, $imcall, this special variable is only expanded in the "dout" typemap.
</p></dd>
<dt><a name="D_importtype"></a><tt>$importtype(SomeDType)</tt></dt>
<dd>
<p>This macro is used in the <tt>dimports</tt> typemap if a dependency on another D type generated by SWIG is added by a custom typemap.</p>

View File

@ -6456,6 +6456,12 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the <a href="Java.html#Java_module_directive">%module directive</a>.
</p>
<p>
<b><tt>$imfuncname</tt></b><br>
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>
<b><tt>$javainterfacename</tt></b><br>
This special variable is only expanded when the <tt>interface</tt> feature is applied to a class.

View File

@ -107,6 +107,22 @@ public class TestThread {
Console.Error.WriteLine("Test failed (thread " + threadId + "): " + e.Message);
Failed = true;
}
// $imfuncname substitution
ProxyA pa = new ProxyA();
if (pa.imfuncname_test() != 123)
throw new ApplicationException("imfuncname_test is not 123");
if (ProxyA.imfuncname_static_test() != 234)
throw new ApplicationException("imfuncname_test is not 234");
if (csharp_typemaps.imfuncname_global_test() != 345)
throw new ApplicationException("imfuncname_test is not 345");
pa.variab = 1000;
if (pa.variab != 1000 + 111 + 222)
throw new ApplicationException("pa.variab is not 1333");
csharp_typemaps.global_variab = 1000;
if (csharp_typemaps.global_variab != 1000 + 333 + 444)
throw new ApplicationException("csharp_typemaps.variab is not 1777");
}
}

View File

@ -136,3 +136,42 @@ namespace Glob {
bool MVar::svar = false;
%}
// $imfuncname substitution
%typemap(csout) int imfuncname_test {
return $modulePINVOKE.$imfuncname(swigCPtr) + 123;
}
%typemap(csout) int imfuncname_static_test {
return $modulePINVOKE.$imfuncname() + 234;
}
%typemap(csout) int imfuncname_global_test {
return $modulePINVOKE.$imfuncname() + 345;
}
%typemap(csvarout, excode=SWIGEXCODE2) int variab %{
get {
int ret = $modulePINVOKE.$imfuncname(swigCPtr) + 222;$excode
return ret;
} %}
%typemap(csvarin, excode=SWIGEXCODE2) int variab %{
set {
$modulePINVOKE.$imfuncname(swigCPtr, value + 111);$excode
} %}
%typemap(csvarout, excode=SWIGEXCODE2) int global_variab %{
get {
int ret = $modulePINVOKE.$imfuncname() + 333;$excode
return ret;
} %}
%typemap(csvarin, excode=SWIGEXCODE2) int global_variab %{
set {
$modulePINVOKE.$imfuncname(value + 444);$excode
} %}
%inline %{
struct ProxyA {
int imfuncname_test() { return 0; }
static int imfuncname_static_test() { return 0; }
int variab;
};
int imfuncname_global_test() { return 0; }
int global_variab;
%}

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

@ -125,3 +125,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; }
%}

View File

@ -2595,6 +2595,7 @@ public:
} else {
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
Replaceall(tm, "$imfuncname", intermediary_function_name);
Replaceall(tm, "$imcall", imcall);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0));
@ -2638,6 +2639,7 @@ public:
if ((tm = Swig_typemap_lookup("csvarin", variable_parm, "", 0))) {
substituteClassname(cvariable_type, tm);
Replaceall(tm, "$csinput", "value");
Replaceall(tm, "$imfuncname", intermediary_function_name);
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarin", variable_parm);
Printf(proxy_class_code, "%s", tm);
@ -2652,6 +2654,7 @@ public:
else
Replaceall(tm, "$owner", "false");
substituteClassname(t, tm);
Replaceall(tm, "$imfuncname", intermediary_function_name);
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarout", n);
Printf(proxy_class_code, "%s", tm);
@ -3164,6 +3167,7 @@ public:
else
Replaceall(tm, "$owner", "false");
substituteClassname(t, tm);
Replaceall(tm, "$imfuncname", overloaded_name);
Replaceall(tm, "$imcall", imcall);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSOUT_UNDEF, input_file, line_number, "No csout typemap defined for %s\n", SwigType_str(t, 0));
@ -3202,6 +3206,7 @@ public:
if ((tm = Getattr(p, "tmap:csvarin"))) {
substituteClassname(pt, tm);
Replaceall(tm, "$csinput", "value");
Replaceall(tm, "$imfuncname", overloaded_name);
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarin", p);
Printf(module_class_code, "%s", tm);
@ -3216,6 +3221,7 @@ public:
else
Replaceall(tm, "$owner", "false");
substituteClassname(t, tm);
Replaceall(tm, "$imfuncname", overloaded_name);
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarout", n);
Printf(module_class_code, "%s", tm);

View File

@ -2898,6 +2898,7 @@ private:
} else {
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
Replaceall(tm, "$imfuncname", intermediary_function_name);
Replaceall(tm, "$imcall", imcall);
} else {
Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,
@ -3100,6 +3101,7 @@ private:
else
Replaceall(tm, "$owner", "false");
replaceClassname(tm, t);
Replaceall(tm, "$imfuncname", overloaded_name);
Replaceall(tm, "$imcall", imcall);
} else {
Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,

View File

@ -2691,6 +2691,7 @@ public:
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
Replaceall(tm, "$imfuncname", intermediary_function_name);
Replaceall(tm, "$jnicall", imcall);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap defined for %s\n", SwigType_str(t, 0));
@ -3176,6 +3177,7 @@ public:
else
Replaceall(tm, "$owner", "false");
substituteClassname(t, tm);
Replaceall(tm, "$imfuncname", overloaded_name);
Replaceall(tm, "$jnicall", imcall);
} else {
Swig_warning(WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF, input_file, line_number, "No javaout typemap defined for %s\n", SwigType_str(t, 0));