Use std::move on this pointer as the default approach to supporting
rvalue ref-qualifiers if a user really wants to wrap.
std::move requires <memory> headers so add swigfragments.swg for all
languages to use common fragments. Just header file fragments for now.
Internally, handle function ref-qualifiers in the function decl type string.
Needed for a whole host of things to work like %feature and %rename.
Add %feature %rename and %ignore testing for ref-qualifiers.
Was not generating code that compiled when the variable was not
a simple member pointer, for example,
a const reference member pointer:
short (Funcs::* const& cc7)(bool) const = cc1;
Fixes#1059
Methods with rvalue ref-qualifiers are ignored by default as it is not
possible to have an rvalue temporary from the target language (which is
needed to call the rvalue ref-qualified method).
A warning 405 is shown mentioning the ignored rvalue ref-qualifier method
which can be seen with the -Wextra option.
cpp_refqualifier.i:15: Warning 405: Method with rvalue ref-qualifier ignored h() const &&.
Usually rvalue and lvalue ref-qualifier overloaded methods are written - the
lvalue method will then be wrapped.
* templates-scope-enforcement:
Test a few %template errors
Add using declarations to templates into typedef table.
Fix type lookup in the presence of using directives and using declarations
More docs on %template
Testcase fix for nameclash in php
%template scope enforcement and class definition fixes
Template documentation tweaks
More consistent formatting of examples in documentation
More consistent formatting of examples in documentation
Documentation corrections to use targetlang formatting
More consistent formatting of examples in documentation
More consistent formatting of examples in documentation
More consistent formatting of examples in documentation
Namespace documentation minor corrections
Improve description of template_parameters_resolve
Minor code optimisation in template_parameters_resolve
Fix scope lookup for template parameters containing unary scope operators
Typemap change for templates
Fixes#1051. Using declarations to templates were missing in SWIG's internal typedef tables.
This led to a few problems, such as, templates that did not instantiate and generated
C++ code that did not compile as SWIG did not know what scope the template was
in. This happened mostly when a using declaration was used on a template type in a
completely unrelated namespace.
Fix some cases of type lookup failure via a combination of both using directives and
using declarations resulting in C++ code that did not compile as the generated type was
not fully qualified for use in the global namespace. Example below:
namespace Space5 {
namespace SubSpace5 {
namespace SubSubSpace5 {
struct F {};
}
}
using namespace SubSpace5;
using SubSubSpace5::F;
void func(SubSubSpace5::F f);
}
The scoping rules around %template have been specified and enforced.
The %template directive for a class template is the equivalent to an
explicit instantiation of a C++ class template. The scope for a valid
%template instantiation is now the same as the scope required for a
valid explicit instantiation of a C++ template. A definition of the
template for the explicit instantiation must be in scope where the
instantiation is declared and must not be enclosed within a different
namespace.
For example, a few %template and explicit instantiations of std::vector
are shown below:
// valid
namespace std {
%template(vin) vector<int>;
template class vector<int>;
}
// valid
using namespace std;
%template(vin) vector<int>;
template class vector<int>;
// valid
using std::vector;
%template(vin) vector<int>;
template class vector<int>;
// ill-formed
namespace unrelated {
using std::vector;
%template(vin) vector<int>;
template class vector<int>;
}
// ill-formed
namespace unrelated {
using namespace std;
%template(vin) vector<int>;
template class vector<int>;
}
// ill-formed
namespace unrelated {
namespace std {
%template(vin) vector<int>;
template class vector<int>;
}
}
// ill-formed
namespace unrelated {
%template(vin) std::vector<int>;
template class std::vector<int>;
}
When the scope is incorrect, an error now occurs such as:
cpp_template_scope.i:34: Error: 'vector' resolves to 'std::vector' and
was incorrectly instantiated in scope 'unrelated' instead of within scope 'std'.
Previously SWIG accepted the ill-formed examples above but this led to
numerous subtle template scope problems especially in the presence of
using declarations and using directives as well as with %feature and %typemap.
Actually, a valid instantiation is one which conforms to the C++03
standard as C++11 made a change to disallow using declarations and
using directives to find a template.
// valid C++03, ill-formed C++11
using std::vector;
template class vector<int>;
Similar fixes for defining classes using forward class references have
also been put in place. For example:
namespace Space1 {
struct A;
}
namespace Space2 {
struct Space1::A {
void x();
}
}
will now error out with:
cpp_class_definition.i:5: Error: 'Space1::A' resolves to 'Space1::A' and
was incorrectly instantiated in scope 'Space2' instead of within scope 'Space1'.
For templates only, the template parameters are fully resolved when
handling typemaps. Without this, it is too hard to have decent rules
to apply typemaps when parameter types are typedef'd and template
parameters have default values.
Fixes %clear for typedefs in templates, eg:
%typemap("in") XXX<int>::Long "..."
template typename<T> struct XXX {
typedef long Long;
};
%clear XXX<int>::Long;
as the typemap was previously incorrectly stored as a typemap for long
instead of XXX<int>::Long.
* fflexo-javalist:
Java std::vector minor improvement
Fix Java container tests for change in vector constructor declaration
Add in missing Java std::list listIterator index range checking
Minor correction in C# std::list doNextIndex
Add missing typedefs to Java std::vector
Consistent destructor declarations
Remove Java std::list::max_size
Java std::list std::vector - test addAll and subList
Handle length_error exceptions in Java std::vector::reserve
Remove Java std::list::assign
Additional add/remove methods added to Java std::list wrappers
More efficient add implementation for Java std::list
Java std::vector std::list: add missing exception handling
Java std::vector std::list enhancements
Modify std::list declarations to match the C++ standard
Fix removing elements from std::list Java wrapper
Improve Java std::list std::vector runtime tests and wrap std::list::clear
Wrap std::list::empty as isEmpty in Java
javabase typemap improvement for std::list
Java std::list - fully qualifiy Java class name to avoid potential name ambiguity
cosmetics
Remove redundant code
Java std::list rework to be consistent with std::vector wrappers
li_std_list testcase not working for most languages
re-enabled li_std_list test
Switched from autobox to jboxtype per #842
Document autobox.i
Made the conversion from long->int for size_type mapping onto Java interfaces cleaner.
Be consistent in semantics of %extend on std::list::iterator
Comment on consideration of making iterator non-static.
Java style fix: iterator->Iterator
Moving iterator functionality into nested Java class now.
Removed typedef from li_std_list test as it's not expected to work properly in templated code
Added a best case workaround for std::list::size_type vs jint problem. There's a bit of commentry added around it too for clarity.
Drop non-const reference from autobox typemap macro to be consistent.
just use a forward declaration for C++ iterator types to fix enum errors
Added enum to li_std_list tests
Added li_std_list to the Java test-suit makefile
added more comments in a few places
Base _runme.java for li_std_list off li_std_vector_runme.java
Expose more types from li_std_list.i
Don't expose sort() to avoid adding dependencies on all std::list users
Target each method specificly for setting modifiers
Don't expose remove() method from std::list to avoid confusing it with Java's remove() in List
- added std_list.i implemenatation that extends Java's AbstractSequentialList base class - added autobox.i that provides supporting typemaps for generics in containers
* fflexo-javalist:
Java std::vector minor improvement
Fix Java container tests for change in vector constructor declaration
Add in missing Java std::list listIterator index range checking
Minor correction in C# std::list doNextIndex
Add missing typedefs to Java std::vector
Consistent destructor declarations
Remove Java std::list::max_size
Java std::list std::vector - test addAll and subList
Handle length_error exceptions in Java std::vector::reserve
Remove Java std::list::assign
Additional add/remove methods added to Java std::list wrappers
More efficient add implementation for Java std::list
Java std::vector std::list: add missing exception handling
Java std::vector std::list enhancements
Modify std::list declarations to match the C++ standard
Fix removing elements from std::list Java wrapper
Improve Java std::list std::vector runtime tests and wrap std::list::clear
Wrap std::list::empty as isEmpty in Java
javabase typemap improvement for std::list
Java std::list - fully qualifiy Java class name to avoid potential name ambiguity
cosmetics
Remove redundant code
Java std::list rework to be consistent with std::vector wrappers
li_std_list testcase not working for most languages
re-enabled li_std_list test
Switched from autobox to jboxtype per #842
Document autobox.i
Made the conversion from long->int for size_type mapping onto Java interfaces cleaner.
Be consistent in semantics of %extend on std::list::iterator
Comment on consideration of making iterator non-static.
Java style fix: iterator->Iterator
Moving iterator functionality into nested Java class now.
Removed typedef from li_std_list test as it's not expected to work properly in templated code
Added a best case workaround for std::list::size_type vs jint problem. There's a bit of commentry added around it too for clarity.
Drop non-const reference from autobox typemap macro to be consistent.
just use a forward declaration for C++ iterator types to fix enum errors
Added enum to li_std_list tests
Added li_std_list to the Java test-suit makefile
added more comments in a few places
Base _runme.java for li_std_list off li_std_vector_runme.java
Expose more types from li_std_list.i
Don't expose sort() to avoid adding dependencies on all std::list users
Target each method specificly for setting modifiers
Don't expose remove() method from std::list to avoid confusing it with Java's remove() in List
- added std_list.i implemenatation that extends Java's AbstractSequentialList base class - added autobox.i that provides supporting typemaps for generics in containers
- Add missing vector copy constructor
- Add constructor to initialize the containers. Note that Java's
equivalent constructor for ArrayList just sets the capacity, whereas
the wrappers behave like the C++ constructor and set the size. I've
done this mainly because there has been a vector(size_type) constructor
in the Java wrappers for many years, so best to keep this unchanged.
1. Fix negative octals. Currently not handled correctly by `-py3`
(unusual case, but incorrect).
2. Fix arguments of type "octal + something" (e.g. `0640 | 04`).
Currently drops everything after the first octal. Nasty!
3. Fix bool arguments "0 + something" (e.g. `0 | 1`) are always
"False" (unusual case, but incorrect).
4. Remove special handling of "TRUE" and "FALSE" from
`convertValue` since there's no reason these have to match
"true" and "false".
5. Remove the Python 2 vs. Python 3 distinction based on the
`-py3` flag. Now the same python code is produced for default
arguments for Python 2 and Python 3. For this, octal default
arguments, e.g. 0644, are now wrapped as `int('644', 8)`. This
is required, as Python 2 and Python 3 have incompatible syntax
for octal literals.
Fixes#707
* tamuratak-fix_ruby_wstring:
[ruby] use %fragment to clarify the dependency of code.
[ruby] should initialize static variables inside %init{}, in which it will not be excuted concurrently by multiple threads.
[ruby] * use static variable to avoid creating stirngs every time. * fix possible overflow.
[ruby] add std::wstring tests for string including a null terminator.
[ruby] * rewrite SWIG_AsWCharPtrAndSize and SWIG_FromWCharPtrAndSize * use UTF-32LE and UTF-16LE to avoid BOM * add tests
[ruby] use WCHAR_MAX to determine the encoding of std::wstring.
[ruby] add a few tests for std::wstring
[ruby] fix support for std::wstring.
This ensures NotImplemented is returned on error so that the Python
interpreter will handle the operators correctly instead of throwing an
exception. NotImplemented was not being returned for non-builtin wrappers
when the operator overload did not have a function overload.
See PEP 207 and https://docs.python.org/3/library/constants.html#NotImplemented
Mentioned in SF patch #303 and SF bug #1208.