Commit graph

4,165 commits

Author SHA1 Message Date
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
Olly Betts
87c2e7d71a [php] Fix long long handling on 32 bit platforms
The typemaps for long long and unsigned long long didn't handle a
string input correctly, and long_long_runme.php had a flawed test
in this case.

Fixes #2155
2022-01-22 13:09:34 +13:00
Olly Betts
5d0679668d [tcl] Drop remnants of support for Tcl < 8
The documented minimum has been Tcl 8.0 since before the great
merge in 2002.
2022-01-21 15:54:06 +13:00
Olly Betts
4f5dfd596d [php] Provide zend_class_implements_interface() for 7.x
It seems instanceof_function_ex() isn't a viable option for PHP 7.3 and
earlier - the implementation is strangely wrong.

So let's just provide a compatibility implementation which does what
zend_class_implements_interface() does in 8.x and use that for all 7.x
so there are fewer variants to worry about testing.
2022-01-21 14:32:36 +13:00
Olly Betts
772ea68084 [php] Fix minor version test 2022-01-21 13:09:47 +13:00
Olly Betts
c197ed719a Fix unterminated comment in previous commit
I'm an idiot - I noticed I'd used a // comment after testing, but failed
to retest after fixing that.
2022-01-21 12:34:38 +13:00
Olly Betts
ce4a9923ed [php] Fix zend_class_implements_interface() compat
The sense of parameter 3 of instanceof_function_ex() appears to have
changed in PHP 7.4 and we need to pass 0 for older versions and 1 for
PHP 7.4.  Words fail me.
2022-01-21 12:11:39 +13:00
Olly Betts
c417250b4e [php] Allow testing if an object is SWIG-wrapped
Since the switch to wrapping classes using PHP's C API, we now
internally need to be able to tell if a PHP object is of or derived
from a class that is wrapped by SWIG so we know if we can offset the
zend_object pointer to get to the swig_object_wrapper.  If we try to
do this to an object which isn't wrapped by SWIG then we invoke C/C++
undefined behaviour (and typically get a segmentation fault).

This check is implemented by having a SWIG\wrapped empty interface which
we make all SWIG-wrapped classes implement simply so we can test for it
to detect such classes.

Fixes #2125
2022-01-20 14:42:02 +13:00
Olly Betts
1f1349741f
[php] Generate PHP type declarations
We now automatically generate PHP type declarations for PHP >= 8.0.

The generated code still compiles with PHP 7.x but without type declarations.
2022-01-20 10:07:44 +13:00
Olly Betts
748a9a5452 [perl] Require at least Perl 5.8.0
As discussed and agreed in #1629, it's become hard to test with Perl
5.6 or earlier, such old versions are no longer in active use, and
4.1.0 is an appropriate time to make such a change.

I've dropped the compatibility code that was obvious to me, but there's
probably more that can be cleaned up now.
2022-01-19 10:07:30 +13:00
Markus Friedrich
a5774a9d0f Fixed octave version check and enabled VPATH build for check-octave-operator example 2022-01-16 09:58:25 +01:00
Markus Friedrich
be0b975e6b Merge remote-tracking branch 'origin/master' into HEAD 2022-01-16 09:57:22 +01:00
William S Fulton
3aa302c08f %callback and Python class access for C++ static member functions fixes
Fix access to C++ static member functions using Python class
staticmethod syntax, such as Klass.memberfunction instead of
Klass_memberfunction, when using -fastproxy and -builtin in
combination with %callback.

The docstring containing the callback pointers were not being patched
during module initialisation.
2022-01-14 23:00:59 +00:00
ERROR
d73f933c4b
Support std::array in Golang (#2045)
Support std::array in Golang

Closes #2045
2022-01-04 12:12:56 +13:00
Olly Betts
69b580dfb6 [php] Use SWIG_TypeCheckStruct to check types
We have the swig_type_info available and SWIG_TypeCheckStruct
is more efficient because it uses a pointer comparison instead of the
string comparison SWIG_TypeCheck uses (this change speeds up `make
check-php-test-suite` by about 10%).
2021-12-19 13:45:25 +13:00
Olly Betts
7d75e3eb7e [PHP] Add new PHP 8.1 keyword
Add PHP keyword 'readonly' (added in 8.1) to the list SWIG knows to
automatically rename.  This keyword is special in that PHP allows it to
be used as a function (or method) name.
2021-12-18 15:30:38 +13:00
Olly Betts
cf802c63f2 Improve naming of zend_class_entry structs
Previously the zend_class_entry for Foo was named SWIGTYPE_Foo_ce, but
this can collide in some cases - e.g. if there's a class named p_Foo
then its zend_class entry will be SWIGTYPE_p_Foo_ce, but that's the same
as the swig_type_info for a class named p_Foo_ce.
2021-12-17 17:14:54 +13:00
Olly Betts
78f5404727 Improve generated object handlers
Do more initialisation at module load time.

Use a shared set of handlers for cases when the C/C++ object is
destroyed with free().

Most of the code in the free_obj and create_object handlers is the
same for every wrapped class so factor that out into common functions.
2021-12-17 14:50:49 +13:00
Olly Betts
6253583809 Rename php_fetch_object with swig_ prefix
We shouldn't be using symbols starting `php` as that risks collisions
with future symbols defined by PHP.
2021-12-17 09:37:00 +13:00
Olly Betts
9ffa15b307 Tweak source whitespace to match SWIG conventions 2021-12-15 19:40:06 +13:00
tytan652
fa2f9dc5da [lua] Fix maybe-uninitialized warning in generated code 2021-12-15 09:31:13 +13:00
Olly Betts
94ad89284d [php] Remove redundant in typemap for bool
This typemap which would wrap C++ bool as PHP int is later overridden
by another which wraps it as PHP bool.  The current result is what
we want so just remove the redundant one.
2021-12-13 09:31:11 +13:00
Olly Betts
c0c7a8dba0 [php] Fix two incorrect PHP 8 conditionals
The correct macro to test is PHP_MAJOR_VERSION so these two PHP 8 cases
weren't ever used, which hid that the PHP8 version of the code was
broken in one of them.

Highlighted in #2113.
2021-12-08 13:10:38 +13:00
William S Fulton
7246cfa6c6
Merge pull request #2116 from vstinner/python311
Add Python 3.11 support: use Py_SET_TYPE()
2021-12-07 20:32:31 +00:00
Victor Stinner
e902ab5160 Add Python 3.11 support: use Py_SET_TYPE()
On Python 3.9 and newer, SwigPyBuiltin_SetMetaType() now calls
Py_SET_TYPE(). Py_TYPE() can no longer be usd as an l-value on
Python 3.11:

* https://docs.python.org/dev/c-api/structures.html#c.Py_SET_TYPE
* https://docs.python.org/dev/whatsnew/3.11.html#c-api-changes
2021-12-06 23:17:33 +01:00
Robert Fries
983b91694f Additional changes due to name changes in octave-6 * is_map to isstruct, is_object to isobject 2021-12-05 22:19:46 +00:00
Robert Fries
81f9e6600f Octave module lets examples and tests work with Octave-6 * Try-catch replacement for check of error_state * Add execute method in addition to call * Replace oct_mach_info with octave::mach_info * Call from interpreter: global_varval global_assign * Assign a global name requires locating the stack which requires interpreter to tree evaluator to callStack * Do not use discard_error_messages or discard_warning_messages 2021-12-05 22:19:46 +00:00
Robert Fries
852eab7db3 Allow swig wrapped modules to compile with -Bsymbolic 2021-12-05 22:19:40 +00:00
William S Fulton
be51cb6a6e Merge branch 'fix-crash-2101'
* fix-crash-2101:
  Added extern "C" block that was removed in previous commit.
  Fixed crashes when using embedded Python interpreters.
2021-12-02 09:01:18 +00:00
Olly Betts
7c97bd5ab3 [js] Remove code to handle v8 < 5.0
We require at least node v6 which means v8 5.0, so code to handle
older v8 is no longer useful.
2021-12-02 14:04:25 +13:00
John Senneker
160b8c5da3 Added extern "C" block that was removed in previous commit. 2021-12-01 15:15:24 -05:00
William S Fulton
f17b6bda93 Merge branch 'fix_SWIG_V8_VERSION'
* fix_SWIG_V8_VERSION:
  [javascript][v8] SWIG_V8_VERSION generation method corrected.
2021-12-01 18:22:29 +00:00
John Senneker
ebe14e6e2a Fixed crashes when using embedded Python interpreters.
Fixes #2101. There are 3 related changes made here:
1. Move the SWIG_globals() singleton into pyrun from pyint so it
   is visible to SWIG_Python_DestroyModule(). The static globals
   varlink has been extracted out of the function so that it can
   be set to NULL in SWIG_Python_DestroyModule(), which fixes the
   issue described in #2101. (Now when the second interpreter
   starts up, the Swig_Globals_global pointer will be NULL, so it
   knows it has to create a new one.)
2. Remove a Py_DECREF on the globals varlink. The decrement is now
   performed by DestroyModule(), so there's no need to do it in
   SWIG_init().
3. Fixed similar issue with SWIG_Python_TypeCache().
2021-11-30 16:13:17 -05:00
Dimitris Apostolou
f586d920f7
Fix typos 2021-11-17 07:07:02 +02:00