Avoid potential race conditions on the delete() method
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9443 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
32a59010e4
commit
2780b5ee3b
4 changed files with 31 additions and 7 deletions
|
|
@ -1,6 +1,21 @@
|
|||
Version 1.3.30 (in progress)
|
||||
============================
|
||||
|
||||
10/12/2006: wsfulton
|
||||
[Java] Remove potential race condition on the proxy class' delete() method
|
||||
(it is now a synchronized method, but is now customisable by changing the
|
||||
methodmodifier attribute in the the javadestruct or javadestruct_derived typemap)
|
||||
|
||||
*** POTENTIAL INCOMPATIBILITY ***
|
||||
|
||||
10/12/2006: wsfulton
|
||||
[Ruby, Python] Remove redundant director code in %extend methods (%extend
|
||||
methods cannot be director methods)
|
||||
|
||||
10/12/2006: wsfulton
|
||||
[Ruby, Python] Fix #1505594 - director objects not returned as director objects
|
||||
in %extend methods.
|
||||
|
||||
10/11/2006: wsfulton
|
||||
[Java] Fix #1238798 - Directors using unsigned long long or any other type
|
||||
marshalled across the JNI boundary using a Java class (where the jni typemap
|
||||
|
|
|
|||
|
|
@ -4816,7 +4816,7 @@ class modifiers for the Java class: default is "public class"
|
|||
Java code is copied verbatim to the Java class: empty default
|
||||
</div>
|
||||
|
||||
<p><tt>%typemap(javadestruct, methodname="delete")</tt> <br></p>
|
||||
<p><tt>%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized")</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
|
||||
|
|
@ -4824,9 +4824,10 @@ used for all proxy classes except those which have a base class
|
|||
<br>
|
||||
<br>
|
||||
Note that the <tt>delete()</tt> method name is configurable and is specified by the <tt>methodname</tt> attribute.
|
||||
The method modifiers are also configurable via the <tt>methodmodifiers</tt> attribute.
|
||||
</div>
|
||||
|
||||
<p><tt>%typemap(javadestruct_derived, methodname="delete")</tt></p>
|
||||
<p><tt>%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized")</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
|
||||
|
|
@ -4834,6 +4835,7 @@ same as "javadestruct" but only used for derived proxy classes
|
|||
<br>
|
||||
<br>
|
||||
Note that the <tt>delete()</tt> method name is configurable and is specified by the <tt>methodname</tt> attribute.
|
||||
The method modifiers are also configurable via the <tt>methodmodifiers</tt> attribute.
|
||||
</div>
|
||||
|
||||
<p><tt>%typemap(javaimports)</tt></p>
|
||||
|
|
@ -4867,7 +4869,7 @@ In summary the contents of the typemaps make up a proxy class like this:
|
|||
implements [ javainterfaces typemap ] {
|
||||
[ javabody or javabody_derived typemap ]
|
||||
[ javafinalize typemap ]
|
||||
public void <i>delete</i>() [ javadestruct OR javadestruct_derived typemap ]
|
||||
public synchronized void <i>delete</i>() [ javadestruct OR javadestruct_derived typemap ]
|
||||
[ javacode typemap ]
|
||||
... proxy functions ...
|
||||
}
|
||||
|
|
@ -4875,7 +4877,7 @@ public void <i>delete</i>() [ javadestruct OR javadestruct_derived typemap ]
|
|||
</div>
|
||||
|
||||
<p>
|
||||
Note the <tt><i>delete</i>()</tt> methodname is configurable, see "javadestruct" and "javadestruct_derived" typemaps above.
|
||||
Note the <tt><i>delete</i>()</tt> methodname and method modifiers are configurable, see "javadestruct" and "javadestruct_derived" typemaps above.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -1133,7 +1133,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") SWIGTYPE {
|
||||
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE {
|
||||
if(swigCPtr != 0 && swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$jnicall;
|
||||
|
|
@ -1141,7 +1141,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
|
|||
swigCPtr = 0;
|
||||
}
|
||||
|
||||
%typemap(javadestruct_derived, methodname="delete") SWIGTYPE {
|
||||
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE {
|
||||
if(swigCPtr != 0 && swigCMemOwn) {
|
||||
swigCMemOwn = false;
|
||||
$jnicall;
|
||||
|
|
|
|||
|
|
@ -1595,17 +1595,24 @@ class JAVA : public Language {
|
|||
const String *tm = NULL;
|
||||
Node *attributes = NewHash();
|
||||
String *destruct_methodname = NULL;
|
||||
String *destruct_methodmodifiers = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup("javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers");
|
||||
} else {
|
||||
tm = typemapLookup("javadestruct", typemap_lookup_type, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname");
|
||||
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers");
|
||||
}
|
||||
if (!destruct_methodname) {
|
||||
Swig_error(input_file, line_number,
|
||||
"No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
}
|
||||
if (!destruct_methodmodifiers) {
|
||||
Swig_error(input_file, line_number,
|
||||
"No methodmodifier attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
}
|
||||
|
||||
// Emit the finalize and delete methods
|
||||
if (tm) {
|
||||
|
|
@ -1622,7 +1629,7 @@ class JAVA : public Language {
|
|||
else
|
||||
Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")");
|
||||
if (*Char(destruct))
|
||||
Printv(proxy_class_def, "\n ", "public void ", destruct_methodname, "() ", destruct, "\n", NIL);
|
||||
Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "() ", destruct, "\n", NIL);
|
||||
}
|
||||
|
||||
/* Insert directordisconnect typemap, if this class has directors enabled */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue