Commit graph

701 commits

Author SHA1 Message Date
William S Fulton
4963a7f88f Fix Python 2 builtin tp_hash hashfunc closure regression when using "python:slot"
Closes https://github.com/swig/swig/issues/843
2016-12-23 23:41:07 +00:00
William S Fulton
bdf71b0067 Zero initialize %array_functions and %array_class 2016-12-18 17:50:47 +00:00
William S Fulton
cc56765a7a Zero initialize newly created arrays
For consistency to previous fixes:
https://github.com/swig/swig/pull/208
https://github.com/swig/swig/issues/440
2016-12-18 17:50:47 +00:00
William S Fulton
173c028dd4 Add test and changes entry for Python -builtin %array_class fix
Issue https://github.com/swig/swig/issues/446
2016-12-18 17:50:47 +00:00
William S Fulton
2a42031b08 Custom Python module importing code
Add optional moduleimport attribute to %module so that the
default module import code can be overridden. See the
"Searching for the wrapper module" documentation in Python.html.
Example:

  %module(moduleimport="import _foo") foo

$module also expands to the low-level C/C++ module name, so
the following is the same as above

  %module(moduleimport="import $module") foo

Issue https://github.com/swig/swig/issues/769
2016-12-01 18:59:33 +00:00
William S Fulton
bdda0a0829 Python - fix compilation error when using -extranative and -builtin.
Closes #816
2016-11-02 22:00:54 +00:00
William S Fulton
c74397bfd0 Merge branch 'liorgold-alias-template'
* liorgold-alias-template:
  Warning header cosmetics
  Fix decl attribute in C++11 alias templates
  Add C++11 alias templates
2016-11-02 09:10:59 +00:00
William S Fulton
96015de0dd Update documentation for using SWIG_ConvertPtr example usage
Add a test case to test the example documentation typemaps
2016-10-23 20:16:35 +01:00
William S Fulton
f9ba371ee4 Remove li_boost_array testcase
Too many problems, this attempt to use std::array typemaps for boost::array
isn't really working. Latest problem is clang compile failures on OSX.
2016-10-15 17:58:17 +01:00
William S Fulton
4b4540056d Turn off Python pickle test for old style classes 2016-10-14 19:48:37 +01:00
William S Fulton
d2cb98c134 Pickle test additions
These are not working yet for all combinations of builtin and PY3
The goal is to have a sensible default error that states that
pickling is not supported.
2016-10-14 07:30:44 +01:00
William S Fulton
96fae38be2 Fix Python pickling and metaclass for builtin wrappers
The metaclass (SwigPyObjectType) for SWIG objects was not defined in
a way that let importlib successfully import the Python wrappers.
The pickle module failed because it couldn't determine what module the
SWIG wrapped objects are in.

I've changed the definition of SwigPyObjectType using more normal
builtin type definitions. There are still some open questions:
- None of the builtin types, like swig_static_var_getset_descriptor and
  SwigPyObject are added into any module. No call to PyModule_AddObject
  is made, so isinstance cannot be used for any wrapped type, all of
  which are derived from SwigPyObject.

Closes #808
2016-10-14 07:30:44 +01:00
William S Fulton
9135ad72e2 Additional static member variable testing for Python 2016-10-14 07:30:44 +01:00
William S Fulton
848628ae91 More flexible python builtin slots
The closure names used for builtin slots are mangled with their functype so
 that overloaded C++ method names can be used for multiple slots.
For example:
%feature("python:slot", "mp_subscript", functype="binaryfunc") SimpleArray::__getitem__;
%feature("python:slot", "sq_item", functype="ssizeargfunc") SimpleArray::__getitem__(Py_ssize_t n);
will generate closures:
  SWIGPY_SSIZEARGFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___ssizeargfunc_closure */
  SWIGPY_BINARYFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___binaryfunc_closure */
2016-09-25 14:15:38 +01:00
William S Fulton
0769e9b727 Fix iterators for containers of NULL pointers (or Python None) when using -builtin.
Previously iteration would stop at the first element that had a NULL pointer value.
2016-09-17 17:53:48 +01:00
William S Fulton
5b7c08c214 Make Python builtin types hashable by default
Default hash is the underlying C/C++ pointer.
This matches up with testing for equivalence (Py_EQ in SwigPyObject_richcompare)
which compares the pointers.
2016-08-23 19:06:36 +01:00
William S Fulton
4f777b181c Correct notes on customising Python builtin comparison operators
Also add example for python:compare feature
2016-08-22 07:22:40 +01:00
William S Fulton
4c0c802aa0 Add Python builtin tp_dealloc override test 2016-08-19 18:35:51 +01:00
William S Fulton
f778ee19df Python builtin hashfunc closure fix
If the wrong return type in the hash function was used, an error:
  SystemError: error return without exception set
was raised

Add some tests for testing builtin slots
2016-08-18 07:10:54 +01:00
William S Fulton
6e9184b6f8 Fix std::vector of pointers which failed if a pointer to a pointer of the container element type existed (Python)
Closes SF Bug 2359417 created after commit 93f0390322 (svn rev 10958)
2016-07-28 22:51:22 +01:00
Lior Goldberg
d0fc5b7b5b Add C++11 alias templates 2016-07-06 00:31:04 +03:00
Lior Goldberg
c363a93d69 Added support for type alias 2016-06-22 23:13:28 +03:00
William S Fulton
86fd5c9858 Fix autodoc testcase for python -fastproxy
Also fixes -O.
This is a minimal change avoiding the differences in the function names
when -fastproxy is used until autodoc code is improved with doxygen
changes.

Closes #721.
2016-06-22 00:15:05 +01:00
William S Fulton
3459099fb8 %shared_ptr and %template testcase modified to work for python -O
Testcase has now been modified to mask the problem by providing the default parameter 'int' in:
%shared_ptr(Space::BaseDefault<short, int>)
If this is not done then d fails to convert to BaseDefault<short>&

This needs fixing in SWIG, but the problem is masked for now, so that the python
testcase works when run with the -O option.
2016-06-21 19:49:27 +01:00
William S Fulton
38cda92938 smartptr inheritance fix when using templates and typedefs
Fixes SF bug 3333549 - %shared_ptr fixes when the type is a template using
template parameters that are typedef'd to another type.

Also fixes python -O optimization where the smart pointer conversion to the
base class needs to work because of the virtual methods that have been
optimized away.
2016-06-21 07:00:56 +01:00
William S Fulton
cc7319f52f Replace assert from Python testcases with code that always runs.
assert code is sometimes not executed, eg when running python -O.
2016-06-19 20:11:51 +01:00
William S Fulton
2d5c32048c Only test python:abc feature when passing -py3 to swig 2016-06-06 19:10:25 +01:00
William S Fulton
ddd1b38fa2 Removing empty error tests - c_default_error
C default arguments are allowed, so migrated the error test to a proper test,
as no error or warning is expected.
2016-06-01 21:25:25 +01:00
William S Fulton
98a31ff633 Fix directorin SWIGTYPE typemaps to make a copy as these are used for pass by value.
Closes #434
2016-05-14 21:32:24 +01:00
William S Fulton
63e2f636de Testcase fix for R
Workaround bug in R when a method with default arguments end in 'get'
2016-05-07 19:30:13 +01:00
William S Fulton
15ebf3df03 Fix assertion handling defaultargs
Occurs when using %extend for a template class and the extended methods
contain default arguments.

Closes #611
2016-05-07 12:33:29 +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
William S Fulton
a09ef99606 Python operator_overload runtime testcase cleanup
Remove C test code comment ... this code is in operator_overload.i already
2016-05-05 20:28:22 +01: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
William S Fulton
333a46f07d Add python AttributeError test for non-existent attribute 2016-04-02 18:03:08 +01:00
William S Fulton
bbd1b8ed05 Add tests for Python -builtin -O and compactdefaultargs and update changes file 2016-04-02 11:29:54 +01:00
William S Fulton
896a0f1f31 Merge branch 'ptomulik-fix/nonclass-constants'
* ptomulik-fix/nonclass-constants:
  fix handling of function pointers by %constant directive
2016-03-24 19:24:02 +00:00
Paweł Tomulik
174523aa80 fix handling of function pointers by %constant directive 2016-03-24 11:22:51 +01:00
Paweł Tomulik
350d43d988 handle const pointers to functions 2016-03-24 10:59:23 +01:00
William S Fulton
7aa5f07dfd Fix 'make partialcheck-test-suite'
Python pep8 should not be run as part of partialcheck
Javascript should also only invoke SWIG during partialcheck
2016-03-18 18:56:55 +00:00
William S Fulton
ac495d5c66 Merge branch 'char-escaping'
* char-escaping:
  Add missing string_constant.i testcase
  changes file update for char wrappers
  C# char wrappers fixes for enum values, static const member char values and %csconst
  D testing added for %dmanifestconst and char constants
  Fix wrapping D constants using %dmanifestconst
  Php fix for enum value of '\0'
  Fix static const char member variables wrappers with %javaconst(1).
  Expand char testing in enums and %constant
  Java char changes file update
  Java enum and static member variable escaping fix for chars
  Add tests for enum values and static const member variables chars containing escape sequences
  Minor documentation tweak

Conflicts:
	CHANGES.current
2016-03-12 23:27:51 +00:00
William S Fulton
0f0345c214 Merge branch 'interfaces'
* interfaces:
  Documentation and CHANGES entry for interface feature
  interface macro argument name tweaks
  Change the name of the interface in %feature to be more portable
  Interface feature fix for typedef types
  Add limited support for %interface_impl and %shared_ptr
  Multiple inheritance warning wording tweak
  C# "override" fix for "extend" case
  Add checks for interface name symbol clashes
  interface feature test changes for the tests to pass for all languages
  Rename feature_interface.i to swiginterface.i
  Re-organization of the interface feature common code
  Port Java interface tests to C#
  Test %interface
  Test %interface_impl
  Use rstrip instead of regex encoder in %feature_rename
  Add rstrip encoder for use in %rename.
  Interface macros: %interface %interface_impl %interface_custom
  Add $interfacename family of special variable expansions
  Add multiple_inheritance_nspace testcase
  Interface name handling improvements and special variable changes
  Correct regex example comment
  Properly hide unexposed naming functions in naming.c
  C++ namespace testing for interface feature
  interface feature - SWIG_JAVABODY_PROXY does not need to be overridden
  Support namespaces and nspace with the interface feature for C#
  Support namespaces and nspace with the interface feature for Java
  Cosmetic test case changes
  Add Java premature garbage collection prevention parameter (pgcpp) to interface feature
  Create javainterfacecode and csinterfacecode typemaps
  IntPtr & HandleRef absolute names used
  virtual/override fix
  Improve interface feature checks
  Add another interface test selecting just one base as an interface
  Comments added to interface feature implementation and cosmetic code changes
  Add overloading tests for interface feature
  Refactor multiple inheritance warnings
  director generation fixes
  interface feature updates for C# latest on master
  interfaces branch merge fixes
  Remove unnecessary interfaces for concrete classes
  cosmetic code formatting changes
  Correct interface name attributes that are internal
  interface macro changes to support templates
  Test non-virtual method in Derived classes
  interface tests for a most derived class inheriting the interfaces further up the chain
  Rename GetCPtr/getCPtr to SWIGInterfaceUpcast
  interface feature support for const ref pointers (used by the STL)
  Interface feature support for arrays
  More interface feature testing for return values
  interface feature support for passing by value
  interface feature support for references
  Multiple inheritance parameters as pointers testing
  Simplify multiple_inheritance_abstract Java runtime test
  Warning fixes
  Rename test functions in multiple_inheritance_abstract testcase
  Formatting fixes in generated code for interface feature
  Cosmetic spacing changes in test case
  interface feature typemap corrections to handle NULL pointers
  interface test added
  javadirectorin fix
  interface implementation visibility
  interface inheritance (2)
  interface inheritance (1)
  feature:interface ported to Java
  propagate non-abstract "interface" base methods (3)
  propagate non-abstract "interface" base methods (2)
  propagate non-abstract "interface" base methods (1)
  namespace support added GetCPtr now returns HandleRef "feature:interface:name" is now mandatory attribute
  interfaces (1)
  interfaces (1)

Conflicts:
	CHANGES.current
2016-03-11 20:01:41 +00:00
William S Fulton
4a3e1fd44c Add rstrip encoder for use in %rename.
This is like the strip encoder but strips the symbol's suffix instead
of the prefix.
2016-03-02 07:11:09 +00: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
William S Fulton
155e31626c Duplicate tests that are run twice as both C and C++ tests to fix parallel make: overload_extend 2016-02-21 19:24:11 +00:00
William S Fulton
0bd41dc14d rename overload_extendc testcase 2016-02-21 18:04:04 +00:00
William S Fulton
a00b4f4463 Duplicate tests that are run twice as both C and C++ tests to fix parallel make: li_cpointer 2016-02-21 18:04:04 +00:00
William S Fulton
819bd9c97e Duplicate tests that are run twice as both C and C++ tests to fix parallel make: li_cdata 2016-02-21 18:04:04 +00:00
William S Fulton
9600c95234 Duplicate tests that are run twice as both C and C++ tests to fix parallel make: li_carrays 2016-02-21 18:04:04 +00:00
William S Fulton
78b113558f Duplicate tests that are run twice as both C and C++ tests to fix parallel make: keyword_rename 2016-02-21 18:04:04 +00:00