Commit graph

877 commits

Author SHA1 Message Date
Zackery Spytz
e4759ae250 C++17 u8 character literals testcase
Issue #1450
2019-02-10 15:53:42 +00:00
Alec Woods
98023054c6 Properly handle destructors as methods for autodoc and fix some stray newlines 2019-01-26 09:30:26 -05:00
Alec Woods
5106573b29 Fixing docstrings for variables and static functions for consistency 2019-01-26 09:30:26 -05:00
Alec Woods
86e08c8e34 Fixes so that fastproxy and autodoc work correctly with both low-level C API and high-level Python Shadow API 2019-01-26 09:30:26 -05:00
Alec Woods
fb58727135 Also check documentation on the low-level API 2019-01-26 09:30:26 -05:00
Alec Woods
591a70378e Fixing python docstring handling for -fastproxy 2019-01-26 09:30:26 -05:00
Vadim Zeitlin
1e22e791ef Always include default parameter values in Python autodoc strings
One of side effects of 15b369028f was that
the default values were only included in Python doc strings if we could
be sure that they could be interpreted as valid Python expressions, but
this change was actually undesirable as it may be useful to see C++
expression for the default value in the doc string even when it isn't
valid in Python.

Undo this part of the change and extend autodoc unit test to check that
this stays fixed.

Closes #1271.
2019-01-21 00:57:02 +01:00
William S Fulton
721f6ddef1 Add autodoc and keyword argument tests 2019-01-19 19:52:40 +00:00
William S Fulton
2e9b270cbb Merge branch 'vadz-better-param-names'
* vadz-better-param-names:
  Enable keyword arguments for keyword_rename unit test
  Update error messages test suite
  Add more tests for Python parameter renaming
  Improve handling parameters clashing with language keywords
2019-01-17 18:19:36 +00:00
William S Fulton
1bd1142d02 Fix python callback test-suite failure 2019-01-16 20:10:37 +00:00
William S Fulton
cf1624ebc4 Python static method wrapper changes
- Static method wrappers were using the 'fastproxy' approach by default.
  This is inconsistent with instance method wrappers. The fastproxy approach
  is now turned off by default to be consistent with instance methods.
  Static method wrappers can now also be controlled using the -fastproxy and
  -olddefs options.

  Example:

    struct Klass {
      static int statmethod(int a = 2);
    };

  generates:

  class Klass(object):
      ...
      @staticmethod
      def statmethod(a=2):
          return _example.Klass_statmethod(a)

  instead of:

    class Klass(object):
      ...
      statmethod = staticmethod(_example.Klass_statmethod)

- Modernise wrappers for static methods to use decorator syntax - @staticmethod.

- Add missing runtime test for static class methods and using the actual
  class method.
2019-01-16 08:21:00 +00:00
Vadim Zeitlin
22158807fa Add more tests for Python parameter renaming
These tests were proposed by @wsfulton.

See https://github.com/swig/swig/issues/1272
2019-01-16 04:29:04 +01:00
William S Fulton
0c4491eaae Add more tests for C++11 raw string literals
Test added to check fixes for:

- Issue #948 and issue #1019 and issue #1273 - raw string delimiters
  not being stripped off
- Issue #538 - Ruby support for "docstring" feature
2019-01-06 00:10:01 +00:00
William S Fulton
2769a8763c Add test for overloading and NULL 2018-12-29 14:15:45 +00:00
William S Fulton
3efea1f4ab Fix typecheck typemaps for non-pointers and NULL
The typecheck typemaps succeed for non pointers (SWIGTYPE, SWIGTYPE&,
SWIGTYPE&&) when the equivalent to C NULL is passed from the target
language. This commit implements a fix for Python to not accept a Python
None for non-pointer types.

Issue #1202
2018-12-29 11:45:46 +00:00
William S Fulton
d9ecff1fca Merge branch 'chlandsi-master'
* chlandsi-master:
  Testcase for testing __new__ override Python 3.6 fix
  fix for creating new shadow class in python 3.6
2018-12-20 08:12:41 +00:00
William S Fulton
6e2b54be2f Testcase for testing __new__ override Python 3.6 fix
Issue #1357
2018-12-20 08:10:35 +00:00
Vadim Zeitlin
5e7426dcc6 Avoid comparing doubles in nested_in_template.i unit test
This should also have been part of
30bb977a64

See #1358.
2018-12-04 20:46:35 +01:00
Vadim Zeitlin
30bb977a64 Fix handling of abstract base classes nested inside templates
Code handling %template in the parser created a totally new top-level
module child of namespace type when handling templates inside a
namespace and copied the nodes from the previously parsed C++ template
declaration to it. However copies of this node kept their original
values of "abstracts" attribute, which contained pointers to the classes
in the original template declaration, i.e. outside of the subtree
created for the instantiated template. This, in turn, meant that during
the types resolution pass, the code in TypePass did not update the types
used in the methods of the classes appearing in the "abstracts" List,
even though it did update the types for the children of the instantiated
template subtree.

And this finally resulted in wrongly detecting overridden virtual
methods as abstract in Allocate::is_abstract_inherit() during the next
pass, as the signatures of the overridden method -- using resolved types
-- and of the method from the class pointed to by "abstract" -- using
the original types from C++ code -- didn't match.

Resolve this simply by not copying "abstracts" attributes when creating
the template subtree and doing another pass over this tree to recreate
them using the new nodes, just as it's already done for "defaultargs"
attribute, presumably for similar reasons. Note that doing another pass
over the tree is not as efficient as doing everything in a single pass,
but merging the new update_abstracts() with update_defaultargs() is not
completely obvious, so for now keep it simple and optimize it later if
necessary.

Also, add a test checking for the situation described above.

Closes #1353.
2018-11-24 19:21:47 +01:00
William S Fulton
c0481ce99d Add Python runtime test for const function pointer 2018-11-13 07:35:44 +00:00
Olly Betts
728b8955bd Drop support for Python classic classes
There were only needed to support Python < 2.2, and we now require at
least Python 2.6.

 Conflicts:
	.travis.yml
	Examples/test-suite/python/autodoc_runme.py
	Source/Modules/python.cxx

This is a cherry-pick and merge from patch in #1261
2018-10-12 07:10:47 +01:00
William S Fulton
dcbccc6f6f Test non-default compare template argument in std::map 2018-10-09 22:43:19 +01:00
William S Fulton
18383340e9 Fix C default arguments with -builtin and -fastunpack and -modernargs.
Problem occurred when there is just one (defaulted) parameter in the parameter list.

Closes #1126
2018-10-04 08:06:01 +01:00
William S Fulton
631e26ae48 Python std::unordered_set tidy up and additional testing 2018-09-23 19:10:26 +01:00
William S Fulton
72ccea5080 Python std::unordered_map std::unordered_multimap improvements
- Fixes for -builtin
- Fix missing iterator support
2018-09-23 19:10:00 +01:00
William S Fulton
146998ce81 Python builtin - add indexing support to std::unordered_set 2018-09-23 19:09:59 +01:00
William S Fulton
05d6717de9 Python builtin - add indexing support to std::set 2018-09-23 19:09:54 +01:00
William S Fulton
4715a4e72c Python -builtin __contains__ fix for map and set like containers.
Fix when using -builtin and wrapping std::map, std::set, std::unordered_map or
std::unordered_set to ensure __contains__ is called. This is a wrapper for the STL
container's find method. Without it, Python will do its own slower sequence search.
2018-09-21 08:51:22 +01:00
William S Fulton
c6547ac44e Fix functors (wrapped as __call__) when using -builtin -modern -fastunpack. 2018-09-19 20:10:11 +01:00
William S Fulton
bf85b6f7a9 Add in an example/test for Python __pow__
- A test for the ternaryfunc builtin slot
- Example of how to wrap C++ class for Python's pow
2018-09-16 17:33:14 +01:00
William S Fulton
4d34d419b6 Disable nondynamic testcase for Python -builtin -O 2018-09-06 21:22:51 +01:00
William S Fulton
de5a2c496b Python runtime test invalid sequence fix
Fixes:
  DeprecationWarning: invalid escape sequence \]
shown using debug build of python-3.7 interpreter.
2018-09-04 07:35:41 +01:00
William S Fulton
2f31c3e94e Python C++11 hash tables compilation fixes
- std::unordered_map compilation fix when just using std_unordered_map.i standalone
- std::unordered_multimap compilation fix when just using std_unordered_multimap.i standalone
- Add in the standalone unordered STL test cases

Closes #1319
2018-08-31 20:26:46 +01:00
William S Fulton
3baf6e9f97 Merge branch 'wkalinin-duplicate-unions'
* wkalinin-duplicate-unions:
  Add testcase for nested C struct name conflict
  Nested structures in "C" mode symbol table fix
2018-08-20 19:22:31 +01:00
William S Fulton
c39a379942 Add testcase for nested C struct name conflict
Issue #1305
2018-08-20 19:21:14 +01:00
William S Fulton
eb81355196 Fix makefile recursion when running python test-suite.
Use terminal / double-colon rules in makefile pattern matching rule to
prevent recursion reported on some versions of make.

Closes #688
2018-08-19 17:40:56 +01:00
William S Fulton
4930fab5a0 Fix some Python tests not being run in out of source tree builds
When there is just a _runme3.py file and no _runme.py file, out of
source builds were not running the script.
Currently only applies to python_abstractbase_runme3.py.
2018-08-19 16:18:38 +01:00
William S Fulton
c9cac931c7 Re-implement Python -fastproxy option.
The previous implementation failed with Python 3 and abstract base clases.
The new implementation replaces the Python 2 implementation using new.instancemethod with C API PyMethod_New to match the equivalent Python 3 implementation which uses PyInstanceMethod_New.

Closes #1310
2018-08-18 00:36:23 +01:00
William S Fulton
bb5c46079b Better detection of builtin in Python testcase 2018-08-14 19:16:25 +01:00
William S Fulton
345b4fec43 Testcase fix 2018-08-14 08:55:55 +01:00
William S Fulton
fdd2bcf0e6 Remove asserts from Python testcase
Also rename testcase python_pybuf to python_pybuffer.
2018-08-12 15:16:03 +01:00
William S Fulton
33f3dbb005 Merge branch 'gmazzamuto-pybuf_test'
* gmazzamuto-pybuf_test:
  pybuffer: don't use the old deprecated buffer protocol for Python 3
  Enable test case for python_pybuf
2018-08-12 14:19:40 +01:00
William S Fulton
4f7406624d Python fastdispatch error message improvements
When overloaded C++ methods are called, the fastdispatch mode sometimes
optimises out the generation of the typecheck typemap code, resulting in
the 'Possible C/C++ prototypes' information not being in the error message.
Now when a TypeError is thrown, the exception message is modified to contain the
'Possible C/C++ prototypes'.

See issue #1293
2018-08-10 08:14:19 +01:00
William S Fulton
fd651ff4e2 Overloaded C++ function Python wrappers now raise a TypeError instead of NotImplementedError
Occurs when the types passed are incorrect. This change means
there is now consistency with non-overloaded function wrappers which have always
raised TypeError when the incorrect types are passed.

See issue #1293
2018-08-10 08:14:12 +01:00
William S Fulton
037bf2b385 Slim down pythonnondynamic testing feature testing
No need to test twice, just test using C.
2018-07-23 07:27:01 +01:00
William S Fulton
fe082382c7 Fix pythonnondynamic feature for modern classes
Fixes nondynamic mode when an instance variable is set with the same
name as a class variable in a class derived from a SWIG proxy class.
The python_nondynamic testcase now works using -modern and testcase
enhanced slightly too.

Fixes #718
2018-07-23 07:25:11 +01:00
Giacomo Mazzamuto
5a8c4fde4c Enable test case for python_pybuf 2018-07-04 10:48:06 +02:00
William S Fulton
602b0d5a2c Add doxygen testing of Java constructor wrappers 2018-06-18 18:56:21 +01:00
William S Fulton
d22ecafb36 Fix Java doxygen:notranslate for single line comments
Remove extra generated line
2018-06-16 21:23:12 +01:00
William S Fulton
e96316bf31 Fix seg fault using Python 2 invalid utf-8 strings and wstring
Fixes seg fault when passing a Python string, containing invalid utf-8 content,
to a wstring or wchar * parameter.  A TypeError is thrown instead, eg:

  %include <std_wstring.i>
  void instring(const std::wstring& s);

  instring(b"h\xe9llooo") # Python
2018-06-15 19:39:12 +01:00