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
|
|
@ -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