diff --git a/CHANGES.current b/CHANGES.current index 4cea8d91b..9e4b02d4d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,12 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2019-03-30: wsfulton + [Java, D] Add the parameters typemap attribute to the javadestruct, + javadestruct_derived, ddispose, ddispose_derived typemaps to mirror enhanced + flexibility in the csdisposing and csdisposing_derived (C#) typemaps. If provided + the contents are generated as the delete/dispose method's parameters declaration. + 2019-03-30: wsfulton [C#] #421 Fix CA1063 warning by implementing the recommended Dispose methods for the IDisposable interface. Previously just the Dispose() method was generated. diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html index a252650ff..f1b3404a6 100644 --- a/Doc/Manual/D.html +++ b/Doc/Manual/D.html @@ -107,8 +107,8 @@ csimports <-> dimports csbody <-> dbody csfinalize <-> ddestructor - csdestruct <-> ddispose - csdestruct_derived <-> ddispose_derived + csdisposing <-> ddispose + csdisposing_derived <-> ddispose_derived diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 3a04b8a79..cdefba6b4 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -6552,7 +6552,7 @@ As there can only be one "javacode" typemap per class, also consider using the and offers nearly identical functionality. -
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized")
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized", parameters="")
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized")
+%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized", parameters="")
%typemap(javaimports)
diff --git a/Lib/d/dclassgen.swg b/Lib/d/dclassgen.swg index 68910b412..84fa03a0b 100644 --- a/Lib/d/dclassgen.swg +++ b/Lib/d/dclassgen.swg @@ -33,7 +33,7 @@ // We do not use »override« attribute for generated dispose() methods to stay // somewhat compatible to Phobos and older Tango versions where Object.dispose() // does not exist. -%typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE { +%typemap(ddispose, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { @@ -45,7 +45,7 @@ } } -%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE { +%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public", parameters="") SWIGTYPE { synchronized(this) { if (swigCPtr !is null) { if (swigCMemOwn) { diff --git a/Lib/java/java.swg b/Lib/java/java.swg index a5b7bbab1..e9309331a 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1313,7 +1313,7 @@ SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) // Set the default for SWIGTYPE: Java owns the C/C++ object. SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) -%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { +%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; @@ -1323,7 +1323,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) } } -%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { +%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized", parameters="") SWIGTYPE { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index 4fa30dd60..5e82dfda3 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -3274,17 +3274,20 @@ private: // attribute called »methodname«. const String *tm = NULL; - String *dispose_methodname; - String *dispose_methodmodifiers; + const String *dispose_methodname; + const String *dispose_methodmodifiers; + const String *dispose_parameters; attributes = NewHash(); if (derived) { tm = lookupCodeTypemap(n, "ddispose_derived", typemap_lookup_type, WARN_NONE, attributes); dispose_methodname = Getattr(attributes, "tmap:ddispose_derived:methodname"); dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose_derived:methodmodifiers"); + dispose_parameters = Getattr(attributes, "tmap:ddispose_derived:parameters"); } else { tm = lookupCodeTypemap(n, "ddispose", typemap_lookup_type, WARN_NONE, attributes); dispose_methodname = Getattr(attributes, "tmap:ddispose:methodname"); dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose:methodmodifiers"); + dispose_parameters = Getattr(attributes, "tmap:ddispose:parameters"); } if (tm && *Char(tm)) { @@ -3298,6 +3301,8 @@ private: "No methodmodifiers attribute defined in ddispose%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } + if (!dispose_parameters) + dispose_parameters = empty_string; } if (tm) { @@ -3324,7 +3329,7 @@ private: Printv(body, methodmods, NIL); else Printv(body, dispose_methodmodifiers, (derived ? " override" : ""), NIL); - Printv(body, " void ", dispose_methodname, "() ", dispose_code, "\n", NIL); + Printv(body, " void ", dispose_methodname, "(", dispose_parameters, ") ", dispose_code, "\n", NIL); } } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index ac845cb09..94087369a 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2035,16 +2035,19 @@ public: String *destruct = NewString(""); const String *tm = NULL; attributes = NewHash(); - String *destruct_methodname = NULL; - String *destruct_methodmodifiers = NULL; + const String *destruct_methodname = NULL; + const String *destruct_methodmodifiers = NULL; + const String *destruct_parameters = NULL; if (derived) { tm = typemapLookup(n, "javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers"); + destruct_parameters = Getattr(attributes, "tmap:javadestruct_derived:parameters"); } else { tm = typemapLookup(n, "javadestruct", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers"); + destruct_parameters = Getattr(attributes, "tmap:javadestruct:parameters"); } if (tm && *Char(tm)) { if (!destruct_methodname) { @@ -2053,6 +2056,8 @@ public: if (!destruct_methodmodifiers) { Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name); } + if (!destruct_parameters) + destruct_parameters = empty_string; } // Emit the finalize and delete methods if (tm) { @@ -2073,7 +2078,7 @@ public: Printv(proxy_class_def, methodmods, NIL); else Printv(proxy_class_def, destruct_methodmodifiers, NIL); - Printv(proxy_class_def, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL); + Printv(proxy_class_def, " void ", destruct_methodname, "(", destruct_parameters, ") ", destructor_throws_clause, " ", destruct, "\n", NIL); } } if (*Char(interface_upcasts))