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:
William S Fulton 2022-09-16 08:36:25 +01:00
commit dad7c93ca0
41 changed files with 909 additions and 19 deletions

View file

@ -0,0 +1,35 @@
if [ catch { load ./cpp11_move_typemaps[info sharedlibextension] cpp11_move_typemaps} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
Counter_reset_counts
MoveOnly mo 111
Counter_check_counts 1 0 0 0 0 0
MoveOnly_take mo
Counter_check_counts 1 0 0 1 0 2
mo -delete
Counter_check_counts 1 0 0 1 0 2
Counter_reset_counts
MovableCopyable mo 111
Counter_check_counts 1 0 0 0 0 0
MovableCopyable_take mo
Counter_check_counts 1 0 0 1 0 2
mo -delete
Counter_check_counts 1 0 0 1 0 2
MoveOnly mo 222
MoveOnly_take mo
set exception_thrown 0
if [ catch {
MoveOnly_take mo
} 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 "Should have thrown 'Cannot release ownership as memory is not owned' error"
}