Commit graph

18,561 commits

Author SHA1 Message Date
Lindley French
8f19d77fec Don't include an STL header in SWIG. 2015-05-07 11:29:47 -07:00
Lindley French
159b3c7958 Use a bitset which is automatically initialized to 0, instead of a bool array which is not. 2015-05-06 11:33:28 -07:00
Lindley French
3ce7867a0a Added missing untracked files. 2015-05-04 15:27:51 -07:00
Lindley French
bd0fa56705 Added director_ref test. 2015-05-04 15:22:14 -07:00
Lindley French
5f0181bfdd Too hard to conditionally define the memset....instead just make sure the array is defined even if it's unused. 2015-05-01 12:40:07 -07:00
Lindley French
e8ca8fb2e6 Only output memset if the array exists. 2015-04-30 23:14:48 -07:00
Lindley French
8acca78953 Zero-initialize swig_override in the director constructor. 2015-04-30 21:16:30 -07:00
Olly Betts
50ba1ea6fa Adjust testcase for unknown directive error
Fixes testcase failure caused by fix for issue #394.
2015-04-30 15:27:12 +12:00
Olly Betts
d26a505dad Ignore unknown preprocessor directives which are inside an inactive
conditional (github issue #394, reported by Dan Wilcox).
Regression introduced in 3.0.3.
2015-04-30 13:40:42 +12:00
Alexander Warg
ece1009c5d lua: push integer constants as integer
This allows better compatibility with Lua 5.3. Otherwise function
overloading assuming integer parameters might not work.
2015-04-28 17:09:57 +02: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
605b95d706 Merge branch 'yazug-ignore_generated_example_files'
* yazug-ignore_generated_example_files:
  Guile gitignore and consistent naming in examples
  Add language specific files to gitignore
  gitignore for python
  Add generated director header files to .ignore
  fix typo of Perl in .gitignore
  Add some generated example files to the .gitignore list
2015-04-26 00:23:24 +01:00
William S Fulton
d7f37f3974 Guile gitignore and consistent naming in examples
Use my-guile for the executable for all the augmented examples
Fix gitignore for Guile
2015-04-26 00:17:42 +01:00
William S Fulton
3f8034395b Add language specific files to gitignore 2015-04-25 23:57:50 +01:00
William S Fulton
f8e4b1beb5 gitignore for python 2015-04-25 21:09:16 +01:00
William S Fulton
a0fe65839c Add generated director header files to .ignore 2015-04-25 18:38:15 +01:00
William S Fulton
4b69bdadd4 Add Python Travis tests for -O 2015-04-24 21:11:09 +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
Jon Schlueter
57f715e2b1 fix typo of Perl in .gitignore 2015-04-24 11:59:44 -04:00
William S Fulton
e4d02d20ad Warning fix for VC++ 2015-04-23 19:21:59 +01:00
William S Fulton
ea1b6e8ed5 Memory leak in java directors when passing byte arrays (char*, size_t)
When passing a byte array from c++ to Java using the director feature, the generated jni code does not release a temporary byte array.

This is the typemap specified in Java.swg:

    %typemap(directorin, descriptor="[B") (char *STRING, size_t LENGTH) {
    jbyteArray jb = (jenv)->NewByteArray($2);
    (jenv)->SetByteArrayRegion(jb, 0, $2, (jbyte *)$1);
    $input = jb;
    }

    %typemap(directorargout) (char *STRING, size_t LENGTH)
    %{(jenv)->GetByteArrayRegion($input, 0, $2, (jbyte *)$1); %}

Notice that the call to NewByteArray doesn't contain a symmetric release logic as the SetByteArrayRegion/GetByteArrayRegion does.

Closes #386
2015-04-23 19:17:35 +01:00
Jon Schlueter
d4a06d75a3 Add some generated example files to the .gitignore list 2015-04-23 12:24:53 -04: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
3394eab52e Fix 'make check-ccache' when one of the CCACHE_ environment variables is set.
Note that CCACHE_DISABLE is now set in the Travis environment.
2015-04-23 08:20:13 +01:00
Vadim Zeitlin
84e9cc6570 Mark the not-always-using-args in Python change as incompatible.
Some existing typemaps actually rely on "*args" being always used, so document
the change fixing the bug which resulted in their use as being potentially
incompatible and point to a way to restore the previous behaviour.
2015-04-22 23:45:30 +02:00
Ian Lance Taylor
661c4ba036 [Go] Add comments telling users that _swig_goallocate and
_swig_makegostring will no longer work in the Go 1.5 release.
Keep the existing code so that existing users with current versions of
Go will not break suddenly.
2015-04-17 09:44:40 -07:00
Olly Betts
6207b8bfa3 Move testflags.py into Tools/ 2015-04-16 10:55:34 +12:00
William S Fulton
7178bb11d3 Expand __declspec documentation 2015-04-14 08:13:13 +01:00
Chris Krycho
aebc9379ed Document %include behavior for __declspec preprocessor directives.
Add a short paragraph and example of how to handle the way Microsoft
recommends to wrap `__declspec` definitions in preprocessor macros and
supply them in a common header file.
2015-04-14 07:44:49 +01:00
William S Fulton
55e7264d43 Clearer warning message for badly constructed typecheck typemaps 2015-04-14 07:34:40 +01:00
William S Fulton
4010d25b91 HTML corrections
[skip ci]
2015-04-13 20:36:12 +01:00
William S Fulton
073bb244e4 Add docs about missing precedence levels for typecheck typemaps 2015-04-13 20:36:12 +01:00
William S Fulton
439313c7f4 Merge pull request #281 from ivan4th/master
CFFI: handle array struct/union members.

I don't know how to test this, but merging anyway.
2015-04-11 22:57:30 +01:00
William S Fulton
25b48b85ec Fix multiple definitions of 'ExceptionMatches' when using directors and multiple modules.
Java problem, closes #353 and closes #355.
2015-04-11 22:51:29 +01:00
William S Fulton
b28ea7d963 Add __dict__ fix to changes file 2015-04-11 12:50:34 +01: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
William S Fulton
1a64e74c46 Add python runtime test for dynamically added attributes
From #320
2015-04-11 12:35:58 +01:00
William S Fulton
3f549a2a5f Correct changes notes on %pythonnondynamic usage 2015-04-10 20:34:01 +01:00
Yoann Vandoorselaere
327d7c968d Attribute of SWIG wrapped classes instances were overwritten on __init__()
When a SWIG classes instances is initialized, its internal dictionary was
reset to NULL, which result in the loss of any attribute that might have
been set for the instance.

Only initialize the internal dictionary on actual PyObject creation.

class Test(MySwigWrappedClass):
        def __init__(self):
                self.val = "Random Value"
                MySwigWrappedClass.__init__(self)

p = Test()
print hasattr(p, "val") # Should return True, but used to return False
2015-04-11 02:05:11 +07:00
Yoann Vandoorselaere
3983d7b230 Fix SwigPyObject->dict memory leak
The following patch attempt to fix a memory leak happening when a
random class attribute is set. The internal instance dictionary is
created but never freed.

This fixes the problem for me, although I am not sure the patch
is correct.

<code>
 p = MySWIGClass()
 p.random_attribute = 0
</code>

Valgrind report:
==18267== 280 bytes in 1 blocks are definitely lost in loss record 1,372 of 1,780
==18267==    at 0x4A0645D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==18267==    by 0x3A90A885DC: PyObject_Malloc (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90B101A8: _PyObject_GC_Malloc (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90B102AC: _PyObject_GC_New (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90A80943: PyDict_New (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90A6E8FC: PyFrame_New (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90AE1A65: PyEval_EvalCodeEx (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90AE088E: PyEval_EvalFrameEx (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90AE21DC: PyEval_EvalCodeEx (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90AE22E1: PyEval_EvalCode (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90AFB71E: ??? (in /usr/lib64/libpython2.7.so.1.0)
==18267==    by 0x3A90AFC8DD: PyRun_FileExFlags (in /usr/lib64/libpython2.7.so.1.0)
==18267==
2015-04-11 02:05:11 +07: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
William S Fulton
fa4223e496 Fix parsing of extern "C" and typedef for example:
extern "C" typedef void (*Hook2_t)(int, const char *);
extern "C" typedef int Integer;

Closes #375
2015-04-07 21:34:23 +01:00
William S Fulton
d62aad9de9 Remove unwanted x bit in configure.ac 2015-04-04 10:23:44 +01:00
William S Fulton
6c76c7bb75 Appveyor - don't show env variables anymore 2015-04-04 02:24:14 +01:00
William S Fulton
10c34adf25 Merge branch 'wsfulton-appveyor2'
* wsfulton-appveyor2:
  Appveyor: partialcheck test-suite
  Remove appveyor debugging code
  Add CI testing for Windows using Appveyor
  Python 2 and 3 testing on Windows
  Detect Java on 64 bit windows
  Allow for spaces in path to java include directory and executables
  gcc and mno-cygwin tweaks on cygwin/mingw
  preinst-swig script support for native windows paths
  Add CSHARPOPTIONS for users to customise C# compiler flags
  Portability fixes for python example
  PY3 fixes for import_package example
  Update AX_PATH_GENERIC for spaces support
  Add support for Windows in AX_BOOST_BASE
  CSharp test-suite support on windows
2015-04-04 02:18:15 +01:00
William S Fulton
083c75e9b6 Appveyor: partialcheck test-suite
Java and Python time out when running just the test-suite.
Compromise for now... run just partialcheck-test-suite, ie
test just invoking SWIG and not C/C++compile and run tests.
2015-04-04 02:17:57 +01:00
William S Fulton
b0e0237347 Remove appveyor debugging code 2015-04-04 02:17:57 +01:00