Provide SWIGTYPE MOVE typemaps in swigmove.i
For implementing full move semantics when passing parameters by value. Based on SWIGTYPE && and std::unique_ptr typemaps which implement move semantics. Added for all languages, but untested for: Go, Ocaml, R, Scilab (and unlikely to be fully functional for same reasons as for std::unique_ptr support). Issue #999
This commit is contained in:
parent
de65875955
commit
dad7c93ca0
41 changed files with 909 additions and 19 deletions
34
Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl
Normal file
34
Examples/test-suite/perl5/cpp11_move_typemaps_runme.pl
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 3;
|
||||
BEGIN { use_ok('cpp11_move_typemaps') }
|
||||
require_ok('cpp11_move_typemaps');
|
||||
|
||||
{
|
||||
cpp11_move_typemaps::Counter::reset_counts();
|
||||
my $mo = new cpp11_move_typemaps::MoveOnly(111);
|
||||
cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 0, 0, 0);
|
||||
cpp11_move_typemaps::MoveOnly::take($mo);
|
||||
cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||
undef $mo;
|
||||
}
|
||||
cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||
|
||||
{
|
||||
cpp11_move_typemaps::Counter::reset_counts();
|
||||
my $mo = new cpp11_move_typemaps::MovableCopyable(111);
|
||||
cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 0, 0, 0);
|
||||
cpp11_move_typemaps::MovableCopyable::take($mo);
|
||||
cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||
undef $mo;
|
||||
}
|
||||
cpp11_move_typemaps::Counter::check_counts(1, 0, 0, 1, 0, 2);
|
||||
|
||||
{
|
||||
my $mo = new cpp11_move_typemaps::MoveOnly(222);
|
||||
cpp11_move_typemaps::MoveOnly::take($mo);
|
||||
eval {
|
||||
cpp11_move_typemaps::MoveOnly::take($mo);
|
||||
};
|
||||
like($@, qr/\bcannot release ownership as memory is not owned\b/, "double usage of takeKlassUniquePtr should be an error");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue