mirror of https://github.com/swig/swig
Add non-const std::unique_ptr & input typemaps
This commit is contained in:
parent
5712ce6464
commit
846b40793e
|
@ -2105,8 +2105,10 @@ Ordering requirements for using this smart pointer macro are the same as the
|
|||
equivalent <tt>%shared_ptr(T)</tt> macro covered in the previous section.
|
||||
</p>
|
||||
|
||||
<H4><a name="Library_std_unique_ptr_by_value">12.4.6 unique_ptr passed by value</a></H4>
|
||||
|
||||
<p>
|
||||
Example usage of a <tt>std::unique_ptr</tt> being returned from a function is shown below.
|
||||
Example usage of a <tt>std::unique_ptr</tt> being returned from a function by value is shown below.
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
|
@ -2210,8 +2212,10 @@ Attempts to pass ownership from a proxy class to a <tt>std::unique</tt> paramete
|
|||
in a "Cannot release ownership as memory is not owned" exception. For example, if <tt>example.take(k)</tt> in the example above is called twice.
|
||||
</p>
|
||||
|
||||
<H4><a name="Library_std_unique_ptr_by_ref">12.4.6 unique_ptr passed by reference</a></H4>
|
||||
|
||||
<p>
|
||||
The effect of passing a <tt>std::unique_ptr</tt> by rvalue refence is identical to passing it by value.
|
||||
The effect of passing a <tt>std::unique_ptr</tt> by rvalue reference into a function 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>
|
||||
|
||||
|
@ -2221,6 +2225,24 @@ void grab(std::unique_ptr<Klass> &&);
|
|||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Passing non-const lvalue references into a function is a bit quirky and not perfect due to ambiguities as
|
||||
to what the function may do.
|
||||
The approach taken is the ownership is transferred out of the target language from the proxy class
|
||||
into C++ space and the proxy class can then no longer be used after the wrapped function returns.
|
||||
In summary it works much like passing a <tt>std::unique_ptr</tt> by value into a function.
|
||||
The assumption is the function will not modify the <tt>std::unique_ptr</tt>.
|
||||
If this is not true and the underlying pointer is changed, such as calling the member functions, <tt>swap</tt>, <tt>reset</tt> or <tt>release</tt>, then the modified <tt>std::unique_ptr</tt> will effectively be ignored.
|
||||
It is destroyed when the function exits C++ space on return to the target language.
|
||||
Example:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
void process(std::unique_ptr<Klass> &);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Move semantics are not provided when wrapping a C++ function that returns a <tt>std::unique_ptr</tt> by reference.
|
||||
The target language proxy class wrapper that is returned does not own the underlying C++ object.
|
||||
|
@ -2237,7 +2259,7 @@ std::unique_ptr<Klass> && RvalueRefReturn();
|
|||
|
||||
<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.
|
||||
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 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>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
%warnfilter(509, 516) overloadTest(Klass);
|
||||
%warnfilter(509, 516) moveOverloadTest(Klass);
|
||||
%warnfilter(509, 516) moveRefOverloadTest(Klass);
|
||||
|
||||
%include "std_string.i"
|
||||
%include "std_unique_ptr.i"
|
||||
|
@ -78,6 +79,13 @@ std::string moveKlassUniquePtr(std::unique_ptr<Klass>&& k) {
|
|||
return s;
|
||||
}
|
||||
|
||||
std::string moveRefKlassUniquePtr(std::unique_ptr<Klass>& k) {
|
||||
// std::cout << "moveRefKlassUniquePtr " << std::hex << (Klass*)k.get() << std::endl;
|
||||
std::string s(k ? k->getLabel() : "null smart pointer");
|
||||
// std::cout << "moveRefKlassUniquePtr string: " << s << std::endl;
|
||||
return s;
|
||||
}
|
||||
|
||||
Klass *make_null() {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -144,6 +152,18 @@ int moveOverloadTest(Klass k) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
int moveRefOverloadTest() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int moveRefOverloadTest(std::unique_ptr<Klass>& kover) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int moveRefOverloadTest(Klass k) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -178,6 +178,81 @@ public class cpp11_std_unique_ptr_runme {
|
|||
checkCount(0);
|
||||
|
||||
|
||||
///// INPUT BY NON-CONST LVALUE REF /////
|
||||
// unique_ptr as input
|
||||
using (Klass kin = new Klass("KlassInput")) {
|
||||
checkCount(1);
|
||||
string s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (s != "KlassInput")
|
||||
throw new ApplicationException("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kin))
|
||||
throw new ApplicationException("is_nullptr failed");
|
||||
} // Dispose should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
using (Klass kin = new Klass("KlassInput")) {
|
||||
checkCount(1);
|
||||
string s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
if (s != "KlassInput")
|
||||
throw new ApplicationException("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kin))
|
||||
throw new ApplicationException("is_nullptr failed");
|
||||
bool exception_thrown = false;
|
||||
try {
|
||||
cpp11_std_unique_ptr.moveRefKlassUniquePtr(kin);
|
||||
} catch (ApplicationException e) {
|
||||
if (!e.Message.Contains("Cannot release ownership as memory is not owned"))
|
||||
throw new ApplicationException("incorrect exception message");
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new ApplicationException("double usage of moveRefKlassUniquePtr should have been an error");
|
||||
} // Dispose should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
using (Klass kin = new Klass("KlassInput")) {
|
||||
bool exception_thrown = false;
|
||||
Klass notowned = cpp11_std_unique_ptr.get_not_owned_ptr(kin);
|
||||
try {
|
||||
cpp11_std_unique_ptr.moveRefKlassUniquePtr(notowned);
|
||||
} catch (ApplicationException e) {
|
||||
if (!e.Message.Contains("Cannot release ownership as memory is not owned"))
|
||||
throw new ApplicationException("incorrect exception message");
|
||||
exception_thrown = true;
|
||||
}
|
||||
if (!exception_thrown)
|
||||
throw new ApplicationException("Should have thrown 'Cannot release ownership as memory is not owned' error");
|
||||
checkCount(1);
|
||||
}
|
||||
checkCount(0);
|
||||
|
||||
using (KlassInheritance kini = new KlassInheritance("KlassInheritanceInput")) {
|
||||
checkCount(1);
|
||||
string s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(kini);
|
||||
checkCount(0);
|
||||
if (s != "KlassInheritanceInput")
|
||||
throw new ApplicationException("Incorrect string: " + s);
|
||||
if (!cpp11_std_unique_ptr.is_nullptr(kini))
|
||||
throw new ApplicationException("is_nullptr failed");
|
||||
} // Dispose should not fail, even though already deleted
|
||||
checkCount(0);
|
||||
|
||||
cpp11_std_unique_ptr.moveRefKlassUniquePtr(null);
|
||||
cpp11_std_unique_ptr.moveRefKlassUniquePtr(cpp11_std_unique_ptr.make_null());
|
||||
checkCount(0);
|
||||
|
||||
// overloaded parameters
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest() != 0)
|
||||
throw new ApplicationException("moveRefOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest(null) != 1)
|
||||
throw new ApplicationException("moveRefOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest(new Klass("over")) != 1)
|
||||
throw new ApplicationException("moveRefOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
// unique_ptr as output
|
||||
Klass k1 = cpp11_std_unique_ptr.makeKlassUniquePtr("first");
|
||||
if (k1.getLabel() != "first")
|
||||
|
|
|
@ -181,6 +181,85 @@ void main() {
|
|||
checkCount(0);
|
||||
|
||||
|
||||
///// INPUT BY NON-CONST LVALUE REF /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
scope Klass kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
string s = moveRefKlassUniquePtr(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 = moveRefKlassUniquePtr(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 {
|
||||
moveRefKlassUniquePtr(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 moveRefKlassUniquePtr 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 {
|
||||
moveRefKlassUniquePtr(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 = moveRefKlassUniquePtr(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);
|
||||
|
||||
moveRefKlassUniquePtr(null);
|
||||
moveRefKlassUniquePtr(make_null());
|
||||
checkCount(0);
|
||||
|
||||
// overloaded parameters
|
||||
if (moveRefOverloadTest() != 0)
|
||||
throw new Exception("moveRefOverloadTest failed");
|
||||
if (moveRefOverloadTest(null) != 1)
|
||||
throw new Exception("moveRefOverloadTest failed");
|
||||
if (moveRefOverloadTest(new Klass("over")) != 1)
|
||||
throw new Exception("moveRefOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
// unique_ptr as output
|
||||
Klass k1 = makeKlassUniquePtr("first");
|
||||
if (k1.getLabel() != "first")
|
||||
|
|
|
@ -207,6 +207,89 @@ public class cpp11_std_unique_ptr_runme {
|
|||
checkCount(0);
|
||||
|
||||
|
||||
///// INPUT BY NON-CONST LVALUE REF /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
Klass kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
String s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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 moveRefKlassUniquePtr 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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(null);
|
||||
cpp11_std_unique_ptr.moveRefKlassUniquePtr(cpp11_std_unique_ptr.make_null());
|
||||
checkCount(0);
|
||||
|
||||
// overloaded parameters
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest() != 0)
|
||||
throw new RuntimeException("moveRefOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest(null) != 1)
|
||||
throw new RuntimeException("moveRefOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest(new Klass("over")) != 1)
|
||||
throw new RuntimeException("moveRefOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
// unique_ptr as output
|
||||
Klass k1 = cpp11_std_unique_ptr.makeKlassUniquePtr("first");
|
||||
if (!k1.getLabel().equals("first"))
|
||||
|
|
|
@ -190,6 +190,91 @@ if (cpp11_std_unique_ptr.moveOverloadTest(new cpp11_std_unique_ptr.Klass("over")
|
|||
checkCount(0);
|
||||
|
||||
|
||||
///// INPUT BY NON-CONST LVALUE REF /////
|
||||
// unique_ptr as input
|
||||
{
|
||||
kin = new cpp11_std_unique_ptr.Klass("KlassInput");
|
||||
checkCount(1);
|
||||
s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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 moveRefKlassUniquePtr 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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(kin);
|
||||
checkCount(0);
|
||||
}
|
||||
|
||||
{
|
||||
kini = new cpp11_std_unique_ptr.KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(null);
|
||||
cpp11_std_unique_ptr.moveRefKlassUniquePtr(cpp11_std_unique_ptr.make_null());
|
||||
checkCount(0);
|
||||
|
||||
// overloaded parameters
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest() != 0)
|
||||
throw new RuntimeException("moveRefOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest(null) != 1)
|
||||
throw new RuntimeException("moveRefOverloadTest failed");
|
||||
if (cpp11_std_unique_ptr.moveRefOverloadTest(new cpp11_std_unique_ptr.Klass("over")) != 1)
|
||||
throw new RuntimeException("moveRefOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
// unique_ptr as output
|
||||
k1 = cpp11_std_unique_ptr.makeKlassUniquePtr("first");
|
||||
if (k1.getLabel() !== "first")
|
||||
|
|
|
@ -164,6 +164,75 @@ end
|
|||
checkCount(0)
|
||||
|
||||
|
||||
--- ---- INPUT BY NON-CONST LVALUE REF ---
|
||||
-- unique_ptr as input
|
||||
kin = cpp11_std_unique_ptr.Klass("KlassInput")
|
||||
checkCount(1)
|
||||
s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(kin) end)
|
||||
assert(s == false and msg == "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' in moveRefKlassUniquePtr")
|
||||
|
||||
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.moveRefKlassUniquePtr(notowned) end)
|
||||
assert(s == false and msg == "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' in moveRefKlassUniquePtr")
|
||||
checkCount(1)
|
||||
kin = nil
|
||||
checkCount(0)
|
||||
|
||||
kini = cpp11_std_unique_ptr.KlassInheritance("KlassInheritanceInput")
|
||||
checkCount(1)
|
||||
s = cpp11_std_unique_ptr.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(nil);
|
||||
cpp11_std_unique_ptr.moveRefKlassUniquePtr(cpp11_std_unique_ptr.make_null());
|
||||
checkCount(0);
|
||||
|
||||
-- overloaded parameters
|
||||
if not (cpp11_std_unique_ptr.moveRefOverloadTest() == 0) then
|
||||
error("moveRefOverloadTest failed")
|
||||
end
|
||||
if not (cpp11_std_unique_ptr.moveRefOverloadTest(nil) == 1) then
|
||||
error("moveRefOverloadTest failed")
|
||||
end
|
||||
if not (cpp11_std_unique_ptr.moveRefOverloadTest(cpp11_std_unique_ptr.Klass("over")) == 1) then
|
||||
error("moveRefOverloadTest failed")
|
||||
end
|
||||
checkCount(0)
|
||||
|
||||
|
||||
-- unique_ptr as output
|
||||
k1 = cpp11_std_unique_ptr.makeKlassUniquePtr("first")
|
||||
k2 = cpp11_std_unique_ptr.makeKlassUniquePtr("second")
|
||||
|
|
|
@ -159,6 +159,75 @@
|
|||
(checkCount 0)
|
||||
|
||||
|
||||
; ;;;; INPUT BY NON-CONST LVALUE REF ;;;;
|
||||
; unique_ptr as input
|
||||
(define kin (new-Klass "KlassInput"))
|
||||
(checkCount 1)
|
||||
(define s (moveRefKlassUniquePtr 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 (moveRefKlassUniquePtr 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)))])
|
||||
(moveRefKlassUniquePtr kin))
|
||||
(unless (string=? exception_thrown "moveRefKlassUniquePtr: 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)))])
|
||||
(moveRefKlassUniquePtr notowned))
|
||||
(unless (string=? exception_thrown "moveRefKlassUniquePtr: 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 (moveRefKlassUniquePtr 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 '())
|
||||
(moveRefKlassUniquePtr null)
|
||||
(moveRefKlassUniquePtr (make-null))
|
||||
(checkCount 0)
|
||||
|
||||
; overloaded parameters
|
||||
(unless (= (moveRefOverloadTest) 0)
|
||||
(error "moveRefOverloadTest failed"))
|
||||
(unless (= (moveRefOverloadTest null) 1)
|
||||
(error "moveRefOverloadTest failed"))
|
||||
(unless (= (moveRefOverloadTest (new-Klass "over")) 1)
|
||||
(error "moveRefOverloadTest failed"))
|
||||
(checkCount 0)
|
||||
|
||||
|
||||
; unique_ptr as output
|
||||
(define k1 (makeKlassUniquePtr "first"))
|
||||
(define k2 (makeKlassUniquePtr "second"))
|
||||
|
|
|
@ -205,6 +205,97 @@ endif
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY NON-CONST LVALUE REF ####
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput");
|
||||
checkCount(1);
|
||||
s = moveRefKlassUniquePtr(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 = moveRefKlassUniquePtr(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
|
||||
moveRefKlassUniquePtr(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 moveRefKlassUniquePtr 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
|
||||
moveRefKlassUniquePtr(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 = moveRefKlassUniquePtr(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();
|
||||
moveRefKlassUniquePtr([]);
|
||||
moveRefKlassUniquePtr(null);
|
||||
moveRefKlassUniquePtr(null_ptr);
|
||||
checkCount(0);
|
||||
|
||||
# overloaded parameters
|
||||
if (moveRefOverloadTest() != 0)
|
||||
error("moveRefOverloadTest failed");
|
||||
endif
|
||||
if (moveRefOverloadTest(null) != 1)
|
||||
error("moveRefOverloadTest failed");
|
||||
endif
|
||||
if (moveRefOverloadTest(Klass("over")) != 1)
|
||||
error("moveRefOverloadTest 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 => 62;
|
||||
use Test::More tests => 86;
|
||||
BEGIN { use_ok('cpp11_std_unique_ptr') }
|
||||
require_ok('cpp11_std_unique_ptr');
|
||||
|
||||
|
@ -147,6 +147,68 @@ is(cpp11_std_unique_ptr::moveOverloadTest(new cpp11_std_unique_ptr::Klass("over"
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY NON-CONST LVALUE REF ####
|
||||
# unique_ptr as input
|
||||
{
|
||||
my $kin = new cpp11_std_unique_ptr::Klass("KlassInput");
|
||||
checkCount(1);
|
||||
my $s = cpp11_std_unique_ptr::moveRefKlassUniquePtr($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::moveRefKlassUniquePtr($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::moveRefKlassUniquePtr($kin);
|
||||
};
|
||||
like($@, qr/\bcannot release ownership as memory is not owned\b/, "double usage of moveRefKlassUniquePtr 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::moveRefKlassUniquePtr($notowned);
|
||||
};
|
||||
like($@, qr/\bcannot release ownership as memory is not owned\b/, "double usage of moveRefKlassUniquePtr 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::moveRefKlassUniquePtr($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::moveRefKlassUniquePtr(undef);
|
||||
cpp11_std_unique_ptr::moveRefKlassUniquePtr(cpp11_std_unique_ptr::make_null());
|
||||
checkCount(0);
|
||||
|
||||
# overloaded parameters
|
||||
is(cpp11_std_unique_ptr::moveRefOverloadTest(), 0, "moveRefOverloadTest failed");
|
||||
is(cpp11_std_unique_ptr::moveRefOverloadTest(undef), 1, "moveRefOverloadTest failed");
|
||||
is(cpp11_std_unique_ptr::moveRefOverloadTest(new cpp11_std_unique_ptr::Klass("over")), 1, "moveRefOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
my $k1 = cpp11_std_unique_ptr::makeKlassUniquePtr("first");
|
||||
my $k2 = cpp11_std_unique_ptr::makeKlassUniquePtr("second");
|
||||
|
|
|
@ -166,6 +166,81 @@ check::equal(moveOverloadTest(new Klass("over")), 1, "moveOverloadTest failed");
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY NON-CONST LVALUE REF ####
|
||||
# unique_ptr as input
|
||||
$kin = new Klass("KlassInput");
|
||||
checkCount(1);
|
||||
$s = moveRefKlassUniquePtr($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 = moveRefKlassUniquePtr($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 {
|
||||
moveRefKlassUniquePtr($kin);
|
||||
} catch (TypeError $e) {
|
||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of moveRefKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
||||
$exception_thrown = true;
|
||||
}
|
||||
check::equal($exception_thrown, true, "double usage of moveRefKlassUniquePtr 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 {
|
||||
moveRefKlassUniquePtr($notowned);
|
||||
} catch (TypeError $e) {
|
||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of moveRefKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
||||
$exception_thrown = true;
|
||||
}
|
||||
check::equal($exception_thrown, true, "double usage of moveRefKlassUniquePtr should have been an error");
|
||||
checkCount(1);
|
||||
$kin = NULL;
|
||||
checkCount(0);
|
||||
|
||||
$kini = new KlassInheritance("KlassInheritanceInput");
|
||||
checkCount(1);
|
||||
$s = moveRefKlassUniquePtr($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);
|
||||
|
||||
moveRefKlassUniquePtr(NULL);
|
||||
moveRefKlassUniquePtr(make_null());
|
||||
checkCount(0);
|
||||
|
||||
# overloaded parameters
|
||||
check::equal(moveRefOverloadTest(), 0, "moveRefOverloadTest failed");
|
||||
check::equal(moveRefOverloadTest(NULL), 1, "moveRefOverloadTest failed");
|
||||
check::equal(moveRefOverloadTest(new Klass("over")), 1, "moveRefOverloadTest failed");
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
$k1 = makeKlassUniquePtr("first");
|
||||
$k2 = makeKlassUniquePtr("second");
|
||||
|
|
|
@ -169,6 +169,83 @@ if moveOverloadTest(Klass("over")) != 1:
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY NON-CONST LVALUE REF ####
|
||||
# unique_ptr as input
|
||||
kin = Klass("KlassInput")
|
||||
checkCount(1)
|
||||
s = moveRefKlassUniquePtr(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 = moveRefKlassUniquePtr(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 = moveRefKlassUniquePtr(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 moveRefKlassUniquePtr 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:
|
||||
moveRefKlassUniquePtr(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 = moveRefKlassUniquePtr(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)
|
||||
|
||||
moveRefKlassUniquePtr(None)
|
||||
moveRefKlassUniquePtr(make_null())
|
||||
checkCount(0)
|
||||
|
||||
# overloaded parameters
|
||||
if moveRefOverloadTest() != 0:
|
||||
raise RuntimeError("moveRefOverloadTest failed")
|
||||
if moveRefOverloadTest(None) != 1:
|
||||
raise RuntimeError("moveRefOverloadTest failed")
|
||||
if moveRefOverloadTest(Klass("over")) != 1:
|
||||
raise RuntimeError("moveRefOverloadTest failed")
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
k1 = makeKlassUniquePtr("first")
|
||||
k2 = makeKlassUniquePtr("second")
|
||||
|
|
|
@ -238,6 +238,110 @@ end
|
|||
checkCount(0);
|
||||
|
||||
|
||||
# #### INPUT BY NON-CONST LVALUE REF ####
|
||||
# unique_ptr as input
|
||||
kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
|
||||
checkCount(1)
|
||||
s = Cpp11_std_unique_ptr.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(kin)
|
||||
rescue RuntimeError => e
|
||||
# puts e.message
|
||||
exception_thrown = true
|
||||
end
|
||||
if (!exception_thrown)
|
||||
raise RuntimeError, "double usage of moveRefKlassUniquePtr 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::moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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.moveRefKlassUniquePtr(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::moveRefKlassUniquePtr(nil)
|
||||
Cpp11_std_unique_ptr::moveRefKlassUniquePtr(Cpp11_std_unique_ptr::make_null())
|
||||
checkCount(0)
|
||||
|
||||
# overloaded parameters
|
||||
if (Cpp11_std_unique_ptr::moveRefOverloadTest() != 0)
|
||||
raise RuntimeError, "moveRefOverloadTest failed"
|
||||
end
|
||||
if (Cpp11_std_unique_ptr::moveRefOverloadTest(nil) != 1)
|
||||
raise RuntimeError, "moveRefOverloadTest failed"
|
||||
end
|
||||
if (Cpp11_std_unique_ptr::moveRefOverloadTest(Cpp11_std_unique_ptr::Klass.new("over")) != 1)
|
||||
raise RuntimeError, "moveRefOverloadTest failed"
|
||||
end
|
||||
checkCount(0);
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
k1 = Cpp11_std_unique_ptr::makeKlassUniquePtr("first")
|
||||
k2 = Cpp11_std_unique_ptr::makeKlassUniquePtr("second")
|
||||
|
|
|
@ -236,6 +236,98 @@ if {[moveOverloadTest [Klass k "over"]] != 1} {
|
|||
checkCount 0
|
||||
|
||||
|
||||
# #### INPUT BY NON-CONST LVALUE REF ####
|
||||
# unique_ptr as input
|
||||
Klass kin "KlassInput"
|
||||
checkCount 1
|
||||
set s [moveRefKlassUniquePtr 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 [moveRefKlassUniquePtr 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 [moveRefKlassUniquePtr 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 moveRefKlassUniquePtr 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 {
|
||||
moveRefKlassUniquePtr 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 [moveRefKlassUniquePtr 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
|
||||
|
||||
moveRefKlassUniquePtr "NULL"
|
||||
moveRefKlassUniquePtr [make_null]
|
||||
checkCount 0
|
||||
|
||||
# overloaded parameters
|
||||
if {[moveRefOverloadTest] != 0} {
|
||||
error "moveRefOverloadTest failed"
|
||||
}
|
||||
if {[moveRefOverloadTest "NULL"] != 1} {
|
||||
error "moveRefOverloadTest failed"
|
||||
}
|
||||
if {[moveRefOverloadTest [Klass k "over"]] != 1} {
|
||||
error "moveRefOverloadTest failed"
|
||||
}
|
||||
checkCount 0
|
||||
|
||||
|
||||
# unique_ptr as output
|
||||
set k1 [makeKlassUniquePtr "first"]
|
||||
set k2 [makeKlassUniquePtr "second"]
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
%typemap(in) std::unique_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
%typemap(in) std::unique_ptr< TYPE > &&
|
||||
%typemap(in) std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > &&
|
||||
%{ $*1_ltype $1_uptr((TYPE *)$input);
|
||||
$1 = &$1_uptr; %}
|
||||
|
||||
%typemap(csin) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "$typemap(cstype, TYPE).swigRelease($csinput)"
|
||||
%typemap(csin) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && "$typemap(cstype, TYPE).swigRelease($csinput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
|
@ -41,7 +41,7 @@
|
|||
}
|
||||
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && ""
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && ""
|
||||
|
||||
%template() std::unique_ptr< TYPE >;
|
||||
%enddef
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
|
||||
%typemap(in) std::unique_ptr< TYPE >
|
||||
%{ $1.reset((TYPE *)$input); %}
|
||||
%typemap(in) std::unique_ptr< TYPE > &&
|
||||
%typemap(in) std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > &&
|
||||
%{ $*1_ltype $1_uptr((TYPE *)$input);
|
||||
$1 = &$1_uptr; %}
|
||||
|
||||
%typemap(din,
|
||||
nativepointer="cast(void*)$dinput"
|
||||
) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "$typemap(dtype, TYPE).swigRelease($dinput)"
|
||||
) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && "$typemap(dtype, TYPE).swigRelease($dinput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
$result = (void *)$1.release();
|
||||
|
@ -47,7 +47,7 @@
|
|||
}
|
||||
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && ""
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && ""
|
||||
|
||||
%template() std::unique_ptr< TYPE >;
|
||||
%enddef
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && {
|
||||
void *vptr = 0;
|
||||
int res = SWIG_ConvertPtr($input, &vptr, $descriptor(TYPE *), 0);
|
||||
$1 = SWIG_CheckState(res);
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
%typemap(in) std::unique_ptr< TYPE > (TYPE *unique_temp)
|
||||
%{ unique_temp = *(TYPE **)&$input;
|
||||
$1.reset(unique_temp); %}
|
||||
%typemap(in) std::unique_ptr< TYPE > &&
|
||||
%typemap(in) std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > &&
|
||||
%{ $*1_ltype $1_uptr((TYPE *)$input);
|
||||
$1 = &$1_uptr; %}
|
||||
|
||||
%typemap(javain) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && "$typemap(jstype, TYPE).swigRelease($javainput)"
|
||||
%typemap(javain) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && "$typemap(jstype, TYPE).swigRelease($javainput)"
|
||||
|
||||
%typemap (out) std::unique_ptr< TYPE > %{
|
||||
jlong lpp = 0;
|
||||
|
@ -44,7 +44,7 @@
|
|||
return (cPtr == 0) ? null : new $typemap(jstype, TYPE)(cPtr, false);
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && ""
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *") std::unique_ptr< TYPE >, std::unique_ptr< TYPE > &, std::unique_ptr< TYPE > && ""
|
||||
|
||||
%template() std::unique_ptr< TYPE >;
|
||||
%enddef
|
||||
|
|
|
@ -21,20 +21,7 @@
|
|||
$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(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -54,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$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) {
|
||||
%typemap(in, checkfn="SWIG_isptrtype", noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
SWIG_NewPointerObj(L, $1->get(), $descriptor(TYPE *), $owner); SWIG_arg++;
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +23,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -45,7 +45,7 @@
|
|||
SWIG_SetPointerZval($result, (void *)$1->get(), $descriptor(TYPE *), $owner);
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
%set_output(SWIG_NewPointerObj($1->get(), $descriptor(TYPE *), $owner | %newpointer_flags));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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,7 +21,7 @@
|
|||
$1.reset((TYPE *)argp);
|
||||
}
|
||||
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > && (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr) {
|
||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > & (void *argp = 0, int res = 0, std::unique_ptr< TYPE > uptr), 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) {
|
||||
|
@ -41,7 +41,7 @@
|
|||
Tcl_SetObjResult(interp, SWIG_NewInstanceObj($1->get(), $descriptor(TYPE *), $owner));
|
||||
%}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, std::unique_ptr< TYPE > && {
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER, equivalent="TYPE *", noblock=1) std::unique_ptr< TYPE >, 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