Commit graph

3,159 commits

Author SHA1 Message Date
William S Fulton
4e8ea4e853 Python SystemError fix with -builtin
Fix error when append on a SWIG Object with -builtin:

  x.append(10)
  SystemError: error return without exception set

Having append and next methods on a SWIG object by default doesn't seem
right to me though.
2015-11-14 22:14:32 +00:00
William S Fulton
00ca9c07d1 Merge branch 'demi-rluddy-golang-unsigned-signed-char-not-string'
* demi-rluddy-golang-unsigned-signed-char-not-string:
  Revert reference change; update CHANGES.current
  Removed golang stringing for signed/unsigned char

Conflicts:
	CHANGES.current
2015-10-11 23:57:46 +01:00
Olly Betts
d0dd63e437 "concret" -> "concrete" 2015-10-12 11:24:07 +13:00
William S Fulton
146252ff21 SWIG_Ruby_ConvertPtrAndOwn changes for smartptr feature
rb_obj_is_kind_of can no longer be used for type checking as the
smartptr feature type, eg shared_ptr<Derived> cannot be cast to
a smartptr of the base class, eg shared_ptr<Base>.
Previously Derived could be cast to Base as they were in an
inheritance chain and the call to rb_define_class_under() used
SWIGTYPE_p_Base->clientdata for all derived classes.
Now SWIG_TypeCheck is always used.
2015-09-25 22:58:00 +01:00
William S Fulton
fcb383b46b shared_ptr typemap error message fix for global variables
$argnum was not being expanded in the generated code
Correct to use the error message from the standard typemaps
2015-09-25 22:57:59 +01:00
William S Fulton
4677dbb796 Add Ruby shared_ptr typemaps 2015-09-25 22:57:53 +01:00
William S Fulton
3d1e20248f Ruby ownership refactor ready for smart pointers
ruby_owntype replaced with swig_ruby_owntype which contains a member own
for forthcoming smart pointer support.
2015-09-14 07:20:43 +01:00
William S Fulton
604b3d009c Ruby trackings bug fix support for 1.8
Issue #225
2015-09-13 20:09:50 +01:00
William S Fulton
e14b392596 Ruby trackings patch tidy up and add changes entry
Closes #225
2015-09-13 14:53:26 +01:00
Klaus Kämpf
0e725b5d9b Fix Ruby tracking code to use C hash
This is a patch to resolve SF bug 2034216 (Github issue #225)
The bug is that the tracking code uses a ruby hash and thus may
allocate objects (Bignum) while running the GC. This was tolerated in
1.8 but is invalid (raises an exception) in 1.9.
The patch uses a C hash (also used by ruby) instead.
2015-09-13 14:53:25 +01:00
Rick Luddy
b1204ce92f Revert reference change; update CHANGES.current 2015-09-03 14:30:18 -04:00
William S Fulton
ab8f05204f Cosmetic changes in Octave runtime
Fix bracket matching!
2015-08-31 12:44:13 +01:00
Rick Luddy
a1e385694e Removed golang stringing for signed/unsigned char
With this change, generated code for golang treats char* as a string but
treats signed char* and unsigned char* as normal pointers. This seems to
fit better with the expected behavior, as the latter are more often used
as non-string data.
2015-08-25 09:17:19 -04:00
Robert Stone
9d19640141 check ranges in perlprimtype.swg more carefully to avoid clang warnings 2015-08-08 11:39:19 -07:00
Vadim Zeitlin
a1bddd56eb Make (char*, size_t) typemap usable for strings of other types in Java.
Notably it now works for "unsigned char*" strings.

Add a test to check that it now works in Java and also showing that it already
worked for the other languages with support for this typemap.
2015-08-07 19:44:45 +02:00
William S Fulton
a1771cb8a0 Fix potential security exploit in generated Java classes 2015-08-02 11:22:46 +01:00
William S Fulton
4b23f5d9d4 Consistent memory initialization in php typemaps.
Memory was only initialized in C and not C++ - potential bug?
2015-07-30 20:41:20 +01:00
William S Fulton
1ba48ceb99 Initialise all newly created arrays in arrays.i library.
Affects C++ code only.

Closes #440.
2015-07-30 20:41:15 +01:00
William S Fulton
cd04b372a4 Consistent memory intiailization between C and C++ in typemaps
Remove unnecessary initialization via calloc calls and replace with
malloc.
2015-07-30 20:20:38 +01:00
Orion Poplawski
5a6a39a4ee Add #include <climits> for INT_MAX 2015-07-10 08:24:09 -06:00
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