Commit graph

3,331 commits

Author SHA1 Message Date
Olly Betts
1169874f59 [PHP] Add support for PHP7.
PHP5's C extension API has changed substantially so you need to use
-php7 to specify you want PHP7 compatible wrappers.
Fixes https://github.com/swig/swig/issues/571
2016-11-30 13:05:59 +13:00
William S Fulton
3b03e6addd Fix a few minor inconsistencies in the STL wrappers
Mainly to use a more normal constructor declaration and to enable
classes with more than one template parameter to be used as container types.
2016-11-29 19:35:09 +00:00
William S Fulton
1079ba7ff8 Merge branch 'm7thon-python23-division-operators'
* m7thon-python23-division-operators:
  [Python] improved wrapping of division operators
2016-11-26 22:00:21 +00:00
Daniel Vollmer
e4c5d82c71 Python: Fix mixed signedness warning for std::array 2016-11-23 22:21:46 +01:00
William S Fulton
0a22fa0df1 Missing transient keywords in Java proxy class
Further security exploit refinements to a1771c
2016-11-13 19:55:50 +00:00
Joseph C Wang
377f756f49 Fix #555 - Add stdio.h
This corrects for compilers that need stdio.h
2016-11-12 00:28:39 +08:00
William S Fulton
bdda0a0829 Python - fix compilation error when using -extranative and -builtin.
Closes #816
2016-11-02 22:00:54 +00:00
William S Fulton
d48b1712a8 Merge branch 'myd7349-master'
* myd7349-master:
  Convert the Java runtime testcase cpp11_li_std_array_runme to C#
  Add C++11 std::array interface file for C#
  SWIG_STD_VECTOR_ENHANCED for std::wstring
2016-10-30 22:27:47 +00:00
William S Fulton
b8ec248494 Merge branch 'tobilau-localref_wstring'
* tobilau-localref_wstring:
  Added LocalRefGuard for wstrings
2016-10-30 13:55:34 +00:00
William S Fulton
e9e6a99f0f Add missing VOID_INT_PTR director typemaps 2016-10-23 16:18:05 +01:00
Tobias Lau
26293546a6 Added LocalRefGuard for wstrings 2016-10-20 13:37:28 +02:00
William S Fulton
87bede9a99 Return to Python builtin tp_new initialization in init function. 2016-10-15 22:43:42 +01:00
William S Fulton
08a98437d0 Fix redundant NULL check in php typemaps
Fix for clang compile error as the address of an array will never be NULL.
2016-10-15 17:58:21 +01:00
William S Fulton
e5fd1c979b Cosmetic change to using SwigPyObject 2016-10-14 07:30:44 +01:00
William S Fulton
96fae38be2 Fix Python pickling and metaclass for builtin wrappers
The metaclass (SwigPyObjectType) for SWIG objects was not defined in
a way that let importlib successfully import the Python wrappers.
The pickle module failed because it couldn't determine what module the
SWIG wrapped objects are in.

I've changed the definition of SwigPyObjectType using more normal
builtin type definitions. There are still some open questions:
- None of the builtin types, like swig_static_var_getset_descriptor and
  SwigPyObject are added into any module. No call to PyModule_AddObject
  is made, so isinstance cannot be used for any wrapped type, all of
  which are derived from SwigPyObject.

Closes #808
2016-10-14 07:30:44 +01:00
Simon Marchetto
6b2caca8b9 scilab: add runtime function SWIG_Scilab_TypeQuery() checks runtime is initialized 2016-10-05 14:09:08 +02:00
Simon Marchetto
36156a2295 scilab: clean runtime code (move error functions..) 2016-10-05 14:09:08 +02:00
William S Fulton
08e32e794c Add further documentation/info on the smartptr feature to the shared_ptr library file
[skip ci]
2016-09-30 18:43:49 +01:00
Simon Marchetto
457ea5d209 scilab: remove compilation warnings 2016-09-26 13:55:45 +02:00
Simon Marchetto
0c09b00d6e scilab: mlists that map pointers can be given a custom type name 2016-09-26 11:54:17 +02:00
William S Fulton
777c825cd2 Rework Python builtin CLOSURE macros
The new approach uses support functions and minimal code in the macros
to make debugging easier.
2016-09-25 14:15:38 +01:00
William S Fulton
848628ae91 More flexible python builtin slots
The closure names used for builtin slots are mangled with their functype so
 that overloaded C++ method names can be used for multiple slots.
For example:
%feature("python:slot", "mp_subscript", functype="binaryfunc") SimpleArray::__getitem__;
%feature("python:slot", "sq_item", functype="ssizeargfunc") SimpleArray::__getitem__(Py_ssize_t n);
will generate closures:
  SWIGPY_SSIZEARGFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___ssizeargfunc_closure */
  SWIGPY_BINARYFUNC_CLOSURE(_wrap_SimpleArray___getitem__) /* defines _wrap_SimpleArray___getitem___binaryfunc_closure */
2016-09-25 14:15:38 +01:00
William S Fulton
5b8e8fa107 Merge pull request #793 from q-p/bad_cast
Add std::bad_cast to std_except.i
2016-09-25 14:12:01 +01:00
Daniel Vollmer
dd7a5a6e6e Fix missed files 2016-09-17 19:01:42 +02:00
William S Fulton
0769e9b727 Fix iterators for containers of NULL pointers (or Python None) when using -builtin.
Previously iteration would stop at the first element that had a NULL pointer value.
2016-09-17 17:53:48 +01:00
Daniel Vollmer
ce1cb85d86 Add <typeinfo> header for std::bad_cast 2016-09-17 13:24:32 +02:00
Daniel Vollmer
2dc87d7485 Add std::bad_cast to std_except.i
This exception occurs when dynamic_cast<T&> fails.

Fixes #783.
2016-09-17 10:26:54 +02:00
Olly Betts
b138f054e5 [Javascript] Fix SWIG_exception() macro (#792)
Fix SWIG_exception() macro to return from the current function.
Fixes #789, reported by Julien Dutriaux.
2016-09-17 17:29:42 +12:00
Olly Betts
26bbc96d58 Arrange to return after calling zend_throw_exception()
Fixes github issue#240.
2016-09-16 17:54:02 +12:00
Marcin Wojdyr
902f5d3f32 cstrings.swg: fix function names inside comments (#790) 2016-09-16 12:26:35 +12:00
William S Fulton
5e50cfba25 Merge branch 'xypron-532'
* xypron-532:
  Csharp: CLS compliance - keyword rename
2016-09-12 08:13:51 +01:00
brgirgis
0f48af8a05 Fix one casting warning on Linux (#787) 2016-09-12 09:21:20 +12:00
Heinrich Schuchardt
073948777e Csharp: CLS compliance - keyword rename
SWIG C# can be used to wrap native libraries as common language
interface compatible assemblies.
If you want to use the assemblies with other languages like
Visual Basic these assemblies should comply to the
Common Language Specification (CLS).

Lib/csharp/csharpkw.swg defines rename rules to avoid collisions
with keywords. Unfortunately these rules prepend an underscore.
Parameters starting with underscores are not CLS compliant.

Hence the rules should be changed to append the underscore
instead of prepending it.

Tested with
make check-csharp-test-suite

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Olly Betts <olly@survex.com>
2016-09-09 16:40:18 +02:00
Simon Marchetto
c252d5cb40 scilab: pointer is mapped to mlist instead of tlist (for scilab overloading) 2016-09-02 11:36:02 +02:00
Olly Betts
c51ce4995c [PHP] Fix "in" typemap for char INPUT[ANY] 2016-09-02 16:38:58 +12:00
William S Fulton
5abb3e8008 More efficient Python slicing
Call reserve for container types that support it to avoid repeated
memory reallocations for new slices or slices that grow in size.
2016-09-01 23:49:30 +01:00
William S Fulton
5ebf1cfa5d Slight simplification of Python slicing 2016-09-01 23:49:30 +01:00
Olly Betts
a4015acaca [PHP] Fix out typemap for member function pointers
The existing typemap was just broken - it correctly created the resource
and then did nothing with it, and instead tried to register the member
pointer as a normal pointer, which is never going to work as it's larger
than a normal pointer.

Add cpp_basic_runme.php as a regression test for this.
2016-09-02 09:51:18 +12:00
William S Fulton
27254cde09 Merge pull request #771 from swig/builtin-hashable
Make Python builtin types hashable by default
2016-09-01 19:26:57 +01:00
Olly Betts
3a8f734221 Remove unused SWIG_landfill
It's not been used in any version of SWIG in the repository, isn't
documented, and I can find no trace of user code using it.
2016-08-30 11:18:28 +12:00
William S Fulton
5b7c08c214 Make Python builtin types hashable by default
Default hash is the underlying C/C++ pointer.
This matches up with testing for equivalence (Py_EQ in SwigPyObject_richcompare)
which compares the pointers.
2016-08-23 19:06:36 +01:00
William S Fulton
253a39fdff Fix hash function type checking for older versions of Python
Python 2.6 was asserting instead of throwing a Python TypeError.
2016-08-23 18:46:28 +01:00
William S Fulton
1cef6b7440 Merge branch 'builtin-tweaks'
* builtin-tweaks:
  Python builtin minor tweaks
  Cosmetic code formatting corrections
  Further additional Python builtin slots as features for user customization
  Add additional Python builtin slots as features for user customization
  Correct notes on customising Python builtin comparison operators
  Set tp_new statically rather than during initialisation
  Customize slots tp_basicsize tp_methods tp_getset
  Additional Python builtin slot overrides and slightly better formatted Python generated code
  Add Python builtin tp_dealloc override test
  Python getSlot() refactor
  Add Python builtin closure method in comment
  Update Python docs on builtin slots
  Python builtin hashfunc closure fix
2016-08-22 19:37:10 +01:00
William S Fulton
ae32fb4f9a Python builtin minor tweaks
Remove internal Python struct names from generated code
Cosmetic code formatting
2016-08-22 19:28:52 +01:00
William S Fulton
4f777b181c Correct notes on customising Python builtin comparison operators
Also add example for python:compare feature
2016-08-22 07:22:40 +01:00
William S Fulton
4f681f751d Update Python docs on builtin slots 2016-08-18 07:11:00 +01:00
William S Fulton
f778ee19df Python builtin hashfunc closure fix
If the wrong return type in the hash function was used, an error:
  SystemError: error return without exception set
was raised

Add some tests for testing builtin slots
2016-08-18 07:10:54 +01:00
Richard Beare
c334efd36b Writing R extensions says:
Most R header files can be included within C++ programs but they should
not be included within an extern "C" block (as they include system headers).

This patch moves the Rdefines.h and Rversion.h outside the extern block.
2016-08-05 15:46:14 +10:00
William S Fulton
91aba9f719 UTL STL container descriptor checks
The vector of pointers (just fixed) were not working correctly because the
descriptors returned from swig::type_info() were sometimes returning
zero. Zero should only be used for void * as the subsequent call to
SWIG_ConvertPtr will blindly cast the pointer without checking
descriptor.

std::vector<void *> does not work and will require further changes:
specializing traits_info<void *> to return 0 and traits_asptr<void *>.
I tried this and traits_asptr<void> also needs to be added in which
seems odd and requires further investigation...

Lib/python/pystdcommon.swg:
  template <> struct traits_info<void *> {
    static swig_type_info *type_info() {
      static swig_type_info *info = 0;
    }
  };

Lib/std/std_common.i:
  template <>
  struct traits_asptr<void *> {
    static int asptr(PyObject *obj, void ***val) {
      void **p;
      swig_type_info *descriptor = 0;
      int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
      if (SWIG_IsOK(res)) {
	if (val) *val = p;
      }
      return res;
    }
  };

  // this is needed, but am not sure this is expected
  template <>
  struct traits_asptr<void> {
    static int asptr(PyObject *obj, void **val) {
      void **p;
      swig_type_info *descriptor = 0;
      int res = SWIG_ConvertPtr(obj, (void **)&p, descriptor, 0);
      if (SWIG_IsOK(res)) {
	if (val) *val = p;
      }
      return res;
    }
  };
2016-07-28 22:51:29 +01:00
William S Fulton
6e9184b6f8 Fix std::vector of pointers which failed if a pointer to a pointer of the container element type existed (Python)
Closes SF Bug 2359417 created after commit 93f0390322 (svn rev 10958)
2016-07-28 22:51:22 +01:00