Add the parameters typemap attribute to D and Java destructor wrapper typemaps
Added 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.
This commit is contained in:
parent
06462acdf9
commit
831fae3c69
7 changed files with 32 additions and 14 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@
|
|||
csimports <-> dimports
|
||||
csbody <-> dbody
|
||||
csfinalize <-> ddestructor
|
||||
csdestruct <-> ddispose
|
||||
csdestruct_derived <-> ddispose_derived
|
||||
csdisposing <-> ddispose
|
||||
csdisposing_derived <-> ddispose_derived
|
||||
</pre></div>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6552,7 +6552,7 @@ As there can only be one "javacode" typemap per class, also consider using the
|
|||
and offers nearly identical functionality.
|
||||
</div>
|
||||
|
||||
<p><tt>%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized")</tt> <br></p>
|
||||
<p><tt>%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized", parameters="")</tt> <br></p>
|
||||
<div class="indent">
|
||||
destructor wrapper - the <tt>delete()</tt> method (proxy classes only),
|
||||
used for all proxy classes except those which have a base class
|
||||
|
|
@ -6563,9 +6563,10 @@ Note that the <tt>delete()</tt> method name is configurable and is specified by
|
|||
The method modifiers are also configurable via the <tt>methodmodifiers</tt> attribute.
|
||||
If a <tt>%javamethodmodifiers</tt> is attached to the class' destructor,
|
||||
it will be used in preference to the <tt>methodmodifiers</tt> typemap attribute for the class.
|
||||
The <tt>delete</tt> method's parameters declaration can be provided in the optional <tt>parameters</tt> typemap attribute.
|
||||
</div>
|
||||
|
||||
<p><tt>%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized")</tt></p>
|
||||
<p><tt>%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized", parameters="")</tt></p>
|
||||
<div class="indent">
|
||||
destructor wrapper - the <tt>delete()</tt> method (proxy classes only),
|
||||
same as "javadestruct" but only used for derived proxy classes
|
||||
|
|
@ -6576,6 +6577,7 @@ Note that the <tt>delete()</tt> method name is configurable and is specified by
|
|||
The method modifiers are also configurable via the <tt>methodmodifiers</tt> attribute.
|
||||
If a <tt>%javamethodmodifiers</tt> is attached to the class' destructor,
|
||||
it will be used in preference to the <tt>methodmodifiers</tt> typemap attribute for the class.
|
||||
The <tt>delete</tt> method's parameters declaration can be provided in the optional <tt>parameters</tt> typemap attribute.
|
||||
</div>
|
||||
|
||||
<p><tt>%typemap(javaimports)</tt></p>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue