cildispose and cildisposeoverride typemaps replaced by
csdestruct_base and csdestruct_derived typemaps. The delete() method has been removed and its functionality put into these typemaps designed for the Dispose method. New typemaps: csfinalize for finalizers. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4877 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9cccf88afa
commit
191a2cc071
2 changed files with 48 additions and 25 deletions
|
|
@ -428,17 +428,28 @@ $1 = &temp; %}
|
|||
%typemap(javainterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
|
||||
%typemap(javaptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal"
|
||||
|
||||
%typemap(cildispose) SWIGTYPE %{
|
||||
public virtual void Dispose() {
|
||||
delete();
|
||||
%typemap(csfinalize) SWIGTYPE %{
|
||||
protected override void Finalize() {
|
||||
Dispose();
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(cildisposeoverride) SWIGTYPE %{
|
||||
public override void Dispose() {
|
||||
delete();
|
||||
%typemap(csdestruct_base) SWIGTYPE {
|
||||
if(swigCPtr != IntPtr.Zero && swigCMemOwn) {
|
||||
$jnicall;
|
||||
swigCMemOwn = false;
|
||||
}
|
||||
swigCPtr = IntPtr.Zero;
|
||||
}
|
||||
|
||||
%typemap(csdestruct_derived) SWIGTYPE {
|
||||
if(swigCPtr != IntPtr.Zero && swigCMemOwn) {
|
||||
$jnicall;
|
||||
swigCMemOwn = false;
|
||||
}
|
||||
swigCPtr = IntPtr.Zero;
|
||||
base.Dispose();
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(javagetcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
|
||||
internal static IntPtr getCPtr($javaclassname obj) {
|
||||
|
|
|
|||
|
|
@ -1088,24 +1088,36 @@ class CSHARP : public Language {
|
|||
NIL);
|
||||
}
|
||||
|
||||
// C++ destructor is wrapped by the delete method
|
||||
String *destruct = NewString("");
|
||||
const String *tm = NULL;
|
||||
if (derived)
|
||||
tm = javaTypemapLookup("csdestruct_derived", classDeclarationName, WARN_NONE);
|
||||
else
|
||||
tm = javaTypemapLookup("csdestruct_base", classDeclarationName, WARN_NONE);
|
||||
|
||||
// Emit the finalize and delete methods
|
||||
if (*Char(destructor_call) && tm) {
|
||||
Printv(destruct, tm, NIL);
|
||||
Replaceall(destruct, "$jnicall", destructor_call);
|
||||
// finalize method
|
||||
Printv(shadow_classdef,
|
||||
javaTypemapLookup("csfinalize", classDeclarationName, WARN_NONE),
|
||||
"\n",
|
||||
NIL);
|
||||
// delete method
|
||||
if (*Char(destruct)) {
|
||||
Printv(shadow_classdef, " public ", derived ? "override" : "virtual", " void Dispose() ", destruct, "\n", NIL);
|
||||
}
|
||||
} else {
|
||||
// Ensure method exists for derived class to call. Don't bother if the typemap doesn't exist.
|
||||
if (tm && *Char(tm))
|
||||
Printv(shadow_classdef, "\n protected ", derived ? "override" : "virtual", " void Dispose() {\n }\n", NIL);
|
||||
}
|
||||
Delete(destruct);
|
||||
|
||||
// Emit various other methods
|
||||
Printv(shadow_classdef,
|
||||
derived ?
|
||||
javaTypemapLookup("cildisposeoverride", classDeclarationName, WARN_NONE) :
|
||||
javaTypemapLookup("cildispose", classDeclarationName, WARN_NONE), // finalize method
|
||||
"\n",
|
||||
*Char(destructor_call) ? " protected " : " private ",
|
||||
derived ? "override" : "virtual",
|
||||
" void delete() {\n",
|
||||
" if(swigCPtr != IntPtr.Zero && swigCMemOwn) {\n",
|
||||
destructor_call,
|
||||
"",
|
||||
" swigCMemOwn = false;\n",
|
||||
derived ? // Zero all pointers up any inheritance hierarchy
|
||||
" base.delete();\n" :
|
||||
"",
|
||||
" }\n",
|
||||
" swigCPtr = IntPtr.Zero;\n",
|
||||
" }\n",
|
||||
javaTypemapLookup("javagetcptr", classDeclarationName, WARN_JAVA_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
javaTypemapLookup("javacode", classDeclarationName, WARN_NONE), // extra Java code
|
||||
"\n",
|
||||
|
|
@ -1551,7 +1563,7 @@ class CSHARP : public Language {
|
|||
String *symname = Getattr(n,"sym:name");
|
||||
|
||||
if(proxy_flag) {
|
||||
Printv(destructor_call, " ", jniclass_name, ".", Swig_name_destroy(symname), "(swigCPtr);\n", NIL);
|
||||
Printv(destructor_call, jniclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue