Merge remote branch 'upstream/master'

This commit is contained in:
Brant K. Kyser 2013-01-05 06:00:21 -06:00
commit a0685d2dc4
7 changed files with 143 additions and 10 deletions

2
.gitignore vendored
View file

@ -77,4 +77,4 @@ Examples/test-suite/python/*/
Examples/test-suite/r/*/
Examples/test-suite/ruby/*/
Examples/test-suite/tcl/*/
Examples/test-suite/uffi/*/
Examples/test-suite/uffi/*/

View file

@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.10 (in progress)
============================
2013-01-03: wsfulton
Pull patch from BrantKyser to fix directors and nspace feature when multilevel namespaces are used.
2013-01-04: wsfulton
[Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction
with directors.
2013-01-03: wsfulton
[Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when
multilevel namespaces are used.

View file

@ -185,6 +185,7 @@ CPP_TEST_CASES += \
director_protected \
director_protected_overloaded \
director_redefined \
director_smartptr \
director_thread \
director_unroll \
director_using \

View file

@ -0,0 +1,63 @@
%module(directors="1") director_smartptr
#ifdef SWIGJAVA
SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
#endif
%{
#include <boost/shared_ptr.hpp>
#include <string>
class FooBar {
public:
FooBar() {}
FooBar(const FooBar&) {}
virtual ~FooBar() {}
std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
};
class Foo {
public:
virtual ~Foo() {}
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
virtual std::string fooBar(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); }
virtual Foo makeFoo() { return Foo(); }
virtual FooBar makeFooBar() { return FooBar(); }
static Foo* get_self(Foo *self_) {return self_;}
};
%}
%include <std_string.i>
%include <boost_shared_ptr.i>
%shared_ptr(Foo)
%feature("director") Foo;
class FooBar {
public:
FooBar();
FooBar(const FooBar&);
virtual ~FooBar();
std::string FooBarDo();
};
class Foo
{
public:
virtual ~Foo();
virtual std::string ping();
virtual std::string pong();
virtual std::string fooBar(FooBar* fooBarPtr);
virtual Foo makeFoo();
virtual FooBar makeFooBar();
static Foo* get_self(Foo *self_);
};

View file

@ -0,0 +1,48 @@
// Make sure that directors are connected and disconnected when used inconjunction with
// being a smart pointer
public class director_smartptr_runme {
static {
try {
System.loadLibrary("director_smartptr");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
director_smartptr_MyBarFoo myBarFoo =
new director_smartptr_MyBarFoo();
}
}
class director_smartptr_MyBarFoo extends director_smartptr.Foo {
@Override
public String ping() {
return "director_smartptr_MyBarFoo.ping();";
}
@Override
public String pong() {
return "director_smartptr_MyBarFoo.pong();" + ping();
}
@Override
public String fooBar(director_smartptr.FooBar fooBar) {
return fooBar.FooBarDo();
}
@Override
public director_smartptr.Foo makeFoo() {
return new director_smartptr.Foo();
}
@Override
public director_smartptr.FooBar makeFooBar() {
return new director_smartptr.FooBar();
}
}

View file

@ -146,10 +146,10 @@
// Base proxy classes
%typemap(javabody) TYPE %{
private long swigCPtr;
private boolean swigCMemOwnBase;
private boolean swigCMemOwn;
PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean cMemoryOwn) {
swigCMemOwnBase = cMemoryOwn;
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}
@ -176,8 +176,8 @@
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
if (swigCPtr != 0) {
if (swigCMemOwnBase) {
swigCMemOwnBase = false;
if (swigCMemOwn) {
swigCMemOwn = false;
$jnicall;
}
swigCPtr = 0;

View file

@ -3381,6 +3381,7 @@ public:
String *swig_director_connect = Swig_name_member(getNSpace(), proxy_class_name, "director_connect");
String *swig_director_connect_jni = makeValidJniName(swig_director_connect);
String *sym_name = Getattr(n, "sym:name");
String *smartptr_feature = Getattr(n, "feature:smartptr");
Wrapper *code_wrap;
Printf(imclass_class_code, " public final static native void %s(%s obj, long cptr, boolean mem_own, boolean weak_global);\n",
@ -3390,9 +3391,24 @@ public:
Printf(code_wrap->def,
"SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, "
"jboolean jweak_global) {\n", jnipackage, jni_imclass_name, swig_director_connect_jni);
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name);
Printf(code_wrap->code, " (void)jcls;\n");
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj);\n", sym_name, sym_name);
if (Len(smartptr_feature)) {
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", smartptr_feature, smartptr_feature);
Printf(code_wrap->code, " (void)jcls;\n");
Printf(code_wrap->code, " // NOTE: Pulling the raw pointer out of the smart pointer as the following code does\n");
Printf(code_wrap->code, " // is generally a bad idea. However, in this case we keep a local instance of the\n");
Printf(code_wrap->code, " // smart pointer around while we are using the raw pointer, which should keep the\n");
Printf(code_wrap->code, " // raw pointer alive. This is done instead of using the smart pointer's dynamic cast\n");
Printf(code_wrap->code, " // feature since different smart pointer implementations have differently named dynamic\n");
Printf(code_wrap->code, " // cast mechanisms.\n");
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj->operator->());\n", sym_name, sym_name);
}
else {
Printf(code_wrap->code, " %s *obj = *((%s **)&objarg);\n", norm_name, norm_name);
Printf(code_wrap->code, " (void)jcls;\n");
Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj);\n", sym_name, sym_name);
}
Printf(code_wrap->code, " if (director) {\n");
Printf(code_wrap->code, " director->swig_connect_director(jenv, jself, jenv->GetObjectClass(jself), "
"(jswig_mem_own == JNI_TRUE), (jweak_global == JNI_TRUE));\n");