SWIG_Python_str_AsChar has undefined behaviour when Py_LIMITED_API is defined
as it returns a pointer to a string in a PyBytes object that no longer exists.
SWIG_PyUnicode_AsUTF8AndSize is an efficient replacement, but requires a
different API and the caller to decrement the refcount on the intermediate
PyObject in the Py_LIMITED_API < 0x030A0000 implementation. The alternative
would have required copying the returned char * string as was done in a
previous implementation requiring a call to the defunct SWIG_Python_str_DelForPy3
function.
Any users calling the removed API will have to make changes.
In the parser, cpp_end and cpp_vend are very similar. cpp_end is removed
and instead replaced by cpp_vend and additional checks that ensure a
non-virtual destructor does not have a pure specifier.
GCC was emitting:
../../cpp11_decltype_wrap.cxx:1374:15: warning: ‘~’ on an expression of type ‘bool’ [-Wbool-operation]
1374 | decltype(~false) should_be_int3;
| ^~~~~
../../cpp11_decltype_wrap.cxx:1374:15: note: did you mean to use logical not (‘!’)?
Adjust to test operator `~` on a character constant instead.
Adjust the floating point constants to be 1.125 and 2.25 (which
can be exactly represented in base-2 floating point) instead of
1.1 and 2.2 (which can't). This avoids problems on platforms where
floating point calculations suffer from excess precision, the most
commonly used of which is x86 when using 387 FP instructions.
* std_filesystem_python:
Add <type_traits> fragment for traits usage in std::filesystem
Correct const std::filesystem & typemaps
Fix memory leak wrapping const std::filesystem&
std::filesystem pointer handling correction
Python std::filesystem cleanup
Cosmetic whitespace corrections
Try to use wstring/wchar_t on windows
Reformat
Rename the helpers within the fragment to be more uniquely named
Make CI rerun (and output all failed cases for the specialPath)
Address review comments
Need to see which assert is failing on mingw
Verbose assert to try and see the failure on mingw
path::string() returns a copy not a const ref.
Remove cpp17_std_filesystem from common.mk, only defined for Python for now
Extend roundtrip test
Address review comment by @degasus on #1999 originally
Had trouble getting the test to be properly ignored. If I wrap the inline line 35 in #if __cplusplus the wrapper code isn't generated
Tweak tests setup
Cherry pick from yasamoka/master
Conflicts:
CHANGES.current
Create a new T_UNKNOWN type code and use this for the cases where
we previously abused T_INT. This means we can now reliably deduce
`int` when we see T_INT.
Fix the deduced result types of unary plus and unary minus which weren't
getting integer promotion applied to them.
Fix the deduced result type of the C++ logical not operator which was
`int` but should be `bool`.
SWIG now supports command line options -std=cXX and -std=c++XX to
specify the C/C++ standards version. The only effect of these options
is to set appropriate values for __STDC_VERSION__ and __cplusplus
respectively, which is useful if you're wrapping headers which have
preprocessor checks based on their values.
Closes#2591
[C#] Support nullable reference types. A generic C# option to the
%module directive allows one to add in any code at the beginning of every
C# file. This can add the #nullable enable preprocessor directive at the beginning
of every C# file in order to enable nullable reference types as follows:
%module(csbegin="#nullable enable\n") mymodule
Closes#2681
[D, Java] Add the dbegin option to the %module directive for generating code at
the beginning of every D file. Similarly javabegin for Java. This enables one
to add a common comment at the start of each D/Java file.
Fix when variable override contains a pointer dereference ->.
This enables use of $1.x as a variable override value as SWIG
replaces $1.x with a pointer dereference expression, such as
(&arg1)->x.
Added a testcase showing how Python typemaps could alternatively
be written using $typemap() instead of using C++ templates as used in
the UTL. I'm not convinced this is fully reliable or even a good idea,
so the variable replacements in $typemap() remain undocumented.
In $typemap(), the $n special variables are replaced by the appropriate
value for the type associated with the typemap calling $typemap().
The (undocumented) special variable overrides now also support
controlling what the $n special variables are replaced with from the
calling typemap, for example:
%typemap(in) std::pair<std::string, int> {
int& input_value_second = $1.second;
$typemap(in, int, 1=input_value_second);
...
}
replaces $1 in the int typemap with input_value_second instead of
whatever is the default for the target language (a variable that holds
the int value after marshalling from the target language).
This additional functionality might make it possible to replace the C++
templates used in the UTL with a much simpler system of typemaps utilising
$typemap(). See follow on commit to typemaps.c.
more than two deep and the using declarations are overloaded.
Using declarations from a base class' base were not available for use
in the target language when the using declaration was before a method
declaration.
Closes#2687
Defining SWIGWORDSIZE64 now applies the (unsigned)
long long typemaps to (unsigned) long for a better match on systems
where long is 64-bits. A new "Type mapping" section has been added into
the CSharp.html documentation covering this and marshalling of primitive
types. C (unsigned) long handling remains as is by default, that is,
marshall as 32-bit.
The INPUT[], OUTPUT[], INOUT[], FIXED[] typemaps for long and unsigned long
in arrays_csharp.i can now be used and compiled on 64-bit platforms where
sizeof(long) != sizeof(int). Requires SWIGWORDSIZE64 to be defined.
Move SWIGWORDSIZE64 check into fragments
Changes also made so that the C# test-suite passes using:
env SWIG_FEATURES=-DSWIGWORDSIZE64 make check-csharp-test-suite
See issue #2379
Defining SWIGWORDSIZE64 now applies the (unsigned) long long
typemaps to (unsigned) long for a better match on systems
where long is 64-bits.
Although size_t typemaps are now applied from the int typemaps instead
of the long typemaps, identical code is generated and the mapping is
still to the Java signed long type.
Closes#646Closes#649
Running the test-suite as follows on a 64-bit long system:
env SWIG_FEATURES=-DSWIGWORDSIZE64 make check-java-test-suite
passes, except for a few tests which fail where they expect the
default Java type to be int or long instead of long or BigInteger
respectively.
Also arrays_java.i results in:
invalid conversion from ‘long int*’ to ‘long long int*’ [-fpermissive]
invalid conversion from ‘long int**’ to ‘long long int**’ [-fpermissive]
* issue/2625:
Enhanced std::map for non-default constructible types changes entry
Add missing exception.i for std::map wrappers for MzScheme and Guile
std::map wrappers and non-default constructible
Fixed make file ordering
Fixed line endings
Added unit test
Using #ifdef instead of #if to prevent warnings
Fix for #2625 Using c++17 insert_or_assign for std::map when available.
Conflicts:
CHANGES.current
Improve li_std_vector_vector runtime test for R
- Fix unittest_sequence to fail if elements don't match.
- li_std_vector_vector testcase fixes.
Replace list with c because vectors in R are not exactly lists,
therefore comparing vectors (returned by C++) with R lists
complicates things a lot. Added as.integer because by default
numbers are numeric and I guess we want to check the exact type
returned by C++ which is integer the first check fails because
make_vector_int returns a vector of strings (containing numbers),
not integers (in the previous version this test would pass
because R does an implicit
Closes#2448
Const member variables such as the following are non-assignable by
by default:
const int x[2][2];
Variable setters are not generated when wrapping these non-assignable
variables and classes containing such non-assignable variables.
Const member variables such as the following are non-assignable by
by default:
char * const x;
const int x;
const int x[1];
but not:
const char * x;
Variable setters are not generated when wrapping these non-assignable
variables and classes containing such non-assignable variables.
A struct/class that contains a non-assignable member variable is
actually assignable itself. Only non-static members, not static members,
contribute to the containing class being non-assignable.
Recent regression fix from a few commits back.