SWIGTYPE && input typemaps now assume object has been moved
Replicated Java implementation. Fully implemented for: - C# - D - Guile - Javascript (UTL) - Lua - MzScheme - Octave (UTL) - Perl (UTL) - PHP - Python (UTL) - Ruby (UTL) - Tcl (UTL) PHP std::auto_ptr std::unique_ptr minor tweaks and testcase corrections
This commit is contained in:
parent
0634883089
commit
e139a36511
31 changed files with 931 additions and 46 deletions
|
|
@ -0,0 +1,66 @@
|
||||||
|
using System;
|
||||||
|
using cpp11_rvalue_reference_move_inputNamespace;
|
||||||
|
|
||||||
|
public class cpp11_rvalue_reference_move_input_runme {
|
||||||
|
public static void Main() {
|
||||||
|
{
|
||||||
|
// Function containing rvalue reference parameter
|
||||||
|
Counter.reset_counts();
|
||||||
|
MovableCopyable mo = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable.movein(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new ApplicationException("is_nullptr failed");
|
||||||
|
mo.Dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move constructor test
|
||||||
|
Counter.reset_counts();
|
||||||
|
MovableCopyable mo = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable mo_moved = new MovableCopyable(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new ApplicationException("is_nullptr failed");
|
||||||
|
mo.Dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
mo_moved.Dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move assignment operator test
|
||||||
|
Counter.reset_counts();
|
||||||
|
MovableCopyable mo111 = new MovableCopyable(111);
|
||||||
|
MovableCopyable mo222 = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 0, 0);
|
||||||
|
mo111.MoveAssign(mo222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo222))
|
||||||
|
throw new ApplicationException("is_nullptr failed");
|
||||||
|
mo222.Dispose();
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
mo111.Dispose();
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// null check
|
||||||
|
Counter.reset_counts();
|
||||||
|
bool exception_thrown = false;
|
||||||
|
try {
|
||||||
|
MovableCopyable.movein(null);
|
||||||
|
} catch (ArgumentNullException e) {
|
||||||
|
if (!e.Message.Contains("MovableCopyable && is null"))
|
||||||
|
throw new ApplicationException("incorrect exception message:" + e);
|
||||||
|
exception_thrown = true;
|
||||||
|
}
|
||||||
|
if (!exception_thrown)
|
||||||
|
throw new ApplicationException("Should have thrown null error");
|
||||||
|
Counter.check_counts(0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -66,7 +66,7 @@ public class runme
|
||||||
li_std_wstring.test_reference(null);
|
li_std_wstring.test_reference(null);
|
||||||
throw new Exception("NULL check failed");
|
throw new Exception("NULL check failed");
|
||||||
} catch (ArgumentNullException e) {
|
} catch (ArgumentNullException e) {
|
||||||
if (!e.Message.Contains("type is null"))
|
if (!e.Message.Contains("is null"))
|
||||||
throw new Exception("Missing text " + e);
|
throw new Exception("Missing text " + e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
module cpp11_rvalue_reference_move_input_runme;
|
||||||
|
|
||||||
|
import cpp11_rvalue_reference_move_input.Counter;
|
||||||
|
import cpp11_rvalue_reference_move_input.MovableCopyable;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
{
|
||||||
|
// Function containing rvalue reference parameter
|
||||||
|
Counter.reset_counts();
|
||||||
|
scope MovableCopyable mo = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable.movein(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new Exception("is_nullptr failed");
|
||||||
|
mo.dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move constructor test
|
||||||
|
Counter.reset_counts();
|
||||||
|
scope MovableCopyable mo = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable mo_moved = new MovableCopyable(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new Exception("is_nullptr failed");
|
||||||
|
mo.dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
mo_moved.dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move assignment operator test
|
||||||
|
Counter.reset_counts();
|
||||||
|
scope MovableCopyable mo111 = new MovableCopyable(111);
|
||||||
|
scope MovableCopyable mo222 = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 0, 0);
|
||||||
|
mo111.MoveAssign(mo222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo222))
|
||||||
|
throw new Exception("is_nullptr failed");
|
||||||
|
mo222.dispose();
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
mo111.dispose();
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// null check
|
||||||
|
Counter.reset_counts();
|
||||||
|
bool exception_thrown = false;
|
||||||
|
try {
|
||||||
|
MovableCopyable.movein(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!canFind(e.msg, "MovableCopyable && is null"))
|
||||||
|
throw new Exception("incorrect exception message:" ~ e.msg);
|
||||||
|
exception_thrown = true;
|
||||||
|
}
|
||||||
|
if (!exception_thrown)
|
||||||
|
throw new Exception("Should have thrown null error");
|
||||||
|
Counter.check_counts(0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
module cpp11_rvalue_reference_move_input_runme;
|
||||||
|
|
||||||
|
import cpp11_rvalue_reference_move_input.Counter;
|
||||||
|
import cpp11_rvalue_reference_move_input.MovableCopyable;
|
||||||
|
import std.algorithm;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
{
|
||||||
|
// Function containing rvalue reference parameter
|
||||||
|
Counter.reset_counts();
|
||||||
|
scope MovableCopyable mo = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable.movein(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new Exception("is_nullptr failed");
|
||||||
|
mo.dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move constructor test
|
||||||
|
Counter.reset_counts();
|
||||||
|
scope MovableCopyable mo = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable mo_moved = new MovableCopyable(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new Exception("is_nullptr failed");
|
||||||
|
mo.dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
mo_moved.dispose();
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move assignment operator test
|
||||||
|
Counter.reset_counts();
|
||||||
|
scope MovableCopyable mo111 = new MovableCopyable(111);
|
||||||
|
scope MovableCopyable mo222 = new MovableCopyable(222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 0, 0);
|
||||||
|
mo111.MoveAssign(mo222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
if (!MovableCopyable.is_nullptr(mo222))
|
||||||
|
throw new Exception("is_nullptr failed");
|
||||||
|
mo222.dispose();
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
mo111.dispose();
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// null check
|
||||||
|
Counter.reset_counts();
|
||||||
|
bool exception_thrown = false;
|
||||||
|
try {
|
||||||
|
MovableCopyable.movein(null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!canFind(e.msg, "MovableCopyable && is null"))
|
||||||
|
throw new Exception("incorrect exception message:" ~ e.msg);
|
||||||
|
exception_thrown = true;
|
||||||
|
}
|
||||||
|
if (!exception_thrown)
|
||||||
|
throw new Exception("Should have thrown null error");
|
||||||
|
Counter.check_counts(0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
(dynamic-call "scm_init_cpp11_rvalue_reference_move_input_module" (dynamic-link "./libcpp11_rvalue_reference_move_input"))
|
||||||
|
(load "testsuite.scm")
|
||||||
|
(load "../schemerunme/cpp11_rvalue_reference_move_input.scm")
|
||||||
|
|
@ -15,6 +15,7 @@ public class cpp11_rvalue_reference_move_input_runme {
|
||||||
public static void main(String argv[]) {
|
public static void main(String argv[]) {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// Function containing rvalue reference parameter
|
||||||
Counter.reset_counts();
|
Counter.reset_counts();
|
||||||
MovableCopyable mo = new MovableCopyable(222);
|
MovableCopyable mo = new MovableCopyable(222);
|
||||||
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
var cpp11_rvalue_reference_move_input = require("cpp11_rvalue_reference_move_input");
|
||||||
|
|
||||||
|
{
|
||||||
|
// Function containing rvalue reference parameter
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts();
|
||||||
|
mo = new cpp11_rvalue_reference_move_input.MovableCopyable(222);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
cpp11_rvalue_reference_move_input.MovableCopyable.movein(mo);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
if (!cpp11_rvalue_reference_move_input.MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new Error("is_nullptr failed");
|
||||||
|
delete mo;
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move constructor test
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts();
|
||||||
|
mo = new cpp11_rvalue_reference_move_input.MovableCopyable(222);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
mo_moved = new cpp11_rvalue_reference_move_input.MovableCopyable(mo);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
if (!cpp11_rvalue_reference_move_input.MovableCopyable.is_nullptr(mo))
|
||||||
|
throw new Error("is_nullptr failed");
|
||||||
|
delete mo;
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
// delete mo_moved;
|
||||||
|
// cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
// Above not deleting the C++ object(node v12) - can't reliably control GC - use the movein function instead to delete
|
||||||
|
cpp11_rvalue_reference_move_input.MovableCopyable.movein(mo_moved);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 2, 0, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Move assignment operator test
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts();
|
||||||
|
mo111 = new cpp11_rvalue_reference_move_input.MovableCopyable(111);
|
||||||
|
mo222 = new cpp11_rvalue_reference_move_input.MovableCopyable(222);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 0, 0);
|
||||||
|
mo111.MoveAssign(mo222);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
if (!cpp11_rvalue_reference_move_input.MovableCopyable.is_nullptr(mo222))
|
||||||
|
throw new Error("is_nullptr failed");
|
||||||
|
delete mo222;
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
// delete mo111;
|
||||||
|
// cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 1, 2);
|
||||||
|
// Above not deleting the C++ object(node v12) - can't reliably control GC - use the movein function instead to delete
|
||||||
|
cpp11_rvalue_reference_move_input.MovableCopyable.movein(mo111);
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 1, 1, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// null check
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts();
|
||||||
|
exception_thrown = false;
|
||||||
|
try {
|
||||||
|
cpp11_rvalue_reference_move_input.MovableCopyable.movein(null);
|
||||||
|
} catch (e) {
|
||||||
|
if (!e.message.includes("invalid null reference"))
|
||||||
|
throw new Error("incorrect exception message " + e.message);
|
||||||
|
exception_thrown = true;
|
||||||
|
}
|
||||||
|
if (!exception_thrown)
|
||||||
|
throw new Error("Should have thrown null error");
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
require("import") -- the import fn
|
||||||
|
import("cpp11_rvalue_reference_move_input") -- import code
|
||||||
|
|
||||||
|
-- catch "undefined" global variables
|
||||||
|
local env = _ENV -- Lua 5.2
|
||||||
|
if not env then env = getfenv () end -- Lua 5.1
|
||||||
|
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||||
|
|
||||||
|
-- Function containing rvalue reference parameter
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts()
|
||||||
|
mo = cpp11_rvalue_reference_move_input.MovableCopyable(222)
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 0, 0, 0)
|
||||||
|
cpp11_rvalue_reference_move_input.MovableCopyable.movein(mo)
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
if not (cpp11_rvalue_reference_move_input.MovableCopyable_is_nullptr(mo)) then
|
||||||
|
error("is_nullptr failed")
|
||||||
|
end
|
||||||
|
mo = nil
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
|
||||||
|
-- Move constructor test
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts()
|
||||||
|
mo = cpp11_rvalue_reference_move_input.MovableCopyable(222)
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 0, 0, 0)
|
||||||
|
mo_moved = cpp11_rvalue_reference_move_input.MovableCopyable(mo)
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 1)
|
||||||
|
if not (cpp11_rvalue_reference_move_input.MovableCopyable_is_nullptr(mo)) then
|
||||||
|
error("is_nullptr failed")
|
||||||
|
end
|
||||||
|
mo = nil
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 1)
|
||||||
|
mo_moved = nil
|
||||||
|
collectgarbage() -- gc nudge needed here
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
|
||||||
|
-- Move assignment operator test
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts()
|
||||||
|
mo111 = cpp11_rvalue_reference_move_input.MovableCopyable(111)
|
||||||
|
mo222 = cpp11_rvalue_reference_move_input.MovableCopyable(222)
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 0, 0)
|
||||||
|
mo111:MoveAssign(mo222)
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 1, 1)
|
||||||
|
if not (cpp11_rvalue_reference_move_input.MovableCopyable_is_nullptr(mo222)) then
|
||||||
|
error("is_nullptr failed")
|
||||||
|
end
|
||||||
|
mo222 = nil
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 1, 1)
|
||||||
|
mo111 = nil
|
||||||
|
collectgarbage() -- gc nudge needed here
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(2, 0, 0, 0, 1, 2)
|
||||||
|
|
||||||
|
-- null check
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.reset_counts()
|
||||||
|
s, msg = pcall(function() cpp11_rvalue_reference_move_input.MovableCopyable.movein(nil) end)
|
||||||
|
assert(s == false and msg:find("Error in MovableCopyable::movein (arg 1), expected 'MovableCopyable &&' got 'nil'", 1, true))
|
||||||
|
cpp11_rvalue_reference_move_input.Counter.check_counts(0, 0, 0, 0, 0, 0)
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
(load-extension "cpp11_rvalue_reference_move_input.so")
|
||||||
|
(require (lib "defmacro.ss"))
|
||||||
|
|
||||||
|
; Copied from ../schemerunme/cpp11_rvalue_reference_move_input.scm and modified for exceptions
|
||||||
|
|
||||||
|
; Function containing rvalue reference parameter
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(define mo (new-MovableCopyable 222))
|
||||||
|
(Counter-check-counts 1 0 0 0 0 0)
|
||||||
|
(MovableCopyable-movein mo)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 2)
|
||||||
|
(unless (MovableCopyable-is-nullptr mo)
|
||||||
|
(error "is_nullptr failed"))
|
||||||
|
(delete-MovableCopyable mo)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 2)
|
||||||
|
|
||||||
|
; Move constructor test
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(define mo (new-MovableCopyable 222))
|
||||||
|
(Counter-check-counts 1 0 0 0 0 0)
|
||||||
|
(define mo_moved (new-MovableCopyable mo))
|
||||||
|
(Counter-check-counts 1 0 0 1 0 1)
|
||||||
|
(unless (MovableCopyable-is-nullptr mo)
|
||||||
|
(error "is_nullptr failed"))
|
||||||
|
(delete-MovableCopyable mo)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 1)
|
||||||
|
(delete-MovableCopyable mo_moved)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 2)
|
||||||
|
|
||||||
|
; Move assignment operator test
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(define mo111 (new-MovableCopyable 111))
|
||||||
|
(define mo222 (new-MovableCopyable 222))
|
||||||
|
(Counter-check-counts 2 0 0 0 0 0)
|
||||||
|
(MovableCopyable-MoveAssign mo111 mo222)
|
||||||
|
(Counter-check-counts 2 0 0 0 1 1)
|
||||||
|
(unless (MovableCopyable-is-nullptr mo222)
|
||||||
|
(error "is_nullptr failed"))
|
||||||
|
(delete-MovableCopyable mo222)
|
||||||
|
(Counter-check-counts 2 0 0 0 1 1)
|
||||||
|
(delete-MovableCopyable mo111)
|
||||||
|
(Counter-check-counts 2 0 0 0 1 2)
|
||||||
|
|
||||||
|
; null check
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(define exception_thrown "no exception thrown for kin")
|
||||||
|
(with-handlers ([exn:fail? (lambda (exn)
|
||||||
|
(set! exception_thrown (exn-message exn)))])
|
||||||
|
(MovableCopyable-movein '()))
|
||||||
|
(unless (string=? exception_thrown "MovableCopyable-movein: swig-type-error (null reference)")
|
||||||
|
(error (format "incorrect exception message: ~a" exception_thrown)))
|
||||||
|
(Counter-check-counts 0 0 0 0 0 0)
|
||||||
|
|
||||||
|
(exit 0)
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
# do not dump Octave core
|
||||||
|
if exist("crash_dumps_octave_core", "builtin")
|
||||||
|
crash_dumps_octave_core(0);
|
||||||
|
endif
|
||||||
|
|
||||||
|
cpp11_rvalue_reference_move_input
|
||||||
|
|
||||||
|
# Function containing rvalue reference parameter
|
||||||
|
Counter.reset_counts();
|
||||||
|
mo = MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable.movein(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
if (!MovableCopyable_is_nullptr(mo))
|
||||||
|
error("is_nullptr failed");
|
||||||
|
endif
|
||||||
|
clear mo;
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
|
||||||
|
# Move constructor test
|
||||||
|
Counter.reset_counts();
|
||||||
|
mo = MovableCopyable(222);
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
mo_moved = MovableCopyable(mo);
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
if (!MovableCopyable_is_nullptr(mo))
|
||||||
|
error("is_nullptr failed");
|
||||||
|
endif
|
||||||
|
clear mo;
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
clear mo_moved;
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
|
||||||
|
# Move assignment operator test
|
||||||
|
Counter.reset_counts();
|
||||||
|
mo111 = MovableCopyable(111);
|
||||||
|
mo222 = MovableCopyable(222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 0, 0);
|
||||||
|
mo111.MoveAssign(mo222);
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
if (!MovableCopyable_is_nullptr(mo222))
|
||||||
|
error("is_nullptr failed");
|
||||||
|
endif
|
||||||
|
clear mo222;
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
clear mo111;
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 2);
|
||||||
|
|
||||||
|
# null check
|
||||||
|
null = []; # NULL pointer
|
||||||
|
Counter.reset_counts();
|
||||||
|
exception_thrown = false;
|
||||||
|
try
|
||||||
|
MovableCopyable.movein(null);
|
||||||
|
catch e
|
||||||
|
if (isempty(strfind(e.message, "invalid null reference")))
|
||||||
|
error("incorrect exception message: %s", e.message)
|
||||||
|
endif
|
||||||
|
exception_thrown = true;
|
||||||
|
end_try_catch
|
||||||
|
if (!exception_thrown)
|
||||||
|
error("Should have thrown null error");
|
||||||
|
endif
|
||||||
|
Counter.check_counts(0, 0, 0, 0, 0, 0);
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Test::More tests => 6;
|
||||||
|
BEGIN { use_ok('cpp11_rvalue_reference_move_input') }
|
||||||
|
require_ok('cpp11_rvalue_reference_move_input');
|
||||||
|
|
||||||
|
{
|
||||||
|
# Function containing rvalue reference parameter
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::reset_counts();
|
||||||
|
my $mo = new cpp11_rvalue_reference_move_input::MovableCopyable(222);
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
cpp11_rvalue_reference_move_input::MovableCopyable::movein($mo);
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
is(cpp11_rvalue_reference_move_input::MovableCopyable::is_nullptr($mo), 1, "is_nullptr check");
|
||||||
|
undef $mo;
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
# Move constructor test
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::reset_counts();
|
||||||
|
my $mo = new cpp11_rvalue_reference_move_input::MovableCopyable(222);
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
my $mo_moved = new cpp11_rvalue_reference_move_input::MovableCopyable($mo);
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
is(cpp11_rvalue_reference_move_input::MovableCopyable::is_nullptr($mo), 1, "is_nullptr check");
|
||||||
|
undef $mo;
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
undef $mo_moved;
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
# Move assignment operator test
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::reset_counts();
|
||||||
|
my $mo111 = new cpp11_rvalue_reference_move_input::MovableCopyable(111);
|
||||||
|
my $mo222 = new cpp11_rvalue_reference_move_input::MovableCopyable(222);
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(2, 0, 0, 0, 0, 0);
|
||||||
|
$mo111->MoveAssign($mo222);
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
is(cpp11_rvalue_reference_move_input::MovableCopyable::is_nullptr($mo222), 1, "is_nullptr check");
|
||||||
|
undef $mo222;
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
undef $mo111;
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(2, 0, 0, 0, 1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
# null check
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::reset_counts();
|
||||||
|
eval {
|
||||||
|
cpp11_rvalue_reference_move_input::MovableCopyable::movein(undef);
|
||||||
|
};
|
||||||
|
like($@, qr/\binvalid null reference/, "Should have thrown null error");
|
||||||
|
cpp11_rvalue_reference_move_input::Counter::check_counts(0, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require "tests.php";
|
||||||
|
|
||||||
|
# Function containing rvalue reference parameter
|
||||||
|
Counter::reset_counts();
|
||||||
|
$mo = new MovableCopyable(222);
|
||||||
|
Counter::check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
MovableCopyable::movein($mo);
|
||||||
|
Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
try {
|
||||||
|
MovableCopyable::is_nullptr($mo);
|
||||||
|
check::fail("is_nullptr check");
|
||||||
|
} catch (TypeError $e) {
|
||||||
|
}
|
||||||
|
$mo = NULL;
|
||||||
|
Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
|
||||||
|
# Move constructor test
|
||||||
|
Counter::reset_counts();
|
||||||
|
$mo = new MovableCopyable(222);
|
||||||
|
Counter::check_counts(1, 0, 0, 0, 0, 0);
|
||||||
|
$mo_moved = new MovableCopyable($mo);
|
||||||
|
Counter::check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
try {
|
||||||
|
MovableCopyable::is_nullptr($mo);
|
||||||
|
check::fail("is_nullptr check");
|
||||||
|
} catch (TypeError $e) {
|
||||||
|
}
|
||||||
|
$mo = NULL;
|
||||||
|
Counter::check_counts(1, 0, 0, 1, 0, 1);
|
||||||
|
$mo_moved = NULL;
|
||||||
|
Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||||
|
|
||||||
|
# Move assignment operator test
|
||||||
|
Counter::reset_counts();
|
||||||
|
$mo111 = new MovableCopyable(111);
|
||||||
|
$mo222 = new MovableCopyable(222);
|
||||||
|
Counter::check_counts(2, 0, 0, 0, 0, 0);
|
||||||
|
$mo111->MoveAssign($mo222);
|
||||||
|
Counter::check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
try {
|
||||||
|
MovableCopyable::is_nullptr($mo222);
|
||||||
|
check::fail("is_nullptr check");
|
||||||
|
} catch (TypeError $e) {
|
||||||
|
}
|
||||||
|
$mo222 = NULL;
|
||||||
|
Counter::check_counts(2, 0, 0, 0, 1, 1);
|
||||||
|
$mo111 = NULL;
|
||||||
|
Counter::check_counts(2, 0, 0, 0, 1, 2);
|
||||||
|
|
||||||
|
# null check
|
||||||
|
Counter::reset_counts();
|
||||||
|
$exception_thrown = false;
|
||||||
|
try {
|
||||||
|
MovableCopyable::movein(NULL);
|
||||||
|
} catch (TypeError $e) {
|
||||||
|
check::str_contains($e->getMessage(), "Invalid null reference", "incorrect exception message: {$e->getMessage()}");
|
||||||
|
$exception_thrown = true;
|
||||||
|
}
|
||||||
|
check::equal($exception_thrown, true, "Should have thrown null error");
|
||||||
|
Counter::check_counts(0, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
check::done();
|
||||||
|
|
@ -40,20 +40,27 @@ try {
|
||||||
check::fail("is_nullptr check");
|
check::fail("is_nullptr check");
|
||||||
} catch (TypeError $e) {
|
} catch (TypeError $e) {
|
||||||
}
|
}
|
||||||
|
$exception_thrown = false;
|
||||||
try {
|
try {
|
||||||
|
takeKlassUniquePtr($kin);
|
||||||
} catch (TypeError $e) {
|
} catch (TypeError $e) {
|
||||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' of takeKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of takeKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
||||||
|
$exception_thrown = true;
|
||||||
}
|
}
|
||||||
|
check::equal($exception_thrown, true, "double usage of takeKlassUniquePtr should have been an error");
|
||||||
$kin = NULL; # Should not fail, even though already deleted
|
$kin = NULL; # Should not fail, even though already deleted
|
||||||
checkCount(0);
|
checkCount(0);
|
||||||
|
|
||||||
$kin = new Klass("KlassInput");
|
$kin = new Klass("KlassInput");
|
||||||
|
$exception_thrown = false;
|
||||||
$notowned = get_not_owned_ptr($kin);
|
$notowned = get_not_owned_ptr($kin);
|
||||||
try {
|
try {
|
||||||
takeKlassUniquePtr($notowned);
|
takeKlassUniquePtr($notowned);
|
||||||
} catch (TypeError $e) {
|
} catch (TypeError $e) {
|
||||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' of takeKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of takeKlassUniquePtr", "Unexpected exception: {$e->getMessage()}");
|
||||||
|
$exception_thrown = true;
|
||||||
}
|
}
|
||||||
|
check::equal($exception_thrown, true, "double usage of takeKlassUniquePtr should have been an error");
|
||||||
checkCount(1);
|
checkCount(1);
|
||||||
$kin = NULL;
|
$kin = NULL;
|
||||||
checkCount(0);
|
checkCount(0);
|
||||||
|
|
|
||||||
|
|
@ -40,20 +40,27 @@ try {
|
||||||
check::fail("is_nullptr check");
|
check::fail("is_nullptr check");
|
||||||
} catch (TypeError $e) {
|
} catch (TypeError $e) {
|
||||||
}
|
}
|
||||||
|
$exception_thrown = false;
|
||||||
try {
|
try {
|
||||||
|
takeKlassAutoPtr($kin);
|
||||||
} catch (TypeError $e) {
|
} catch (TypeError $e) {
|
||||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' of takeKlassAutoPtr", "Unexpected exception: {$e->getMessage()}");
|
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of takeKlassAutoPtr", "Unexpected exception: {$e->getMessage()}");
|
||||||
|
$exception_thrown = true;
|
||||||
}
|
}
|
||||||
|
check::equal($exception_thrown, true, "double usage of takeKlassAutoPtr should have been an error");
|
||||||
$kin = NULL; # Should not fail, even though already deleted
|
$kin = NULL; # Should not fail, even though already deleted
|
||||||
checkCount(0);
|
checkCount(0);
|
||||||
|
|
||||||
$kin = new Klass("KlassInput");
|
$kin = new Klass("KlassInput");
|
||||||
|
$exception_thrown = false;
|
||||||
$notowned = get_not_owned_ptr($kin);
|
$notowned = get_not_owned_ptr($kin);
|
||||||
try {
|
try {
|
||||||
takeKlassAutoPtr($notowned);
|
takeKlassAutoPtr($notowned);
|
||||||
} catch (TypeError $e) {
|
} catch (TypeError $e) {
|
||||||
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of type 'Klass *' of takeKlassAutoPtr", "Unexpected exception: {$e->getMessage()}");
|
check::equal($e->getMessage(), "Cannot release ownership as memory is not owned for argument 1 of SWIGTYPE_p_Klass of takeKlassAutoPtr", "Unexpected exception: {$e->getMessage()}");
|
||||||
|
$exception_thrown = true;
|
||||||
}
|
}
|
||||||
|
check::equal($exception_thrown, true, "double usage of takeKlassAutoPtr should have been an error");
|
||||||
checkCount(1);
|
checkCount(1);
|
||||||
$kin = NULL;
|
$kin = NULL;
|
||||||
checkCount(0);
|
checkCount(0);
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,11 @@ class check {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function str_contains($a,$b,$message=null) {
|
||||||
|
# Use strpos as PHP function str_contains requires PHP 8
|
||||||
|
return check::equal(strpos($a,$b)!==false,true,$message);
|
||||||
|
}
|
||||||
|
|
||||||
static function isnull($a,$message=null) {
|
static function isnull($a,$message=null) {
|
||||||
return check::equal($a,NULL,$message);
|
return check::equal($a,NULL,$message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
from cpp11_rvalue_reference_move_input import *
|
||||||
|
|
||||||
|
# Function containing rvalue reference parameter
|
||||||
|
Counter.reset_counts()
|
||||||
|
mo = MovableCopyable(222)
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0)
|
||||||
|
MovableCopyable.movein(mo)
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
if not MovableCopyable.is_nullptr(mo):
|
||||||
|
raise RuntimeError("is_nullptr check")
|
||||||
|
del mo
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
|
||||||
|
# Move constructor test
|
||||||
|
Counter.reset_counts()
|
||||||
|
mo = MovableCopyable(222)
|
||||||
|
Counter.check_counts(1, 0, 0, 0, 0, 0)
|
||||||
|
mo_moved = MovableCopyable(mo)
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1)
|
||||||
|
if not MovableCopyable.is_nullptr(mo):
|
||||||
|
raise RuntimeError("is_nullptr check")
|
||||||
|
del mo
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 1)
|
||||||
|
del mo_moved
|
||||||
|
Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
|
||||||
|
# Move assignment operator test
|
||||||
|
Counter.reset_counts()
|
||||||
|
mo111 = MovableCopyable(111)
|
||||||
|
mo222 = MovableCopyable(222)
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 0, 0)
|
||||||
|
mo111.MoveAssign(mo222)
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1)
|
||||||
|
if not MovableCopyable.is_nullptr(mo222):
|
||||||
|
raise RuntimeError("is_nullptr check")
|
||||||
|
del mo222
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 1)
|
||||||
|
del mo111
|
||||||
|
Counter.check_counts(2, 0, 0, 0, 1, 2)
|
||||||
|
|
||||||
|
# null check
|
||||||
|
Counter.reset_counts()
|
||||||
|
exception_thrown = False
|
||||||
|
try:
|
||||||
|
MovableCopyable.movein(None)
|
||||||
|
except ValueError as e:
|
||||||
|
if "invalid null reference" not in str(e):
|
||||||
|
raise RuntimeError("incorrect exception message:" + str(e))
|
||||||
|
exception_thrown = True
|
||||||
|
if not exception_thrown:
|
||||||
|
raise RuntimeError("Should have thrown null error")
|
||||||
|
Counter.check_counts(0, 0, 0, 0, 0, 0)
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'swig_assert'
|
||||||
|
|
||||||
|
require 'cpp11_rvalue_reference_move_input'
|
||||||
|
|
||||||
|
# Function containing rvalue reference parameter
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.reset_counts()
|
||||||
|
mo = Cpp11_rvalue_reference_move_input::MovableCopyable.new(222)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 0, 0, 0)
|
||||||
|
Cpp11_rvalue_reference_move_input::MovableCopyable.movein(mo)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
exception_thrown = false
|
||||||
|
begin
|
||||||
|
Cpp11_rvalue_reference_move_input::MovableCopyable.is_nullptr(mo)
|
||||||
|
rescue ObjectPreviouslyDeleted
|
||||||
|
exception_thrown = true
|
||||||
|
end
|
||||||
|
if (!exception_thrown)
|
||||||
|
raise RuntimeError, "is_nullptr failed to throw"
|
||||||
|
end
|
||||||
|
mo = nil
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
|
||||||
|
# Move constructor test
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.reset_counts()
|
||||||
|
mo = Cpp11_rvalue_reference_move_input::MovableCopyable.new(222)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 0, 0, 0)
|
||||||
|
mo_moved = Cpp11_rvalue_reference_move_input::MovableCopyable.new(mo)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 1, 0, 1)
|
||||||
|
exception_thrown = false
|
||||||
|
begin
|
||||||
|
Cpp11_rvalue_reference_move_input::MovableCopyable.is_nullptr(mo)
|
||||||
|
rescue ObjectPreviouslyDeleted
|
||||||
|
exception_thrown = true
|
||||||
|
end
|
||||||
|
if (!exception_thrown)
|
||||||
|
raise RuntimeError, "is_nullptr failed to throw"
|
||||||
|
end
|
||||||
|
mo = nil
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 1, 0, 1)
|
||||||
|
# mo_moved = nil
|
||||||
|
# Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 1, 0, 2)
|
||||||
|
# Above not deleting the C++ object(node v12) - can't reliably control GC - use the movein function instead to delete
|
||||||
|
Cpp11_rvalue_reference_move_input::MovableCopyable.movein(mo_moved)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(1, 0, 0, 2, 0, 3)
|
||||||
|
|
||||||
|
# Move assignment operator test
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.reset_counts()
|
||||||
|
mo111 = Cpp11_rvalue_reference_move_input::MovableCopyable.new(111)
|
||||||
|
mo222 = Cpp11_rvalue_reference_move_input::MovableCopyable.new(222)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(2, 0, 0, 0, 0, 0)
|
||||||
|
mo111.MoveAssign(mo222)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(2, 0, 0, 0, 1, 1)
|
||||||
|
exception_thrown = false
|
||||||
|
begin
|
||||||
|
Cpp11_rvalue_reference_move_input::MovableCopyable.is_nullptr(mo222)
|
||||||
|
rescue ObjectPreviouslyDeleted
|
||||||
|
exception_thrown = true
|
||||||
|
end
|
||||||
|
if (!exception_thrown)
|
||||||
|
raise RuntimeError, "is_nullptr failed to throw"
|
||||||
|
end
|
||||||
|
mo222 = nil
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(2, 0, 0, 0, 1, 1)
|
||||||
|
# mo111 = nil
|
||||||
|
# Cpp11_rvalue_reference_move_input::Counter.check_counts(2, 0, 0, 0, 1, 2)
|
||||||
|
# Above not deleting the C++ object(node v12) - can't reliably control GC - use the movein function instead to delete
|
||||||
|
Cpp11_rvalue_reference_move_input::MovableCopyable.movein(mo111)
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(2, 0, 0, 1, 1, 3)
|
||||||
|
|
||||||
|
# null check
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.reset_counts()
|
||||||
|
exception_thrown = false
|
||||||
|
begin
|
||||||
|
Cpp11_rvalue_reference_move_input::MovableCopyable.movein(nil)
|
||||||
|
rescue ArgumentError => e
|
||||||
|
if (!e.to_s.include? "invalid null reference")
|
||||||
|
raise RuntimeError, "incorrect exception message: #{e.to_s}"
|
||||||
|
end
|
||||||
|
exception_thrown = true
|
||||||
|
end
|
||||||
|
if (!exception_thrown)
|
||||||
|
raise RuntimeError, "Should have thrown null error"
|
||||||
|
end
|
||||||
|
Cpp11_rvalue_reference_move_input::Counter.check_counts(0, 0, 0, 0, 0, 0)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
; Function containing rvalue reference parameter
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(define mo (new-MovableCopyable 222))
|
||||||
|
(Counter-check-counts 1 0 0 0 0 0)
|
||||||
|
(MovableCopyable-movein mo)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 2)
|
||||||
|
(unless (MovableCopyable-is-nullptr mo)
|
||||||
|
(error "is_nullptr failed"))
|
||||||
|
(delete-MovableCopyable mo)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 2)
|
||||||
|
|
||||||
|
; Move constructor test
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(define mo (new-MovableCopyable 222))
|
||||||
|
(Counter-check-counts 1 0 0 0 0 0)
|
||||||
|
(define mo_moved (new-MovableCopyable mo))
|
||||||
|
(Counter-check-counts 1 0 0 1 0 1)
|
||||||
|
(unless (MovableCopyable-is-nullptr mo)
|
||||||
|
(error "is_nullptr failed"))
|
||||||
|
(delete-MovableCopyable mo)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 1)
|
||||||
|
(delete-MovableCopyable mo_moved)
|
||||||
|
(Counter-check-counts 1 0 0 1 0 2)
|
||||||
|
|
||||||
|
; Move assignment operator test
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(define mo111 (new-MovableCopyable 111))
|
||||||
|
(define mo222 (new-MovableCopyable 222))
|
||||||
|
(Counter-check-counts 2 0 0 0 0 0)
|
||||||
|
(MovableCopyable-MoveAssign mo111 mo222)
|
||||||
|
(Counter-check-counts 2 0 0 0 1 1)
|
||||||
|
(unless (MovableCopyable-is-nullptr mo222)
|
||||||
|
(error "is_nullptr failed"))
|
||||||
|
(delete-MovableCopyable mo222)
|
||||||
|
(Counter-check-counts 2 0 0 0 1 1)
|
||||||
|
(delete-MovableCopyable mo111)
|
||||||
|
(Counter-check-counts 2 0 0 0 1 2)
|
||||||
|
|
||||||
|
; null check
|
||||||
|
(Counter-reset-counts)
|
||||||
|
(expect-throw 'misc-error
|
||||||
|
(MovableCopyable-movein '()))
|
||||||
|
; TODO: check the exception message
|
||||||
|
(Counter-check-counts 0 0 0 0 0 0)
|
||||||
|
|
||||||
|
(exit 0)
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
if [ catch { load ./cpp11_rvalue_reference_move_input[info sharedlibextension] cpp11_rvalue_reference_move_input} err_msg ] {
|
||||||
|
puts stderr "Could not load shared object:\n$err_msg"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Function containing rvalue reference parameter
|
||||||
|
Counter_reset_counts
|
||||||
|
MovableCopyable mo 222
|
||||||
|
Counter_check_counts 1 0 0 0 0 0
|
||||||
|
MovableCopyable_movein mo
|
||||||
|
Counter_check_counts 1 0 0 1 0 2
|
||||||
|
if {![MovableCopyable_is_nullptr mo]} {
|
||||||
|
error "is_nullptr failed to throw"
|
||||||
|
}
|
||||||
|
mo -delete
|
||||||
|
Counter_check_counts 1 0 0 1 0 2
|
||||||
|
|
||||||
|
# Move constructor test
|
||||||
|
Counter_reset_counts
|
||||||
|
MovableCopyable mo 222
|
||||||
|
Counter_check_counts 1 0 0 0 0 0
|
||||||
|
MovableCopyable mo_moved mo
|
||||||
|
Counter_check_counts 1 0 0 1 0 1
|
||||||
|
if {![MovableCopyable_is_nullptr mo]} {
|
||||||
|
error "is_nullptr failed to throw"
|
||||||
|
}
|
||||||
|
mo -delete
|
||||||
|
Counter_check_counts 1 0 0 1 0 1
|
||||||
|
mo_moved -delete
|
||||||
|
Counter_check_counts 1 0 0 1 0 2
|
||||||
|
|
||||||
|
# Move assignment operator test
|
||||||
|
Counter_reset_counts
|
||||||
|
MovableCopyable mo111 111
|
||||||
|
MovableCopyable mo222 222
|
||||||
|
Counter_check_counts 2 0 0 0 0 0
|
||||||
|
mo111 MoveAssign mo222
|
||||||
|
Counter_check_counts 2 0 0 0 1 1
|
||||||
|
if {![MovableCopyable_is_nullptr mo222]} {
|
||||||
|
error "is_nullptr failed to throw"
|
||||||
|
}
|
||||||
|
mo222 -delete
|
||||||
|
Counter_check_counts 2 0 0 0 1 1
|
||||||
|
mo111 -delete
|
||||||
|
Counter_check_counts 2 0 0 0 1 2
|
||||||
|
|
||||||
|
# null check
|
||||||
|
Counter_reset_counts
|
||||||
|
set exception_thrown 0
|
||||||
|
if [ catch {
|
||||||
|
MovableCopyable_movein "NULL"
|
||||||
|
} e ] {
|
||||||
|
if {[string first "invalid null reference" $e] == -1} {
|
||||||
|
error "incorrect exception message: $e"
|
||||||
|
}
|
||||||
|
set exception_thrown 1
|
||||||
|
}
|
||||||
|
if {!$exception_thrown} {
|
||||||
|
error "Should have thrown null error"
|
||||||
|
}
|
||||||
|
Counter_check_counts 0 0 0 0 0 0
|
||||||
|
|
@ -420,14 +420,15 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
%}
|
%}
|
||||||
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
||||||
if (!$1) {
|
if (!$1) {
|
||||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
|
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type is null", 0);
|
||||||
return $null;
|
return $null;
|
||||||
} %}
|
} %}
|
||||||
%typemap(in, canthrow=1) SWIGTYPE && %{ $1 = ($1_ltype)$input;
|
%typemap(in, canthrow=1, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) %{ $1 = ($1_ltype)$input;
|
||||||
if (!$1) {
|
if (!$1) {
|
||||||
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
|
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type is null", 0);
|
||||||
return $null;
|
return $null;
|
||||||
} %}
|
}
|
||||||
|
rvrdeleter.reset($1); %}
|
||||||
%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
|
%typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
|
||||||
%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
|
%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|
@ -613,7 +614,8 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
||||||
"$csinput"
|
"$csinput"
|
||||||
%typemap(csin) char *, char *&, char[ANY], char[] "$csinput"
|
%typemap(csin) char *, char *&, char[ANY], char[] "$csinput"
|
||||||
%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
|
%typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
|
||||||
%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
|
%typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
|
||||||
|
%typemap(csin) SWIGTYPE && "$csclassname.swigRelease($csinput)"
|
||||||
%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
|
%typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
|
||||||
|
|
||||||
/* The csout typemap is used for converting function return types from the return type
|
/* The csout typemap is used for converting function return types from the return type
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@
|
||||||
|
|
||||||
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
|
||||||
if (!$1) {
|
if (!$1) {
|
||||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type type is null");
|
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type is null");
|
||||||
return $null;
|
return $null;
|
||||||
} %}
|
} %}
|
||||||
%typemap(out) SWIGTYPE & "$result = (void *)$1;"
|
%typemap(out) SWIGTYPE & "$result = (void *)$1;"
|
||||||
|
|
@ -157,11 +157,12 @@
|
||||||
* Rvalue reference conversion typemaps.
|
* Rvalue reference conversion typemaps.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%typemap(in, canthrow=1) SWIGTYPE && %{ $1 = ($1_ltype)$input;
|
%typemap(in, canthrow=1, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) %{ $1 = ($1_ltype)$input;
|
||||||
if (!$1) {
|
if (!$1) {
|
||||||
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type type is null");
|
SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type is null");
|
||||||
return $null;
|
return $null;
|
||||||
} %}
|
}
|
||||||
|
rvrdeleter.reset($1); %}
|
||||||
%typemap(out) SWIGTYPE && "$result = (void *)$1;"
|
%typemap(out) SWIGTYPE && "$result = (void *)$1;"
|
||||||
|
|
||||||
%typemap(directorin) SWIGTYPE &&
|
%typemap(directorin) SWIGTYPE &&
|
||||||
|
|
@ -182,7 +183,7 @@
|
||||||
|
|
||||||
%typemap(din,
|
%typemap(din,
|
||||||
nativepointer="cast(void*)$dinput"
|
nativepointer="cast(void*)$dinput"
|
||||||
) SWIGTYPE && "$dclassname.swigGetCPtr($dinput)"
|
) SWIGTYPE && "$dclassname.swigRelease($dinput)"
|
||||||
%typemap(dout, excode=SWIGEXCODE,
|
%typemap(dout, excode=SWIGEXCODE,
|
||||||
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE && {
|
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE && {
|
||||||
$dclassname ret = new $dclassname($imcall, $owner);$excode
|
$dclassname ret = new $dclassname($imcall, $owner);$excode
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,33 @@
|
||||||
* Guile-specific typemaps
|
* Guile-specific typemaps
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* These are defined with a view to eventually merging with those defined for other target languages in swigtypemaps.swg and exception.swg */
|
||||||
|
#define %set_output(obj) $result = obj
|
||||||
|
#define %set_varoutput(obj) $result = obj
|
||||||
|
#define %argument_fail(_code, _type, _name, _argn) scm_wrong_type_arg((char *) FUNC_NAME, _argn, $input)
|
||||||
|
#define %as_voidptr(ptr) (void*)(ptr)
|
||||||
|
#define %argument_nullref(_type, _name, _argn) scm_misc_error(FUNC_NAME, "invalid null reference for argument " #_argn " of type '" _type "'", SCM_EOL)
|
||||||
|
#define %releasenotowned_fail(_code, _type, _name, _argn) scm_misc_error(FUNC_NAME, "cannot release ownership as memory is not owned for argument " #_argn " of type '" _type "'", SCM_EOL)
|
||||||
|
|
||||||
/* Pointers */
|
/* Pointers */
|
||||||
|
|
||||||
%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
|
%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
|
||||||
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
|
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
|
||||||
}
|
}
|
||||||
%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] "";
|
%typemap(in, noblock=1, fragment="<memory>") SWIGTYPE && (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) {
|
||||||
|
res = SWIG_ConvertPtr($input, &argp, $descriptor, SWIG_POINTER_RELEASE);
|
||||||
|
if (!SWIG_IsOK(res)) {
|
||||||
|
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||||
|
%releasenotowned_fail(res, "$1_type", $symname, $argnum);
|
||||||
|
} else {
|
||||||
|
%argument_fail(res, "$1_type", $symname, $argnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!argp) { %argument_nullref("$1_type", $symname, $argnum); }
|
||||||
|
$1 = ($1_ltype)argp;
|
||||||
|
rvrdeleter.reset($1);
|
||||||
|
}
|
||||||
|
%typemap(freearg) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] ""
|
||||||
|
|
||||||
%typemap(in) void * {
|
%typemap(in) void * {
|
||||||
$1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0);
|
$1 = ($1_ltype)SWIG_MustGetPtr($input, NULL, $argnum, 0);
|
||||||
|
|
@ -372,11 +393,6 @@ typedef unsigned long SCM;
|
||||||
* taken from typemaps/swigtype.swg
|
* taken from typemaps/swigtype.swg
|
||||||
* ------------------------------------------------------------ */
|
* ------------------------------------------------------------ */
|
||||||
|
|
||||||
#define %set_output(obj) $result = obj
|
|
||||||
#define %set_varoutput(obj) $result = obj
|
|
||||||
#define %argument_fail(code, type, name, argn) scm_wrong_type_arg((char *) FUNC_NAME, argn, $input);
|
|
||||||
#define %as_voidptr(ptr) (void*)(ptr)
|
|
||||||
|
|
||||||
%typemap(in) SWIGTYPE (CLASS::*) {
|
%typemap(in) SWIGTYPE (CLASS::*) {
|
||||||
int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($1), $descriptor);
|
int res = SWIG_ConvertMember($input, %as_voidptr(&$1), sizeof($1), $descriptor);
|
||||||
if (!SWIG_IsOK(res)) {
|
if (!SWIG_IsOK(res)) {
|
||||||
|
|
|
||||||
|
|
@ -692,12 +692,12 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); }
|
||||||
}
|
}
|
||||||
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
|
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
|
||||||
if (!$1) {
|
if (!$1) {
|
||||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type is null");
|
||||||
return $null;
|
return $null;
|
||||||
} %}
|
} %}
|
||||||
%typemap(in, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) %{ $1 = *($&1_ltype)&$input;
|
%typemap(in, fragment="<memory>") SWIGTYPE && (std::unique_ptr<$*1_ltype> rvrdeleter) %{ $1 = *($&1_ltype)&$input;
|
||||||
if (!$1) {
|
if (!$1) {
|
||||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type is null");
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
rvrdeleter.reset($1); %}
|
rvrdeleter.reset($1); %}
|
||||||
|
|
|
||||||
|
|
@ -151,11 +151,17 @@ SWIGINTERN int SWIG_lua_isnilstring(lua_State *L, int idx) {
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE&&
|
%typemap(in,checkfn="lua_isuserdata",fragment="<memory>") SWIGTYPE&& (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) %{
|
||||||
%{
|
res = SWIG_ConvertPtr(L, $input, &argp, $descriptor, SWIG_POINTER_RELEASE);
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){
|
if (!SWIG_IsOK(res)) {
|
||||||
SWIG_fail_ptr("$symname",$argnum,$descriptor);
|
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||||
|
lua_pushfstring(L, "Cannot release ownership as memory is not owned for argument $argnum of type '$1_type' in $symname"); SWIG_fail;
|
||||||
|
} else {
|
||||||
|
SWIG_fail_ptr("$symname", $argnum, $descriptor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$1 = ($1_ltype)argp;
|
||||||
|
rvrdeleter.reset($1);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
// out is simple
|
// out is simple
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,6 @@
|
||||||
* C++ layer when passed as a parameter to a wrapped function.
|
* C++ layer when passed as a parameter to a wrapped function.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv);
|
|
||||||
#define %set_output(obj) $result = obj
|
|
||||||
|
|
||||||
%define %auto_ptr(TYPE)
|
%define %auto_ptr(TYPE)
|
||||||
%typemap(in, noblock=1) std::auto_ptr< TYPE > (void *argp = 0, int res = 0) {
|
%typemap(in, noblock=1) std::auto_ptr< TYPE > (void *argp = 0, int res = 0) {
|
||||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,6 @@
|
||||||
* C++ layer when passed as a parameter to a wrapped function.
|
* C++ layer when passed as a parameter to a wrapped function.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv);
|
|
||||||
#define %set_output(obj) $result = obj
|
|
||||||
|
|
||||||
%define %unique_ptr(TYPE)
|
%define %unique_ptr(TYPE)
|
||||||
%typemap(in, noblock=1) std::unique_ptr< TYPE > (void *argp = 0, int res = 0) {
|
%typemap(in, noblock=1) std::unique_ptr< TYPE > (void *argp = 0, int res = 0) {
|
||||||
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
res = SWIG_ConvertPtr($input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#define %set_output(obj) $result = obj
|
#define %set_output(obj) $result = obj
|
||||||
#define %set_varoutput(obj) $result = obj
|
#define %set_varoutput(obj) $result = obj
|
||||||
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv);
|
#define %argument_fail(code, type, name, argn) scheme_wrong_type(FUNC_NAME, type, argn, argc, argv)
|
||||||
#define %as_voidptr(ptr) (void*)(ptr)
|
#define %as_voidptr(ptr) (void*)(ptr)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -72,9 +72,23 @@
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
%typemap(in) SWIGTYPE &, SWIGTYPE && {
|
%typemap(in) SWIGTYPE & {
|
||||||
$1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
|
$1 = ($ltype) SWIG_MustGetPtr($input, $descriptor, $argnum, 0);
|
||||||
if ($1 == NULL) scheme_signal_error("swig-type-error (null reference)");
|
if ($1 == NULL) scheme_signal_error(FUNC_NAME ": swig-type-error (null reference)");
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(in, noblock=1, fragment="<memory>") SWIGTYPE && (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) {
|
||||||
|
res = SWIG_ConvertPtr($input, &argp, $descriptor, 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 '$1_type'");
|
||||||
|
} else {
|
||||||
|
%argument_fail(res, "$1_type", $symname, $argnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (argp == NULL) scheme_signal_error(FUNC_NAME ": swig-type-error (null reference)");
|
||||||
|
$1 = ($1_ltype)argp;
|
||||||
|
rvrdeleter.reset($1);
|
||||||
}
|
}
|
||||||
|
|
||||||
%typemap(out) SWIGTYPE &, SWIGTYPE && {
|
%typemap(out) SWIGTYPE &, SWIGTYPE && {
|
||||||
|
|
|
||||||
|
|
@ -125,14 +125,31 @@
|
||||||
swig_acquire_ownership_obj((void*)$result, own);
|
swig_acquire_ownership_obj((void*)$result, own);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%typemap(in, phptype="SWIGTYPE") SWIGTYPE &,
|
%typemap(in, phptype="SWIGTYPE") SWIGTYPE &
|
||||||
SWIGTYPE &&
|
|
||||||
%{
|
%{
|
||||||
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
|
if (SWIG_ConvertPtr(&$input, (void **) &$1, $1_descriptor, 0) < 0 || $1 == NULL) {
|
||||||
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
|
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
%typemap(in, fragment="<memory>") SWIGTYPE && (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) %{
|
||||||
|
res = SWIG_ConvertPtr(&$input, &argp, $descriptor, 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 $1_descriptor of $symname");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
zend_type_error("Expected $1_descriptor for argument $argnum of $symname");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!argp) {
|
||||||
|
zend_type_error("Invalid null reference for argument $argnum of $1_descriptor of $symname");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$1 = ($1_ltype)argp;
|
||||||
|
rvrdeleter.reset($1);
|
||||||
|
%}
|
||||||
|
|
||||||
%typemap(directorout) SWIGTYPE & ($1_ltype tmp),
|
%typemap(directorout) SWIGTYPE & ($1_ltype tmp),
|
||||||
SWIGTYPE && ($1_ltype tmp)
|
SWIGTYPE && ($1_ltype tmp)
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@
|
||||||
res = SWIG_ConvertPtr(&$input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
res = SWIG_ConvertPtr(&$input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||||
if (!SWIG_IsOK(res)) {
|
if (!SWIG_IsOK(res)) {
|
||||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||||
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of type 'TYPE *' of $symname");
|
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of $descriptor(TYPE *) of $symname");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
zend_type_error("Expected TYPE * for argument $argnum of $symname");
|
zend_type_error("Expected $descriptor(TYPE *) for argument $argnum of $symname");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@
|
||||||
res = SWIG_ConvertPtr(&$input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
res = SWIG_ConvertPtr(&$input, &argp, $descriptor(TYPE *), SWIG_POINTER_RELEASE);
|
||||||
if (!SWIG_IsOK(res)) {
|
if (!SWIG_IsOK(res)) {
|
||||||
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||||
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of type 'TYPE *' of $symname");
|
zend_type_error("Cannot release ownership as memory is not owned for argument $argnum of $descriptor(TYPE *) of $symname");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
zend_type_error("Expected TYPE * for argument $argnum of $symname");
|
zend_type_error("Expected $descriptor(TYPE *) for argument $argnum of $symname");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,13 +68,18 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Rvalue reference */
|
/* Rvalue reference */
|
||||||
%typemap(in, noblock=1) SWIGTYPE && (void *argp = 0, int res = 0) {
|
%typemap(in, noblock=1, fragment="<memory>") SWIGTYPE && (void *argp = 0, int res = 0, std::unique_ptr<$*1_ltype> rvrdeleter) {
|
||||||
res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
|
res = SWIG_ConvertPtr($input, &argp, $descriptor, SWIG_POINTER_RELEASE | %convertptr_flags);
|
||||||
if (!SWIG_IsOK(res)) {
|
if (!SWIG_IsOK(res)) {
|
||||||
%argument_fail(res, "$type", $symname, $argnum);
|
if (res == SWIG_ERROR_RELEASE_NOT_OWNED) {
|
||||||
|
%releasenotowned_fail(res, "$type", $symname, $argnum);
|
||||||
|
} else {
|
||||||
|
%argument_fail(res, "$type", $symname, $argnum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
|
||||||
$1 = %reinterpret_cast(argp, $ltype);
|
$1 = %reinterpret_cast(argp, $ltype);
|
||||||
|
rvrdeleter.reset($1);
|
||||||
}
|
}
|
||||||
%typemap(freearg) SWIGTYPE && ""
|
%typemap(freearg) SWIGTYPE && ""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue