* builtin-heap-types:
Changes entry for python -builtin and heap types
Revert previous commit as it breaks setting arbitrary attributes on builtin wrapped types
Fix TypeError: multiple bases have instance lay-out conflict
Py_LIMITED_API support in SwigPyObject_Check for -builtin
Py_LIMITED_API support in SwigPyBuiltin_SetMetaType for -builtin
Remove pyname_compat.i
Python type creation functions refactor
Small move towards Py_LIMITED_API for -builtin
Add SwigPyObjectType and SwigPyStaticVar to the swig runtime module
SWIG_HEAPTYPES for SwigPyStaticVar and add it to the runtime module
Cosmetic whitespace formatting around PY_VERSION_HEX
SWIG_HEAPTYPES for SwigPyObjectType and add it to the runtime module
Better error handling creating types with python -builtin
Gracefully handle errors in PyType_FromSpecWithBases for -builtin
Gracefully handle errors in PyModule_AddObject for -builtin
More graceful error in failures calling back_reference
Show ref count before final decrement when using SWIG_REFCNT_DEBUG
Simplify implementation for -builtin, which does not need a fallback to
use strcmp as PyType_IsSubtype() 'just works' even when using multiple
modules (I think perhaps because SwigPyObject_stype->clientdata->pytype is
common across modules due to the implementation in SwigPyObject_Type()).
In the non-builtin case SwigPyObject is not a base type and usage is
different and when multiple modules are being used, SwigPyObject_Type()
returns two implementations of SwigPyObject which is solved in a hacky
way by comparing the types as strings when the pointer comparison fails.
Add import_callback test - tests %import and %callback to exercise
all of SwigPyPacked_Check(). Python only - the main callback example is
not widely tested and needs work in most of the other languages.
Only using the parameter value in the generated code, such as when using
kwargs. This is known to be fundamentally flawed as sometimes the
generated value is not accessible outside of the class it is defined in.
Fixes regression due to a037e2f2e2.
The new fix now attempts to treat all value and name attributes as
a SwigType instead of an unparsed type in a String. However, it does
it more consistently instead of just for the "value" attribute in
add_parms.
Also subtle problem fix where cpatchlist was incorrectly being used
instead of patchlist.
Closes#3179
if the same wrapped function is called more than once. Note that using returning
pointers in directors is still full of traps and not recommended. As such,
warning SWIGWARN_TYPEMAP_DIRECTOROUT_PTR (473) continues to be issued.
The debug Python interpreter failed 3 director testcases which have been
modified in this patch to work around unrecommended director usage
returning from director methods. These are C strings and std::string_view.
A Pyton reference count leak is chosen over undefined behaviour for
returning std::string_view.
I tried with -Werror but observed the warning messages disappearing
and tests not failing - probably because the wrapper code is swallowing
warnings and catching the resulting error. Seen in python_overload_simple_cast_runme.py
on Linux (not Windows!). Also when the warning is turned into an error
just a seg fault can occur without the warning message. All round better
to actually see the warning.
I think these are due to problems inside the Python interpreter sorted out in 3.10.
From 3.10 release notes:
Builtin and extension functions that take integer arguments no longer accept Decimals,
Fractions and other objects that can be converted to integers only with a loss (e.g.
that have the __int__() method but do not have the __index__() method).
SWIG_NOEXCEPT is generated instead of throw() which is deprecated in
c++11. If c++11 or later is being used, then this macro expands to
noexcept instead of throw().
Affects director code only.
Also fix up some testcase to not use throw() when using c++11 or later.
Tested with clang and -Wdeprecated-dynamic-exception-spec as gcc
doesn't seem to warn for this deprecation.
Closes#3027
Avoid import_fragments testcase testing for buggy ruby-3.1.x and ruby-3.2.x.
Closes#2800.
I've run ruby-3.3 testing on Github Actions 8 times and flakiness in
cpp11_rvalue_reference_move testcase seems to have gone away using
latest 3.3.x version (3.3.8). Restoring latest 3.3.x testing to see how
it goes.
Closes issue #3030.
Workaround initialises additional members in the A struct when created
using new(A) as opposed to created with A().
Probably the typemaps for int etc should be fixed to not crash if the
input is not initialised though.
- Modify example to actually use the external runtime in example.cxx.
- Correct formatting of files.
- Add exception handling.
- Rename two main classes in example for better clarity.
This commit fixes the previous commit so that the example now correctly
tests the commmit prior to it.
Note that -builtin is not run as it does not work (seg faults - needs
investigation).
Issue #3067
Fixes removeFirst() and removeLast() incompatibilities with methods
of the same name in the Java base class java.util.AbstractSequentialList
which were added in JDK 21 as part of JEP-431.
configure.ac has been modified to detect the version of JDK/Java for use
in testing the test-suite via the JAVA_VERSION_MAJOR variable.
Needed to continue testing removeFirst(), removeLast(), addFirst(), addLast().
Closes#3156
Fixes:
[cast] redundant cast
[rawtypes] found raw type
[serial] serializable class has no definition of serialVersionUID
Also suppress warning: auxiliary class TargetLanguageBase in ./inherit_target_language.java should not be accessed from outside its own source file
Don't collapse runs of whitespace to a single space, instead replace
each whitespace with one space.
Leave the expression as-is if it contains one or more double quotes
as we don't want to change the value of string literals, and any
expression containing double quotes won't currently work in the context
where we need to replace newlines anyway.
Fixes#3127 better
Fix bad generated code in some cases when a constant expression is split
over multiple lines and used as part of a type. This manifested in
cases where SWIG's parser calls skip_balanced('(', ')') then grabs the
skipped expression's program text from scanner_ccode.
Fixes#3127
For example:
%typemap(in) int MYINT (int $1_temp) { ... }
$1_temp is typically expanded to arg1_temp, arg2_temp etc depending on
which argument the typemap is applied to.
The existing code didn't work correctly for strings longer than 2GB.
This does require using at least Go 1.20, but that should be OK as
the last currently supported version of Go is 1.22.
Perform repeated typedef lookups instead of a single typedef
lookup on the type being applied in %apply when looking for a family
of typemaps to apply.
Closes#3064
Remove casts to local variables that have initial values taken from the
default arguments being wrapped. This is for the default case, that is,
for all types, except references.
This fixes handling of parameters with default arguments that are initializer
lists by removing a cast to the initializer.
For wrapping parameter X x = {}, the generated code previously would have
contained:
X arg2 = (X) {};
Now it is:
X arg2 = {};
Closes#1851
Casts should have the same high precedence as unary plus and minus, but
actually had a lower precedence than anything else.
This could lead to the wrong type being deduced in obscure cases, but
also prevented SWIG deducing a type for expressions such as (0)*1+2
which SWIG parses as a cast and then fixes up afterwards.
A bug fixed in 4.3.0 made this latter problem manifest more often
(previously type deduction happened to work for (0)*1+2 due to an
internal field not getting cleared properly).
Fixes#3058