Commit graph

588 commits

Author SHA1 Message Date
William S Fulton
bfde148887 The kwargs feature no longer turns on compactdefaultargs for languages that don't support kwargs.
Affects all languages except Python and Ruby.

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

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

Patch supplied on swig-devel mailing list on 12 Sep with details...

==============================================
I just wanted to mention that I found a crash issue in bug..

I am using SWIG 2.0.11 with python and have –threads enabled.  I have a C++ std::vector that I instantiate in SWIG with %template.  I also have a method in a class that returns this vector.  I also include std_vector.i, btw..

When I iterate like so:

children = Action.getActionList()
for child in children:
  pass

Everything is fine..

When I iterate like this:

for child in Action.getActionList()
  pass

Product crashes.

The problem is the following.  This code gets called first:

SWIGINTERN PyObject *_wrap_delete_SwigPyIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
  PyObject *resultobj = 0;
  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
  void *argp1 = 0 ;
  int res1 = 0 ;
  PyObject * obj0 = 0 ;

  if(!PyArg_UnpackTuple(args,(char *)"delete_SwigPyIterator",1,1,&obj0)) SWIG_fail;
  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
  if (!SWIG_IsOK(res1)) {
    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SwigPyIterator" "', argument " "1"" of type '" "swig::SwigPyIterator *""'");
  }
  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
  {
    SWIG_PYTHON_THREAD_BEGIN_ALLOW;
    delete arg1;
    SWIG_PYTHON_THREAD_END_ALLOW;
  }
  resultobj = SWIG_Py_Void();
  return resultobj;
fail:
  return NULL;
}

Note the SWIG_PYTHON_THREAD_BEGIN_ALLOW/END_ALLOW. In between those two statements, we delete arg1.  That in turn will eventually end up in this code:

namespace swig {
  class SwigPtr_PyObject {
  protected:
    PyObject *_obj;

  public:
    … snip! …
    ~SwigPtr_PyObject()
    {
      Py_XDECREF(_obj);
    }

Uh-oh!  We call Py_XDECREF when we aren’t supposed to because we are in a SWIG_PYTHON_THREAD_BEGIN_ALLOW/END_ALLOW section!

This takes care of the issue:

namespace swig {
  class SwigPtr_PyObject {
  protected:
    PyObject *_obj;

  public:
    … snip! …
    ~SwigPtr_PyObject()
    {
      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
      Py_XDECREF(_obj);
      SWIG_PYTHON_THREAD_END_BLOCK;
    }

There are several other methods in this class that use the Python API, but don’t have the BEGIN/END block defined.  I’m not sure if they are required for all of them, but I believe they are..

I have attached a modified pyclasses.swg with what I believe are the correct changes.  This code is from 2.0.11, but as far as I can tell, it’s the same as what is in 3.0.2…

Apologies for not doing more here (making/running tests, getting it in the code repository, etc..), but I’m under some pressure to get some unrelated things done…
2014-09-23 22:33:25 +01:00
Julien Schueller
11b5a61879 Check multi-module examples. Dont use sed. 2014-06-10 08:59:55 +02:00
Julien Schueller
7a4cef998c Enable pep8 check 2014-06-07 13:10:27 +02:00
Karl Wette
b8026cc02f Fix cleaning of Python runme.py scripts for in-source-tree builds 2014-05-29 14:40:50 +02:00
Karl Wette
cc0738bbda Fully clean Python examples and test-suite 2014-05-29 02:29:27 +02:00
Harvey Falcic
91e93838fc unicode_strings test: manually check values instead of using assert 2014-05-24 18:00:04 -04:00
Harvey Falcic
ab527b0e4b unicode_strings_runme.py: fix version check
Python 3.0.1 shouldn't pass.
2014-05-24 17:57:16 -04:00
Harvey Falcic
2533d0210f unicode_strings test: check return values 2014-05-24 16:50:33 -04:00
Harvey Falcic
5c5dfc106f Python unicode_strings test case: restrict to Python > 3.0
Also adjust the test method names and content to match the docs.
2014-05-24 15:39:53 -04:00
Harvey Falcic
791f070e66 Add "unicode_strings" test case for new Python 3 behavior 2014-05-23 15:40:01 -04:00
William S Fulton
2b5499a262 Slight simplification of test-suite build for new out-of-source changes
Provide default SRCDIR and SCRIPTDIR variables in common.mk and override
only where needed.
2014-05-15 23:11:07 +01:00
Karl Wette
f574a34155 Allow examples and test-suite to be built out of source tree
- Examples/Makefile.in rules use SRCDIR as the relative source directory

- ./config.status replicates Examples/ source directory tree in build
  directory, and copies each Makefile to build directory, prefixed with
  a header which sets SRCDIR to source directory

- Examples/test-suite/.../Makefile.in set SRCDIR from Autoconf-set srcdir

- Examples/test-suite/errors/Makefile.in needs to filter out source
  directory from SWIG error messages

- Lua: embedded interpreters are passed location of run-time test

- Python: copy run-time scripts to build directory because of 2to3
  conversion; import_packages example copies __init__.py from source
  directory; test-suite sets SCRIPTDIR to location of run-time tests

- Javascript: binding.gyp renamed to binding.gyp.in so that $srcdir
  can be substituted with SRCDIR; removed './' from require() statements
  so that NODE_PATH can be used to point Node.js to build directory
2014-05-11 23:21:10 +02:00
Karl Wette
d5b765d388 Whitespace cleanup of all Makefiles*
- some of the %.clean rules in the test-suite Makefiles were using a single tab
  as an empty rule, dangerous! I've replaced these with the safer '@exit 0'.
2014-05-02 20:06:11 +02:00
William S Fulton
0fdfa3b6ce Add runtime test for commit 7a96fba836 2014-03-31 19:29:19 +01:00
William S Fulton
e5f928e97a Add metaprogramming type_traits example in C++11 documentation 2014-03-14 01:57:16 +00:00
William S Fulton
01ce992f5d C++11 result_of testcase 2014-03-14 01:57:16 +00:00
William S Fulton
504c2030bb Change in default behaviour wrapping C++ bool for Python.
Only a Python True or False will now work for C++ bool parameters.
This fixes overloading bool with other types.
2014-03-08 12:04:19 +00: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
William S Fulton
a3a0535229 Add testcase and info on python -builtin missing argument count check 2014-03-01 16:44:01 +00:00
William S Fulton
c5911cc08d Add %$isextendmember for %rename of members added via %extend 2014-02-18 23:21:46 +00:00
William S Fulton
9cbd742b66 Fix %$ismember %rename predicate for members added via %extend
Bug reported was incorrect renaming of PHP built-in functions, such as
next. See PHPFN in phpkw.swg.

Add some tests for the %rename predicates.
2014-02-18 07:30:55 +00:00
William S Fulton
844695b674 Fix typedef_typedef test 2014-02-06 19:31:31 +00:00
William S Fulton
e531578c54 Modify typedef_typedef testcase to work for all languages
Add CHANGES note

Closes #112.
2014-01-14 07:21:40 +00:00
Yann Diorcet
2e186244d6 Add test for checking prefix resolving in typedef 2014-01-14 07:21:40 +00:00
Vadim Zeitlin
cdf1ba9120 Don't accept strings too long to fit in char[N] with trailing NUL.
It was previously possible to assign "hello" to a variable backed by char[5]
storage in C, and the array contained the correct character data but without
the trailing NUL, which was unexpected in C.

This is not allowed any more, only "helo" can fit into a char[5] now and
anything else fails the type check, just as it already happened for the longer
strings before.

Closes #122
2013-12-23 21:13:25 +00:00
Vadim Zeitlin
88a0e228a9 Change the length of strings created from fixed-size buffers.
Use the usual C rule for NUL-terminated strings instead of discarding all the
trailing NUL characters.

This was unexpected (as buffers in C code are not necessarily always padded
with NULs to their full length) and also inconsistent among languages as this
was only done for those of them using typemaps/strings.swg but not for C# or
Java, for example, which terminated the string at the first NUL even before
this change.

Notice that this patch couldn't use strlen() or wcslen() with possibly not
NUL-terminated strings, so we had to add [our own equivalents of] strnlen()
and wcsnlen() and use them instead. This required adding yet another parameter
to string typemap macros, so update the example using them accordingly too.
2013-12-23 21:12:17 +00:00
Vadim Zeitlin
ed28725a15 Add std_auto_ptr.i defining typemaps for returning std::auto_ptr<>.
These typemaps are currently defined for C#, Java and Python only and the
tests are provided only for these languages.

Also add a brief description of the new header to the documentation.
2013-12-03 23:45:20 +01:00
Vadim Zeitlin
72afb74f47 Add support for case conversion characters in regex substitutions.
Allow using Perl-like \l, \L, \u, \U and \E escape sequences in the
substitution string used with %rename("%(regex:/pattern/subst/)s").
This is useful for e.g. title casing all string after removing some prefix.

Closes #82
2013-10-15 07:17:56 +01: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
William S Fulton
738cc36aab Rename all C++0x to C++11 and cpp0x to cpp11 2013-10-07 20:37:00 +01:00
William S Fulton
a91cd0bc5c Infinity is now by default an acceptable value for type 'float'.
This fix makes the handling of type 'float' and 'double' the same. The implementation requires the
C99 isfinite() macro, or otherwise some platform dependent equivalents, to be available.
2013-09-12 07:28:12 +01:00
William S Fulton
b58dabced9 %implicitconv is improved for overloaded functions.
Like in C++, the methods with the actual types are considered before trying implicit conversions.
2013-08-28 20:30:46 +01:00
William S Fulton
1cc735df5e %implicitconv will now accept None where the implicit conversion takes a C/C++ pointer.
Problem highlighted by Bo Peng on the swig-user mailing list. SF patch #230.
2013-08-28 20:28:15 +01:00
William S Fulton
1c44078751 Improve testing of %pythonprepend and %pythonappend 2013-07-02 20:00:17 +01:00
William S Fulton
ace8fcd972 SWIG_AsWCharPtrAndSize improper operation if cptr NULL
SF bug #1327

This doesn't have any noticeable effect with the usage of
SWIG_AsWCharPtrAndSize as shipped by SWIG, but could be a problem if a
user is using this function with cptr equal to zero and psize is non-zero
 - the length would be incorrectly set due to the call to PyUnicode_GetSize
failing.
2013-07-02 18:58:56 +01:00
Paweł Tomulik
c9295401da clean all .py files generated by python-test-suite
Closes #49
2013-06-04 22:23:53 +01:00
William S Fulton
72f2d8ac8f Fix Python test-suite makefile to show which tests have runtime tests (for Python 3). 2013-05-27 10:24:02 +01:00