Commit graph

818 commits

Author SHA1 Message Date
William S Fulton
cd9b7c3c34 std_basic_string.i fixes
- Remove python code from octave's std_basic_string.i
- Correctly return an error to fix error handling when using std::basic_string in
  overloaded methods - issue #1171.
2018-01-04 07:00:26 +00:00
William S Fulton
b0e29fbdf3 Add missing checks for failures in calls to PyUnicode_AsUTF8String.
Previously a seg fault could occur when passing invalid UTF8 strings (low
surrogates), eg passing u"\udcff" to the C layer (Python 3).
2017-12-04 20:14:04 +00:00
William S Fulton
3f8b8fe734 Enhancements for directorin typemaps
The directorin typemaps will now generate a temporary variable
(specified after the type), such as:
%typemap(directorin) MyType (MyType *temp) { ... use temp ... }

The shared_ptr director typemaps have been fixed for use in functions
that take more than one parameter.
2017-10-16 19:28:27 +01:00
William S Fulton
6470fe8c36 Director shared_ptr typemaps for scripting languages
Modify the Python and Ruby director shared_ptr typemaps to be language neutral.
Port the director modifications to other scripting languages that
have shared_ptr support - Octave, R and Scilab. Scilab shared_ptr
support is not fully working and needs work though.
2017-10-13 07:34:38 +01:00
William S Fulton
d0615d98a9 Merge branch 'radarsat1-fix-null-shared_ptr-directors'
* radarsat1-fix-null-shared_ptr-directors:
  Remove duplicate director shared_ptr pointer reference typemaps
  For shared_ptr directorin, make copy of shared_ptr in all cases.
  Add directorin typemap for Python and Ruby shared_ptr.
2017-10-11 09:03:01 +01:00
William S Fulton
000e63e0f8 Remove duplicate director shared_ptr pointer reference typemaps 2017-10-11 07:08:46 +01:00
Olly Betts
5a9422d980 Remove GCJ support
GCC7 dropped GCJ.

Closes https://sourceforge.net/p/swig/bugs/823/
2017-10-09 08:32:01 +13:00
William S Fulton
e01cfd70c7 Add missing declaration for std::complex
Fixes missing type information for std::complex in scripting languages.
Closes #732.

Update Javascript and Octave complextest, although they don't actually
get run as they don't work
2017-10-02 19:07:24 +01:00
Stephen Sinclair
52ca39b5ab For shared_ptr directorin, make copy of shared_ptr in all cases. 2017-09-27 18:10:59 -03:00
Stephen Sinclair
bda750ee15 Add directorin typemap for Python and Ruby shared_ptr. 2017-09-27 11:22:30 -03:00
William S Fulton
ed4b84f4d3 Fix overloading of shared_ptr method overloading
Add 'equivalent' attribute to typecheck typemap.
Closes #1098.
2017-09-23 15:19:34 +01:00
William S Fulton
af3d59917d Merge branch 'VLAM3D-master'
* VLAM3D-master:
  Define _DEBUG to 1 to do exactly like /LDd, /MDd or /MTd compiler options
2017-09-10 17:15:55 +01:00
Lamarre, Mathieu
711ae14541 Define _DEBUG to 1 to do exactly like /LDd, /MDd or /MTd compiler options 2017-08-31 09:43:07 -04:00
William S Fulton
fbada9959c Fix types when calling PyTuple_New
Replace int with Py_ssize_t to fix warnings on Windows when using -O
and/or -builtin.
2017-08-27 14:18:00 +01:00
Olly Betts
90f9117e10 Fix various comment and documentation typos 2017-08-13 18:04:33 +12:00
Mike Romberg
b229d92f9b remove bool from as() (it now always throws).
catch std::invalid_argument (what is expected) instread of std::exception.
2017-07-03 12:49:30 -06:00
Mike Romberg
bfaafde020 traits_as<Type,...>::as() ignores throw_error and always throws. 2017-07-03 12:25:04 -06:00
Mike Romberg
6c0885ff67 Use the Type() ctor and avoid:
- clang warning about memset overwrite of vtable
  - memory leak
  - Undefined behavior in Type copy/move operations and dtor.
2017-07-01 17:58:59 -06:00
Mike Romberg
74345c92e4 supress clang warning about vtable ptr overwrite.
Use calloc to zero memory just once.
Document memory leak.
2017-07-01 17:38:48 -06:00
William S Fulton
005ff93dbd Fix construction from dict for std::multimap std::unordered_multimap (Python 3) 2017-06-23 14:38:26 +01:00
William S Fulton
b56d7c0539 Python builtin C++11 STL fixes
Compilation fixes for std::multimap, std::unordered_map and
std::unordered_multimap.
2017-06-19 20:32:32 +01:00
William S Fulton
4ab2aff0a1 Fix Python unordered_map and ordered_map compilation error when using -builtin 2017-06-19 19:43:51 +01:00
William S Fulton
82969b0755 Fix warning in generated code - traits_asptr.
Visual Studio 2015 debug builds:
error C4703: potentially uninitialized local pointer variable 'p' used
2017-06-13 19:02:59 +01:00
William S Fulton
430f20a533 Merge branch 'tamuratak-fix_python_unordered_2'
* tamuratak-fix_python_unordered_2:
  [python] add %swig_sequence_iterator_with_making_function and          make %swig_sequence_iterator forward to it.          add %swig_sequence_forward_iterator too.
  [python] make SwigPyIteratorClosed_T and SwigPyIteratorOpen_T          inherit from forward iterator classes.
  [python] fix std unordered containers
2017-04-25 07:55:21 +01:00
William S Fulton
ab1e9f5bd9 Consistent whitespace amongst all the shared_ptr and intrusive_ptr typemaps
[skip ci]
2017-04-20 19:21:47 +01:00
William S Fulton
ea118c945b Merge branch 'srepmub-coverity_replacecount'
* srepmub-coverity_replacecount:
  Fix Coverity issue reported for setslice (pycontainer.swg):
2017-03-24 07:42:59 +00:00
William S Fulton
fa65b24b78 Add stddef.h back in to SwigPySequence_Base fragment 2017-03-17 19:20:02 +00:00
Vadim Zeitlin
51aa2bdea1 Fix dependency of SwigPySequence_Base fragment
This fragment needs to depend on StdTraits fragment as it specializes the
template struct traits<> defined there and it could happen that the struct was
not declared before being specialized, resulting in compilation errors in the
generated code.

It doesn't seem to need to depend on stddef.h inclusion, however, so replace
it with the correct dependency instead of keeping both.
2017-03-11 18:07:51 +01:00
Mark Dufour
5803e81d48 Fix Coverity issue reported for setslice (pycontainer.swg):
"CID 11151 (#3-1 of 3): Using invalid iterator (INVALIDATE_ITERATOR)18.
increment_iterator: Incrementing iterator it though it is already past
the end of its container."

Coverity does not understand 'replace_count', so warns that we may go
past self->end() (or self->rend() I guess).
2017-03-06 21:16:41 +01:00
Mark Dufour
21f532975f [Coverity] fix issue reported for SWIG_Python_ConvertFunctionPtr
Fix Coverity issue reported for SWIG_Python_ConvertFunctionPtr:

"Execution cannot reach this statement: *ptr = vptr;"

Because if 'ty' is null, then desc becomes null and we return with
SWIG_ERROR. So 'ty' cannot be null at 'if (ty)'.
2017-02-19 09:47:34 +13:00
Mark Dufour
9825fcbab5 [Coverity] fix issue reported for SWIG_Python_FixMethods
Fix Coverity issue reported for SWIG_Python_FixMethods:

"buffer_size: Calling strncpy with a source string whose length
(10 chars) is greater than or equal to the size argument (10)
will fail to null-terminate buff."

The issue is only reported for the "swig_ptr: " line, but for
consistency we replace both occurrences of strncpy with memcpy.
2017-02-15 15:58:26 +13:00
Takashi Tamura
3174e1488c [python] add %swig_sequence_iterator_with_making_function and
make %swig_sequence_iterator forward to it.
         add %swig_sequence_forward_iterator too.
2017-02-11 15:26:52 +09:00
Takashi Tamura
9c6d5dc53c [python] make SwigPyIteratorClosed_T and SwigPyIteratorOpen_T
inherit from forward iterator classes.
2017-02-11 15:26:52 +09:00
Takashi Tamura
db8bc1c9c7 [python] fix std unordered containers 2017-02-11 15:26:52 +09:00
Anthony Heading
1871acd4bc Remove inheritance from std::unary_function and std::binary_function,
they are deprecated in C++11 and already removed in Visual C++ '15'
running with /std:c++latest

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3145.html
2016-12-29 00:56:46 -05:00
William S Fulton
4963a7f88f Fix Python 2 builtin tp_hash hashfunc closure regression when using "python:slot"
Closes https://github.com/swig/swig/issues/843
2016-12-23 23:41:07 +00:00
William S Fulton
6f0af6bec6 Merge branch 'ezralanglois-fix-memory-leak'
* ezralanglois-fix-memory-leak:
  Replicate Python memory leak fix in std::pair for Octave and Ruby
  Fix memory leak in std::pair Python binding

Conflicts:
	CHANGES.current
2016-12-18 20:02:40 +00:00
William S Fulton
364fa82499 Replicate Python memory leak fix in std::pair for Octave and Ruby
https://github.com/swig/swig/pull/851
2016-12-18 20:00:40 +00:00
Tsutomu IKEGAMI
b630cc603c Fix %array_class in carrays.i for Python -builtin
Closes https://github.com/swig/swig/issues/446
2016-12-18 17:49:47 +00:00
Robert Langlois
631f0c34cc Fix memory leak in std::pair Python binding 2016-12-17 13:27:25 -08: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
bdda0a0829 Python - fix compilation error when using -extranative and -builtin.
Closes #816
2016-11-02 22:00:54 +00: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
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
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
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
brgirgis
0f48af8a05 Fix one casting warning on Linux (#787) 2016-09-12 09:21:20 +12:00