Commit graph

3,398 commits

Author SHA1 Message Date
William S Fulton
1d56bc6b85 Add initialisers for additional members in PyHeapTypeObject
(builtin mode) for Python-3.11 - _ht_tpname, _spec_cache.
2022-08-01 08:24:52 +01:00
Olly Betts
dce4254377 [php] Fix handling of friend functions
We were incorrectly considering them as methods of the class they
are a friend of for the purposes of calculate PHP type declarations.
2022-07-29 16:37:22 +12:00
Olly Betts
8cc3d04a35 [perl] Note in -help that -proxy is on by default 2022-07-28 10:23:54 +12:00
William S Fulton
7592722e39 Order of interfaces generated for %interface macros
Ensure the order of interfaces generated in proxy interfaces for the
%interface family of macros is the same as that parsed from the bases in C++.
2022-07-20 19:50:53 +01:00
Olly Betts
6b4d5fe3f0 Remove remaining code to support macos9
This OS has been unsupported for over 20 years.  We stopped providing
macswig builds more than 20 years ago too:

https://sourceforge.net/projects/swig/files/macswig/

The required SIOUX library doesn't seem to be available anywhere
now either.

Closes #2323
2022-07-19 11:22:37 +12:00
Olly Betts
892557e799 Improve #include guard macros
Avoid using reserved identifiers such as `_DOHINT_H` (fixes #1989),
fix cases where the name doesn't match the filename, and make the naming
more consistent and less likely to collide with include guards in other
headers.
2022-07-19 09:35:46 +12:00
Olly Betts
64fa88c0eb [php] Omit incompatible return type declaraction
Under %feature("php:type", "compat") we don't generate return type
declaration for virtual methods if directors are enabled for that class.
However if a base class of the class has a method of the same name which
isn't directed this was still getting a return type declaration which
caused PHP to give an error when it tried to load the module.

Now we detect this situation and suppress the base class method's
return type declaration too.

Re-enable testcase director_redefined which now works again (it was
failing under PHP8 due to this issue).

See #2151
2022-07-13 16:01:59 +12:00
Olly Betts
cfc3888cba [php] Emit arginfo after all the code
Another step in preparation for a fix for the incompatible overridden
method problem discussed in #2151.
2022-07-13 15:21:12 +12:00
Olly Betts
7cf91c12dc php: Move ME and FE generation back out of PHPTypes
It's more natural to leave it where it was, and will work better
when we delay the arginfo generation.
2022-07-11 17:38:34 +12:00
Olly Betts
6503200684 php: Encapsulate arginfo generation
Encapsulate the code to generate arginfo in the PHPTypes class.
By itself this should result in no functional changes, but it's
a step towards being able to delay arginfo generation which I
think is necessary to address the incompatible overridden
method problem discussed in #2151.
2022-07-11 17:23:20 +12:00
Olly Betts
cf9422b4d9 [php] Stop setting unused php:proxy attribute
This is no longer used since we changed how classes are wrapped.
2022-07-11 15:32:43 +12:00
Olly Betts
22a4355f34 [xml] Move to "Experimental" target language status
The XML target language support is not in good shape and is likely to be
removed unless somebody steps up to bring it up to the expected standard
(it fails to even meet the criteria for "Experimental" currently).

Closes #2213
2022-07-08 16:34:19 +12:00
Ian Lance Taylor
87cbf8c341 [Go] #2245 Handle NULL pointers for string* conversions.
Rearrange generation of director methods and rename
receiver argument from p to swig_p.

Fixes #2245
2022-07-05 17:00:48 -07:00
Olly Betts
f5e2d044df Remove set but not used variables
Highlighted by clang-15 warnings such as:

warning: variable 'index' set but not used [-Wunused-but-set-variable]
2022-06-30 12:52:37 +12:00
Olly Betts
9cdf46e8c8 [php] Adjust #required params for subclass methods
If the same method name is implemented in a parent class then the
subclass can't have more required parameters than that or else we
get a compatibility error when the module is loaded.

The testsuite wasn't catching this problem because it was no longer
trying to load the modules for testcases without _runme.php, because
the mechanism to do that relied on there being a generated .php
wrapper, which we no longer have by default.  Fix that to provide a
regression test for this fix.

See #2151
2022-06-14 16:00:46 +12:00
Olly Betts
c95df57976 [php] Fix missing parameter type declarations
In some cases of overloaded functions the parameter type information was
missing for some or all parameters.

See #2151
2022-06-12 09:22:27 +12:00
Olly Betts
2df27036b7 [php] Skip directorout typemap if PHP exception pending
Otherwise can end up with a second PHP exception if the directorout
typemap doesn't accept PHP Null.  `SWIG_fail` in this case results
in us returning to PHP which then propagates the pending exception.

This commit fixes a failure in smoketest.php in Xapian's PHP bindings,
but I've not managed to come up with a reproducer which works for
SWIG's testsuite.
2022-06-10 16:01:05 +12:00
Olly Betts
2de2efb0bb Fix PHP parameter type declarations compatibility
Ensure PHP parameter type declarations are compatible with those for
the same method in any classes we inherit from.

See #2151
2022-06-10 11:12:54 +12:00
Olly Betts
d43d62cd7a Revert "Fix PHP parameter type declarations compatibility"
I missed that this change breaks cpp_static, which seems to be to do
with handling the combined getter and setter we emit for static
member variables.  Reverting while I figure out how to handle that.

This reverts commit a277748870.
2022-06-09 17:55:09 +12:00
Olly Betts
a277748870 Fix PHP parameter type declarations compatibility
Ensure PHP parameter type declarations are compatible with those for
the same method in any classes we inherit from.

See #2151
2022-06-09 17:36:11 +12:00
Olly Betts
a8994d4186 Rename zend_types to be clearer
It's actually tracking pointer types which aren't wrapped as classes.
2022-06-09 12:49:30 +12:00
Olly Betts
d7ed1a8b97 [php] Eliminate sprintf to temp buffer to create ZVAL
Use zend_strpprintf() which handles this more cleanly without risk of
buffer overflow and without a fixed length limit.
2022-06-09 09:06:12 +12:00
Olly Betts
97a109ecc9 WIP: Refactor pararent class tracking 2022-06-08 17:41:00 +12:00
William S Fulton
34c219b5f7 Merge branch 'imfunc'
* imfunc:
  Add special variable imfuncname expansion for C# and D
  Test and document imfuncname special variable expansion
  Update docs.
  Also expose  in proxyClassFunctionHandler
  Expose  to javaout typemaps.

Conflicts:
	CHANGES.current
2022-05-30 19:45:28 +01:00
William S Fulton
954f29b032 Add special variable imfuncname expansion for C# and D
Same functionality as Java
2022-05-30 19:43:04 +01:00
William S Fulton
b4cc35ddbc Merge branch 'csharp-strenghten-overload-check'
* csharp-strenghten-overload-check:
  Fix expanded director_basic test.
  Improve correctness of SwigDerivedClassHasMethod() by making sure only methods that have `override` are used connected by director.
2022-05-26 08:23:18 +01:00
William S Fulton
6939d91e4c Header file tidyup
Fix Visual C++ warning in scilab.cxx:
  warning C4996: 'strtok': This function or variable may be unsafe.
2022-05-07 11:56:06 +01:00
William S Fulton
69dba70319 Visual C++ warning fix 2022-05-07 11:56:06 +01:00
Kris Thielemans
f5934b099b [Python] Replace tp_print with tp_vectorcall_offset slot for Python 3.8
The tp_print slot is no longer supported and replaced with tp_vectorcall_offset.
The (printfunc) cast that we used caused problems on PyPy.

Fixes #2262
2022-04-21 12:28:54 +01:00
Corey Minyard
fb4c69b4b0 [Go] Add missing newlines for goin typemaps
In some cases the \n was missing from goin directives in some places.
Without this change, you will get

}	swig_r = (int)(C....

in the output in some cases, and that won't compile in Go, it will
error with:

  ../gensio/gensio.go:1508:3: expected ';', found swig_r

It only did this on director callbacks with godirectorin, and only if
the virtual function wasn't assigned to zero.  So the following will
fail:

    class callbacks {
    public:
        virtual bool call1(int v, const char * const *strarray);
        virtual ~callbacks() = default;
    };

but the following won't:

    class callbacks {
    public:
        virtual bool call1(int v, const char * const *strarray) = 0;
        virtual ~callbacks() = default;
    };

Add "\n" to the proper places to fix this.
2022-04-16 16:10:32 -05:00
luz paz
c8bec18554 Fix various typos
Found via `codespell -q 3 -L ans,anumber,ba,bae,chello,clos,cmo,coo,dout,fo,funktion,goin,inout,methid,nd,nin,nnumber,object,objekt,od,ois,packag,parm,parms,pres,statics,strack,struc,tempdate,te,thru,uint,upto,writen`
2022-04-11 07:59:36 +12:00
Olly Betts
1aeaa2a644 Recognise and ignore Doxygen group commands @{ and @}
Fixes #1750
2022-04-07 12:05:54 +12:00
William S Fulton
fe0af80933 Remove some unnecessary empty lines from generated .py file 2022-04-07 00:17:18 +01:00
William S Fulton
a12fc916e4 Remove unused functions in Python builtin mode 2022-04-07 00:17:15 +01:00
William S Fulton
9c67a2c007 Remove legacy USE_THISOWN conditional compilation
Seems to be a left over from 'thisown' partial removal
in 985adc13fb
2022-04-06 22:58:17 +01:00
William S Fulton
a5be4a10b5 Slight performance improvement for %pythonnondynamic
Setting this is much more likely than thisown
2022-04-06 22:48:33 +01:00
William S Fulton
b35ebc81a9 Doxygen comments take precedence over the autodoc feature.
If a "docstring" feature is present it will still override a Doxygen comment.
If the "autodoc" feature is also present, the combined "autodoc" and "docstring"
will override the Doxygen comment. If no "docstring" is present then the
"autodoc" feature will not be generated when there is a Doxygen comment.

This way the "autodoc" feature can be specified and used to provide documentation
for 'missing' Doxygen comments.

Closes #1635
2022-04-06 08:08:14 +01:00
Olly Betts
ef3f25ab1c Remove -browse command line option
This option was undocumented.  If used it quietly did nothing
unless you'd installed the SWILL library before building SWIG, but
SWILL is no longer maintained and hasn't seen a release since
2008-04-10.

It's clear nobody has used this functionality for some time as the
code to support it in SWIG isn't actually valid ISO C++:

Modules/browser.cxx: In member function ‘void Browser::show_attributes(Node*)’:
Modules/browser.cxx:57:23: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
57 |         char *trunc = "";
   |                       ^~
Modules/browser.cxx:61:21: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
61 |             trunc = "...";
   |                     ^~~~~

Closes #2251
2022-04-03 08:56:07 +12: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
1db04bf322 Improvements to the -debug command line options
The debug command line options that display parse tree nodes
(-debug-module, -debug-top, -debug-symtabs) now display previously hidden
linked list pointers which are useful for debugging parse trees.

Added new command line option -debug-quiet. This suppresses the display
of most linked list pointers and symbol table pointers in the parse tree nodes.

The keys in the parse tree node are now shown in alphabetical order.
2022-03-25 23:34:52 +00:00
William S Fulton
b737a64ec5 Remove minimum Python version check
The version checking was historically done to deal with
different versions and importing the low-level Python
module. Then it was used to try and help when using -py3.
A minimum version check implies that the wrappers work
with any version >= 2.7, which is not really correct.
The correct thing to do is to check that the exact
version used matches the one that the C layer was compiled
against, which can only be left for the user to do, perhaps
using %pythonbegin.

Issue #1779
2022-03-25 19:09:17 +00:00
William S Fulton
469f694ae6 Fix using declaration in derived class bugs
Problem when all the base class's overloaded methods were
overridden in the derived class - fixes "multiply defined" errors.

Linked lists of the overloaded methods were not set up correctly
when handling the using declaration.

Closes #2244
2022-03-24 20:52:58 +00:00
William S Fulton
a343b7e254 Remove -py3 command line option
Closes #1779
2022-03-23 18:13:07 +00:00
William S Fulton
df86fbc54e Remove option to use Python 3 only syntax for %pythonnondynamic feature
A metaclass is added using a decorator @_swig_add_metaclass which
is designed to provide a metaclass that works for both Python 2 and Python 3.
The option to use the Python 3 only syntax: metaclass=_SwigNonDynamicMeta
via the -py3 command line option has been removed as part of a
simplification to remove the -py3 option.

Issue #1779
2022-03-23 07:58:39 +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
William S Fulton
9fd2356104 Merge branch 'flatstaticmember'
* flatstaticmember:
  Test -flatstaticmethod and %extend
  Python -flatstaticmethod corrections
  Enable flat static constructor methods
  Move low level static methods
  Use flat static method if it's a "friend"
  Python: Option to generate flat class methods
2022-03-21 19:28:52 +00:00
William S Fulton
21c2e47661 Python -flatstaticmethod corrections
Correct logic for suppressing static methods.
Previous logic was missing director disown methods.
Add changes file entry for -flatstaticmethod.

Closes #2137
2022-03-21 19:22:49 +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
Ian Lance Taylor
90aa3f75ba [Go] Implement %extend base methods in child classes.
Fixes #337
2022-03-18 18:34:28 -07:00