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,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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue