Commit Graph

644 Commits

Author SHA1 Message Date
William S Fulton e5a09c4141 Add additional Python builtin slots as features for user customization
Added:
- tp_is_gc
- tp_bases
- tp_mro
- tp_cache
- tp_subclasses
- tp_weaklist
- tp_del
- tp_allocs
- tp_frees
- tp_maxalloc
- tp_prev
- tp_next
2016-08-22 07:51:42 +01:00
William S Fulton 3b6f4af15c Set tp_new statically rather than during initialisation 2016-08-21 14:29:27 +01:00
William S Fulton 3744c45082 Customize slots tp_basicsize tp_methods tp_getset 2016-08-19 23:46:50 +01:00
William S Fulton 239785ce7d Additional Python builtin slot overrides and slightly better formatted Python generated code
The following slots can now be overidden by users if they know what they
are doing:
- tp_dictoffset
- tp_init
- tp_new
- tp_as_number
- tp_as_sequence
- tp_as_mapping
- tp_as_buffer
2016-08-19 23:16:32 +01:00
William S Fulton 67ece1d2bf Python getSlot() refactor
getSlot() now takes a default that can override "0" default - simpler
code and for future commits to override some currently non-overridable
slots.
2016-08-19 08:43:40 +01:00
William S Fulton a3fc743f32 Add Python builtin closure method in comment
For less mystifying code and easier code searching
2016-08-18 08:41:07 +01:00
William S Fulton 9b73cd036f Avoid polluting global python namespace with version_info symbol 2016-06-07 08:12:48 +01:00
William S Fulton 81adedd7dd Python: Do not import all of sys when using -relativeimport 2016-06-06 22:20:07 +01:00
Mike Romberg d55151ac70 > to >= 2016-06-06 13:26:55 -06:00
Mike Romberg 9ce4b58df4 Make the check for python3 -relative does python runtime check. 2016-06-06 01:28:40 -06:00
Mike Romberg 1495313e53 fix for new split module test cases. 2016-06-02 23:56:15 -06:00
William S Fulton bee6964b48 Compile warning fix 2016-05-28 15:13:23 +01:00
William S Fulton d01efd82e1 Merge branch 'mromberg-implpkg'
* mromberg-implpkg:
  Minor edits to Python implicit namespace package docs
  use %inline for test
  use relative import for -builtin and python2
  Python3 removes support for relative imports
  Document implicit namespace packages for python
  disable namespace package build
  Attempt to calm the testing gods...
  use whatever name winders uses for .so files.
  Examples (and tests) for python namespace packages
  disable namespace package build
  spelling
  Attempt to calm the testing gods...
  use whatever name winders uses for .so files.
  Don't run example for old pythons
  Examples (and tests) for python namespace packages
  use importlib to load C extension modules for python 2.7 and newer
2016-05-24 22:48:37 +01:00
Mike Romberg 10d71ca01a use relative import for -builtin and python2 2016-05-24 22:46:35 +01:00
William S Fulton 5e6ab1d61d Merge branch 'ejulien-python_operator_overload_test_suite'
* ejulien-python_operator_overload_test_suite:
  Add __str__ to operator_overload testcase for python builtin
  Python operator_overload runtime testcase cleanup
  Work around a limitation of the Python binding generator related to the += family of operators.
  Fix Python 3 division member operator when -builtin is not used.
  Fix class member division operator.
  Remove the PY3BUILTIN switch as its behavior can be achieved with the existing SWIG_FEATURES=-builtin switch.
  Implement the operator overload test suite for Python.

Conflicts:
	Examples/test-suite/operator_overload.i
2016-05-05 23:01:35 +01:00
Mike Romberg ca63491d7a Python3 removes support for relative imports 2016-04-05 11:10:04 -06:00
Mike Romberg 23d2eb555f use importlib to load C extension modules for python 2.7 and newer 2016-04-05 10:58:50 -06:00
William S Fulton a97441613e Merge branch 'ahnolds-py_gettar'
* ahnolds-py_gettar:
  update changes file for attribute fix
  Add python AttributeError test for non-existent attribute
  Fixing python attribute lookup

Conflicts:
	CHANGES.current
2016-04-02 18:06:03 +01:00
Ling Li 79bb343ffe Fix single arguments using python -builtin -O with %feature("compactdefaultargs")
Setattr argcount for non-default-args and non-varargs functions.
Fixes #607
Closes #610
2016-04-02 11:29:43 +01:00
Paweł Tomulik 174523aa80 fix handling of function pointers by %constant directive 2016-03-24 11:22:51 +01:00
Paweł Tomulik 0c819d1ba9 prevent _swigconstant boilerplate for non-class types 2016-03-15 10:27:13 +01:00
Emmanuel Julien 8df7c5fb7e Fix Python 3 division member operator when -builtin is not used. 2016-02-22 16:30:24 +01:00
Emmanuel Julien cf370fb504 Fix class member division operator.
Define the nb_divide/nb_inplace_divide slots in the interface and use it them as nb_divide/nb_inplace_divide for Python 2.x and as nb_true_divide/nb_inplace_trus_divide for Python 3.x.

The Python 3.x nb_floor_divide/nb_inplace_floor_divide slots (operator // in Python) are not populated by the interface.
2016-02-22 14:54:19 +01:00
Alec Cooper 506a5bc8e6 Don't claim to new-style support in classic mode 2016-02-04 15:27:54 -05:00
Alec Cooper 475d03f195 Clean up setting _object
Don't bother setting _object in modern mode since it isn't used
Catch __builtin__.Exception rather than AttributeError since the check for
object hasn't been through something that would raise an AttributeError since
3d8ddfc4 in 2008
2016-02-04 15:27:54 -05:00
Alec Cooper 866429d0f7 Removing __swig_getmethods__ for static methods
Static methods will always be found by normal attribute lookup, so there's no
need to check for them during __getattr__ (aka _swig_getattr_nondynamic)
2016-02-04 15:27:54 -05:00
Alec Cooper b45164e098 Support python(pre|ap)pend on static methods in classic mode
Adding a test that covers this case to the python_append test-suite
Note: staticmethod function has been available since Python 2.2
2016-02-04 15:27:54 -05:00
Alec Cooper d91064aa6a Add support for static methods in classic mode 2016-02-04 15:27:54 -05:00
Alec Cooper de4b3a4a59 Fixing python attribute lookup
Cleans up patch #232
Fixes misleading error messages from #588

If __getattr__ is called, this means that normal attribute lookup has failed.
  If checking thisown and __swig_getmethods__ fails, then give up and raise
  AttributeError instead of calling the non-existent object.__getattr__.
  Note that in practice the result is essentially the same, since trying to
  access object.__getattr__ fails and raises AttributeError, just with a
  misleading message.
In addition, there's no point in having nondynamic attribute lookup.
2016-01-24 15:40:34 -05:00
William S Fulton 55f303d286 Merge pull request #584 from benmwebb/master
(Python) Qualify use of "__builtin__.Exception" class.
2016-01-23 23:24:34 +00:00
Ben Webb 2a5bbb6018 Qualify use of "__builtin__.Exception" class.
It is possible that the module we're wrapping defines an Exception
class. This will confuse code that uses an unqualified "Exception"
class (e.g. "try: ... except Exception") since it now won't match
the Python builtin Exception. Fix this by explicitly using
the class from the __builtin__ module ("builtins" in Python 3).
2016-01-11 21:43:10 -08:00
Olly Betts 584b328239 Fix minor memory leak in Python module docstring handling
Noted in #582 by aurelj.
2016-01-12 13:49:55 +13:00
Olly Betts f910607e26 Fix typo: "neccessary" -> "necessary" 2016-01-12 13:37:39 +13:00
Petre Eftime 0a07cd4c30 Prevent redefinition warnings when compiling with SWIG<module> defined
Signed-off-by: Petre Eftime <petre.p.eftime@intel.com>
2015-12-22 14:33:21 +02:00
William S Fulton f77839dfbf Initialize missing PyNumberMethods for Python 3.5 and -builtin
Add nb_matrix_multiply nb_inplace_matrix_multiply
2015-12-16 18:32:21 +00:00
William S Fulton 3e27d45b2a Merge branch 'ahnolds-python34'
* ahnolds-python34:
  Python tp_allocs -> tp_next corrections
  Cosmetic correction for Python tp_version -> tp_version_tag
  Add -Wmissing-field-initializers to python Travis testing
  Python 3.3 builtin missing field initializers added
  Adding tp_finalize field to PyTypeObject for Python 3.4 and -builtin
  Adding nb_matrix_multiply and nb_inplace_matrix_multiply fields to PyNumberMethods for Python version 3.5 and up
  Adding tp_finalize field to PyTypeObject for Python version 3.4 and up
2015-12-14 01:59:39 +00:00
William S Fulton 5f93c94e87 Python tp_allocs -> tp_next corrections
Updates for Python 2.5 and later and for -builtin.
2015-12-14 01:56:11 +00:00
William S Fulton f7b9466dff Python 3.3 builtin missing field initializers added
Add in ht_qualname and ht_cached_keys for Python 3.3 and later
2015-12-14 01:22:41 +00:00
William S Fulton 5724195b8b Adding tp_finalize field to PyTypeObject for Python 3.4 and -builtin 2015-12-14 01:22:41 +00:00
William S Fulton c5322a9ecb Python use Py_ssize_t instead of int for better portability 2015-12-05 09:00:04 +00:00
William S Fulton ed044e4b8c Warning fix for Visual Studio 2015-11-28 18:48:52 +00:00
William S Fulton ef001de524 Support Python 3.5 and -builtin.
PyAsyncMethods is a new member in PyHeapTypeObject.
Closes#539
2015-10-10 01:25:52 +01:00
William S Fulton faeaacf112 smartptr feature support - factor out common code 2015-09-25 22:57:59 +01:00
Olly Betts 8a6874e633 Fix docstrings for callback functions with -builtin 2015-09-04 15:29:06 +12:00
Olly Betts 8ab622c6d0 [Python] Fix docstrings for %callback functions
Reinstates autodoc for callback function testcase from #467, actually
tests the resulting docstring in the _runme.py and fixes SWIG/Python
so the expected result is obtained.
2015-09-04 13:04:37 +12:00
Sjoerd Job Postmus 5be177e5c3 Do not use bare exception in generated Python code.
By using the 'except:', you can catch all kinds of exceptions, including
the KeyboardInterrupt and SystemExit exceptions. From the generated
code, it is quite obvious that it is not these cases that should be
caught, but more specific ones like AttributeError and TypeError. To be
on the safe side, I decided to keep using 'Exception' for now.
2015-08-28 17:43:28 +02:00
xantares 92328a2016 pep257 & numpydoc conforming docstrings 2015-08-07 22:15:13 +01:00
William S Fulton e69cc0c0f5 Improve python code indentation warning / error messages 2015-07-30 08:26:17 +01:00
William S Fulton a779f9bbc1 Function comment header formatting corrections 2015-07-30 08:26:17 +01: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
xantares 812f789db6 Avoid gcc uninitialized variable warnings in Python wrappers.
Just initialize the local array with zeroes.

Closes #453.
2015-07-25 19:10:06 +02:00
Vadim Zeitlin 302955a152 Another merge with master.
Updated Doxygen error numbers yet again, as Python errors got added in the
meanwhile, pushing the Doxygen ones further off.

And re-merged PEP8/whitespace-related conflicts in autodoc_runme.py once again
(if anybody is looking for a motivating example about why significant
whitespace is bad, here is a great use case).
2015-07-20 00:44:26 +02:00
Michael Thon 7ed63b11d7 Set class docstring in tp_doc slot for python -builtin 2015-07-09 02:05:33 +02:00
William S Fulton edcdaaec16 Warning fixes for 64bit visual c++ on Windows 2015-07-03 20:59:24 +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 53b7659ebf Fix Python pep8 warning when using -fastinit (or -O)
Fixes: E231 missing whitespace after ','
2015-06-16 08:11:29 +01:00
William S Fulton 180e21269d Fix python -builtin -O and overloaded functions
More specifically fixes compile errors using -builtin -fastunpack -modernargs.
Recent regression (416277b). Closes #436.
2015-06-16 07:59:22 +01: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 0a70498591 Refactor PYTHON::convertValue
Remove multiple return statements for upcoming commits.
2015-05-27 08:06:23 +01: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 d64c241e1c gcc-5.1 warning fixes 2015-04-26 01:18:26 +01: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
William S Fulton e4d02d20ad Warning fix for VC++ 2015-04-23 19:21:59 +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 2369e2c500 No changes, just added an explanatory comment to Python module.
Explain a bit better when and why do we decide to use "*args" in the generated
Python code.
2015-04-23 15:11:02 +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 b886a54fce Merge branch 'amaeldoe-master'
* amaeldoe-master:
  Add python runtime test for dynamically added attributes
  Attribute of SWIG wrapped classes instances were overwritten on __init__()
  Fix SwigPyObject->dict memory leak
  Make __dict__ accessible for Python builtin classes
2015-04-11 12:37:11 +01:00
Yoann Vandoorselaere 92b88db7ab Make __dict__ accessible for Python builtin classes
Attribute set within instance of a SWIG Python wrapped class are
stored in SwigPyObject->dict, which tp_dictoffset slot is pointing to.

However, SWIG wrapped classes did not have a __dict__ attribute.
Inheriting subclasses did not get the attribute either because the
SWIG wrapped classes initialize the tp_dictoffset slot:

From http://bugs.python.org/issue16272:

"If a type defines a nonzero tp_dictoffset, that type is responsible for
defining a `__dict__` slot as part of the tp_getset structures. Failure to
do so will result in the dict being inaccessible from Python via
`obj.__dict__` from instances of the type or subtypes."

Provide a SwigPyObject_get___dict__() function to retrieve the dict
attribute or create it when it does not exist yet (it is normally
created when setting attribute set), and a PyGetSetDef entry pointing
to this function.
2015-04-11 02:05:06 +07:00
Olly Betts 7ba0652677 Create director_common.swg for language-indep code
Move -DSWIG_DIRECTOR_STATIC handling there, so this is now supported for
all languages with director support, not just Python and PHP.
2015-03-12 19:51:11 +13:00
Vadim Zeitlin d92bc54662 Remove unused <sstream> header.
std::stringstream is not used in this file, so it is unneeded.
2015-02-16 23:55:01 +01:00
Vadim Zeitlin 300ccce46c Another merge with master.
Change Doxygen error codes to start at 740 instead of at 720 as the latter was
taken by Scilab in the meanwhile.

Resolve conflicts in autodoc_runme.py once again.
2015-02-16 23:46:39 +01:00
William S Fulton 39a75442a1 Fix Python -classic and property setting
Setting properties on classic classes was broken in swig-3.0.3 by attempting to use __setattr__. This regression is fixed now by using __dict__ again when using -classic.

Fixes patch #232.
2015-01-30 23:27:22 +00:00
William S Fulton 727d74f6be Python C89 fix mixed code and declarations compiler error in constants code from patch #250 2015-01-28 08:09:06 +00:00
William S Fulton 760d603918 Warning and error fixes for Solaris Sun Studio compiler 2015-01-27 19:30:24 +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 944fbfb426 Python 3 default args fix
Fix 0U and 0L as default args for Python 3 (tests committed in
previously commit of default_args.i).
Relates to issue #294.
2015-01-13 07:55:31 +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 06e361dbf2 Fix linux gcc warnings and strtol corrections 2015-01-11 17:30:25 +00:00
Vadim Zeitlin adbe3f2e77 Python default arg improvements
Merge the code fixes from patch #294 to more reliably generate
default argument values into the python layer.
2015-01-11 16:42:21 +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 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
Vadim Zeitlin fd47e6870e Fix autodoc strings generated in Python builtin case and the test.
Use the proper AUTODOC_METHOD for autodoc strings generation when using
"-builtin", there is no reason to use AUTODOC_FUNC here when AUTODOC_METHOD is
used by default (i.e. without "-builtin").

This allows to (almost) stop differentiating between the two cases in the
autodoc unit test, allowing to simplify it significantly.

Also fix this test to pass after the recent changes removing docstring
indentation in the generated code.
2014-12-15 20:27:46 +01:00
Vadim Zeitlin d5c5cd4521 Use class docstrings in "-builtin" Python case.
Put the docstring into tp_doc slot which exists exactly for this purpose.
2014-12-15 13:59:17 +01:00
Vadim Zeitlin 410b508e9a Don't indent Doxygen doc strings in generated Python code.
This is unnecessary and inconsistent with "builtin" case in which the
docstrings are not indented in the generated C++ code, thus making it
impossible to write tests working in both cases.

Most of the changes in this commit simply remove the extra whitespace from the
expected values in the tests.
2014-12-15 13:59:17 +01:00
Vadim Zeitlin 9b857e6cf1 Merge latest master into doxygen branch. 2014-12-15 02:55:26 +01:00
William S Fulton 6d6cefa791 Fix 'self' parameter name clash when generating for Python builtin 2014-10-31 07:23:08 +00:00
William S Fulton cd725fbe94 Minor cosmetic source code changes 2014-10-28 07:07:44 +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
William S Fulton b57a675d00 Cosmetic comment changes
Note: copyrights are in the COPYRIGHT file
2014-10-21 07:34:51 +01:00
Yann Diorcet 558af639bd Python: Fix property access with director 2014-10-01 11:07:02 +02:00
Olly Betts 926fd75878 Additional fixes for #218. 2014-09-02 23:12:09 -03:00
Olly Betts f3a6c55929 [Python] Fix regression in indentation of python code produced with -modern,
introduced by changes in #188.  Reported by fabiencastan in #218.
2014-09-02 02:34:01 -03:00
Vadim Zeitlin 52bd2a1921 Allow using enum elements as default values for Python functions.
Enum values are just (integer) constants in Python and so can be used as the
function default values just as well as literal numbers, account for this when
checking whether function parameters can be represented in Python.

Also rename is_primitive_defaultargs() to is_representable_as_pyargs() to
describe better what this function does.
2014-08-22 17:45:24 +02:00
Vadim Zeitlin 8734c658d7 Don't always use "*args" for all Python wrapper functions.
Due to what seems like a bug introduced during Python 3 support merge, all the
generated Python functions used the general "*args" signature instead of using
the named parameters when possible.

This happened due to is_primitive_defaultargs() always returning false for the
functions without any default arguments as "value" passed to convertValue()
was NULL in this case and convertValue() always returns false for NULL.

Fix this by checking for value being non-NULL before calling convertValue().

Doing this exposed several problems with the handling of unnamed, duplicate
(happens for parameters called INOUT, for example) or clashing with keywords
parameter names, so the code dealing with them had to be fixed too. Basically
just use makeParameterName() consistently everywhere.
2014-08-22 17:45:23 +02:00
Vadim Zeitlin 1f41850e34 No real changes, just make PYTHON::check_kwargs() const.
This will allow calling it from const methods too.
2014-08-22 17:45:23 +02:00
Vadim Zeitlin 9a511f1a33 Remove long line wrapping from Python parameter list generation code.
This doesn't play well with PEP8 checks which imposes very strict continuation
line indentation rules which need to be _visually_ aligned, i.e. the subsequent
lines must be indented by the position of the opening bracket in the function
declaration line, but the code generating the parameter lists doesn't have
this information and so it's impossible to do it while avoiding either E128 or
E123 ("continuation line {under,over}-indented for visual indent" respectively)
error from pep8.

Moreover, the wrapping code didn't work correctly anyhow as it only took into
account the length of the parameter list itself and not the total line length,
which should include the function name as well.

So just disable wrapping entirely, long lines shouldn't be a problem anyhow in
auto-generated code.
2014-08-22 17:45:23 +02:00
Vadim Zeitlin 16548cced0 Simplify and make more efficient building Python docstrings.
Make the rules for combining explicitly specified docstring, autodoc one and
the one obtained by translating Doxygen comments implicit in the structure of
the code itself instead of writing complicated conditions checking them.

This results in small changes to the whitespace in the generated Python code
when using autodoc, but this makes it PEP 8-compliant, so it is the right
thing to do anyhow.

Also cache the docstring built from translated Doxygen comments. The existing
code seemed to intend to do it, but didn't, really. This helps with
performance generally speaking (-10% for a relatively big library using a lot
of Doxygen comments) and also makes debugging Doxygen translation code less
painful as it's executed only once instead of twice for each comment.

Finally, avoid putting "r", used for Python raw strings, into docstrings in C
code, it is really not needed there.
2014-08-22 17:45:23 +02:00
Vadim Zeitlin 15b369028f Allow using enum elements as default values for Python functions.
Enum values are just (integer) constants in Python and so can be used as the
function default values just as well as literal numbers, account for this when
checking whether function parameters can be represented in Python.

Also rename is_primitive_defaultargs() to is_representable_as_pyargs() to
describe better what this function does.
2014-08-17 01:08:32 +02:00
Vadim Zeitlin fdc6bbeda3 Don't always use "*args" for all Python wrapper functions.
Due to what seems like a bug introduced during Python 3 support merge, all the
generated Python functions used the general "*args" signature instead of using
the named parameters when possible.

This happened due to is_primitive_defaultargs() always returning false for the
functions without any default arguments as "value" passed to convertValue()
was NULL in this case and convertValue() always returns false for NULL.

Fix this by checking for value being non-NULL before calling convertValue().

Doing this exposed several problems with the handling of unnamed, duplicate
(happens for parameters called INOUT, for example) or clashing with keywords
parameter names, so the code dealing with them had to be fixed too. Basically
just use makeParameterName() consistently everywhere.
2014-08-17 01:08:32 +02:00
Vadim Zeitlin 80a72d50c7 No real changes, just make PYTHON::check_kwargs() const.
This will allow calling it from const methods too.
2014-08-16 13:11:22 +02:00
Vadim Zeitlin acc5bb60a1 Attach Doxygen comments to enum elements in Python output.
Sphinx is smart enough to use the docstrings following the constant definition
in Python code as its documentation, so doing this is still useful even if
Python itself doesn't support having docstrings for the variables (and this is
why it's impractical to write a unit test for the changes of this commit: we
can't easily extract the generated docstrings).
2014-08-13 16:11:30 +02:00
Vadim Zeitlin f684242467 Replace DoxygenTranslator debug parameters with a single flags one.
This makes the code more readable and more extensible as more flags are easier
to add in the future than more boolean parameters.

No user-visible changes.
2014-08-13 16:11:30 +02:00
Vadim Zeitlin 6cce652762 Merge latest master into doxygen branch again.
Update Doxygen-specific Python unit tests to work with the new indentation.

Update one of Doxygen-specific Java tests to still build with the new handling
of srcdir.
2014-08-13 16:11:21 +02:00
Vadim Zeitlin 07e2568a20 Remove long line wrapping from Python parameter list generation code.
This doesn't play well with PEP8 checks which imposes very strict continuation
line indentation rules which need to be _visually_ aligned, i.e. the subsequent
lines must be indented by the position of the opening bracket in the function
declaration line, but the code generating the parameter lists doesn't have
this information and so it's impossible to do it while avoiding either E128 or
E123 ("continuation line {under,over}-indented for visual indent" respectively)
error from pep8.

Moreover, the wrapping code didn't work correctly anyhow as it only took into
account the length of the parameter list itself and not the total line length,
which should include the function name as well.

So just disable wrapping entirely, long lines shouldn't be a problem anyhow in
auto-generated code.
2014-08-10 14:52:00 +02:00
Julien Schueller 6fe71da9fa Fixed remaining pep8 errors 2014-06-07 13:09:15 +02:00
Julien Schueller 93e06c0e58 Fixed another E231 2014-06-06 14:44:46 +02:00
Julien Schueller 36cac80166 Fixed some pep8 issues E701 2014-06-06 14:27:17 +02:00
Julien Schueller 01a9946455 Fixed some pep8 issues E302 2014-06-06 11:28:00 +02:00
Julien Schueller 0d589349a1 Fixed pep8 issues E701, E203, E231, E261 2014-06-06 11:03:46 +02:00
Julien Schueller e0c432f70d Use 4 spaces in emitFunctionShadowHelper for python 2014-06-05 16:51:23 +02:00
Vadim Zeitlin c6ef433b9b Don't leak doxygenTranslator in Python module.
Delete the pointer we allocate, just as in Java module.
2014-05-07 18:57:14 +02:00
Vadim Zeitlin 1ebd2334b8 Merge branch 'master' into doxygen
Merge with ~3.0.1 sources from master.
2014-04-30 18:37:57 +02:00
Olly Betts 36be36d618 Eliminate needless casting away const from string constants 2014-04-30 12:00:23 +12:00
William S Fulton 4fb940d913 Further fixes when using type() when using -builtin to include module name
Using type() on a builtin type should include the package and module
name, see http://docs.python.org/2/c-api/typeobj.html
2014-03-01 23:26:27 +00:00
Soeren Sonnenburg d8bfe00e25 Include module name if non NULL in tp_name 2014-03-01 23:26:27 +00:00
Arnaud Diederen 8998f11ca3 Fix Python argument count checking when using -modern
SF bug: https://sourceforge.net/p/swig/mailman/message/31957171/
SF Patch: 3471
2014-03-01 16:43:49 +00:00
William S Fulton 44dd28950c Python import code beautify 2013-12-24 17:22:42 +00:00
Paweł Tomulik 5562deec62 Fixed SF bug #1297 (Python imports)
This changeset resolves several issues related to python imports.
For example, it's possible now to import modules having same module
names, but belonging to different packages.

From the user's viewpoint, this patch gives a little bit more control on
import directives generated by swig. The user may choose to use relative
or absolute imports (docs are provided in separate PR).

Some details:
  - we (still) generate import directives in form 'import a.b.c' which
    corresponds to absolute imports in python3 and (the only available)
    ambiguous one in python2.
  - added -relativeimport option to use explicit relative import syntax
    (python3),

Tests are under Examples/python, these are in fact regression tests but
with the current swig testing framework it seems to be impossible to put
appropriate tests under test-suite.

Closes #7
2013-12-24 17:22:25 +00:00
William S Fulton 279ebdc0cf Beautify director output 2013-12-23 18:21:52 +00:00
William S Fulton bcb7aee022 Merge branch 'master' into gsoc2009-matevz
Conflicts:
	Examples/Makefile.in
	Examples/guile/Makefile.in
	Lib/php/php.swg
	Makefile.in
	Source/CParse/parser.y
	configure.ac
2013-10-10 07:26:09 +01:00
Olly Betts 12708c9241 Fix typos 2013-09-25 17:29:33 +12:00
Olly Betts 628b4710e5 [Python] Fix clang++ warning in generated wrapper code. 2013-08-24 08:40:08 +12:00
Olly Betts b477cb66be Use offsetof() rather than icky homemade equivalent 2013-08-24 08:34:50 +12:00
William S Fulton d0af4f50d3 Add %pythonbegin directive.
For adding code at the beginning of the generated .py file.
2013-07-05 06:30:16 +01:00
William S Fulton 779dc402b6 Fix a const_cast in generated code that was generating a <:: digraph when using the unary scope operator (::) (global scope) in a template type.
Affects Python, Ruby, Ocaml.

Based on SF patch #341.
2013-07-01 20:00:12 +01:00
William S Fulton 0f1e3da5de Fix the high passed to PyTuple_GetSlice in varargs wrappers.
Harmless bug as slices can take any size larger than the actual size for
the high value. Reported in SF Bug 1326.
2013-05-23 21:25:41 +01:00
Marko Klopcic 9cd379b800 fixed bug with autodoc, manual updated with table description and tests description 2013-02-21 22:50:15 +01:00
Marko Klopcic 29d1bba70a improved comment formatting for Python 2013-02-02 23:01:09 +01:00
William S Fulton d172e3d0ed Apply patch SF #334 - Fix Python default value conversions TRUE->True, FALSE->False. 2013-01-29 07:31:11 +00:00
William S Fulton e805d5f925 Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up

Conflicts:
	Doc/Devel/engineering.html
	Examples/Makefile.in
	Lib/allegrocl/allegrocl.swg
	Lib/csharp/csharp.swg
	Lib/csharp/enums.swg
	Lib/csharp/enumsimple.swg
	Lib/csharp/enumtypesafe.swg
	Lib/java/java.swg
	Lib/python/pydocs.swg
	Lib/r/rtype.swg
	Source/Include/swigwarn.h
	Source/Modules/octave.cxx
	Source/Modules/python.cxx
	Source/Modules/ruby.cxx
	Source/Swig/scanner.c
	Source/Swig/stype.c
	Source/Swig/swig.h
	configure.ac
2013-01-28 07:01:37 +00:00
William S Fulton 7841a0d097 Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
William S Fulton 4c1b566f62 Fix fully qualified package paths for Python 3 even if a module is in the same package
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13955 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-12-11 18:42:58 +00:00
William S Fulton 092e2104c7 More consistent use of DOH namespace
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13940 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-26 20:31:54 +00:00
William S Fulton d93dc0f8e2 Distinguish between an "abstract" attribute on a class containing a list of abstract members and an "abstract" flag on pure virtual methods - renamed former to "abstracts"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13935 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-24 14:13:58 +00:00
William S Fulton 0d2c459046 Remove some unused code and pointless variable assignments
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13932 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-23 07:38:00 +00:00
William S Fulton 2b8bfe410e Remove unnecessary null checks or fix potential null dereferences
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13924 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-20 23:29:35 +00:00
William S Fulton d918bddfc0 Fix segfaults when using filename paths greater than 1024 characters in length - use String * and heap instead of fixed size static char array buffers.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13904 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-18 00:45:18 +00:00
William S Fulton 5a1e82a2f4 Remove DohClose (Close) and replace with calls to DohDelete (Delete) to fix some minor memory leaks in most uses of NewFile.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13885 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-14 22:16:07 +00:00
William S Fulton b1ee062d2a Cosmetic variable renaming for consistency across language modules
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13874 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-10-27 17:38:05 +00:00
William S Fulton f6229d4b73 Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously the name was ignored during the typemap search. Implemented by ensuring the 'type' attribute in the Node is set up correctly and using the usual Swig_typemap_lookup on the Node.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13873 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-10-27 17:37:34 +00:00
William S Fulton ecac2d2a68 Improve nullptr constant wrapping
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13842 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-09-20 19:09:38 +00:00
Dmitry Kabak c592e0db51 Made doxygen parsing switched off by default
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13602 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-08-13 09:09:25 +00:00
Dmitry Kabak 3fbe45f0c6 Added nice doxygen debug switching (-debug-doxygen-parser and -debug-doxygen-translator)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13427 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-07-29 13:48:03 +00:00
William S Fulton 7b58300cbd Fix display of pointers on 64 bit systems, only 32 bit values were being shown.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13340 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-07-21 22:52:30 +00:00
Dmitry Kabak 2004ff23b9 Removed the unwanted header
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13251 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-07-04 21:47:57 +00:00
Dmitry Kabak 4289b8e273 Refactored comment translator class, implemented result caching
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13191 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-06-25 15:47:36 +00:00
Dmitry Kabak 72b23954fb Fix integration of doxygen with autodoc feature, fixed autodoc test and some code refactored
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13183 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-06-18 18:33:30 +00:00
Dmitry Kabak ac6b51f13e Fix to include comment for non-member functions in python
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13149 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-06-04 18:02:51 +00:00
Dmitry Kabak ce39e74f28 Applied Christopher Mangiardi's patch that fixes incorrect comment placement in python single line functions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2012-doxygen@13133 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-05-28 19:47:03 +00:00
William S Fulton af1c6ac3c3 Merge trunk (up to just after swig 2.0.5 release - rev 13009) to gsoc2008-cherylfoil
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-cherylfoil@13017 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-27 18:55:37 +00:00
Olly Betts 49efe65a08 Remove superfluous ; after closing } of if statement
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12966 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-05 01:20:51 +00:00
Olly Betts d3987ca87c Fix bad change from r12830.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12964 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-04-04 13:46:16 +00:00
William S Fulton 468ca084fc Correct special variables in 'directorargout' typemap. This change will break any 'directorargout' typemaps you may have written. Please change: to and to \n Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't previously compile and add in , etc expansion.\n [C#, Go, Java, D] Add support for the 'directorargout' typemap.\n [Java] Add (char *STRING, size_t LENGTH) director typemaps.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12877 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-12-20 20:50:36 +00:00
William S Fulton 24133bacd7 Remove numerous hard coded 'result' variable name in generated c/c++ wrappers. The variable name is now defined in just one place, making it possible to change the name easily if a target language so wishes - see cwrap.c.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12830 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-10-30 21:51:50 +00:00
Stefan Zager b61ccd00ec Bug 3400486: Fix error signalling for built-in constructors.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12792 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-08-30 21:37:16 +00:00
William S Fulton 44c202d048 Add in $symname expansion for director methods
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12772 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-08-04 19:45:19 +00:00
Stefan Zager 498367bc9d From swig-user 7/6/11: fix closure for tp_call.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12761 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-07-20 15:20:24 +00:00
Stefan Zager 0df6937fbf Bug 3324753: fix %rename for member variables under -builtin
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12756 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-07-14 05:15:05 +00:00
William S Fulton 72ffdb930d Repeat autodoc fixes for Octave and Ruby as done previously for Python
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12740 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-06-13 20:46:20 +00:00
William S Fulton a4f8ed4fc9 Fix last checkin for renamed parameters
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12736 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-06-10 20:26:07 +00:00
William S Fulton 3243cbaad4 Numerous autodoc fixes for Python
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12735 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-06-10 19:33:40 +00:00
William S Fulton 315dd8fb2f Add in error handling in the even of not being able to find a base when initializing a builtin type - should the base not be loaded
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12693 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-05-20 05:58:05 +00:00
William S Fulton b78392832f [Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded method with incorrect arguments improved to show always show fully qualified name and if a const method. Also fixed other Lua error messages in generated code which weren't consistently using the fully qualified C++ name.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12655 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-05-05 06:23:02 +00:00
Stefan Zager e629b192e2 Fixed the argument counts passed to SWIG_Python_UnpackTuple for varargs.
Removed obsolete methods from std_map.i and pyiterators.swg.

Added builtin-check target to python test suite Makefile.

Fixed using_namespace_loop.i so that the generated wrappers will compile.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12644 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-29 18:25:16 +00:00
Stefan Zager 8f07b3f851 Testcase and fix for bug 1163440: vararg typemaps.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12639 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-12 18:55:24 +00:00
Stefan Zager 257b75c23c Fixed PyVarObject_HEAD_INIT calls for VC++.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12634 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-11 22:06:02 +00:00
William S Fulton 139ccc434e Workaround incorrect gcc 4.4 and 4.5 warning with -O2 -Wextra in generated code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12631 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-11 18:45:07 +00:00
William S Fulton 781b468aa1 Sun Studio warning fixes for Python builtin
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12625 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-10 00:23:48 +00:00
William S Fulton abdd41dc91 Restore extern "C" back to what it was to remove Solaris warnings
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12621 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-09 23:08:03 +00:00
Stefan Zager 8f876a6287 Minor tweaks to enable -builtin with C code.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12618 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-08 23:05:20 +00:00
Stefan Zager 5c4f47302a Initialize all fields of PyTypeObject, to eliminate compiler warnings. Fixed typo in docs.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12612 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-05 23:16:13 +00:00
William S Fulton b2b9e2eb91 Python builtin - warning suppression/fixes for 'gcc -Wall' and cosmetic changes in generated code.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12609 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-05 20:39:44 +00:00
William S Fulton 5f6389ab31 Cosmetic Python changes and replace DOH types
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12608 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-04 20:13:14 +00:00
Stefan Zager 20cda0168e Eliminate warnings about empty case statements.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12604 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-03 19:44:46 +00:00
Stefan Zager c95cc72454 Merged %pythonnondynamic fix
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12594 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-03 05:15:48 +00:00
Stefan Zager 90fe22acf7 Fix for METH_O and -compactdefaultargs, in two parts:
- Don't mark a method as METH_O if it has compactdefaultargs
  - In SWIG_Python_UnpackTuple, allow for a non-tuple 'args'.

Added compatibility for python versions 2.3 and 2.4.  These are only
partially supported; inheriting from wrapped types looks problematic.
Versions older that 2.3 are unlikely ever to work.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12590 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-02 21:40:00 +00:00
Stefan Zager cd7fc2047b Factored some #ifdef noise out of the initialization function by adding
SwigPyBuiltin_SetMetaType.

For %import statements, move the runtime import out of SWIG_init and into the
.py file.  The reason for this is that the import must be executed within the
python execution frame of the module, which is true in the .py file, but *not*
true in the initialization function.  Had to re-order the .py file slightly
to put the 'import' statements at the top; that's necessary to make sure base
types from an imported module are initialized first.  If -builtin isn't used,
then the .py code is not re-ordered.

Added an explanation and workaround for the limitation that wrapped types are
not raise-able.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12585 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-04-01 19:35:30 +00:00
Stefan Zager 51ef340eed Converted rest of slot outputting to use printSlot.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12583 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-31 21:26:12 +00:00
Stefan Zager f1cb5b7ca6 Bug fix: missing quotation mark on autodoc string
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12582 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-31 20:37:23 +00:00
Stefan Zager bc200998b1 Added usage message for -builtin, and tweaked -builtin docs.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12574 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-30 19:51:22 +00:00
Stefan Zager 3d444101d1 A slew of changes based on William Fulton's code review.
- Fixed naming conventions; SwigPyBuiltin is used a lot
- Removed use of std::vector
- builtin.swg isn't included if -builtin isn't specified
- Changed many feature names to use a "python:" prefix
- Eliminated static vars in std_pair.i
- Eliminated C++-style comments (//)
- Enabled autodoc and docstring with -builtin
- Fixed non-ansi generated C code
- Detect and complain if two incompatible swig modules are loaded
- Removed argcargvtest_runme3.py, and fixed argcargvtest_runme.py
  so that 2to3 handles it better
- Removed anonymous namespaces
- Eliminated builtin_init typemaps; consolidated functionality into
  SWIG_Python_NewPointerObj
- Eliminate printf warnings from %U conversion character by switching
  to %S, which works just as well
- Fixed li_std_set_runme.py for python3, which returns set members in
  a different order from python2





git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12562 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-29 06:57:02 +00:00
Stefan Zager 93499e12af Merged trunk up to revision 12551
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12552 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-24 05:46:05 +00:00
William S Fulton a63d456f8a Remove redundant code highlighted by warnings in gcc-4.6
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12536 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-14 07:22:08 +00:00
William S Fulton 5f4d8c6112 Fix SF #3194294 - corner case bug when 'NULL' is used as the default value for a primitive type parameter in a method declaration.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12525 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-09 22:31:08 +00:00
William S Fulton d008ab2bc6 Remove local mode editor setting - editors should be set up correctly for the whole of SWIG
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12517 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-03 19:42:43 +00:00
William S Fulton cca5a76d91 Minor rewrites of some recent builtin changes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12516 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-03 19:39:48 +00:00
William S Fulton 908c37cef8 Coding style fixes for Python builtin changes added on the szager-builtin branch
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12515 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-03 19:34:18 +00:00
William S Fulton 084a3c7205 Run make beautify on python.cxx to fix code style to match style on szager-builtin branch
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12514 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-03 19:33:25 +00:00
William S Fulton 0a5ca9ccd6 Fix potential name clash in director class
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12501 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-20 13:47:14 +00:00
Stefan Zager ea4cab8e4c A small unicode fix.
A partial fix for the problem with overloading, varargs,
and fastunpack: with this fix, the wrappers will compile.
However, they still contain faulty logic and unreachable
code in the dispatch function.

The comprehensive fix would have to be in overload.cxx.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12465 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-17 05:52:18 +00:00
Stefan Zager b5889b8b0f Unicode fixes for python3.
Added a few more closure types.

Guard against operator overloads outside of a class declaration.

Incorporate fix for patch #3171793.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12446 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-09 08:59:09 +00:00
Stefan Zager 62fef1bf99 python3 support; passes all regressions.
Adding argcargvtest_runme3.py, because 2to3 can't handle it.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12425 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-03 07:21:37 +00:00
Stefan Zager 00b5fa9c47 Now passes regressions with '-O -builtin'. Almost all changes
are to accomodate -fastunpack.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12423 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-02 10:28:46 +00:00
Stefan Zager 288c37f5bf Regressions pass! With a few tweaks for unsupported features, primarily:
- Throwing wrapped types as exceptions is unsupported.
- Reverse comparison operators (e.g., __radd__) aren't supported.

Rationalized destructors.

Finished std::map implementation.  Required fixes to typecheck for
SWIGTYPE* const&.

Need a little special handling of the swig_type_info for SwigPyObject
when multiple modules are loaded.

Fall back to SwigPyObject_richcompare if there's no operator overload.

"memberget" and "memberset" attrs are applied strangely; work around
them.

Added 'this' attribute.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12415 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-30 03:17:28 +00:00
Stefan Zager d4b8048e9a Stopped using template class SwigPyBuiltin, because it caused problems
when two typedef-equivalent types are wrapped as separate classes.

Now failing on refcount.cpptest.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12392 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-01-12 00:43:01 +00:00