Commit graph

4,198 commits

Author SHA1 Message Date
William S Fulton
e1e4e4df28 Add rvalue reference typemaps for D 2022-03-28 19:25:17 +01:00
William S Fulton
d1b93f2c0e Merge branch 'feature/python-builtin-separate-runtime-data'
* feature/python-builtin-separate-runtime-data:
  Rework swig_and_compile_multi_cpp makefile helper
  Different capsule names for builtin changes entry
  Use different capsule names with and without -builtin

Conflicts:
	CHANGES.current
2022-03-26 15:18:55 +00:00
William S Fulton
f068f2c2d6 Add Python < 3.3 support for pyabc.i
pyabc.i for abstract base classes now supports versions of Python
prior to 3.3 by using the collection module for these older versions.
Python-3.3 and later continue to use the collections.abc module.
The -py3 option no longer has any effect on the %pythonabc feature.
2022-03-23 07:58:01 +00:00
Olly Betts
b2c58115d7 Fix previous commit
Revert changes inadvertently included, and fix `=` to `==`.
2022-03-20 19:44:23 +13:00
Olly Betts
029ddab8b5 [ci] Try to fix failing appveyor python builds 2022-03-20 18:42:50 +13:00
Eugene Toder
f733efd3c0 Use different capsule names with and without -builtin
Types generated with and without -builtin are not compatible. Mixing
them in a common type list leads to crashes. Avoid this by using
different capsule names: "type_pointer_capsule" without -builtin and
"type_pointer_capsule_builtin" with.

See #1684
2022-03-18 13:44:54 -04:00
William S Fulton
1da824ceff Fix compiler warning using Java std::wstring
Fixes: conversion from 'size_t' to 'jsize', possible loss of data
2022-03-16 22:32:53 +00:00
Olly Betts
2da3815f99 [Go] Make -intgosize optional
We no longer support Go < 1.2 so we can default intgo to ptrdiff_t
and uintgo to size_t.

Fixes #683
Fixes #2233
2022-03-16 18:30:05 +13:00
Ian Lance Taylor
0c0b93f8e0 [Go] add typemaps for std::string*
Fixes #2214
2022-03-15 20:30:53 -07:00
William S Fulton
dea0c3f0b2 Add some code comments about Python objects and capsule reference counting
Issue #2208
2022-03-15 08:46:20 +00:00
YungLee
31f7b437f4
[scilab] Fix to work on Windows
* Change the builder filename to match the loader filename

* Mark extern functions with SWIGEXPORT

* Fix bug: builder.sce not generated if with  '-scilab -builder'  option

Fixes #1853
2022-03-15 15:06:17 +13:00
Olly Betts
b4a92ae34f Fix SWIG_Py*Method_New conditional
This should be a SWIG-time conditional, but was inside %{ %} so was
instead a compile-time conditional.

Fix for bug in the changes in #2191
2022-03-14 12:49:41 +13:00
Ian Lance Taylor
70d530adfc swig -go: treat a nil argument as NULL
Let Go code pass "nil" when calling a C++ function that accepts a
pointer to a class.  The Go "nil" will be treated as a C++ "nullptr".

Fixes #2203
2022-03-08 15:15:05 -08:00
Olly Betts
663299281e [Tcl] Fix SWIG_AsWCharPtrAndSize() to assign result
Fix SWIG_AsWCharPtrAndSize() to actually assign to result variable.  It
looks like SWIG/Tcl wide character handling is currently fundamentally
broken except on systems which use wide characters as the system
encoding, but this should fix wrapping functions which take a wide
string as a parameter on Microsoft Windows.

Patch from Omar Medina.

Fixes https://sourceforge.net/p/swig/bugs/1290/
2022-03-08 08:10:46 +13:00
Ian Lance Taylor
a4c82052ce swig -go: free correct variable in char *& typemap 2022-03-06 21:58:13 -08:00
Olly Betts
e5996be10c [Python] Fix memory leak.
SWIG python objects were being freed after the corresponding SWIG
module information was destroyed in Python 3, causing leaks when as
a result the object destructor could not be invoked. To prevent this
misordering, SWIG python objects now obtain a reference to the
Python capsule wrapping the module information, so that the module
information is correctly destroyed after all SWIG python objects
have been freed (and corresponding destructors invoked).

Fixes #2154
Fixes #2208
2022-03-07 14:29:17 +13:00
Olly Betts
8dbcd710ff [Javascript] Fix handling of functions which take void*
Fixes #682
2022-03-07 14:17:52 +13:00
Olly Betts
e1bb265bf7 Remove redundant conditional
clang defines __GNUC__ and __GNUC_MINOR__ as if it were GCC 4.2.1
and has since clang 2.4, which was before __has_builtin() was added.

Closes #1239
2022-03-07 09:11:50 +13:00
Ian Lance Taylor
27bdbc1f05 swig -go: treat non-const references as pointers
Also clean up the handling of int* and int& to convert between the C
type int and the Go type int, which are often different sizes.

Fixes #2210
2022-03-05 21:57:36 -08:00
Olly Betts
713438e879 Fix GCC -Wunused warning in generated Tcl wrappers 2022-03-04 12:00:36 +13:00
Olly Betts
b127e11f1e Fix typos in docs and comments 2022-02-27 18:15:46 +13:00
Olly Betts
b5544a1812 Remove commented out redundant code
This was an alternate version without NULL checks on free() and
delete, but we removed those checks globally in
7ec2f89fe2 so now it's just the
same as the active code.
2022-02-27 18:15:46 +13:00
William S Fulton
546062fdf1 Add %rename matching docs and improvements
Add in %$isusing macro for %rename.
Improve docs for %$not and notmatch.
2022-02-26 12:49:07 +00:00
Olly Betts
e36e898c0a
Merge pull request #2205 from swig-fortran/extend-tests
Fix and add additional tests to test suite
2022-02-25 10:16:22 +13:00
Olly Betts
1707d6b89b [PHP] Fix cleanup code handling issues
Fix to call cleanup code in exception situations and not to invoke
the freearg typemap twice in certain situations.

Fixes https://sourceforge.net/p/swig/bugs/1211/
2022-02-17 13:52:44 +13:00
William S Fulton
8e4868af75 More director const std::string& testing and C# leak fix
Issue #998
2022-02-13 23:00:04 +00:00
Seth R Johnson
fb0cddfd2b Add C "contract" test
Tests that the `%contract` code (viz., each target language's
implementation of SWIG_contract_assert) compiles in C as expected. Update
the note in the source code since `%contract` is in the official
documentation.
2022-02-12 19:40:03 -05:00
Olly Betts
31af3ce9bf Avoid -Wempty-body warnings from SWIG_contract_assert 2022-02-11 18:39:08 +13:00
Olly Betts
89a0a3c5f7
Merge pull request #2197 from swig-fortran/rename-warn
Print rename warnings except anonymous template methods
2022-02-10 16:15:10 +13:00
Dimitris Apostolou
40c3bf30b2 Fix typos 2022-02-10 16:12:24 +13:00
Olly Betts
b415f566a0 [Tcl] std_vector.i: Remove unneeded \ line joins 2022-02-10 09:56:42 +13:00
Olly Betts
bb15c4eccf [Tcl] Fix Tcl generic input typemap for std::vector
Fixes https://sourceforge.net/p/swig/bugs/1207/
Fixes https://sourceforge.net/p/swig/bugs/1213/
2022-02-10 09:55:58 +13:00
Seth R Johnson
de78b80de9 Renames performed by %namewarn with rename= are printed in warning message
This is necessary for regex-like renames (where you can't use the #define trick
as is done in many of the %keywordwarn directives). It's now unnecessary to print
the "renaming to '`x`'" code explicitly by the kw.swg files.
2022-02-06 13:51:37 -05:00
William S Fulton
aef4a0f90a Merge branch 'doc-work' into upstream-master
* doc-work:
  Move the attribute.i docs into Library.html
  Move %attribute documentation into the manual
2022-02-05 20:52:42 +00:00
Olly Betts
a60655a86b Merge branch 'octave-4-4-bugfix' of https://github.com/friedrichatgc/swig
Fixes #1672
2022-02-04 16:36:05 +13:00
Olly Betts
951f946341 [Python] Improve handling of SWIG_Py*Method_New
The SWIG_PyInstanceMethod_New method is no longer added to wrapped
classes except when it's actually needed, which is when
(!builtin && fastproxy) is true (which it isn't by default).

The SWIG_PyStaticMethod_New method is no longer is now similarly
gated - previously only (fastproxy) was checked.

Finally the C/C++ functions that implement these were always compiled
into the module, but now they're only included if
(!builtin && fastproxy) is true.

Issue noted by vadz in #2190.
2022-02-04 12:58:56 +13:00
Olly Betts
7a21da90fd [C#] Fix memory leak in directorin typemap for std::string.
Fixes #998
2022-02-03 22:50:28 +13:00
Olly Betts
bede0b407b [python] Workaround MSVC2022-related bug
Fixes #2090
2022-02-03 17:54:50 +13:00
Justus Winter
5691f3f685 Fix function prototypes of generated pointer functions
Previously, the emitted constructors were incomplete prototypes.  When
compiling the wrapper code using gcc 6 and -Wstrict-prototypes, the
following warnings were emitted:

  warning: function declaration isn’t a prototype [-Wstrict-prototypes]

See #801
2022-02-03 17:25:44 +13:00
Olly Betts
0cdbbf326b Fix -Wstrict-prototypes warning in generated PHP wrappers 2022-02-03 17:21:17 +13:00
Clement David
aee380ce82 [scilab] Name init function name to avoid collision
Use SWIG_<module>_Init() function to init the module rather than
<module>_Init() as the latter can collide with a function being wrapped.

Fixes #745
Fixes #1739
2022-02-02 09:43:06 +13:00
Olly Betts
3e019977c5
Merge pull request #1398 from swig-fortran/missing-includes
Add missing includes to library and test cases
2022-02-01 14:05:17 +13:00
Olly Betts
9f74955e8d [Ocaml] Fix to work with CAML_SAFE_STRING
CAML_SAFE_STRING is on by default in current Ocaml versions, and was
stopping SWIG-generated wrappers from compiling.

Fixes #2083
2022-02-01 13:29:53 +13:00
Olly Betts
6f4adde4b4 [Tcl] Fix std_vector typecheck typemaps
In some cases the typecheck typemap would try to access the first
element of an empty Tcl list.

Fixes https://sourceforge.net/p/swig/bugs/1309/
2022-02-01 13:09:00 +13:00
Olly Betts
7ec2f89fe2
Remove redundant NULL checks before free()/delete (#2184)
Remove redundant NULL checks before free()/delete

The ISO C and C++ standards guarantee that it's safe to call these
on a NULL pointer, so it's not necessary for the calling code to
also check.

Fixes https://sourceforge.net/p/swig/feature-requests/70/
2022-01-29 22:03:48 +13:00
Thomas Reitmayr
5a10e10399 Ruby: Fix warnings in generated code about missing parameter in variadic macro
The Ruby C API function 'rb_funcall' is used in various places in generated
code for invoking a Ruby method without parameters. The C function uses a
variadic parameter list for the arguments passed to Ruby, therefore in these
cases the list of variadic parameters is empty.
As an optimization Ruby may implement the 'rb_funcall' function as a macro
which however will not accept an empty list of arguments for '...' as of
C99 and C++11.
In order to prevent compiler warnings, this commit replaces all such
occurrences with a call to 'rb_funcall2' (which in its current name
'rb_funcallv' is invoked by the 'rb_funcall' macro anyway, at least for
Ruby 2.6.6).
2022-01-29 11:07:57 +13:00
Olly Betts
7963807308 [python] Remove unused bogus fallback macro
This fallback version of PyString_AS_STRING() for Python 3 makes use of
PyUnicode_AS_STRING, but I can find no evidence that ever existed in
Python - all references I've found are to SWIG or SWIG-generated code.

The only uses of PyString_AS_STRING() in SWIG generated code are for
Python 2 #if-branches, so this fallback is never used by SWIG.

Because it doesn't work it can't be usefully used in user interface
files either, so let's remove it to avoid potential user confusion
(such as #987).
2022-01-27 09:32:25 +13:00
Corey Minyard
f77af57bd7 Move %attribute documentation into the manual
It's fairly hidden where it is, put it where users can see it more
easily.

Fixes #2166
2022-01-26 09:18:55 -06:00
Olly Betts
5f5a8f2d4a [php] Initialise zval in directorin typemaps
SWIG_SetPointerZval() requires the zval structure passed to be
initialised (so it can handle the constructor case where the zval is
already initialised as a PHP object.

I couldn't think of a suitable regression test for this, but it fixes 2
issues detected by running director_basic under valgrind.
2022-01-24 13:32:22 +13:00
Olly Betts
7b929dce82 [php] Fix director upcall check
This resolves an issue uncovered by adding a _runme.php for testcase
director_alternating.
2022-01-22 20:01:00 +13:00