Commit graph

18 commits

Author SHA1 Message Date
William S Fulton
bf36bf7d8a Movable and move-only types supported in "out" typemaps.
Enhance SWIGTYPE "out" typemaps to use std::move when copying
objects, thereby making use of move semantics when wrapping a function returning
by value if the returned type supports move semantics.

Wrapping functions that return move only types 'by value' now work out the box
without having to provide custom typemaps.

The implementation removed all casts in the "out" typemaps to allow the compiler to
appropriately choose calling a move constructor, where possible, otherwise a copy
constructor. The implementation alsoand required modifying SwigValueWrapper to
change a cast operator from:

  SwigValueWrapper::operator T&() const;

to

  #if __cplusplus >=201103L
    SwigValueWrapper::operator T&&() const;
  #else
    SwigValueWrapper::operator T&() const;
  #endif

This is not backwards compatible for C++11 and later when using the valuewrapper feature
if a cast is explicitly being made in user supplied "out" typemaps. Suggested change
in custom "out" typemaps for C++11 and later code:

1. Try remove the cast altogether to let the compiler use an appropriate implicit cast.
2. Change the cast, for example, from static_cast<X &> to static_cast<X &&>, using the
   __cplusplus macro if all versions of C++ need to be supported.

Issue #999
Closes #1044

More about the commit:
Added some missing "varout" typemaps for Ocaml which was falling back to
use "out" typemaps as they were missing.

Ruby std::set fix for SwigValueWrapper C++11 changes.
2022-06-30 17:26:48 +01:00
William S Fulton
2e0d1b12dc Fix delete_if (reject!) for the STL container wrappers.
Previously they would sometimes seg fault or not work.
2013-03-29 06:28:15 +00:00
William S Fulton
347f2782d2 Fix missing stddef.h when %import of STL containers. Was causing compile failures witht g++-4.6.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12939 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-03-20 20:07:56 +00:00
William S Fulton
12b89ff406 Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11859 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-13 15:06:26 +00:00
William S Fulton
da8791792b STL fixes when using %import rather than %include and the Solaris Workshop compiler
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10424 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-05-07 21:33:19 +00:00
Gonzalo Garramuno
f2f29c9ba5 Moved the std::pair< iterator, bool > typemap to std_set.i
where it belongs.
This solves the problem with swig conflicts (at least for now).



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10071 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-10-29 22:12:56 +00:00
Gonzalo Garramuno
169a953991 Added fix for std::pair< iterator, bool >.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10070 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-10-29 16:39:05 +00:00
Gonzalo Garramuno
c568d170dc Added an additional fix to std_set to handle erase
properly (sigh).
Fixed a comment in rubyiterators.swg.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10056 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-10-27 21:58:36 +00:00
Gonzalo Garramuno
7bc4e56614 Added new typemap and function to turn a
std::set<T>::iterator and std::multiset<T>::iterator
into a ruby const iterator so that the key value
cannot be changed.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10055 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-10-27 21:41:22 +00:00
Gonzalo Garramuno
b20fd0d06f Moved functors away from std_set.i and std_map.i
into their own std_functors.i file.
Made binarypredicate, etc. be templates to allow more
strict predicates/functors.




git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9815 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-16 22:48:01 +00:00
Gonzalo Garramuno
d4eec2670b Fixed renames of std_* containers to a safer
%rename directive.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9810 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-16 21:27:08 +00:00
Gonzalo Garramuno
315bd2da6e Added new iterator changes to std.
This change does not break backwards compatability
with python, so all works.
The python stuff, however, will still not do all
that ruby can now do.
Updated manual to reflect the change and improve
typemap documentation on the ruby side.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9787 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-07 05:00:46 +00:00
Gonzalo Garramuno
1cf8fd332b Added constructor that can take functors to all
containers that can use one.
Created file rubystdfunctors.swg to allow passing in
Ruby procs as functors to STL functions (swig-user list
suggestion for Python).
Fixed a bug in type_info() always failing for std::set.
Fixed a bug in type_info() always accepting any failed
conversion which could lead to overloaded functions to
fail when input wrong parameters.




git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9775 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-06 03:56:33 +00:00
Gonzalo Garramuno
81c84b7e8c Rename fixes to STL.
Removed object reporting in non-verbose from 
newobject demos.
Made wstring treat them as normal strings as
advertised.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9771 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-05 00:46:20 +00:00
Gonzalo Garramuno
4cd98d3865 Improved algorithm of renaming of methods with numbers at the end.
Fixed some const issues.
Improved report on overloaded function error.
Fixed some minor iterator potential problems.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9770 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-04 13:12:31 +00:00
Gonzalo Garramuno
fd964ef50c std::set is now Enumerable once again.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9741 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-01 10:00:14 +00:00
Gonzalo Garramuno
8564ff90c0 Improved multimap, vector and set by rearranging
some methods.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9739 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-05-01 06:43:56 +00:00
Gonzalo Garramuno
a0b74a907e Updated Ruby's STL to new framework.
Still need to add new tests for multimap,
multiset, list, etc.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9719 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-04-30 06:36:55 +00:00