Commit graph

3,934 commits

Author SHA1 Message Date
Chris Burr
eafe1e2daa
Use Py_TYPE in SwigPyBuiltin_SetMetaType 2020-07-28 08:11:02 +02:00
Chris Burr
917110212e
PyTypeObject::ob_base isn't available in PyPy 2020-07-17 12:15:54 +02:00
William S Fulton
938c3bbb54 Merge branch 'fix-1199'
* fix-1199:
  fix #1199
2020-06-07 10:29:55 +01:00
William S Fulton
a6dc8821c2 Merge branch 'andreas-schwab-master'
* andreas-schwab-master:
  Ruby wstring - only include endian.h on linux
2020-06-06 08:42:17 +01:00
Andreas Schwab
58ffbe616f Ruby wstring - only include endian.h on linux
This file is not always available on other systems.
See #1801
2020-06-06 08:39:47 +01:00
William S Fulton
85f2378b84 Merge branch 'r-script-fixes'
* r-script-fixes:
  Fix further missing semicolons in R code.
  fixed some missing semicolons. Each one caused a compile error in generated code
2020-06-02 18:11:12 +01:00
Karl Wette
d73ef20475 octrun.swg: ensure type_id() is set correctly 2020-05-31 22:11:51 +10:00
Karl Wette
d11e29615d Octave: use pre-compiled headers to speed up test suite, if supported 2020-05-31 22:11:51 +10:00
Karl Wette
26423d06b3 octruntime.swg: do not use atexit() to quit Octave
- This reverts commit 931656bcbe
- Since atexit() does not pass along the desired exit status,
  __swig_atexit__() always exits with status zero, regardless
  of whether Octave completed successfully or raised an error.
- This means the success/failure of Octave scripts which load
  SWIG modules cannot be determined by other programs, which
  makes them unusable.
- Instead, provide a Octave function swig_exit() which calls
  ::_Exit() with a given exit status. This way at least a
  clean exit from Octave can be guaranteed for future versions
  if the seg-fault problem is not fixed.
2020-05-31 06:43:15 +10:00
Karl Wette
30132bf777 octrun.swg: remove octave_value type-id from octave_swig_bound_func
- The {DECLARE|DEFINE}_OV_TYPEID_FUNCTIONS_AND_DATA declarations
  attached to this class cause a seg-fault in the module_load
  Octave example. Removing these declarations fixes the seg-fault.
- While cause of seg-fault is unknown, note that (in Octave 5.1.0)
  the declaration of octave_function, which is the base class for
  octave_swig_bound_func, does not use these declarations. So it's
  possible they simply are not required for this type of subclass.
2020-05-31 06:43:15 +10:00
Marcel Steinbeck
3c9dd44ff4 D: Replace deprecated imports (package std.c). Fixes #1593 2020-05-30 16:28:48 +01:00
William S Fulton
02e967d05d
Merge pull request #1716 from ZackerySpytz/Python-utf8-cache
Use PyUnicode_AsUTF8() for Python >= 3.3
2020-05-29 23:56:10 +01:00
khoran
d58041606e fixed some missing semicolons. Each one caused a compile error in generated code 2020-03-25 11:01:12 -07:00
William S Fulton
aad43031a4 Merge branch 'ryannevell-master'
* ryannevell-master:
  Clean up test cases
  Fix unwrapping of LUA lightuserdata type. Add test case.
2020-02-18 22:07:05 +00:00
William S Fulton
4ce77ffb77 Ruby - catch exceptions by const reference 2020-02-18 22:06:20 +00:00
William S Fulton
c08e0d19f9 Merge branch 'catch-value'
* catch-value:
  Catch exceptions by reference rather than by value.
2020-02-18 22:00:45 +00:00
Ryan Nevell
33c59614fc Fix unwrapping of LUA lightuserdata type. Add test case. 2020-02-17 09:16:24 -08:00
Daniel Mach
70f6ee9656 Catch exceptions by reference rather than by value.
Fixes -Wcatch-value gcc warnings.
2020-02-14 12:58:49 +01:00
William S Fulton
6cec69ef7b Remove an unnecessary shared_ptr reference count increment in Ruby wrappers
When wrapping STL containers, remove a shared_ptr reference count
increment when an upcast is needed when checking type conversion
in traits_check::check.
2020-02-13 19:48:30 +00:00
William S Fulton
67a38589a8 Minor code refactor in Python traits_asptr::asptr 2020-02-13 19:32:13 +00:00
William S Fulton
339d427910 Merge branch 'master-fix-vector-shared_ptr'
* master-fix-vector-shared_ptr:
  fixing memleak of shared_ptr objects in python with creating a [wrapped] vector<shared_ptr<Foo>> from a list of shared_ptr<Bar> where Bar is derived from Foo.
2020-02-13 19:21:12 +00:00
William S Fulton
94b4c7dc21 Better error checking when setting 'this' in Python
If python_append.i is modified to use:
__slots__ = []
instead of
__slots__ = ["this"]
then this additional error checking prevents a crash and shows a stack trace and error:
  AttributeError: 'ForSlots' object has no attribute 'this'

Related to issue #1674
2020-02-06 07:27:08 +00:00
William S Fulton
a01e8474f6 Fixing setting this in Python when using __slots__
Don't attempt to use the class's __dict__ for setting 'this' when
a user has extended a class with:
    __slots__ = ['this'].
Was segfaulting. Now we fall back to a simple PyObject_SetAttr if the
usual approach to setting 'this' in __dict__ does not work.

Closes #1673 Closes #1674
2020-02-06 07:08:16 +00:00
Viktor Gal
7d2dbe3670 fix #1199 2020-02-01 11:25:30 +01:00
Zackery Spytz
f6d97d2338 Use PyUnicode_AsUTF8() for Python >= 3.3 2020-01-31 23:48:32 -07:00
William S Fulton
ebc324dfd5 Merge branch 'ruby-autoptr'
* ruby-autoptr:
  Extend std::auto_ptr<> support to Ruby
2020-01-31 19:26:19 +00:00
William S Fulton
10cbc9481f Merge branch 'Python-coverity'
* Python-coverity:
  Fix possible refleaks.
  Check Py{Bytes,String}_AsStringAndSize() for failure
2020-01-31 19:14:47 +00:00
William S Fulton
a0d4218543 Minor refactor of R error handling code 2020-01-31 08:58:09 +00:00
Arnaud Barré
3fa5c8c652 Fix R memory leak on exception
There is a possible memory leak in case the SWIG_exception_fail macro
is called. The problem is related to its definition that call the
function Rf_warning. This function (as well as Rf_error) involves
a longjmp over C++ destructors on the stack. Thus, all the objects
allocated on the heap are not freed.

Closes #914
2020-01-30 20:43:39 +00:00
Zackery Spytz
58e409dd2b Fix possible refleaks. 2020-01-29 10:00:22 -07:00
Vadim Zeitlin
7cc94808b6 Extend std::auto_ptr<> support to Ruby
This is trivial as exactly the same typemap as for Python can be used
for Ruby too, all the differenced are abstracted by the unified typemap
library.
2020-01-17 15:09:17 +01:00
Julien Schueller
96c6bf4cc2 Fix unused-parameter warning in pycontainer.swg 2020-01-17 11:09:57 +01:00
William S Fulton
5ce839932c Merge branch 'OCaml-caml_named_value-const'
* OCaml-caml_named_value-const:
  [OCaml] Fix compilation errors with OCaml 4.09.0
2020-01-13 19:46:29 +00:00
William S Fulton
3759fcf999 Merge branch 'builtin-ctor-kwargs'
* builtin-ctor-kwargs:
  Python -builtin constructors silently ignored keyword arguments.
2020-01-13 19:29:47 +00:00
William S Fulton
67e8334ac8 Python -builtin constructors silently ignored keyword arguments.
Instead of silenty ignoring them, now a "TypeError: f() takes no keyword arguments"
exception is thrown if keyword arguments are used. Hence constructors and normal
methods/functions behave in the same way.

Closes issue #1595
2020-01-13 19:26:22 +00:00
Zackery Spytz
6adf19b52f Check Py{Bytes,String}_AsStringAndSize() for failure
PyBytes_AsStringAndSize() and PyString_AsStringAndSize() were not
being checked for failure.

Closes #1349.
2020-01-09 21:14:12 -07:00
William S Fulton
be5dbc2bf8 Merge branch 'py38_initializer'
* py38_initializer:
  Fix missing-field-initializers warning with Py3.8
2020-01-05 21:48:51 +00:00
William S Fulton
40ec65ae5e Merge branch 'octave_swig_this'
* octave_swig_this:
  Changed return type of swig_this() to size_t.
2020-01-05 11:03:51 +00:00
Thomas Reitmayr
f5908eca76 Improve description of cast macros for Ruby
The macros for casting function pointers are now fully described and also
clarify why the macros act transparently for C even before Ruby 2.7.

In addition, an "if (CPlusPlus)" was removed in the code generator for
global variables in order to keep the distinction between C and C++ in
one place, which is at the definition of said macros.
2020-01-04 18:37:35 +01:00
Thomas Reitmayr
5542cc228a Move new macros for Ruby to their dedicated namespace 2020-01-03 21:45:53 +01:00
Thomas Reitmayr
00e291b319 Add support for Ruby 2.7
This commit fixes the signatures of various callback methods
and cleans up the macro definitions used for casting callbacks.

Note that the transparent version of the macro RUBY_METHOD_FUNC
is currently masked behind RUBY_DEVEL, see commit
1d91feaf13
In order to still support strict signature checking and prevent
nasty deprecation warnings, the use of RUBY_METHOD_FUNC had to
be replaced with VALUEFUNC.
2019-12-31 17:53:53 +01:00
Zackery Spytz
02862fb278 [OCaml] Fix compilation errors with OCaml 4.09.0
caml_named_value() was modified to return a const value* in OCaml
4.09.0.

Closes #1686.
2019-12-29 22:41:43 -07:00
Markus Friedrich
a2d9a24f4d Changed return type of swig_this() to size_t.
The type long may be 4 bytes but swig_this() must return the address of
the object as an integer. Using size_t ensures that the return type can
store a pointer.
2019-12-24 14:06:25 +01:00
Julien Schueller
b536702c01 Fix missing-field-initializers warning with Py3.8
Python 3.8 adds tp_vectorcall, tp_print is added for compat just for 3.8
https://github.com/python/cpython/pull/13185/files#diff-b5db2632fa7acaf3b44abb56f18b9615
2019-11-20 15:40:52 +01:00
William S Fulton
97a107ed25
Merge pull request #1619 from emminizer/fix-msvc2019-python
Fix error in generated code for Python in MSVC 2019.
2019-10-01 08:12:58 +01:00
William S Fulton
719eea090d Improve error handling calling PyObject_SetAttr
Less obscure error when setting 'this' on the SWIG proxy object
attempting to override __setattr__ in C++ (swig-user mailing list
query 19 Aug 2019).
2019-09-13 07:37:03 +01:00
Daniel Emminizer
9fc57f47bd Fix error in generated code for Python in MSVC 2019.
Visual Studio 2019 release builds:
error C4703: potentially uninitialized local pointer variable 'p' used
2019-08-29 09:10:41 -04:00
William S Fulton
4f948d01d6 Merge branch 'illegal_state_except'
* illegal_state_except:
  [Java] Add support for throwing IllegalStateException
2019-08-20 07:06:46 +01:00
William S Fulton
87a0dd2d90 Merge branch 'sjml-patch-1-lua-print'
* sjml-patch-1-lua-print:
  removing unnecessary bits
  closer match to Python's output
  typo
  actually seeing both is useful
  matching code conventions
  Lua userdata print pointing to wrapped memory
2019-08-19 07:48:23 +01:00
Brad Kotsopoulos
85edc6de99 [Java] Add support for throwing IllegalStateException 2019-08-18 23:33:11 -04:00