Commit graph

4,668 commits

Author SHA1 Message Date
William S Fulton
c06f2b4497 Remove -cppcast and -nocppcast command line options
The -cppcast option is still turned on by default. The -nocppcast option
to turn off the use of c++ casts (const_cast, static_cast etc) has been
removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts
instead of C++ casts for C++ wrappers.
2018-11-06 10:26:06 +00:00
William S Fulton
23ce449ea5 Remove Python -new_vwm
Use the -newvwm alias name instead.
2018-10-24 20:04:31 +01:00
William S Fulton
39b48b8689 Remove Python -oldrepr option
This option controlled the __repr__ proxy class method.

Also removes:
  -old_repr
  -oldrepr
  -new_repr
  -newrepr

Note: -newrepr was and remains on by default. When -oldrepr/-old_repr
option resulted in code that did not run.
2018-10-24 20:04:31 +01:00
William S Fulton
1274c1abfc Remove Python -classptr option
This option was for backwards compatibility with very old versions of
SWIG that generated a shadow 'XPtr' class derived from proxy class X.

If anyone is still using these, they are best off using the actual proxy
class, or otherwise add them in manually using %pythoncode.

Issue #1340.
2018-10-24 20:04:31 +01:00
William S Fulton
cd8fc0a025 Remove Python -aliasobj0 option
This option was originally added to help users switch to using
-fastunpack so that typemaps using obj0 did not need changing by
providing an alias for swig_obj[0] to obj0. The correct solution was
always to replace obj0 with $self in the typemap. This is now mandatory.
However, the -nofastunpack option can still be used to circumvent using
the mandatory typemap change.
2018-10-22 08:19:50 +01:00
William S Fulton
04c5061698 Hardwire Python -fastunpack be on by default
The -nofastunpack option has been left in as there isn't much code
simplification in removing the nofastunpack code. This is because the
nofastunpack code is still sometimes needed (eg varags and overloaded
functions).
2018-10-22 08:19:50 +01:00
William S Fulton
a1f40568d6 Remove non-const char * usage where the Python API now supports it
Python fixed many APIs to use const char * instead of char * at around
Python 2.4. As we support 2.7 and later, we can now remove the non-const
string usage.
Types changed:
  PyArg_ParseTuple
  PyArg_ParseTupleAndKeywords
  PyArg_UnpackTuple
  PyDict_SetItemString
  PyMethodDef
  PyModuleDef
  SWIG_Python_UnpackTuple
  SWIG_Python_str_FromChar
  SWIG_addvarlink
  swig_const_info
2018-10-22 08:19:50 +01:00
William S Fulton
de26ebbad1 Remove Python -safecstrings option.
This option, if used, has not had any effect on Python 3 code since commit a863d3 9 years ago.
I think we can assume that it is not needed for Python 3.
Running the examples and test-suite (Python 2) doesn't change the code
paths with and without -safecstrings because only SWIG_OLDOBJ and SWIG_NEWOBJ
are used in the typemaps and the following code is thus unaltered by -safecstrings
(which sets SWIG_PYTHON_SAFE_CSTRINGS):

%#if defined(SWIG_PYTHON_SAFE_CSTRINGS)
  if (*alloc != SWIG_OLDOBJ)
%#else
  if (*alloc == SWIG_NEWOBJ)
%#endif
  {
    *cptr = %new_copy_array(cstr, len + 1, char);
    *alloc = SWIG_NEWOBJ;
printf("safe strings: %s\n", *cptr ? *cptr : "NULLSTRING");
  } else {
    *cptr = cstr;
    *alloc = SWIG_OLDOBJ;
  }

Note: nosafecstrings was also the default and -O didn't actually change this.
2018-10-22 08:19:50 +01:00
William S Fulton
b2aa01f492 Python options simplification: Remove -buildnone, -nobuildnone
A custom implementation for Py_None was implemented in SWIG_Py_None().
This was used by default on Windows only. It isn't clear why this
was done just for Windows. Now Py_None is the real Py_None on all
operating systems.
2018-10-22 08:19:50 +01:00
William S Fulton
d84d26832f Hardwire Python -fastquery option to be always on
The Python dictionary cache used for SWIG types lookup is now always on.
2018-10-22 08:19:50 +01:00
William S Fulton
350396fcae Hardwire Python -fastinit option to be always on
This option runs the equivalent init code in Python C code instead of pure Python code.
The init code adds the C++ pointer into the 'this' variable.
If the variable already exists, it appends it. This
seems to only happen in directors and multiple inheritance, see
PyMulti in director_basic_runme.py.
2018-10-22 08:19:50 +01:00
Olly Betts
4a48e59dc6 Hard-wire -noproxydel on
We only still default to generate a no-op __del__ method for theoretical
compatibility with old code, and 4.0.0 is a good time to make a cut-off
should such code really still exist.

On the flip-side, the presence of a __del__ method seems to be able to
prevent garbage collection from kicking in (see #1215), so it's
definitely desirable to get rid of it when there's nothing for it to do.

 Conflicts:
	Source/Modules/python.cxx

This is a cherry-pick and merge from the patch in #1261
2018-10-12 07:10:47 +01:00
Olly Betts
e4fceee12f Hard-wire -modern and -modernargs on
What SWIG calls "modern" classes are supported by Python 2.3 and up
which means they're supported by all the Python versions we aim to
support in 4.0.0.

 Conflicts:
	Source/Modules/python.cxx

This is a cherry-pick and merge from the patch in #1261
2018-10-12 07:10:47 +01: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
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
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
luz.paz
ed28e7cbe2 Misc. typo and whitespace fixes
Found via `codespell -q 3 -L "uint,bae,objext,cmo,goin,struc,ois,upto"`
whitespaces were unintentionally fixed due to my editors settings.

Rebased patch #1327
2018-09-19 20:29:14 +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
040683d1b3 Fix Python -builtin and -fastdispatch regression.
Generated code did not compile
2018-09-06 21:07:59 +01:00
Rokas Kupstys
0a102e2846 Fix class having method Connect() creating a name collision with SwigDirectorConnect().
Issue is fixed by prepending director methods with `SwigDirectorMethod` instead of `SwigDirector`.
2018-09-06 12:43:51 +03: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
c2805e5a44 Change location of Python -fastproxy methods in proxy class
Output methods in the same place that they would be generated in the
proxy class when not using -fastproxy. When using autodoc, the two
definitions of the method are then right after each other.
2018-08-20 07:37:29 +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
Vladimir Kalinin
5a22bcf007 Nested structures in "C" mode symbol table fix 2018-08-14 21:25:35 +03:00
William S Fulton
91e9743014 Fix to make ISOC89 compliant: -Werror=declaration-after-statement 2018-08-10 12:44:23 +01:00
William S Fulton
36a7c49b1e Merge branch 'python-type-error'
* python-type-error:
  Python fastdispatch error message improvements
  Correct PyErr_Fetch/PyErr_Restore variable names
  Overloaded C++ function Python wrappers now raise a TypeError instead of NotImplementedError
2018-08-10 08:17:43 +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
aaa67702ec Cosmetic corrections in python.cxx 2018-08-06 19:51:13 +01:00
William S Fulton
8f224694e7 Python help for py3 update 2018-07-23 07:56:47 +01:00
William S Fulton
89f00ca2f3 Fix pythonnondynamic feature for modern classes and Python 3
Corrects adding metaclass to the nondynamic class so that the
implementation works. Uses metaclass syntax that will work for both
python 2 and 3 or proper Python 3 syntax when using -py3.
2018-07-23 07:26:48 +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
William S Fulton
9f3ee5b965 Doxygen JavaDoc class comments fix
Generate "javaimports" typemap contents before Doxygen JavaDoc comments.
2018-06-17 00:17:07 +01:00
William S Fulton
5cfb04adb7 Show enum name in presence of Doxygen comment for simple Java enums 2018-06-17 00:17:07 +01:00
William S Fulton
cb8d42b750 Doxygen comment JavaDoc indentation fix for simple Java enums 2018-06-17 00:17:07 +01:00
William S Fulton
ae32180709 Remove duplicate doxygen comment when using simple Java enums 2018-06-17 00:17:07 +01:00
William S Fulton
ecc66fdcbd Add Doxygen test for constant and fix JavaDoc indentation 2018-06-17 00:17:07 +01:00
William S Fulton
50d7f36f45 Correct JavaDoc from doxygen comments indentation
Adds missing JavaDoc indentation for doxygen comments obtained from:
- enum values
- class methods
- constructors
- global functions/variables
2018-06-17 00:16:57 +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
Olly Betts
7f98830110 [Python] Fix new GCC8 warnings in generated code
Avoid casts between incompatible function types where possible (when
keyword args are in use, it is not possible to avoid such warnings as
they are inherent in the design of Python's C API in that particular
case).  Fixes #1259.
2018-06-11 15:51:53 +12:00
Olly Betts
1198155083 Drop Python 2.6 support too
See #701.
2018-06-08 11:08:31 +12:00
Philipp Kraft
0f88f9997c Stop exposing <CLASS>_swigregister to Python
It's not useful for user Python code to call this, and it just clutters the API unnecessarily.

Fixes #1225
2018-06-08 10:31:49 +12:00
Olly Betts
7c034ead32 Remove special handling for Python < 2.6
See #701.
2018-06-08 09:34:48 +12:00
William S Fulton
33921666a1 Merge branch 'vadz-doxygen'
This is the Doxygen work begun in Google Summer of Code projects 2008
and 2012 and subsequently improved by numerous contributors.

* vadz-doxygen: (314 commits)
  Add changes entry for Doxygen support
  Add some missing doctype tyemaps
  Doxygen warnings cleanup
  Move doxygen warning numbers
  Add Python doxygen example
  Doxygen example
  Add Doxygen to include paths
  Doxygen source rename
  More merge fixes from doxygen branches
  Correct python example headers
  Correct source code headers
  Another merge fix from doxygen branches
  Java enums output format fixes
  Add omitted doxygen_parsing_enums testcase
  PEP8 conformance for comment verifier module
  Clean up merge problem
  Doxygen html tweaks
  Update html chapter numbering for added Doxygen chapter
  Fixes to makechap.py to detect ill-formed headers
  html fixes for Doxygen
  Add missing CPlusPlus17.html file
  Format files to unix format
  Doxygen testcase tweak to match that in the html docs
  Doxygen html documentation updates and corrections
  Remove doxygen Examples subdirectory
  Beautify doxygen source code
  Code formatting fixes in doxygen code
  Remove unused doxygen code
  new_node refactor
  Various merge fixes in doxygen branches
  Unused variable warning fix
  Fix wrongly resetting indent after formulae in Doxygen comments
  Add support for doxygen:alias feature
  Get rid of meaningless return type of DoxygenParser methods
  Return enum, not untyped int, when classifying Doxygen commands
  Get rid of unnecessary "typedef enum" in C++ code
  Use slash, not backslash, in "C/C++" in the documentation
  Replace literal "<" with "&lt;" in HTML documentation
  Fix broken link to java.sun.com in Doxygen documentation
  Fix using com.sun.tools.javadoc package under macOS
  Fix error reporting for special characters in Doxygen parsing code
  Switch Python Doxygen unit tests to use inspect.getdoc()
  Use correct separator in Java class path under Windows.
  Remove executable permission from appveyor.yml.
  Use JAVA_HOME value in configure to detect Java.
  Display JAVA_HOME value in "make java_version".
  Fix harmless MSVC warning in DoxygenTranslator code.
  Reset "_last" for all but first enum elements.
  Don't duplicate Javadoc from global enum Doxygen comments twice.
  Move Doxygen comments concatenation from the parser to the lexer.
  Fix shift/reduce conflicts in Doxygen pre/post comment parsing.
  Rewrote part of the grammar dealing with Doxygen comments for enums.
  No changes, just remove spurious white space only differences.
  Move Doxygen comment mangling from the parser to the lexer.
  Merge "-builtin" autodoc bugs workarounds from master into test.
  Quote JAVA_HOME variable value in Java test suite makefile.
  Remove unused C_COMMENT_STRING terminal from the grammar.
  Fix missing returns in the Doxygen test suite code.
  Fix trimming whitespace from Doxygen comments.
  Remove code not doing anything from PyDocConverter.
  Remove unused <sstream> header.
  Remove unreferenced struct declaration.
  Remove unused Swig_warn() function.
  Remove any whitespace before ignored Doxygen commands.
  Remove trailing space from one of Doxygen tests.
  Fix autodoc strings generated in Python builtin case and the test.
  Fix Doxygen unit test in Python "-builtin" case.
  Use class docstrings in "-builtin" Python case.
  Don't indent Doxygen doc strings in generated Python code.
  Add a possibility to flexibly ignore custom Doxygen tags.
  Stop completely ignoring many Doxygen comments.
  Fix structural Doxygen comment recognition in the parser.
  No changes, just make checking for Doxygen structural tags more sane.
  Use "//", not "#", for comments in SWIG input.
  Allow upper case letters and digits in Doxygen words.
  Pass the node the Doxygen comment is attached to to DoxygenParser.
  Get rid of findCommand() which duplicaed commandBelongs().
  Recognize unknown Doxygen tags correctly.
  No real changes, just pass original command to commandBelongs().
  Describe Doxygen-specific %features in a single place.
  Give warnings for unknown Doxygen commands in Doxygen parser.
  Document the return type when translating Doxygen @return to Python.
  Fix translated Doxygen comments for overloaded functions in Python.
  Also merge Doxygen comments for overloaded constructors in Python.
  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.
  Simplify and make more efficient building Python docstrings.
  Translate Doxygen code blocks to Sphinx code blocks.
  Add a simple test of multiple parameters to Doxygen test suite.
  Make Python parameters types hyperlinks in the doc strings.
  Make Language::classLookup() and enumLookup() static.
  Fix arguments of @param, @return etc translations to Python.
  Remove unused method from PyDocConverter.
  No real changes, just remove an unnecessary variable.
  Preserve relative indentation when parsing Doxygen comments.
  Use Sphinx-friendly formatting for overloaded functions documentation.
  Add poor man trailing white space detection to Doxygen Python tests.
  ...
2018-06-07 08:13:10 +01:00
Olly Betts
d7ac8581b1 [php] Drop support for long-deprecated %pragma(php4)
Finally removed support for %pragma(php4) which was deprecated back in
2008.  The replacement is %pragma(php), which has been supported since
at least 2005.
2018-06-07 18:09:14 +12:00
Olly Betts
d6d5db122b Remove support for PHP5
PHP5 is no longer actively supported by the PHP developers and security
support for it ends completely at the end of 2018, so it doesn't make
sense to include support for it in the upcoming SWIG 4.0.0 release.

See #701.
2018-06-07 18:09:03 +12:00
William S Fulton
396910c100 Doxygen warnings cleanup
- Remove unused warnings.
- Refactor some warnings.
- Document all Doxygen warnings.
2018-06-05 18:40:30 +01:00
William S Fulton
15f16155f2 Move doxygen warning numbers
Move out of the range reserved for language modules
2018-06-01 21:00:06 +01:00
William S Fulton
ec2cb809cd Add Doxygen to include paths 2018-05-29 06:59:26 +01:00
Olly Betts
d721b4d639 Fix comment typo "aruments" 2018-05-29 09:00:18 +12:00