Commit Graph

644 Commits

Author SHA1 Message Date
Olly Betts 9ddc9dceb7 Remove support for $source and $target
These were officially deprecated in 2001, and attempts to use them have
resulted in a warning (including a pointer to what to update them to)
for most if not all of that time.

Fixes #1984
2021-04-30 10:20:14 +12:00
Olly Betts 0bf846f56f Eliminate unused Printf args 2021-04-13 10:43:51 +12:00
Olly Betts 1757f548a4 Make -py3 generate a check for Python >= 3.0
Closes #1777
2021-04-12 15:07:00 +12:00
William S Fulton 90cdbee6a6 Python -builtin fix wrapping constructors with varargs
Fix compilation error when using -builtin and wrapping varargs in constructors

Closes #1942
2021-03-23 23:57:49 +00:00
Michel Zou ee8d47cec4 Fix few unused variable warnings 2021-03-07 11:20:31 +00:00
William S Fulton e774fe5cfd Python 3.9 support for -builtin
Add missing initializer for member ‘_heaptypeobject::ht_module’ to complete
Python 3.9 support.
2020-08-27 20:22:39 +01:00
Vadim Zeitlin f57b096c92 Fix generated Python code for Doxygen comments with triple quotes
In addition to the changes in the previous commit, also avoid syntax
errors in the generated Python docstrings by splitting them into several
parts if there are 3 quotes in a row in the input, as it's impossible to
have them inside triple-quoted strings, generally speaking (i.e. if
there are occurrences of both """ and ''' inside the string).
2020-03-04 00:57:31 +01:00
Vadim Zeitlin b81cd1bdab Fix generated Python code for Doxygen comments ending with quote
Single-line Doxygen comments ending with a double quote resulted in
syntactically-invalid Python docstrings in the output, so use triple
single quotes as delimiters in this case to avoid it.
2020-03-04 00:56:27 +01:00
Vadim Zeitlin e14532ce52 Fix crash in Python backend when using empty docstrings
Due to confusion in build_combined_docstring(), we could call
DohDelete() on the "feature:docstring" string, which resulted in a crash
when trying to use it later.

Fix this and simplify the code at the same time by ensuring that we
always use a copy of "feature:docstring" if it's not empty or don't use
it at all if it's empty -- like this we don't have to check for its
length each time before using it.

Closes #1648.
2020-01-30 16:11:18 +01:00
William S Fulton 3759fcf999 Merge branch 'builtin-ctor-kwargs'
* builtin-ctor-kwargs:
  Python -builtin constructors silently ignored keyword arguments.
2020-01-13 19:29:47 +00:00
William S Fulton 67e8334ac8 Python -builtin constructors silently ignored keyword arguments.
Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments"
exception is thrown if keyword arguments are used. Hence constructors and normal
methods/functions behave in the same way.

Closes issue #1595
2020-01-13 19:26:22 +00:00
William S Fulton 489629fd53 Python 3.8 builtin tp_print initializer
Add missing initializer for tp_print added in python-3.8
when using -builtin

Issue #1670
2020-01-05 22:40:41 +00:00
Alexander Shadchin eaa16914d1 Adding tp_vectorcall field to PyTypeObject for Python version 3.8 2020-01-05 03:32:10 +03:00
William S Fulton cb5d7398b5 Fix bug in Python builtin support for keyword args
The fix is when using kwargs feature or -keyword.
The fix is in the argument error checking when wrapping zero
argument constructors only. Supplied keyword args were silently
ignored.

Issue #1595
2019-11-01 19:46:42 +00:00
William S Fulton 2cf075558c Replace all exit() with SWIG_exit()
For consistent cleanup on error
2019-07-31 00:08:49 +01:00
Vadim Zeitlin 0ff6893b2d Make Python module source non-executable again
0f88f9997c (probably accidentally) changed
this file to be executable, undo this as it doesn't make sense for a
source file to have this mode.

See #1242.
2019-07-24 20:10:35 +02:00
Dmitry D. Chernov c20b6f5b0e Generator: Unify string quoting in generated Python sources 2019-07-14 11:08:17 +10:00
Dmitry D. Chernov 9f79fb5216 Generator: Remove trailing whitespaces in the Python module 2019-07-14 11:06:10 +10:00
William S Fulton 4301fa548d Remove some legacy cruft from Python proxy class
These methods are no longer used:
_swig_getattr
_swig_setattr
_swig_setattr_nondynamic
2019-06-27 07:40:49 +01:00
luz.paz 87695dacb1 Misc. documentation and source comment typo fixes
Found via `codespell -q 3 -L uint,od,objext,ba,cmo,bae,ans,struc,fo,clos,goin,upto,thru`
Revert changes in previous commit
2019-05-28 11:41:22 +12:00
William S Fulton 39599f2112 Always use fastunpack for Python swigconstant wrappers 2019-03-21 21:17:21 +00:00
William S Fulton 9f0b9da024 Always use fastunpack for Python swigregister function 2019-03-21 20:59:54 +00:00
William S Fulton 826f1448b8 Fix Python low-level static member setters.
The low-level API for setting static member variables stopped working
when the fastunpack option was turned on by default. The PyMethodDef
setup requires METH_O, not METH_VARARGS with fastunpack.
2019-03-20 21:44:34 +00:00
Zackery Spytz a0b84f5180 Fix some MSVC compiler warnings in the test suite
nested_in_template_wrap.cxx(247): warning C4244: 'initializing': conversion from 'double' to 'int', possible loss of data
python_pybuffer_wrap.cxx(2788): warning C4267: 'return': conversion from 'size_t' to 'int', possible loss of data
Modules\python.cxx(2227) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
2019-03-07 09:44:01 -07:00
William S Fulton 83ea2280e2 Fix Python compile errors with overloading and varargs
Fixes wrapping overloaded functions/constructors where a vararg
function is declared after a non-vararg function.
This is a long standing bug in the Python layer exposed since fastunpack
was turned on by default.
2019-02-25 19:27:23 +00:00
William S Fulton 43438b66ab Re-organise some generate Python code for method creation and docstring support
Fix ‘PyMethodDef* SWIG_PythonGetProxyDoc(const char*)’ declared ‘static’ but
never defined [-Wunused-function]

Closes #1448
2019-02-10 22:55:16 +00:00
William S Fulton b50e5fac8e Python docstring - add in missing Delete calls 2019-02-03 00:28:53 +00:00
William S Fulton 64a7678759 Remove some unnecessary casts in Python builtin code 2019-02-03 00:28:02 +00:00
William S Fulton 62c5ca89a6 Minor refactoring of generated Python code 2019-02-03 00:27:57 +00:00
William S Fulton fddaf3f814 Minor refactoring of Python autodoc related code 2019-02-02 21:42:47 +00:00
Alec Woods 120a6df838 Apparently nicely lining things up violates pep8, so don't try 2019-01-26 13:39:50 -05:00
Alec Woods ed81f8ac73 Don't use bool in the generated files for C compatability 2019-01-26 09:30:26 -05: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 e150d58092 Fixing a bug where the cached doxygen docstring could be deleted while still in use, causing swig to segfault 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 97a624f360 Fix a bug where anonymous arguments were misnumbered when used in constructors 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
William S Fulton 8a1ad6adc6 Merge branch 'vadz-py-restore-autodoc-defval'
* vadz-py-restore-autodoc-defval:
  Always include default parameter values in Python autodoc strings
2019-01-22 07:21:31 +00:00
William S Fulton d8478d671d Fix segfault using -python -noproxy and %pythonbegin 2019-01-21 07:50:48 +00: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
Olly Betts 3b03f920e7 Suppress warnings about PyCFunction casts
These remaining warnings are due to the design of Python's C API,
so suppress them by casting via void(*)(void) (which GCC documents
as the way to suppress this warning).

Closes #1259.
2019-01-20 12:27:36 +13: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 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 3f5c17824c Improve handling parameters clashing with language keywords
Previously, only Python tried to preserve the original parameter name
(by prepending or appending an underscore to it, but otherwise keeping
the original name) if it conflicted with one of the language keywords,
while all the other languages replaced the parameter name with a
meaningless "argN" in this case.

Now do this for all languages as this results in more readable generated
code and there doesn't seem to be any reason to restrict this to Python
only.
2019-01-16 04:16:59 +01:00
William S Fulton 07884f10ee Python - remove duplicate proxy method definitions for global function wrappers.
Global functions previously generated two definitions, eg:

  def foo():
      return _example.foo()
  foo = _example.foo

The first definition is replaced by the second definition and so the second definition
is the one used when the method is actually called. Now just the first definition is
generated by default and if the -fastproxy command line option is used, just the second
definition is generated. The second definition is faster as it avoids the proxy Python
method as it calls the low-level C wrapper directly. Using both -fastproxy and -olddefs
command line options will restore the previously generated code as it will generate both
method definitions.

With this change, the wrappers for global C/C++ functions and C++ class methods now work
in the same way wrt to generating just a proxy method by default and control via
-fastproxy/-olddefs options.

Closes #639.
2019-01-01 12:12:56 +00:00
William S Fulton d314b53820 Python -newvwm command line option remains undocumented
Remove option from -help output text
It is hard to explain exactly what it does and is unclear as to how useful it is!
2018-12-18 19:51:38 +00:00
William S Fulton 5d6786598c Python command line options tidyup 2018-12-18 19:51:38 +00:00
William S Fulton 398ac5f01c Remove redundant Python options: -nocastmode -nodirvtable -noextranative -nofastproxy
Also remove redundant %module options: nocastmode, noextranative
Issue #1340
2018-12-18 19:51:32 +00:00
William S Fulton 152b66deaf Tidy up Python command line options help text
Also remove non-existent -noexcept option
2018-12-18 18:32:55 +00:00