Commit graph

3,139 commits

Author SHA1 Message Date
Orion Poplawski
350c410d4b Update print() signature for octave 4.0 2015-07-09 19:20:46 -06:00
Orion Poplawski
248890aad0 Support for octave 4.0.0 2015-07-08 13:26:36 -06:00
William S Fulton
4e23595704 Unused method warning suppression for Javascript v8 2015-07-05 17:59:41 +01:00
William S Fulton
41fd7c17e0 Merge branch 'appveyor-check-test-suite'
* appveyor-check-test-suite:
  Appveyor testing expanded
  Fix array overrun in li_carrays testcase
  Warning fixes in generated Python code for 64bit Visual C++ on Windows.
  Warning fixes in generated C# code for 64bit Visual C++ on Windows.
  Warning fixes for 64bit visual c++ on Windows
  Warning fixes in generated Java code for 64bit Visual C++ on Windows.
  Warning fixes for 64bit visual c++ on Windows
  C# gc tests failure fix
  Add a space between literal and string macro
2015-07-04 21:34:42 +01:00
Joseph C Wang
fe39ef5fae suppress warning for ExternalReference print 2015-07-04 13:22:55 +08:00
William S Fulton
236822b488 Warning fixes in generated C# code for 64bit Visual C++ on Windows. 2015-07-03 20:59:24 +01:00
William S Fulton
c7da8bb06e Warning fixes in generated Java code for 64bit Visual C++ on Windows. 2015-07-03 20:59:24 +01:00
Nils Gladitz
ca208cfe35 lua: push characters as unformatted 1-character strings
Since Lua 5.3 the "%c" format character in lua_pushfstring will produce
the string "<\XXX>" (XXX being a decimal code sequence) when
given unprintable characters.

Use lua_pushlstring instead to reproduce the old behavior.
2015-07-01 12:24:12 +02:00
Simon Marchetto
078ad6cb86 simplify SWIG_SciString_AsChar() 2015-06-23 16:24:35 +02:00
Simon Marchetto
b05f0057ca improve support of varargs 2015-06-23 16:24:35 +02:00
Simon Marchetto
05cfa06dbb scilab: use freeAllocatedSingleString() after getAllocatedSingleTree() 2015-06-23 16:24:35 +02:00
Simon Marchetto
64e5215f29 scilab: fix memory leak 2015-06-23 16:24:35 +02:00
William S Fulton
5fb344e0e6 R - fix duplicate generation of 'self' parameter.
Fixes director_keywords test case.
2015-06-12 20:25:00 +01:00
William S Fulton
1891b82e00 R - Call to SWIG_createNewRef in copyToC was incorrectly named.
Closes #430
2015-06-12 20:23:56 +01:00
Olly Betts
a89a4d9e84 [Python] Fix warning when compiling generated code with MSVC.
Fixes https://sourceforge.net/p/swig/patches/351/ reported by Mateusz
Szymański).
2015-05-19 15:48:25 +12:00
Olly Betts
e796ecaa23 Fix swapped parameters in memset call 2015-05-12 14:20:11 +12:00
William S Fulton
6c1630b152 Fix Java multi-argument typemaps (char *STRING, size_t LENGTH)
Now they can be applied to a wider range of types.
Closes #385.
2015-05-10 13:35:51 +01:00
William S Fulton
775afd3579 Refactor Java director swig_override array code
Remove code duplication: Use new Swig::BoolArray to replace multiple
instances of ZeroedBoolArray.

Refactors #403 and #413.
2015-05-10 11:40:42 +01:00
Olly Betts
b06ec2c847 Fix typo in method description 2015-05-10 01:23:09 +12:00
Olly Betts
d1a8675ac4 Fix incorrect comments 2015-05-09 21:59:03 +12:00
Olly Betts
083a03710a Remove no-op calls to swig_incref().
Python and Perl were calling this from the Director constructor, but
swig_disown_flag is always false at that point, so the call doesn't
do anything.
2015-05-09 18:34:11 +12:00
Ian Lance Taylor
48263f4802 [Go] Make sure that arguments for which use memcpy when calling C are
still live after the call.  This ensures that they will not be
collected if the GC runs during the call.
2015-05-04 15:11:31 -07:00
Olly Betts
0fad8a3728 '#undef seed' macro which Perl API headers define
This macro breaks '#include <algorithm>', causing generated Perl
bindings to fail to compile with 'g++ -std=gnu++11'.
2015-05-02 00:06:58 +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
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
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
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
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
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
Simon Marchetto
4c6f29b778 scilab: fix possible crash by using consistent allocation/free methods (use SWIG macros) 2015-03-24 16:52:18 +01:00
Olly Betts
c8a7322a4d Use %{ %} instead of { } after %pythoncode
Simpler and safer change to address PR#357.
2015-03-20 13:45:19 +13:00
Olly Betts
7eb890e64f Fix typo in forward declaration 2015-03-18 13:42:53 +13:00
Olly Betts
f2c2baf2af Remove bogus comment 2015-03-18 13:39:26 +13:00
Olly Betts
ab677205d8 Suppress warning from Intel compiler
Fixes issue #192, reported by kesmit13
2015-03-16 18:12:38 +13: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
Olly Betts
c4268c369b Fix cut-and-paste typo 2015-03-12 17:50:52 +13:00
Ian Lance Taylor
9ad497c08e [Go] Add -cgo option, required for Go version 1.5 and later. 2015-03-02 14:03:33 -08:00
Ian Lance Taylor
1dd401899f [Go] Change SWIG directors to use a handle instead of a Go pointer.
In future releases of Go it will not be possible to pass Go pointers
into C/C++ code.  The handle is automatically translated back to the
Go value using a Go map.  Since directors must be explicitly deleted,
we can reliably use that call to remove the handle from the map.
2015-02-22 11:09:58 -08:00
Simon Marchetto
4b2ccd2892 scilab: fix compilation error on Windows 2015-02-13 12:07:27 +01:00
William S Fulton
2947b711d9 Warning fixes in Go cdata library
GCC warnings -Wpointer-to-int-cast and -Wdeclaration-after-statement
2015-02-11 23:34:16 +00:00
William S Fulton
1ef899a57b Merge branch 'stricter-warnings'
* stricter-warnings:
  Go changes for wrappers to compile as ISO C90
  Scilab typecheck typemaps fix for C90
  No error for one Javascript node warning
  Warning fix in testcase for Javascript node
  nested_extend_c testcase fix when compiled by C++ target languages
  Temporarily remove -Werror for Scilab testing
  C90 fixes for Javascript JSC
  There are a couple of testcases that aren't compliant and supression via pragmas doesn't work for gcc < 4.8
  Warning suppression change
  Scilab typemap fixes for C89
  compiler warning suppression correction in testcase
  Suppress pedantic warnings in C# testcases
  Suppress pedantic warnings in testcases
  Pedantic warning fix in testcase
  pedantic warning fix for D wrappers
  Travis testing to use testflags.py for setting CFLAGS and CXXFLAGS
  Add travis build for error-declaration-after-statement branch
2015-02-11 23:33:26 +00:00
William S Fulton
4e86210e74 Scilab typecheck typemaps fix for C90
Fix mix of mixed declarations and code.
Also redo these typemaps so that the SWIG preprocessor comments don't appear
in the generated code.
2015-02-11 23:32:45 +00:00
William S Fulton
59ff3e6a3a C90 fixes for Javascript JSC 2015-02-11 23:32:45 +00:00
William S Fulton
0236435c48 Scilab typemap fixes for C89 2015-02-11 23:24:40 +00:00
William S Fulton
ef75735e9b pedantic warning fix for D wrappers 2015-02-11 23:24:39 +00:00
Björn Esser
4490f19dcc Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework 2015-02-10 16:40:56 +01:00
Ian Lance Taylor
0a021a938e [Go] Remove all generated calls to _swig_makegostring, as it will no
longer as of Go 1.5.  In Go 1.5 or later user calls to
_swig_makegostring will fail at link time.

Instead, use goout and godirectorin typemaps to allocate strings in Go
code.

Change the Go typemaps support to ignore empty strings, so that we can
define empty strings for regular types so that %apply will override
the definitions for string types.

Fix the gccgo code to wrap SwigCgoCallback around all godirectorin
typemaps.

Add a few newlines after typemap code so that the typemaps don't have
to include them.
2015-02-05 10:15:37 -08:00
Ian Lance Taylor
603e3b49b3 Merge branch 'master' of git://github.com/swig/swig 2015-02-04 16:09:51 -08:00