summaryrefslogtreecommitdiff
path: root/Lib/typemaps
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup SWIG_VERSION definitionWilliam S Fulton2022-10-133-19/+0
| | | | | | | | | | | | | Add Swig_obligatory_macros which must be called by each target language to define SWIG_VERSION correctly in the generated code, as well as the language specific macro SWIGXXX where XXX is the target language name. Drop the #ifdef SWIGXXX that was previously generated - I can't see the point of this and if users are defining this macro somehow, then users will need to change this Closes #1050
* Quick fix SWIG_VERSION not being defined correctly in wrappersWilliam S Fulton2022-10-131-1/+0
|
* Fix compile error when using directorsWilliam S Fulton2022-10-101-1/+1
| | | | | | | | Fix when using templates with more than one template parameter and used as an input parameter in a virtual method in a director class (problem affecting most of the scripting languages). Fixes #2160
* Sort out predefined SWIG-specific macrosOlly Betts2022-10-053-9/+19
| | | | | | | | | | | | | | | | | | | Ensure that SWIG_VERSION is defined both at SWIG-time and in the generated C/C++ wrapper code (it was only defined in the wrapper for some target languages previously). SWIGGO and SWIGJAVASCRIPT are now defined in the generated wrappers to match behaviour for all other target languages. Stop defining SWIGVERSION in the wrapper. This only happened as a side-effect of how SWIG_VERSION was defined but was never documented and is redundant. The new testcase also checks that SWIG is defined at SWIG-time but not in the generated wrapper, and that exactly one of a list of target-language specific macros is defined. Fixes #1050
* Provide SWIGTYPE MOVE typemaps in swigmove.iWilliam S Fulton2022-09-161-0/+19
| | | | | | | | | | | | For implementing full move semantics when passing parameters by value. Based on SWIGTYPE && and std::unique_ptr typemaps which implement move semantics. Added for all languages, but untested for: Go, Ocaml, R, Scilab (and unlikely to be fully functional for same reasons as for std::unique_ptr support). Issue #999
* Remove broken %implicitconv for const SWIGTYPE &&William S Fulton2022-09-051-24/+0
| | | | | | Typemaps should be for SWIGTYPE &&, not just const SWIGTYPE &&. Needs updating for new approach where the proxy object is moved for a parameter containing an rvalue reference.
* Remove unnecessary const SWIGTYPE & typemapWilliam S Fulton2022-09-051-9/+1
| | | | | This is a duplicate of SWIGTYPE & and the typemap rules result in SWIGTYPE & being used if there is no const SWIGTYPE & tyemap.
* SWIGTYPE && input typemaps now assume object has been movedWilliam S Fulton2022-08-311-3/+8
| | | | | | | | | | | | | | | | | | | | Replicated Java implementation. Fully implemented for: - C# - D - Guile - Javascript (UTL) - Lua - MzScheme - Octave (UTL) - Perl (UTL) - PHP - Python (UTL) - Ruby (UTL) - Tcl (UTL) PHP std::auto_ptr std::unique_ptr minor tweaks and testcase corrections
* Cosmetic stray semi-colon removal after %typemap using quotesWilliam S Fulton2022-08-317-21/+21
|
* Remove redundant check for NULL in char * typemapsWilliam S Fulton2022-07-241-3/+3
| | | | | | | No need to check for NULL before calling delete/free. Anyone using typemaps_string_alloc with custom allocators and deallocators need to ensure the custom allocators behave in the same way as the standard deallocators in this respect.
* Add Python support for std::unique_ptr inputsWilliam S Fulton2022-07-172-0/+2
| | | | Equivalent to Java/C# implementation.
* Performance optimisation for directors for classes passed by valueWilliam S Fulton2022-07-041-1/+1
| | | | | | | The directorin typemaps in the director methods now use std::move on the input parameter when copying the object from the stack to the heap prior to the callback into the target language, thereby taking advantage of move semantics if available.
* Movable and move-only types supported in "out" typemaps.William S Fulton2022-06-301-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enhance SWIGTYPE "out" typemaps to use std::move when copying objects, thereby making use of move semantics when wrapping a function returning by value if the returned type supports move semantics. Wrapping functions that return move only types 'by value' now work out the box without having to provide custom typemaps. The implementation removed all casts in the "out" typemaps to allow the compiler to appropriately choose calling a move constructor, where possible, otherwise a copy constructor. The implementation alsoand required modifying SwigValueWrapper to change a cast operator from: SwigValueWrapper::operator T&() const; to #if __cplusplus >=201103L SwigValueWrapper::operator T&&() const; #else SwigValueWrapper::operator T&() const; #endif This is not backwards compatible for C++11 and later when using the valuewrapper feature if a cast is explicitly being made in user supplied "out" typemaps. Suggested change in custom "out" typemaps for C++11 and later code: 1. Try remove the cast altogether to let the compiler use an appropriate implicit cast. 2. Change the cast, for example, from static_cast<X &> to static_cast<X &&>, using the __cplusplus macro if all versions of C++ need to be supported. Issue #999 Closes #1044 More about the commit: Added some missing "varout" typemaps for Ocaml which was falling back to use "out" typemaps as they were missing. Ruby std::set fix for SwigValueWrapper C++11 changes.
* Correct warning message for wchar_t * typemapsWilliam S Fulton2022-05-063-3/+12
| | | | | Use separate warning for char * and wchar_t * typemaps SWIGWARN_TYPEMAP_CHARLEAK_MSG and SWIGWARN_TYPEMAP_WCHARLEAK_MSG
* Remove redundant conditionalOlly Betts2022-03-071-4/+0
| | | | | | | clang defines __GNUC__ and __GNUC_MINOR__ as if it were GCC 4.2.1 and has since clang 2.4, which was before __has_builtin() was added. Closes #1239
* Avoid -Wempty-body warnings from SWIG_contract_assertOlly Betts2022-02-111-1/+1
|
* Merge branch 'doc-work' into upstream-masterWilliam S Fulton2022-02-051-126/+0
|\ | | | | | | | | | | * doc-work: Move the attribute.i docs into Library.html Move %attribute documentation into the manual
| * Move %attribute documentation into the manualCorey Minyard2022-01-261-126/+0
| | | | | | | | | | | | | | It's fairly hidden where it is, put it where users can see it more easily. Fixes #2166
* | Fix function prototypes of generated pointer functionsJustus Winter2022-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | Previously, the emitted constructors were incomplete prototypes. When compiling the wrapper code using gcc 6 and -Wstrict-prototypes, the following warnings were emitted: warning: function declaration isn’t a prototype [-Wstrict-prototypes] See #801
* | Remove redundant NULL checks before free()/delete (#2184)Olly Betts2022-01-291-2/+2
|/ | | | | | | | | Remove redundant NULL checks before free()/delete The ISO C and C++ standards guarantee that it's safe to call these on a NULL pointer, so it's not necessary for the calling code to also check. Fixes https://sourceforge.net/p/swig/feature-requests/70/
* Member function pointer typemap tweaksWilliam S Fulton2021-04-261-7/+7
| | | | | | Use sizeof variable name rather than variable type. Workaround Visual C++ unable to parse some complex C++11 types, such as sizeof(short (Funcs::*)(bool) const &&)
* Fix typos in attribute2ref() in Lib/typemaps/attribute.swgZackery Spytz2021-02-091-1/+1
| | | | | | AccessorName was being used instead of AttributeName. Closes #1872.
* Fix typecheck typemaps for non-pointers and NULLWilliam S Fulton2018-12-291-8/+8
| | | | | | | | | The typecheck typemaps succeed for non pointers (SWIGTYPE, SWIGTYPE&, SWIGTYPE&&) when the equivalent to C NULL is passed from the target language. This commit implements a fix for Python to not accept a Python None for non-pointer types. Issue #1202
* Remove -cppcast and -nocppcast command line optionsWilliam S Fulton2018-11-131-9/+2
| | | | | | | | | | | | | The -cppcast option is still turned on by default. The -nocppcast option to turn off the use of c++ casts (const_cast, static_cast etc) has been removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts instead of C++ casts for C++ wrappers. This a revert of commit fc79264a48f186f8bbd367e91fa9dbf9758aa092: "Revert "Remove -cppcast and -nocppcast command line options"" The Scilab and Javascript casting problems are now fixed, so -cppcast is now switched on as default.
* Fix constant function pointer typemapsWilliam S Fulton2018-11-131-0/+2
| | | | | | | | | The function pointer typemaps were not being used when the function pointer is const, like ADD_BY_VALUE_C in the funcptr_cpp.i testcase: %constant int (* const ADD_BY_VALUE_C)(const int &, int) = addByValue; Problem affecting Javascript and observable when running test-suite with -cppcast.
* Revert "Remove -cppcast and -nocppcast command line options"William S Fulton2018-11-061-2/+9
| | | | | | This reverts commit c06f2b4497bffeb185dbf0e65dc925514537ef37. More work to be done as it breaks Scilab and Javascript tests.
* Remove -cppcast and -nocppcast command line optionsWilliam S Fulton2018-11-061-9/+2
| | | | | | | The -cppcast option is still turned on by default. The -nocppcast option to turn off the use of c++ casts (const_cast, static_cast etc) has been removed. However, defining SWIG_NO_CPLUSPLUS_CAST will still generate C casts instead of C++ casts for C++ wrappers.
* Enhance SWIG_isfinite for older standards: C++03/C++98/C89William S Fulton2018-05-041-0/+6
| | | | | | Fixes testcase overload_numeric with -std=c++98 (clang and gcc 6 and later) Issue #1239
* __cplusplus macro usage tweakWilliam S Fulton2018-05-041-1/+1
|
* Fix directorout typemaps which were causing undefined behaviour when ↵William S Fulton2017-12-141-2/+4
| | | | | | returning pointers by reference. Closes #1167
* Add director typemaps for pointer const ref typesWilliam S Fulton2017-10-241-3/+22
|
* Add unignore for rvalue ref-qualifiersWilliam S Fulton2017-08-301-69/+0
| | | | | | | | Use std::move on this pointer as the default approach to supporting rvalue ref-qualifiers if a user really wants to wrap. std::move requires <memory> headers so add swigfragments.swg for all languages to use common fragments. Just header file fragments for now.
* Fix wrapping of references/pointers and qualifiers to member pointersWilliam S Fulton2017-03-161-0/+3
| | | | Also fix Go wrapping of member const function pointers.
* Octave: add support for version 4.2Karl Wette2017-01-221-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - .travis.yml: - ppa:kwwette/octaves has Octave version 4.2, also run C++11 tests - configure.ac: - prefer Octave program "octave-cli" to "octave" - extract any -std=* flags from CXX, add to OCTAVE_CXXFLAGS - Lib/typemaps/fragments.swg: - SWIG_isfinite_func(): extern "C++" is required as this fragment can end up inside an extern "C" { } block - Lib/octave: - add std_wstring.i (copied from std_string.i) for C++11 tests - Lib/octave/octrun.swg: - move Octave version-checking macros to octruntime.swg - Octave single()/double() functions now call .as_single()/.as_double() methods; redirect calls to __float__() method as per .scalar_value() - << and >> operators are no longer supported by Octave - Lib/octave/octruntime.swg: - move Octave version-checking macros here for conditional #includes - #include interpreter.h instead of #toplev.h - #include call-stack.h (now needed for octave_call_stack) - unwind_protect is now in octave:: namespace - error_state and warning_state are deprecated; use try/catch to catch errors in feval() instead - always set octave_exit = ::_Exit, to try to prevent segfault on exit - Lib/octave/octopers.swg: - << and >> operators are no longer supported by Octave - Lib/octave/exception.i: - Add macro SWIG_RETHROW_OCTAVE_EXCEPTIONS which rethrows any exceptions raised by Octave >= 4.2 - Examples/test-suite/exception_order.i: - Use macro SWIG_RETHROW_OCTAVE_EXCEPTIONS to rethrow exceptions raised by error() function in Octave >= 4.2 - Update Doc/Manual/Octave.html and CHANGES.current
* Add some missing SWIGINTERN usageWilliam S Fulton2017-01-172-2/+2
|
* Fix isfinite() checks to work with all C++11 compilersOlly Betts2016-12-211-2/+14
| | | | | Fixes https://github.com/swig/swig/issues/615, https://github.com/swig/swig/pull/788 and https://github.com/swig/swig/pull/849.
* Zero initialize %array_functions and %array_classWilliam S Fulton2016-12-181-2/+2
|
* Zero initialize newly created arraysWilliam S Fulton2016-12-181-5/+5
| | | | | | For consistency to previous fixes: https://github.com/swig/swig/pull/208 https://github.com/swig/swig/issues/440
* Fix missed filesDaniel Vollmer2016-09-171-0/+1
|
* cstrings.swg: fix function names inside comments (#790)Marcin Wojdyr2016-09-161-3/+3
|
* UTL STL container descriptor checksWilliam S Fulton2016-07-281-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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; } };
* Remove unused traits.swgWilliam S Fulton2016-07-271-305/+0
| | | | This file has code that looks like it was migrated to Lib/std/std_common.i
* Fix directorin SWIGTYPE typemaps to make a copy as these are used for pass ↵William S Fulton2016-05-141-1/+1
| | | | | | by value. Closes #434
* handle const pointers to functionsPaweł Tomulik2016-03-241-0/+1
|
* [Python] Use std::isfinite() under C++11Olly Betts2016-03-011-2/+4
| | | | Follow-up fix for https://github.com/swig/swigissues/615
* [Python] Fix isfinite() check to work with GCC6Olly Betts2016-03-011-1/+2
| | | | Fixes https://github.com/swig/swig/issues/615 reported by jplesnik.
* Add support for ptrdiff_t and size_t == long longAlec Cooper2016-01-061-12/+58
| | | | | New fragment to check if long long is available using LLONG_MAX AsVal and From functions for ptrdiff_t and size_t now use long long if available and sizeof(ptrdiff_t) > sizeof(long)
* Scilab typemap fixes for C89William S Fulton2015-02-111-1/+1
|
* Spelling fixWilliam S Fulton2014-10-211-1/+1
|
* Merge branch 'master' into develOliver Buchtala2014-03-301-3/+3
|\ | | | | | | | | | | Conflicts: .travis.yml Examples/test-suite/common.mk