C#, D, Java methodmodifiers on destructors
Add support so that the %csmethodmodifiers, %dmethodmodifiers, %javamethodmodifiers can modify the method modifiers for the destructor wrappers in the proxy class: dispose, Dispose, delete. With this feature, it is now possible to make a C# proxy class sealed, eg when wrapping a class X, the virtual method modifiers can be removed using: %typemap(csclassmodifiers) X "public sealed class" %csmethodmodifiers X::~X "public /*virtual*/";
This commit is contained in:
parent
1f7689fa8f
commit
ee17f8d04f
9 changed files with 210 additions and 13 deletions
|
|
@ -1910,9 +1910,15 @@ public:
|
|||
Replaceall(destruct, "$imcall", destructor_call);
|
||||
else
|
||||
Replaceall(destruct, "$imcall", "throw new global::System.MethodAccessException(\"C++ destructor does not have public access\")");
|
||||
if (*Char(destruct))
|
||||
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " ", derived ? "override" : "virtual", " void ", destruct_methodname, "() ", destruct, "\n",
|
||||
NIL);
|
||||
if (*Char(destruct)) {
|
||||
Printv(proxy_class_def, "\n ", NIL);
|
||||
const String *methodmods = Getattr(n, "destructmethodmodifiers");
|
||||
if (methodmods)
|
||||
Printv(proxy_class_def, methodmods, NIL);
|
||||
else
|
||||
Printv(proxy_class_def, destruct_methodmodifiers, " ", derived ? "override" : "virtual", NIL);
|
||||
Printv(proxy_class_def, " void ", destruct_methodname, "() ", destruct, "\n", NIL);
|
||||
}
|
||||
}
|
||||
if (*Char(interface_upcasts))
|
||||
Printv(proxy_class_def, interface_upcasts, NIL);
|
||||
|
|
@ -2860,7 +2866,11 @@ public:
|
|||
|
||||
if (proxy_flag) {
|
||||
Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL);
|
||||
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
|
||||
if (methodmods)
|
||||
Setattr(getCurrentClass(), "destructmethodmodifiers", methodmods);
|
||||
}
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1298,7 +1298,12 @@ public:
|
|||
virtual int destructorHandler(Node *n) {
|
||||
Language::destructorHandler(n);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
Printv(destructor_call, im_dmodule_fq_name, ".", Swig_name_destroy(getNSpace(),symname), "(cast(void*)swigCPtr)", NIL);
|
||||
const String *methodmods = Getattr(n, "feature:d:methodmodifiers");
|
||||
if (methodmods)
|
||||
Setattr(getCurrentClass(), "destructmethodmodifiers", methodmods);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -3312,9 +3317,13 @@ private:
|
|||
}
|
||||
|
||||
if (*Char(dispose_code)) {
|
||||
Printv(body, "\n", dispose_methodmodifiers,
|
||||
(derived ? " override" : ""), " void ", dispose_methodname, "() ",
|
||||
dispose_code, "\n", NIL);
|
||||
Printv(body, "\n", NIL);
|
||||
const String *methodmods = Getattr(n, "destructmethodmodifiers");
|
||||
if (methodmods)
|
||||
Printv(body, methodmods, NIL);
|
||||
else
|
||||
Printv(body, dispose_methodmodifiers, (derived ? " override" : ""), NIL);
|
||||
Printv(body, " void ", dispose_methodname, "() ", dispose_code, "\n", NIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1987,8 +1987,15 @@ public:
|
|||
Replaceall(destruct, "$jnicall", destructor_call);
|
||||
else
|
||||
Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")");
|
||||
if (*Char(destruct))
|
||||
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL);
|
||||
if (*Char(destruct)) {
|
||||
Printv(proxy_class_def, "\n ", NIL);
|
||||
const String *methodmods = Getattr(n, "destructmethodmodifiers");
|
||||
if (methodmods)
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (*Char(interface_upcasts))
|
||||
Printv(proxy_class_def, interface_upcasts, NIL);
|
||||
|
|
@ -2830,6 +2837,9 @@ public:
|
|||
if (proxy_flag) {
|
||||
Printv(destructor_call, full_imclass_name, ".", Swig_name_destroy(getNSpace(), symname), "(swigCPtr)", NIL);
|
||||
generateThrowsClause(n, destructor_throws_clause);
|
||||
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
|
||||
if (methodmods)
|
||||
Setattr(getCurrentClass(), "destructmethodmodifiers", methodmods);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue