Commit graph

5,613 commits

Author SHA1 Message Date
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
2c6e7f99a6 Test -flatstaticmethod and %extend 2022-03-21 19:23:15 +00:00
Ian Lance Taylor
90aa3f75ba [Go] Implement %extend base methods in child classes.
Fixes #337
2022-03-18 18:34:28 -07:00
Olly Betts
9ab3ef8e96 Update testcase comment 2022-03-19 08:55:39 +13:00
Olly Betts
d7e83c1cbc Fix checking of "optimal" typemap attribute
Previously SWIG checked that the typemap action contained ";\n" not
followed by an identifier character, and that it contained no other
`;`, but that incorrectly allows some cases it shouldn't.

Instead check that the action ends with `;\n` and contains no other
`;`, which is simpler and correctly rejects these cases.
2022-03-19 08:13:09 +13:00
Jim Easterbrook
3cfc26bc30 Move low level static methods
Like the non-static methods these are no longer present when using
-builtin
2022-03-18 11:10:14 +01:00
Julien Schueller
484e5316f2 Python: Option to generate flat class methods 2022-03-18 11:10:14 +01:00
William S Fulton
06364ae749 Merge remote-tracking branch 'wsfulton/appveyor-vs2022'
* wsfulton/appveyor-vs2022:
  Cygwin testing - test python3 (3.9) instead of python-2.7
  Last resort to use /usr/lib in python linking
  mingw - install python from pacman
  Fix detection of python .lib file for 2 digits in minor version
  cpp11_result_of testcase and result_of deprecation in c++17
  Testcase correction for using declaration and members
  Fix compiler warning using Java std::wstring
  Appveyor changes to use Visual Studio 2022 image
2022-03-17 08:23:13 +00:00
Olly Betts
c7af8eabb3 Default to running tests with Python 3
Specify PY2=1 to use Python 2.

See #1779
Closes #2235
2022-03-17 18:55:10 +13:00
William S Fulton
a9a110fbae cpp11_result_of testcase and result_of deprecation in c++17
Avoid deprecations warnings using c++17 and later compiler.
Keep testing using c++11 and c++14 compilers.
Provide simple alternative to keep run time tests working with
c++17 and later compilers.
2022-03-16 22:42:27 +00:00
William S Fulton
7f97278739 Testcase correction for using declaration and members
The compiler calls setWindowGrab(bool) instead of setWindowsGrab(NativeWindowType*)
and gives a warning with Visual C++ when calling setWindowGrab(true)
with a pointer to ApplicationContextSDL.
Looks like function function hiding of the non-virtual method.
I can't see this changing testing of the original bug.
2022-03-16 22:42:27 +00:00
Ian Lance Taylor
0c0b93f8e0 [Go] add typemaps for std::string*
Fixes #2214
2022-03-15 20:30:53 -07:00
Ian Lance Taylor
b819363117 [Go] Don't convert arrays to pointers if there is a "gotype" typemap entry.
Fixes #749
2022-03-15 12:18:47 -07:00
William S Fulton
ae8aa4e08f Re-enable overloading test for php8 2022-03-15 08:32:27 +00:00
Olly Betts
936e9264e8 Adjust Python variables example for Python 2
Explicitly call str() as previously Python 2 seemed to end up calling
repr().
2022-03-15 18:11:34 +13:00
Olly Betts
250afd6dc3 List variables in variables example
Seems useful in itself, but also serves to check if
https://sourceforge.net/p/swig/bugs/976/ is still reproducible.
2022-03-15 11:06:20 +13:00
William S Fulton
598736a6b2 %interface family of macros no longer add variable wrappers
The getter/setter methods used for wrapping methods are no longer
added to the interface class.

Closes #1524

Also add in testcase for enums.
2022-03-12 23:04:24 +00:00
William S Fulton
b6ece11fc1 Fixes for the family of %interface macros for overloaded methods
When C++ methods are not able to be overloaded in a derived class,
such as when they differ by just const, or the target language
parameters types are identical even when the C++ parameter types
are different, SWIG will ignore one of the overloaded methods with
a warning. A %ignore is required to explicitly ignore one of the
overloaded methods to avoid the warning message. Methods added
in the derived classes due to one of the %interface macros are now
similarly ignored/not added to the derived class.

The adding of additional methods into the parse tree is now more
robust and complete resulting in support for %feature and %rename
for the added methods.

Closes #1277
2022-03-12 23:04:24 +00:00
William S Fulton
50518d4e77 Using declarations, directors and overloaded methods
Language::unrollVirtualMethods was assuming that the using
declaration would only introduce one method. Fix this by adding
in all the overloaded methods from a base class.

Affects code generation in C# and Java, but I was not able
to construct a test that failed before this commit.
2022-03-10 22:18:23 +00:00
William S Fulton
e53f51b89d Add missing symtab for functions added by using declarations
Fixes fully qualified names for functions added by using declarations:
- Error messages show fully qualified names in Lua
- Overload warning messages show fully qualified names
- Error messages calling dispatch functions for handling overloaded methods in OCaml, Python and Tcl
2022-03-10 22:18:23 +00:00
William S Fulton
c88a9436bc Fix segfault in C# layer handling using declarations
Segfault was actually avoided in previous commit ab23cb29.
This commit makes handling more robust in the event of
using %ignore just on the derived method, not tested as it is not
what one should do with directors, and possibly other cases.

Go still segfaults with the new testcase director_using_member_scopes.i.

Issue #1441.
2022-03-10 22:18:23 +00:00
William S Fulton
bd5ffe86e4 Using declarations in derived class parameters scoping fix
Fix using declaration in derived class incorrectly introducing a method
from a base class when the using declaration is declared before the method
declaration. Problem occurred when within a namespace and the parameter types
in the method signatures were not fully qualified.

Issue #1441
2022-03-10 22:18:23 +00: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
f8a766295c Handle ) in command line interface filename
SWIG now handles an interface filename specified on the command line
which contains a closing parenthesis `)`, and more generally with
attributes to `%include` and `%import` which are quoted and contain
parentheses.

Fixes #1006
2022-03-08 18:15:18 +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
314df0f71e Fix rename_camel testcase to work for Go 2022-03-07 12:36:37 +13:00
Olly Betts
4f5613b4e9 Reenable rename_camel testcase
It was on the "broken" list, but it should now work.
2022-03-07 09:22:13 +13:00
Olly Betts
cf7bdcf2df Fix and expand rename_camel.i testcase
The regex pattern to upper-case things containing an `i` had incorrect
escaping (`\\(`...`\\)` instead of `(`...`)`) so `import` didn't get
renamed.

This wasn't detected because there were no `_runme` files for this
testcase, so add rename_camel_runme.php which uses reflection to check
the wrapped PHP classes, functions and constants are all named as
expected.

Also expand coverage of converting to underscore case and add coverage
for converting to lower-camel-case.

Related to #1041.
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
Ian Lance Taylor
4499422308 swig -go: fail test if "go build" fails 2022-03-05 21:54:48 -08:00
Olly Betts
6d29260a1a Eliminate C++11 from constant_expr test
This was introduced by a recent commit adding a testcase matching
an example in the manual.  There doesn't seem to be a suitable
termplate in the standard library before C++11, so instead use
a dummy version of std::array defined in the testcase.
2022-03-06 14:21:12 +13:00
Olly Betts
7bdef23304 Fix incorrect expected output in new testcase 2022-03-06 12:13:51 +13:00
Olly Betts
8cd2cfa9d1 Improve the change to allow parsing 9%a
If there was a later syntax error, this could incorrectly get
reported as:

Error: Unknown directive '%a'.
2022-03-04 17:00:20 +13:00
Olly Betts
8f54f6180a Update docs for expression parsing improvements 2022-03-04 16:36:04 +13:00
Olly Betts
9eb75a0c07 Improve typemap method and attribute checking
Specifying a value on the typemap method now gives an error, e.g.:

%typemap(argout=123) char * ""

The old way of specifying a language name in the typemap attributes
is no longer supported (it has been deprecated for 16 years).

Closes #891
2022-03-03 18:46:15 +13:00
William S Fulton
3159de3e9f Add support for Python variable annotations as a feature.
Both function annotations and variable annotations are turned on using the
"python:annotations" feature. Example:

  %feature("python:annotations", "c");

  struct V {
    float val;
  };

The generated code contains a variable annotation containing the C float type:

  class V(object):
      val: "float" = property(_example.V_val_get, _example.V_val_set)
      ...

Python 3.5 and earlier do not support variable annotations, so variable
annotations can be turned off with a "python:annotations:novar" feature flag.
Example turning on function annotations but not variable annotations globally:

  %feature("python:annotations", "c");
  %feature("python:annotations:novar");

or via the command line:

  -features python:annotations=c,python:annotations:novar

Closes #1951
2022-03-02 19:33:03 +00:00
Olly Betts
aa24e6b22b Handle typemap argument without a value
This now gives an error, previously SWIG segfaulted.

Fixes #891
2022-03-02 15:56:43 +13:00
Olly Betts
735fe4b60a Filter out is_python_* in PHP tests
These functions are added in a number of testcases but for all
languages not just Python.  It's tedious having to update the
PHP expected function lists for them, so let's just filter them
out.
2022-03-02 12:20:57 +13:00
William S Fulton
afc915f490 Turn on Python annotations testing again
Testing is skipped where there is no support for it, that is,
using -builtin or -fastproxy. How to add this support in needs
determining, it's not clear how to do so.
2022-02-28 19:40:35 +00:00
William S Fulton
8ce010b915 Disable Python annotations test due to incomplete support 2022-02-27 18:39:31 +00:00
William S Fulton
2072ae19c9 Python function annotations removed from -py3 option.
Python function annotations containing C/C++ types are no longer
generated when using the -py3 option. Function annotations support
has been moved to a feature to provide finer grained control.
It can be turned on globally by adding:

  %feature("python:annotations", "c");

or by using the command line argument:

  -features python:annotations=c

The implementation is designed to be expandable to support different
annotations implementations. Future implementations could implement
something like the following for generating pure Python types:

  %feature("python:annotations", "python");

or typing module types to conform to PEP-484:

  %feature("python:annotations", "typing");

Closes #1561
Issue #735
2022-02-27 10:47:50 +00:00
Olly Betts
bf382f01b4 Update _runme.php for new testcase functions and globals 2022-02-27 18:27:58 +13:00
Olly Betts
b127e11f1e Fix typos in docs and comments 2022-02-27 18:15:46 +13:00
Seth R Johnson
f4e2a4feee Fix warning and improve description of ignore_parameter test
See https://github.com/swig/swig/pull/2205#issuecomment-1052648190
2022-02-27 18:15:39 +13:00
William S Fulton
961424a986 Fix line/file info for methods added by using declarations 2022-02-26 20:07:58 +00:00
William S Fulton
eb32a6298d Add omitted testcase cpp_using_rename.i 2022-02-26 20:01:57 +00:00
William S Fulton
79a1bbee8b Using declarations in inheritance hierarchy improvements.
- Improved documentation for using declarations.
- Issue new warning WARN_LANG_USING_NAME_DIFFERENT when there
  is a conflict in the target language name to be used when
  introducing a method via a using declaration. Previously
  the method was silently ignored. Issue #1840. Issue #655.
2022-02-26 12:46:06 +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
7f37bfe2b5 Mark error messages more consistent
Always include English name of a mentioned character.
2022-02-25 10:07:17 +13:00