diff options
author | Vadim Zeitlin <vz-swig@zeitlins.org> | 2013-11-27 15:44:46 +0100 |
---|---|---|
committer | Vadim Zeitlin <vz-swig@zeitlins.org> | 2013-12-03 23:45:20 +0100 |
commit | ed28725a15fb2b0a967e3e049a1bd43429e1a336 (patch) | |
tree | ed3f735d3503c7923490dd1484bbd96b97ddbbdb /Lib/java | |
parent | 9d3fc0069c5e62dff004f951e34bd75b47c397f0 (diff) | |
download | swig-ed28725a15fb2b0a967e3e049a1bd43429e1a336.tar.gz |
Add std_auto_ptr.i defining typemaps for returning std::auto_ptr<>.
These typemaps are currently defined for C#, Java and Python only and the
tests are provided only for these languages.
Also add a brief description of the new header to the documentation.
Diffstat (limited to 'Lib/java')
-rw-r--r-- | Lib/java/std_auto_ptr.i | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/java/std_auto_ptr.i b/Lib/java/std_auto_ptr.i new file mode 100644 index 000000000..9b3cd7315 --- /dev/null +++ b/Lib/java/std_auto_ptr.i @@ -0,0 +1,27 @@ +/* + The typemaps here allow to handle functions returning std::auto_ptr<>, + which is the most common use of this type. If you have functions taking it + as parameter, these typemaps can't be used for them and you need to do + something else (e.g. use shared_ptr<> which SWIG supports fully). + */ + +%define %auto_ptr(TYPE) +%typemap (jni) std::auto_ptr<TYPE > "jlong" +%typemap (jtype) std::auto_ptr<TYPE > "long" +%typemap (jstype) std::auto_ptr<TYPE > "$typemap(jstype, TYPE)" + +%typemap (out) std::auto_ptr<TYPE > %{ + jlong lpp = 0; + *(TYPE**) &lpp = $1.release(); + $result = lpp; +%} +%typemap(javaout) std::auto_ptr<TYPE > { + long cPtr = $jnicall; + return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true); + } +%template() std::auto_ptr<TYPE >; +%enddef + +namespace std { + template <class T> class auto_ptr {}; +} |