Commit graph

627 commits

Author SHA1 Message Date
xantares
92328a2016 pep257 & numpydoc conforming docstrings 2015-08-07 22:15:13 +01:00
Vadim Zeitlin
a1bddd56eb Make (char*, size_t) typemap usable for strings of other types in Java.
Notably it now works for "unsigned char*" strings.

Add a test to check that it now works in Java and also showing that it already
worked for the other languages with support for this typemap.
2015-08-07 19:44:45 +02:00
William S Fulton
fa282b3540 Improve Python docstring indentation handling
SWIG-3.0.5 and earlier sometimes truncated text provided in the docstring
feature.
SWIG-3.0.6 gave a 'Line indented less than expected' error instead of
truncating the docstring text.
Now the indentation for the 'docstring' feature is smarter and is
adjusted so that no truncation occurs.

Closes #475
2015-07-30 08:26:08 +01:00
William S Fulton
3718b810c7 Don't generate constructor wrappers if a base class has a private constructor
g++-5 errors out with this now with errors such as:

default_constructor_wrap.cxx:665:27: error: use of deleted function ‘FFF::FFF()’
   result = (FFF *)new FFF();
                           ^
default_constructor_wrap.cxx:314:7: note: ‘FFF::FFF()’ is implicitly deleted because the default definition would be ill-formed:
 class FFF : public F {
       ^
default_constructor_wrap.cxx:301:4: error: ‘F::~F()’ is private
    ~F() { }
    ^
default_constructor_wrap.cxx:314:7: error: within this context
2015-07-07 20:15:55 +01:00
Olly Betts
822b2355c0 Improve handling of whitespace in %pythoncode
Previously SWIG looked at the indentation of the first line and removed
that many characters from each subsequent line, regardless of what those
characters were.  This was made worse because SWIG's preprocessor removes
any whitespace before a '#'.  Fixes github issue #379, reported by Joe
Orton.
2015-06-29 22:12:38 +12:00
William S Fulton
b8e1a66a38 Add new feature "python:cdefaultargs"
Controls default argument code generation to obtain the default
arguments from the C++ layer instead of the Python layer.
2015-05-28 20:11:57 +01:00
William S Fulton
986a13f1a0 Fix Python typedef bool default arguments that are not booleans.
Includes code optimisation in PYTHON::convertValue().

Closes #327
2015-05-27 20:55:56 +01:00
William S Fulton
0f94ea9208 Example and test-suite makefile tidy up
Python output is less verbose if pep8 is not available (tweaks for patch #416)
2015-05-11 00:09:40 +01:00
Jon Schlueter
b77f3afafb autopep8 cleanup of Examples/test-suite/python
automated cleanup of python pep8 whitespace compliance
2015-05-08 21:35:52 -04:00
Olly Betts
c2972b8bf0 [Python] Deal with an integer as the default value of a bool
parameter in the C++ prototype.  Fixes github #327, reported by
Greg Allen.
2015-05-07 16:25:32 +12:00
Vadim Zeitlin
6988b00aba Fix handling of default arguments after ignored ones in Python.
Don't skip checking subsequent arguments just because one of them has "in"
typemap with numinputs=0 attribute.

Add a unit test showing the problem which is relatively rare as it doesn't
happen for the class methods and is hidden unless autodoc feature is used for
the global functions.

Closes #377.
2015-04-27 23:17:14 +02:00
William S Fulton
416277b3a5 Python code generated with '-builtin -modernargs' segfaults for any method taking zero arguments.
Also fixes: "SystemError: error return without exception set" during error checking
when using just -builtin and the incorrect number of arguments is passed to a class
method expecting zero arguments.

Closes #256
Closes #382
2015-04-24 21:08:17 +01:00
Vadim Zeitlin
5569d91bd0 Fix handling of "default" typemap in Python.
Use "compact" arguments form for the function if "default" typemap is defined
for any of its arguments to allow omitting this argument when calling it from
Python.

Closes #377.
2015-04-23 15:11:05 +02:00
Vadim Zeitlin
0eae8a8efa Fix handling of NULL default argument values for pointer types.
Accept not only manifest pointer types (such as e.g. "void *") but also types
that are typedefs for pointer types when checking whether C++ value of 0 must
be represented as 0 or None in Python.

Closes #365, #376.
2015-04-23 15:11:02 +02:00
William S Fulton
1a64e74c46 Add python runtime test for dynamically added attributes
From #320
2015-04-11 12:35:58 +01:00
William S Fulton
f1213809a2 Fix python tests for old versions of Python 2015-01-31 17:39:36 +00:00
William S Fulton
76bcec1d87 Test-suite fixes for python -classic
These are mostly workarounds for static class members not being supported for
old style classes, as documented in Python.html, "C++ classes".
2015-01-31 15:04:35 +00:00
William S Fulton
06fb68af5b Merge branch 'ptomulik-fix/py-object-const'
* ptomulik-fix/py-object-const:
  constant_directive_runme.py and classic classes
  additional fixes to %constant directive
  make %constant directive to work with structs/classes
2015-01-15 20:18:21 +00:00
William S Fulton
afba5b755a Fix Python default args when using kwargs
Recent default arg handling fixes didn't fix the case when kwargs is turned on
2015-01-15 07:54:36 +00:00
William S Fulton
9d87b9f099 Revert introduction of python:defaultargs feature
See issue #294
2015-01-12 21:35:47 +00:00
William S Fulton
efb8784c8b Fix python default_args testcase for Python 3
Changes for the default_args testcase to run under Python 3 when called
from python_default_args testcase
2015-01-09 00:37:23 +00:00
William S Fulton
38ba81811e Fix Python default argument handing broken since swig-3.0.3
Default values are no longer generated as Python code by default.
They must be explicitly turned on using the "python:defaultargs" feature.

Closes #294
Closes #296

The problems in these two issues when "python:defaultargs" is turned
on still need to be fixed and should be addressed in separate patches.
The important thing is the default code generation is now fixed.
2015-01-09 00:34:17 +00:00
Paweł Tomulik
2f6dee3adb constant_directive_runme.py and classic classes 2015-01-02 18:50:49 +01:00
Paweł Tomulik
cfaf2f97fd additional fixes to %constant directive 2015-01-02 18:50:49 +01:00
Paweł Tomulik
c21e2423a0 make %constant directive to work with structs/classes 2015-01-02 18:50:49 +01:00
William S Fulton
5c57a8c877 Warning suppressions in tests 2014-12-22 20:35:13 +00:00
William S Fulton
93d58cd3ed Fix use of preprocessor null directive
This was broken recently in commit 255c929c56
for issue #217
2014-12-20 17:05:13 +00:00
William S Fulton
68a936a638 Add testcase for nested inner class deriving from a templated base class and defined outside of the outer class.
For languages that don't support nested class support, use flatnested.
See issue #270
2014-12-19 19:35:38 +00:00
Vadim Zeitlin
e12a1d7671 Ignore E402 (import not on top of file) PEP8 error.
Travis uses the latest pep8 sources from Git and since

f3a12babd4

this error is given for all Python files generated by SWIG with -builtin
option.
2014-12-16 17:28:27 +01:00
Vadim Zeitlin
cb53e3063b Add PEP8_FLAGS variable to the test suite Python makefile.
Put pep8 options into this variable to avoid repeating them twice.

No real changes.
2014-12-16 17:28:25 +01:00
William S Fulton
80ae335319 Enhance C++11 strongly typed enums testcase 2014-11-27 19:56:08 +00:00
William S Fulton
7ffea44d80 C++11 strongly typed enums runtime test for python 2014-11-25 19:56:34 +00:00
William S Fulton
6029b2f7d8 Fix for 'self' being used as a parameter name 2014-10-30 07:22:59 +00:00
William S Fulton
fc1eaa5213 Fix autodoc testcase for python -builtin 2014-10-29 12:23:51 +00:00
William S Fulton
7d4af72dde Revert "Fix when is 'self' used as a parameter name in Python"
This reverts commit a6efdb7999.
2014-10-29 09:42:11 +00:00
William S Fulton
a6efdb7999 Fix when is 'self' used as a parameter name in Python
Fix corner case for variable names called 'self' after merging in patch #201
2014-10-28 07:07:44 +00:00
William S Fulton
5d71f91b29 Fix autodoc testcase for new named python arguments when using python -builtin
For the changes in #201.
2014-10-28 07:07:00 +00:00
William S Fulton
36ae32e941 Merge remote-tracking branch 'vadz/py-args'
* vadz/py-args:
  Allow using enum elements as default values for Python functions.
  Don't always use "*args" for all Python wrapper functions.
  No real changes, just make PYTHON::check_kwargs() const.
  Refactor: move makeParameterName() to common Language base class.
  Remove long line wrapping from Python parameter list generation code.
2014-10-27 20:02:59 +00:00
William S Fulton
bfde148887 The kwargs feature no longer turns on compactdefaultargs for languages that don't support kwargs.
Affects all languages except Python and Ruby.

Closes #242
2014-10-21 07:34:51 +01:00
Yann Diorcet
aeacff3b14 Improve cpp11_function_objects test for python 2014-10-11 20:20:10 +02:00
William S Fulton
78b904764a Merge branch 'diorcety-python_property'
* diorcety-python_property:
  Changes file entry for Python director property fix
  Python: Fix property access with director

Conflicts:
	CHANGES.current
2014-10-11 00:22:21 +01:00
William S Fulton
ef4d44e92d Fix syntax error in autodoc testcase when using Python 2.4 and earlier 2014-10-10 23:56:14 +01:00
William S Fulton
49038b30b7 Bypass Python tests not supported by -builtin
Builtin types can't inherit from pure-python abstract bases
2014-10-07 20:58:40 +01:00
William S Fulton
ab79441151 Bypass Python tests not supported by -builtin
The base class is needed for the builtin class hierarchy, like many
other languages
2014-10-07 20:58:40 +01:00
William S Fulton
185d65895f Bypass Python tests not supported by -builtin
There are a number of autodoc comment differences when using -builtin.
Some of which might need fixing, but for now we'll accept them as they
are.
2014-10-07 20:58:39 +01:00
William S Fulton
afcd61388a Bypass Python tests not supported by -builtin
The old static syntax (e.g., dc.new_A() rather than dc.A()) is not
supported with -builtin
2014-10-07 20:58:39 +01:00
William S Fulton
9f1b051c16 Bypass Python tests failing with -builtin
Reverse operators not supported in builtin types
2014-10-07 20:58:39 +01:00
William S Fulton
bbad7f96ab Bypass Python tests throwing base classes as exceptions for -builtin
Throwing builtin classes as exceptions is not supported
2014-10-07 20:58:30 +01:00
William S Fulton
34eb4b15d3 Add some more Python -builtin tests that don't work 2014-10-02 19:08:58 +01:00
Yann Diorcet
558af639bd Python: Fix property access with director 2014-10-01 11:07:02 +02:00