mirror of https://github.com/swig/swig
parent
2d352c6da2
commit
ae22a97f1b
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.3.0 (in progress)
|
||||
===========================
|
||||
|
||||
2024-02-02: wsfulton
|
||||
#2650 Add support for movable std::unique_ptr by adding in std::unique_ptr &&
|
||||
typemaps.
|
||||
|
||||
2024-01-23: wsfulton
|
||||
Add missing use of move constructor instead of copy constructor when
|
||||
passing movable types by value. This was previously implemented only for
|
||||
|
|
|
@ -2092,7 +2092,12 @@ The languages that support shared_ptr also have support for using shared_ptr wit
|
|||
|
||||
<p>
|
||||
The <tt>std_unique_ptr.i</tt> library file provides SWIG's unique_ptr support.
|
||||
It defines typemaps and a macro, <tt>%unique_ptr(T)</tt>, to use for handling
|
||||
It provides move semantics for the smart pointer's underlying object,
|
||||
both from C++ to the target language and vice versa.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The library defines typemaps and a macro, <tt>%unique_ptr(T)</tt>, to use for handling
|
||||
<tt>std::unique_ptr<T></tt> for a type <tt>T</tt>.
|
||||
The type <tt>T</tt> must be non-primitive.
|
||||
This macro should be used before any code declaring or using type <tt>T</tt>.
|
||||
|
@ -2206,7 +2211,19 @@ in a "Cannot release ownership as memory is not owned" exception. For example, i
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<b>Compatibility note:</b> Support for <tt>std::unique_ptr</tt> was added in SWIG-4.1.0.
|
||||
The effect of passing a <tt>std::unique_ptr</tt> by rvalue refence is identical to passing it by value.
|
||||
The ownership of the memory of the object being pointed to by the underyling pointer is transferred from the proxy class to the C++ function being called. Example:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
void grab(std::unique_ptr<Klass> &&);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<b>Compatibility note:</b> Support for <tt>std::unique_ptr</tt> was first added in SWIG-4.1.0.
|
||||
This initial support contained the move semantics when passing a <tt>std::unique_ptr</tt> around by value. Support for passing a <tt>std::unique_ptr</tt> around by rvalue reference was added in SWIG-4.3.0.
|
||||
</p>
|
||||
|
||||
<H3><a name="Library_std_auto_ptr">12.4.7 auto_ptr smart pointer</a></H3>
|
||||
|
|
|
@ -23,6 +23,7 @@ void main() {
|
|||
}
|
||||
checkCount(0);
|
||||
|
||||
///// INPUT BY VALUE /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
scope Klass kin = new Klass("KlassInput");
|
||||
|
@ -101,6 +102,85 @@ void main() {
|
|||
checkCount(0);
|
||||
|
||||
|
||||
///// INPUT BY RVALUE REF /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
scope Klass kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
string s = moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (s != "KlassInput")
|
||||
throw new Exception("Incorrect string: " ~ s);
|
||||
if (!is_nullptr(kin))
|
||||
throw new Exception("is_nullptr failed");
|
||||
} // dispose should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
{
|
||||
scope Klass kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
string s = moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (s != "KlassInput")
|
||||
throw new Exception("Incorrect string: " ~ s);
|
||||
if (!is_nullptr(kin))
|
||||
throw new Exception("is_nullptr failed");
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
moveKlassUniquePtr(kin);
|
||||
} catch (Exception e) {
|
||||
if (!canFind(e.msg, "Cannot release ownership as memory is not owned"))
|
||||
throw new Exception("incorrect exception message: " ~ e.msg);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Exception("double usage of moveKlassUniquePtr should have been an error");
|
||||
} // dispose should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
{
|
||||
scope Klass kin = new Klass("KlassInput");
|
||||
bool exception_thrown = false;
|
||||
Klass notowned = get_not_owned_ptr(kin);
|
||||
try {
|
||||
moveKlassUniquePtr(notowned);
|
||||
} catch (Exception e) {
|
||||
if (!canFind(e.msg, "Cannot release ownership as memory is not owned"))
|
||||
throw new Exception("incorrect exception message: " ~ e.msg);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Exception("Should have thrown 'Cannot release ownership as memory is not owned' error");
|
||||
checkCount(1);
|
||||
}
|
||||
checkCount(0);
|
||||
|
||||
{
|
||||
scope KlassInheritance kini = new KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
string s = moveKlassUniquePtr(kini);
|
||||
checkCount(0);
|
||||
if (s != "KlassInheritanceInput")
|
||||
throw new Exception("Incorrect string: " ~ s);
|
||||
if (!is_nullptr(kini))
|
||||
throw new Exception("is_nullptr failed");
|
||||
} // dispose should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
moveKlassUniquePtr(null);
|
||||
moveKlassUniquePtr(make_null());
|
||||
checkCount(0);
|
||||
|
||||
// overloaded parameters
|
||||
if (moveOverloadTest() != 0)
|
||||
throw new Exception("moveOverloadTest failed");
|
||||
if (moveOverloadTest(null) != 1)
|
||||
throw new Exception("moveOverloadTest failed");
|
||||
if (moveOverloadTest(new Klass("over")) != 1)
|
||||
throw new Exception("moveOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
// unique_ptr as output
|
||||
Klass k1 = makeKlassUniquePtr("first");
|
||||
if (k1.getLabel() != "first")
|
||||
|
|
|
@ -41,6 +41,7 @@ public class cpp11_std_unique_ptr_runme {
|
|||
checkCount(0);
|
||||
}
|
||||
|
||||
///// INPUT BY VALUE /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
Klass kin = new Klass("KlassInput");
|
||||
|
@ -123,6 +124,89 @@ public class cpp11_std_unique_ptr_runme {
|
|||
checkCount(0);
|
||||
|
||||
|
||||
///// INPUT BY RVALUE REF /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
Klass kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
String s = cpp11_std_unique_ptr.moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (!s.equals("KlassInput"))
|
||||
throw new RuntimeException("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kin))
|
||||
throw new RuntimeException("is_nullptr failed");
|
||||
kin.delete(); // Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
Klass kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
String s = cpp11_std_unique_ptr.moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (!s.equals("KlassInput"))
|
||||
throw new RuntimeException("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kin))
|
||||
throw new RuntimeException("is_nullptr failed");
|
||||
boolean exception_thrown = false;
|
||||
try {
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(kin);
|
||||
} catch (RuntimeException e) {
|
||||
if (!e.getMessage().contains("Cannot release ownership as memory is not owned"))
|
||||
throw new RuntimeException("incorrect exception message");
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new RuntimeException("double usage of moveKlassUniquePtr should have been an error");
|
||||
kin.delete(); // Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
Klass kin = new Klass("KlassInput");
|
||||
boolean exception_thrown = false;
|
||||
Klass notowned = cpp11_std_unique_ptr.get_not_owned_ptr(kin);
|
||||
try {
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(notowned);
|
||||
} catch (RuntimeException e) {
|
||||
if (!e.getMessage().contains("Cannot release ownership as memory is not owned"))
|
||||
throw new RuntimeException("incorrect exception message");
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new RuntimeException("Should have thrown 'Cannot release ownership as memory is not owned' error");
|
||||
checkCount(1);
|
||||
kin.delete();
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
KlassInheritance kini = new KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
String s = cpp11_std_unique_ptr.moveKlassUniquePtr(kini);
|
||||
checkCount(0);
|
||||
if (!s.equals("KlassInheritanceInput"))
|
||||
throw new RuntimeException("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kini))
|
||||
throw new RuntimeException("is_nullptr failed");
|
||||
kini.delete(); // Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(null);
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(cpp11_std_unique_ptr.make_null());
|
||||
checkCount(0);
|
||||
|
||||
// overloaded parameters
|
||||
if (cpp11_std_unique_ptr.moveOverloadTest() != 0)
|
||||
throw new RuntimeException("moveOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveOverloadTest(null) != 1)
|
||||
throw new RuntimeException("moveOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveOverloadTest(new Klass("over")) != 1)
|
||||
throw new RuntimeException("moveOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
// unique_ptr as output
|
||||
Klass k1 = cpp11_std_unique_ptr.makeKlassUniquePtr("first");
|
||||
if (!k1.getLabel().equals("first"))
|
||||
|
|
|
@ -20,6 +20,7 @@ var checkCount = function(expected_count) {
|
|||
}
|
||||
|
||||
|
||||
///// INPUT BY VALUE /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
kin = new cpp11_std_unique_ptr.Klass("KlassInput");
|
||||
|
@ -104,6 +105,91 @@ if (cpp11_std_unique_ptr.overloadTest(new cpp11_std_unique_ptr.Klass("over")) !=
|
|||
checkCount(0);
|
||||
|
||||
|
||||
///// INPUT BY RVALUE REF /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
kin = new cpp11_std_unique_ptr.Klass("KlassInput");
|
||||
checkCount(1);
|
||||
s = cpp11_std_unique_ptr.moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (s !== "KlassInput")
|
||||
throw new Error("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kin))
|
||||
throw new Error("is_nullptr failed");
|
||||
delete kin; // Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
kin = new cpp11_std_unique_ptr.Klass("KlassInput");
|
||||
checkCount(1);
|
||||
s = cpp11_std_unique_ptr.moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (s !== "KlassInput")
|
||||
throw new Error("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kin))
|
||||
throw new Error("is_nullptr failed");
|
||||
exception_thrown = false;
|
||||
try {
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(kin);
|
||||
} catch (e) {
|
||||
if (!e.message.includes("cannot release ownership as memory is not owned"))
|
||||
throw new Error("incorrect exception message " + e.message);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Error("double usage of moveKlassUniquePtr should have been an error");
|
||||
delete kin; // Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
kin = new cpp11_std_unique_ptr.Klass("KlassInput");
|
||||
exception_thrown = false;
|
||||
notowned = cpp11_std_unique_ptr.get_not_owned_ptr(kin);
|
||||
try {
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(notowned);
|
||||
} catch (e) {
|
||||
if (!e.message.includes("cannot release ownership as memory is not owned"))
|
||||
throw new Error("incorrect exception message " + e.message);
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new Error("Should have thrown 'Cannot release ownership as memory is not owned' error");
|
||||
checkCount(1);
|
||||
// delete kin;
|
||||
// Above not deleting the C++ object(node v12) - can't reliably control GC
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
kini = new cpp11_std_unique_ptr.KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
s = cpp11_std_unique_ptr.moveKlassUniquePtr(kini);
|
||||
checkCount(0);
|
||||
if (s !== "KlassInheritanceInput")
|
||||
throw new Error("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kini))
|
||||
throw new Error("is_nullptr failed");
|
||||
delete kini; // Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(null);
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(cpp11_std_unique_ptr.make_null());
|
||||
checkCount(0);
|
||||
|
||||
// overloaded parameters
|
||||
if (cpp11_std_unique_ptr.moveOverloadTest() != 0)
|
||||
throw new RuntimeException("moveOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveOverloadTest(null) != 1)
|
||||
throw new RuntimeException("moveOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveOverloadTest(new cpp11_std_unique_ptr.Klass("over")) != 1)
|
||||
throw new RuntimeException("moveOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
// unique_ptr as output
|
||||
k1 = cpp11_std_unique_ptr.makeKlassUniquePtr("first");
|
||||
if (k1.getLabel() !== "first")
|
||||
|
|
|
@ -26,6 +26,7 @@ end
|
|||
kini = nil
|
||||
checkCount(0)
|
||||
|
||||
--- ---- INPUT BY VALUE ---
|
||||
-- unique_ptr as input
|
||||
kin = cpp11_std_unique_ptr.Klass("KlassInput")
|
||||
checkCount(1)
|
||||
|
@ -94,6 +95,75 @@ end
|
|||
checkCount(0)
|
||||
|
||||
|
||||
--- ---- INPUT BY RVALUE REF ---
|
||||
-- unique_ptr as input
|
||||
kin = cpp11_std_unique_ptr.Klass("KlassInput")
|
||||
checkCount(1)
|
||||
s = cpp11_std_unique_ptr.moveKlassUniquePtr(kin)
|
||||
checkCount(0)
|
||||
if not (s == "KlassInput") then
|
||||
error("Incorrect string: "..s)
|
||||
end
|
||||
if not (cpp11_std_unique_ptr.is_nullptr(kin)) then
|
||||
error("is_nullptr failed")
|
||||
end
|
||||
kin = nil -- Should not fail, even though already deleted
|
||||
checkCount(0)
|
||||
|
||||
kin = cpp11_std_unique_ptr.Klass("KlassInput")
|
||||
checkCount(1)
|
||||
s = cpp11_std_unique_ptr.moveKlassUniquePtr(kin)
|
||||
checkCount(0)
|
||||
if not (s == "KlassInput") then
|
||||
error("Incorrect string: "..s)
|
||||
end
|
||||
if not (cpp11_std_unique_ptr.is_nullptr(kin)) then
|
||||
error("is_nullptr failed")
|
||||
end
|
||||
s, msg = pcall(function() cpp11_std_unique_ptr.moveKlassUniquePtr(kin) end)
|
||||
assert(s == false and msg == "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' in moveKlassUniquePtr")
|
||||
|
||||
kin = nil -- Should not fail, even though already deleted
|
||||
checkCount(0)
|
||||
|
||||
kin = cpp11_std_unique_ptr.Klass("KlassInput")
|
||||
notowned = cpp11_std_unique_ptr.get_not_owned_ptr(kin)
|
||||
s, msg = pcall(function() cpp11_std_unique_ptr.moveKlassUniquePtr(notowned) end)
|
||||
assert(s == false and msg == "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' in moveKlassUniquePtr")
|
||||
checkCount(1)
|
||||
kin = nil
|
||||
checkCount(0)
|
||||
|
||||
kini = cpp11_std_unique_ptr.KlassInheritance("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = cpp11_std_unique_ptr.moveKlassUniquePtr(kini)
|
||||
checkCount(0)
|
||||
if not (s == "KlassInheritanceInput") then
|
||||
error("Incorrect string: "..s)
|
||||
end
|
||||
if not (cpp11_std_unique_ptr.is_nullptr(kini)) then
|
||||
error("is_nullptr failed")
|
||||
end
|
||||
kini = nil -- Should not fail, even though already deleted
|
||||
checkCount(0)
|
||||
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(nil);
|
||||
cpp11_std_unique_ptr.moveKlassUniquePtr(cpp11_std_unique_ptr.make_null());
|
||||
checkCount(0);
|
||||
|
||||
-- overloaded parameters
|
||||
if not (cpp11_std_unique_ptr.moveOverloadTest() == 0) then
|
||||
error("moveOverloadTest failed")
|
||||
end
|
||||
if not (cpp11_std_unique_ptr.moveOverloadTest(nil) == 1) then
|
||||
error("moveOverloadTest failed")
|
||||
end
|
||||
if not (cpp11_std_unique_ptr.moveOverloadTest(cpp11_std_unique_ptr.Klass("over")) == 1) then
|
||||
error("moveOverloadTest failed")
|
||||
end
|
||||
checkCount(0)
|
||||
|
||||
|
||||
-- unique_ptr as output
|
||||
k1 = cpp11_std_unique_ptr.makeKlassUniquePtr("first")
|
||||
k2 = cpp11_std_unique_ptr.makeKlassUniquePtr("second")
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
(set! kini '()) (gc)
|
||||
(checkCount 0)
|
||||
|
||||
; ;;;; INPUT BY VALUE ;;;;
|
||||
; unique_ptr as input
|
||||
(define kin (new-Klass "KlassInput"))
|
||||
(checkCount 1)
|
||||
|
@ -89,6 +90,75 @@
|
|||
(checkCount 0)
|
||||
|
||||
|
||||
; ;;;; INPUT BY RVALUE REF ;;;;
|
||||
; unique_ptr as input
|
||||
(define kin (new-Klass "KlassInput"))
|
||||
(checkCount 1)
|
||||
(define s (moveKlassUniquePtr kin))
|
||||
(checkCount 0)
|
||||
(unless (string=? s "KlassInput")
|
||||
(error "Incorrect string: " s))
|
||||
(unless (is-nullptr kin)
|
||||
(error "is_nullptr failed"))
|
||||
(set! kini '()) (gc) ; Should not fail, even though already deleted
|
||||
(checkCount 0)
|
||||
|
||||
(define kin (new-Klass "KlassInput"))
|
||||
(checkCount 1)
|
||||
(define s (moveKlassUniquePtr kin))
|
||||
(checkCount 0)
|
||||
(unless (string=? s "KlassInput")
|
||||
(error "Incorrect string: " s))
|
||||
(unless (is-nullptr kin)
|
||||
(error "is_nullptr failed"))
|
||||
|
||||
(define exception_thrown "no exception thrown for kin")
|
||||
(with-handlers ([exn:fail? (lambda (exn)
|
||||
(set! exception_thrown (exn-message exn)))])
|
||||
(moveKlassUniquePtr kin))
|
||||
(unless (string=? exception_thrown "moveKlassUniquePtr: cannot release ownership as memory is not owned for argument 1 of type 'Klass *'")
|
||||
(error "Wrong or no exception thrown: " exception_thrown))
|
||||
(set! kin '()) (gc) ; Should not fail, even though already deleted
|
||||
(checkCount 0)
|
||||
|
||||
(define kin (new-Klass "KlassInput"))
|
||||
(define notowned (get-not-owned-ptr kin))
|
||||
(set! exception_thrown "no exception thrown for notowned")
|
||||
(with-handlers ([exn:fail? (lambda (exn)
|
||||
(set! exception_thrown (exn-message exn)))])
|
||||
(moveKlassUniquePtr notowned))
|
||||
(unless (string=? exception_thrown "moveKlassUniquePtr: cannot release ownership as memory is not owned for argument 1 of type 'Klass *'")
|
||||
(error "Wrong or no exception thrown: " exception_thrown))
|
||||
(checkCount 1)
|
||||
(set! kin '()) (gc)
|
||||
(checkCount 0)
|
||||
|
||||
(define kini (new-KlassInheritance "KlassInheritanceInput"))
|
||||
(checkCount 1)
|
||||
(define s (moveKlassUniquePtr kini))
|
||||
(checkCount 0)
|
||||
(unless (string=? s "KlassInheritanceInput")
|
||||
(error "Incorrect string: " s))
|
||||
(unless (is-nullptr kini)
|
||||
(error "is_nullptr failed"))
|
||||
(set! kini '()) (gc) ; Should not fail, even though already deleted
|
||||
(checkCount 0)
|
||||
|
||||
(define null '())
|
||||
(moveKlassUniquePtr null)
|
||||
(moveKlassUniquePtr (make-null))
|
||||
(checkCount 0)
|
||||
|
||||
; overloaded parameters
|
||||
(unless (= (moveOverloadTest) 0)
|
||||
(error "moveOverloadTest failed"))
|
||||
(unless (= (moveOverloadTest null) 1)
|
||||
(error "moveOverloadTest failed"))
|
||||
(unless (= (moveOverloadTest (new-Klass "over")) 1)
|
||||
(error "moveOverloadTest failed"))
|
||||
(checkCount 0)
|
||||
|
||||
|
||||
; unique_ptr as output
|
||||
(define k1 (makeKlassUniquePtr "first"))
|
||||
(define k2 (makeKlassUniquePtr "second"))
|
||||
|
|
|
@ -23,6 +23,7 @@ clear kini;
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY VALUE ####
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput");
|
||||
checkCount(1);
|
||||
|
@ -113,6 +114,97 @@ endif
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY RVALUE REF ####
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput");
|
||||
checkCount(1);
|
||||
s = moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (!strcmp(s, "KlassInput"))
|
||||
error("Incorrect string: %s", s);
|
||||
endif
|
||||
if (!is_nullptr(kin))
|
||||
error("is_nullptr failed");
|
||||
endif
|
||||
clear kin; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
kin = Klass("KlassInput");
|
||||
checkCount(1);
|
||||
s = moveKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (!strcmp(s, "KlassInput"))
|
||||
error("Incorrect string: %s", s);
|
||||
endif
|
||||
if (!is_nullptr(kin))
|
||||
error("is_nullptr failed");
|
||||
endif
|
||||
exception_thrown = false;
|
||||
try
|
||||
moveKlassUniquePtr(kin);
|
||||
catch e
|
||||
if (isempty(strfind(e.message, "cannot release ownership as memory is not owned")))
|
||||
error("incorrect exception message %s", e.message);
|
||||
endif
|
||||
exception_thrown = true;
|
||||
end_try_catch
|
||||
if (!exception_thrown)
|
||||
error("double usage of moveKlassUniquePtr should have been an error");
|
||||
endif
|
||||
clear kin; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
kin = Klass("KlassInput");
|
||||
exception_thrown = false;
|
||||
notowned = get_not_owned_ptr(kin);
|
||||
try
|
||||
moveKlassUniquePtr(notowned);
|
||||
catch e
|
||||
if (isempty(strfind(e.message, "cannot release ownership as memory is not owned")))
|
||||
error("incorrect exception message %s", e.message);
|
||||
endif
|
||||
exception_thrown = true;
|
||||
end_try_catch
|
||||
if (!exception_thrown)
|
||||
error("Should have thrown 'Cannot release ownership as memory is not owned' error");
|
||||
endif
|
||||
checkCount(1);
|
||||
clear kin;
|
||||
checkCount(0);
|
||||
|
||||
kini = KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
s = moveKlassUniquePtr(kini);
|
||||
checkCount(0);
|
||||
if (!strcmp(s, "KlassInheritanceInput"))
|
||||
error("Incorrect string: %s", s);
|
||||
endif
|
||||
if (!is_nullptr(kini))
|
||||
error("is_nullptr failed");
|
||||
endif
|
||||
clear kini; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
null = []; # NULL pointer
|
||||
null_ptr = make_null();
|
||||
moveKlassUniquePtr([]);
|
||||
moveKlassUniquePtr(null);
|
||||
moveKlassUniquePtr(null_ptr);
|
||||
checkCount(0);
|
||||
|
||||
# overloaded parameters
|
||||
if (moveOverloadTest() != 0)
|
||||
error("moveOverloadTest failed");
|
||||
endif
|
||||
if (moveOverloadTest(null) != 1)
|
||||
error("moveOverloadTest failed");
|
||||
endif
|
||||
if (moveOverloadTest(Klass("over")) != 1)
|
||||
error("moveOverloadTest failed");
|
||||
endif
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
k1 = makeKlassUniquePtr("first");
|
||||
if (!strcmp(k1.getLabel(), "first"))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 34;
|
||||
use Test::More tests => 58;
|
||||
BEGIN { use_ok('cpp11_std_unique_ptr') }
|
||||
require_ok('cpp11_std_unique_ptr');
|
||||
|
||||
|
@ -23,6 +23,7 @@ sub checkCount {
|
|||
}
|
||||
|
||||
|
||||
# #### INPUT BY VALUE ####
|
||||
# unique_ptr as input
|
||||
{
|
||||
my $kin = new cpp11_std_unique_ptr::Klass("KlassInput");
|
||||
|
@ -84,6 +85,68 @@ is(cpp11_std_unique_ptr::overloadTest(new cpp11_std_unique_ptr::Klass("over")),
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY RVALUE REF ####
|
||||
# unique_ptr as input
|
||||
{
|
||||
my $kin = new cpp11_std_unique_ptr::Klass("KlassInput");
|
||||
checkCount(1);
|
||||
my $s = cpp11_std_unique_ptr::moveKlassUniquePtr($kin);
|
||||
checkCount(0);
|
||||
is($s, "KlassInput", "Incorrect string: $s");
|
||||
is(cpp11_std_unique_ptr::is_nullptr($kin), 1, "is_nullptr check");
|
||||
undef $kin; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
my $kin = new cpp11_std_unique_ptr::Klass("KlassInput");
|
||||
checkCount(1);
|
||||
my $s = cpp11_std_unique_ptr::moveKlassUniquePtr($kin);
|
||||
checkCount(0);
|
||||
is($s, "KlassInput", "Incorrect string: $s");
|
||||
is(cpp11_std_unique_ptr::is_nullptr($kin), 1, "is_nullptr check");
|
||||
eval {
|
||||
cpp11_std_unique_ptr::moveKlassUniquePtr($kin);
|
||||
};
|
||||
like($@, qr/\bcannot release ownership as memory is not owned\b/, "double usage of moveKlassUniquePtr should be an error");
|
||||
undef $kin; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
my $kin = new cpp11_std_unique_ptr::Klass("KlassInput");
|
||||
my $notowned = cpp11_std_unique_ptr::get_not_owned_ptr($kin);
|
||||
eval {
|
||||
cpp11_std_unique_ptr::moveKlassUniquePtr($notowned);
|
||||
};
|
||||
like($@, qr/\bcannot release ownership as memory is not owned\b/, "double usage of moveKlassUniquePtr should be an error");
|
||||
checkCount(1);
|
||||
undef $kin;
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
my $kini = new cpp11_std_unique_ptr::KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
my $s = cpp11_std_unique_ptr::moveKlassUniquePtr($kini);
|
||||
checkCount(0);
|
||||
is($s, "KlassInheritanceInput", "Incorrect string: $s");
|
||||
is(cpp11_std_unique_ptr::is_nullptr($kini), 1, "is_nullptr failed");
|
||||
undef $kini; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
cpp11_std_unique_ptr::moveKlassUniquePtr(undef);
|
||||
cpp11_std_unique_ptr::moveKlassUniquePtr(cpp11_std_unique_ptr::make_null());
|
||||
checkCount(0);
|
||||
|
||||
# overloaded parameters
|
||||
is(cpp11_std_unique_ptr::moveOverloadTest(), 0, "moveOverloadTest failed");
|
||||
is(cpp11_std_unique_ptr::moveOverloadTest(undef), 1, "moveOverloadTest failed");
|
||||
is(cpp11_std_unique_ptr::moveOverloadTest(new cpp11_std_unique_ptr::Klass("over")), 1, "moveOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
my $k1 = cpp11_std_unique_ptr::makeKlassUniquePtr("first");
|
||||
my $k2 = cpp11_std_unique_ptr::makeKlassUniquePtr("second");
|
||||
|
|
|
@ -16,6 +16,7 @@ $kini = NULL;
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY VALUE ####
|
||||
# unique_ptr as input
|
||||
$kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
|
@ -90,6 +91,81 @@ check::equal(overloadTest(new Klass("over")), 1, "overloadTest failed");
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY RVALUE REF ####
|
||||
# unique_ptr as input
|
||||
$kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
$s = moveKlassUniquePtr($kin);
|
||||
checkCount(0);
|
||||
check::equal($s, "KlassInput", "Incorrect string: $s");
|
||||
try {
|
||||
is_nullptr($kin);
|
||||
check::fail("is_nullptr check");
|
||||
} catch (TypeError $e) {
|
||||
}
|
||||
$kin = NULL; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
$kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
$s = moveKlassUniquePtr($kin);
|
||||
checkCount(0);
|
||||
check::equal($s, "KlassInput", "Incorrect string: $s");
|
||||
try {
|
||||
is_nullptr($kin);
|
||||
check::fail("is_nullptr check");
|
||||
} catch (TypeError $e) {
|
||||
}
|
||||
$exception_thrown = false;
|
||||
try {
|
||||
moveKlassUniquePtr($kin);
|
||||
} catch (TypeError $e) {
|
||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of moveKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
||||
$exception_thrown = true;
|
||||
}
|
||||
check::equal($exception_thrown, true, "double usage of moveKlassUniquePtr should have been an error");
|
||||
$kin = NULL; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
$kin = new Klass("KlassInput");
|
||||
$exception_thrown = false;
|
||||
$notowned = get_not_owned_ptr($kin);
|
||||
try {
|
||||
moveKlassUniquePtr($notowned);
|
||||
} catch (TypeError $e) {
|
||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of moveKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
||||
$exception_thrown = true;
|
||||
}
|
||||
check::equal($exception_thrown, true, "double usage of moveKlassUniquePtr should have been an error");
|
||||
checkCount(1);
|
||||
$kin = NULL;
|
||||
checkCount(0);
|
||||
|
||||
$kini = new KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
$s = moveKlassUniquePtr($kini);
|
||||
checkCount(0);
|
||||
check::equal($s, "KlassInheritanceInput", "Incorrect string: $s");
|
||||
try {
|
||||
is_nullptr($kini);
|
||||
check::fail("is_nullptr check");
|
||||
} catch (TypeError $e) {
|
||||
}
|
||||
|
||||
$kini = NULL; # Should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
moveKlassUniquePtr(NULL);
|
||||
moveKlassUniquePtr(make_null());
|
||||
checkCount(0);
|
||||
|
||||
# overloaded parameters
|
||||
check::equal(moveOverloadTest(), 0, "moveOverloadTest failed");
|
||||
check::equal(moveOverloadTest(NULL), 1, "moveOverloadTest failed");
|
||||
check::equal(moveOverloadTest(new Klass("over")), 1, "moveOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
$k1 = makeKlassUniquePtr("first");
|
||||
$k2 = makeKlassUniquePtr("second");
|
||||
|
|
|
@ -15,6 +15,7 @@ del kini
|
|||
checkCount(0)
|
||||
|
||||
|
||||
# #### INPUT BY VALUE ####
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput")
|
||||
checkCount(1)
|
||||
|
@ -91,6 +92,83 @@ if overloadTest(Klass("over")) != 1:
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY RVALUE REF ####
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput")
|
||||
checkCount(1)
|
||||
s = moveKlassUniquePtr(kin)
|
||||
checkCount(0)
|
||||
if kin.thisown:
|
||||
raise RuntimeError("thisown should be false")
|
||||
if s != "KlassInput":
|
||||
raise RuntimeError("Incorrect string: " + s)
|
||||
if not is_nullptr(kin):
|
||||
raise RuntimeError("is_nullptr failed")
|
||||
del kin # Should not fail, even though already deleted
|
||||
checkCount(0)
|
||||
|
||||
kin = Klass("KlassInput")
|
||||
checkCount(1)
|
||||
s = moveKlassUniquePtr(kin)
|
||||
checkCount(0)
|
||||
if kin.thisown:
|
||||
raise RuntimeError("thisown should be false")
|
||||
if s != "KlassInput":
|
||||
raise RuntimeError("Incorrect string: " + s)
|
||||
if not is_nullptr(kin):
|
||||
raise RuntimeError("is_nullptr failed")
|
||||
exception_thrown = False
|
||||
try:
|
||||
s = moveKlassUniquePtr(kin)
|
||||
except RuntimeError as e:
|
||||
if "cannot release ownership as memory is not owned" not in str(e):
|
||||
raise RuntimeError("incorrect exception message");
|
||||
exception_thrown = True
|
||||
if not exception_thrown:
|
||||
raise RuntimeError("double usage of moveKlassUniquePtr should have been an error")
|
||||
del kin # Should not fail, even though already deleted
|
||||
checkCount(0)
|
||||
|
||||
kin = Klass("KlassInput")
|
||||
exception_thrown = False
|
||||
notowned = get_not_owned_ptr(kin)
|
||||
try:
|
||||
moveKlassUniquePtr(notowned)
|
||||
except RuntimeError as e:
|
||||
exception_thrown = True
|
||||
if not exception_thrown:
|
||||
raise RuntimeError("Should have thrown 'Cannot release ownership as memory is not owned' error")
|
||||
checkCount(1)
|
||||
del kin
|
||||
checkCount(0)
|
||||
|
||||
kini = KlassInheritance("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = moveKlassUniquePtr(kini)
|
||||
checkCount(0)
|
||||
if kini.thisown:
|
||||
raise RuntimeError("thisown should be false")
|
||||
if s != "KlassInheritanceInput":
|
||||
raise RuntimeError("Incorrect string: " + s)
|
||||
if not is_nullptr(kini):
|
||||
raise RuntimeError("is_nullptr failed")
|
||||
del kini # Should not fail, even though already deleted
|
||||
checkCount(0)
|
||||
|
||||
moveKlassUniquePtr(None)
|
||||
moveKlassUniquePtr(make_null())
|
||||
checkCount(0)
|
||||
|
||||
# overloaded parameters
|
||||
if moveOverloadTest() != 0:
|
||||
raise RuntimeError("moveOverloadTest failed")
|
||||
if moveOverloadTest(None) != 1:
|
||||
raise RuntimeError("moveOverloadTest failed")
|
||||
if moveOverloadTest(Klass("over")) != 1:
|
||||
raise RuntimeError("moveOverloadTest failed")
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
k1 = makeKlassUniquePtr("first")
|
||||
k2 = makeKlassUniquePtr("second")
|
||||
|
|
|
@ -30,6 +30,7 @@ Cpp11_std_unique_ptr.takeKlassUniquePtr(kini) # Ensure object is deleted (can't
|
|||
checkCount(0)
|
||||
|
||||
|
||||
# #### INPUT BY VALUE ####
|
||||
# unique_ptr as input
|
||||
kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
|
||||
checkCount(1)
|
||||
|
@ -133,6 +134,110 @@ end
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY RVALUE REF ####
|
||||
# unique_ptr as input
|
||||
kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
|
||||
checkCount(1)
|
||||
s = Cpp11_std_unique_ptr.moveKlassUniquePtr(kin)
|
||||
checkCount(0)
|
||||
if (s != "KlassInput")
|
||||
raise RuntimeError, "Incorrect string: " + s
|
||||
end
|
||||
exception_thrown = false
|
||||
begin
|
||||
Cpp11_std_unique_ptr.is_nullptr(kin)
|
||||
rescue ObjectPreviouslyDeleted
|
||||
exception_thrown = true
|
||||
end
|
||||
if (!exception_thrown)
|
||||
raise RuntimeError, "is_nullptr failed to throw"
|
||||
end
|
||||
kin = nil
|
||||
checkCount(0)
|
||||
|
||||
kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
|
||||
checkCount(1)
|
||||
s = Cpp11_std_unique_ptr.moveKlassUniquePtr(kin)
|
||||
checkCount(0)
|
||||
if (s != "KlassInput")
|
||||
raise RuntimeError, "Incorrect string: " + s
|
||||
end
|
||||
exception_thrown = false
|
||||
begin
|
||||
Cpp11_std_unique_ptr.is_nullptr(kin)
|
||||
rescue ObjectPreviouslyDeleted
|
||||
exception_thrown = true
|
||||
end
|
||||
if (!exception_thrown)
|
||||
raise RuntimeError, "is_nullptr failed to throw"
|
||||
end
|
||||
exception_thrown = false
|
||||
begin
|
||||
Cpp11_std_unique_ptr.moveKlassUniquePtr(kin)
|
||||
rescue RuntimeError => e
|
||||
# puts e.message
|
||||
exception_thrown = true
|
||||
end
|
||||
if (!exception_thrown)
|
||||
raise RuntimeError, "double usage of moveKlassUniquePtr should have been an error"
|
||||
end
|
||||
kin = nil
|
||||
checkCount(0)
|
||||
|
||||
kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
|
||||
exception_thrown = false
|
||||
notowned = Cpp11_std_unique_ptr::get_not_owned_ptr(kin)
|
||||
begin
|
||||
Cpp11_std_unique_ptr::moveKlassUniquePtr(notowned)
|
||||
rescue RuntimeError => e
|
||||
if (!e.to_s.include? "cannot release ownership as memory is not owned")
|
||||
raise RuntimeError, "incorrect exception message"
|
||||
end
|
||||
exception_thrown = true
|
||||
end
|
||||
if (!exception_thrown)
|
||||
raise RuntimeError, "Should have thrown 'Cannot release ownership as memory is not owned' error"
|
||||
end
|
||||
checkCount(1)
|
||||
Cpp11_std_unique_ptr.moveKlassUniquePtr(kin) # Ensure object is deleted (can't rely on GC)
|
||||
checkCount(0)
|
||||
|
||||
kini = Cpp11_std_unique_ptr::KlassInheritance.new("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = Cpp11_std_unique_ptr.moveKlassUniquePtr(kini)
|
||||
checkCount(0)
|
||||
if (s != "KlassInheritanceInput")
|
||||
raise RuntimeError, "Incorrect string: " + s
|
||||
end
|
||||
exception_thrown = false
|
||||
begin
|
||||
Cpp11_std_unique_ptr.is_nullptr(kini)
|
||||
rescue ObjectPreviouslyDeleted
|
||||
exception_thrown = true
|
||||
end
|
||||
if (!exception_thrown)
|
||||
raise RuntimeError, "is_nullptr failed to throw"
|
||||
end
|
||||
kini = nil
|
||||
checkCount(0)
|
||||
|
||||
Cpp11_std_unique_ptr::moveKlassUniquePtr(nil)
|
||||
Cpp11_std_unique_ptr::moveKlassUniquePtr(Cpp11_std_unique_ptr::make_null())
|
||||
checkCount(0)
|
||||
|
||||
# overloaded parameters
|
||||
if (Cpp11_std_unique_ptr::moveOverloadTest() != 0)
|
||||
raise RuntimeError, "moveOverloadTest failed"
|
||||
end
|
||||
if (Cpp11_std_unique_ptr::moveOverloadTest(nil) != 1)
|
||||
raise RuntimeError, "moveOverloadTest failed"
|
||||
end
|
||||
if (Cpp11_std_unique_ptr::moveOverloadTest(Cpp11_std_unique_ptr::Klass.new("over")) != 1)
|
||||
raise RuntimeError, "moveOverloadTest failed"
|
||||
end
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
k1 = Cpp11_std_unique_ptr::makeKlassUniquePtr("first")
|
||||
k2 = Cpp11_std_unique_ptr::makeKlassUniquePtr("second")
|
||||
|
|
|
@ -52,6 +52,7 @@ kini -delete
|
|||
checkCount 0
|
||||
|
||||
|
||||
# #### INPUT BY VALUE ####
|
||||
# unique_ptr as input
|
||||
Klass kin "KlassInput"
|
||||
checkCount 1
|
||||
|
@ -143,6 +144,98 @@ if {[overloadTest [Klass k "over"]] != 1} {
|
|||
checkCount 0
|
||||
|
||||
|
||||
# #### INPUT BY RVALUE REF ####
|
||||
# unique_ptr as input
|
||||
Klass kin "KlassInput"
|
||||
checkCount 1
|
||||
set s [moveKlassUniquePtr kin]
|
||||
checkCount 0
|
||||
if {[kin cget -thisown]} {
|
||||
error "thisown should be false"
|
||||
}
|
||||
if {$s != "KlassInput"} {
|
||||
error "Incorrect string: $s"
|
||||
}
|
||||
if {![is_nullptr kin]} {
|
||||
error "is_nullptr failed"
|
||||
}
|
||||
kin -delete # Should not fail, even though already deleted
|
||||
checkCount 0
|
||||
|
||||
Klass kin "KlassInput"
|
||||
checkCount 1
|
||||
set s [moveKlassUniquePtr kin]
|
||||
checkCount 0
|
||||
if {[kin cget -thisown]} {
|
||||
error "thisown should be false"
|
||||
}
|
||||
if {$s != "KlassInput"} {
|
||||
error "Incorrect string: $s"
|
||||
}
|
||||
if {![is_nullptr kin]} {
|
||||
error "is_nullptr failed"
|
||||
}
|
||||
set exception_thrown 0
|
||||
if [ catch { set s [moveKlassUniquePtr kin] } e ] {
|
||||
if {[string first "cannot release ownership as memory is not owned" $e] == -1} {
|
||||
error "incorrect exception message: $e"
|
||||
}
|
||||
set exception_thrown 1
|
||||
}
|
||||
if {!$exception_thrown} {
|
||||
error "double usage of moveKlassUniquePtr should have been an error"
|
||||
}
|
||||
kin -delete # Should not fail, even though already deleted
|
||||
checkCount 0
|
||||
|
||||
Klass kin "KlassInput"
|
||||
set exception_thrown 0
|
||||
set notowned [get_not_owned_ptr kin]
|
||||
if [ catch {
|
||||
moveKlassUniquePtr notowned
|
||||
} ] {
|
||||
set exception_thrown 1
|
||||
}
|
||||
if {!$exception_thrown} {
|
||||
error "Should have thrown 'Cannot release ownership as memory is not owned' error"
|
||||
}
|
||||
checkCount 1
|
||||
kin -delete
|
||||
checkCount 0
|
||||
|
||||
KlassInheritance kini "KlassInheritanceInput"
|
||||
checkCount 1
|
||||
set s [moveKlassUniquePtr kini]
|
||||
checkCount 0
|
||||
if {[kini cget -thisown]} {
|
||||
error "thisown should be false"
|
||||
}
|
||||
if {$s != "KlassInheritanceInput"} {
|
||||
error "Incorrect string: $s"
|
||||
}
|
||||
if {![is_nullptr kini]} {
|
||||
error "is_nullptr failed"
|
||||
}
|
||||
kini -delete # Should not fail, even though already deleted
|
||||
checkCount 0
|
||||
|
||||
moveKlassUniquePtr "NULL"
|
||||
moveKlassUniquePtr [make_null]
|
||||
checkCount 0
|
||||
|
||||
# overloaded parameters
|
||||
if {[moveOverloadTest] != 0} {
|
||||
error "moveOverloadTest failed"
|
||||
}
|
||||
if {[moveOverloadTest "NULL"] != 1} {
|
||||
error "moveOverloadTest failed"
|
||||
}
|
||||
if {[moveOverloadTest [Klass k "over"]] != 1} {
|
||||
error "moveOverloadTest failed"
|
||||
}
|
||||
checkCount 0
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
set k1 [makeKlassUniquePtr "first"]
|
||||
set k2 [makeKlassUniquePtr "second"]
|
||||
|
|
|
@ -9,16 +9,19 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%define %unique_ptr(TYPE)
|
||||
%typemap (ctype) std::unique_ptr< TYPE > "void *"
|
||||
%typemap (imtype) std::unique_ptr< TYPE > "void*"
|
||||
%typemap (dtype) std::unique_ptr< TYPE > "$typemap(dtype, TYPE)"
|
||||
%typemap (ctype) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "void *"
|
||||
%typemap (imtype) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "void*"
|
||||
%typemap (dtype) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "$typemap(dtype, TYPE)"
|
||||
|
||||
%typemap(in) std::unique_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
%typemap(in) std::unique_ptr< TYPE > &&
|
||||
%{ $*1_ltype $1_uptr((TYPE *)$input);
|
||||
$1 = &$1_uptr; %}
|
||||
|
||||
%typemap(din,
|
||||
nativepointer="cast(void*)$dinput"
|
||||
) std::unique_ptr< TYPE > "$typemap(dtype, TYPE).swigRelease($dinput)"
|
||||
) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "$typemap(dtype, TYPE).swigRelease($dinput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
|
@ -32,7 +35,7 @@
|
|||
return ret;
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE > ""
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && ""
|
||||
|
||||
%template() std::unique_ptr< TYPE >;
|
||||
%enddef
|
||||
|
|
|
@ -20,12 +20,25 @@
|
|||
}
|
||||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
scm_misc_error(FUNC_NAME, "Cannot release ownership as memory is not owned for argument $argnum of type 'TYPE *'", SCM_EOL);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -10,15 +10,18 @@
|
|||
|
||||
%define %unique_ptr(TYPE)
|
||||
|
||||
%typemap (jni) std::unique_ptr< TYPE > "jlong"
|
||||
%typemap (jtype) std::unique_ptr< TYPE > "long"
|
||||
%typemap (jstype) std::unique_ptr< TYPE > "$typemap(jstype, TYPE)"
|
||||
%typemap (jni) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "jlong"
|
||||
%typemap (jtype) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "long"
|
||||
%typemap (jstype) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "$typemap(jstype, TYPE)"
|
||||
|
||||
%typemap(in) std::unique_ptr< TYPE > (TYPE *unique_temp)
|
||||
%{ unique_temp = *(TYPE **)&$input;
|
||||
$1.reset(unique_temp); %}
|
||||
%typemap(in) std::unique_ptr< TYPE > &&
|
||||
%{ $*1_ltype $1_uptr((TYPE *)$input);
|
||||
$1 = &$1_uptr; %}
|
||||
|
||||
%typemap(javain) std::unique_ptr< TYPE > "$typemap(jstype, TYPE).swigRelease($javainput)"
|
||||
%typemap(javain) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "$typemap(jstype, TYPE).swigRelease($javainput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
jlong lpp = 0;
|
||||
|
@ -31,7 +34,7 @@
|
|||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, true);
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE > ""
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && ""
|
||||
|
||||
%template() std::unique_ptr< TYPE >;
|
||||
%enddef
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, checkfn="SWIG_isptrtype", noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr(L, $input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
lua_pushfstring(L, "Cannot release ownership as memory is not owned for argument $argnum of type 'TYPE *' in $symname"); SWIG_fail;
|
||||
} else {
|
||||
SWIG_fail_ptr("$symname", $argnum, $descriptor(TYPE *));
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
SWIG_NewPointerObj(L, $1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN); SWIG_arg++;
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr(L, $input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
scheme_signal_error(FUNC_NAME ": cannot release ownership as memory is not owned for argument $argnum of type 'TYPE *'");
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -23,11 +23,26 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr(&$input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of $descriptor(TYPE *) of $symname");
|
||||
return;
|
||||
} else {
|
||||
zend_type_error("Expected $descriptor(TYPE *) for argument $argnum of $symname");
|
||||
return;
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
SWIG_SetPointerZval($result, (void *)$1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN);
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr(&$input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
%set_output(SWIG_NewPointerObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -21,11 +21,24 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||
if (!SWIG_IsOK(res)) {
|
||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||
%releasenotowned_fail(res, "TYPE *", $symname, $argnum);
|
||||
} else {
|
||||
%argument_fail(res, "TYPE *", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
uptr.reset((TYPE *)argp);
|
||||
$1 = &uptr;
|
||||
}
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
Tcl_SetObjResult(interp, SWIG_NewInstanceObj($1.release(), $descriptor(TYPE *), SWIG_POINTER_OWN));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE > {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
Loading…
Reference in New Issue