Add C# support std::unique_ptr inputs
Based on Java implementation.
This commit is contained in:
parent
8bd9eb3f16
commit
c737bd5713
5 changed files with 103 additions and 4 deletions
|
|
@ -913,6 +913,19 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef swigRelease($csclassname obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
// Derived proxy classes
|
||||
|
|
@ -926,6 +939,19 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef swigRelease($csclassname obj) {
|
||||
if (obj != null) {
|
||||
if (!obj.swigCMemOwn)
|
||||
throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
|
||||
global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
|
||||
obj.swigCMemOwn = false;
|
||||
obj.Dispose();
|
||||
return ptr;
|
||||
} else {
|
||||
return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
|
|
@ -945,6 +971,10 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef getCPtr($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
|
||||
CPTR_VISIBILITY static global::System.Runtime.InteropServices.HandleRef swigRelease($csclassname obj) {
|
||||
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(csbody) TYPE (CLASS::*) %{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
%define %auto_ptr(TYPE)
|
||||
%typemap (ctype) std::auto_ptr< TYPE > "void *"
|
||||
%typemap (imtype, out="System.IntPtr") std::auto_ptr< TYPE > "HandleRef"
|
||||
%typemap (imtype, out="System.IntPtr") std::auto_ptr< TYPE > "global::System.Runtime.InteropServices.HandleRef"
|
||||
%typemap (cstype) std::auto_ptr< TYPE > "$typemap(cstype, TYPE)"
|
||||
%typemap (out) std::auto_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
|
|
|
|||
|
|
@ -9,8 +9,14 @@
|
|||
|
||||
%define %unique_ptr(TYPE)
|
||||
%typemap (ctype) std::unique_ptr< TYPE > "void *"
|
||||
%typemap (imtype, out="System.IntPtr") std::unique_ptr< TYPE > "HandleRef"
|
||||
%typemap (imtype, out="System.IntPtr") std::unique_ptr< TYPE > "global::System.Runtime.InteropServices.HandleRef"
|
||||
%typemap (cstype) std::unique_ptr< TYPE > "$typemap(cstype, TYPE)"
|
||||
|
||||
%typemap(in) std::unique_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
|
||||
%typemap(csin) std::unique_ptr< TYPE > "$typemap(cstype, TYPE).swigRelease($csinput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
%}
|
||||
|
|
@ -23,5 +29,5 @@
|
|||
%enddef
|
||||
|
||||
namespace std {
|
||||
template <class T> class unique_ptr {};
|
||||
template <class T> class unique_ptr {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue