summaryrefslogtreecommitdiff
path: root/Lib/ocaml
Commit message (Collapse)AuthorAgeFilesLines
* Cleanup SWIG_VERSION definitionWilliam S Fulton2022-10-131-2/+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
* Sort out predefined SWIG-specific macrosOlly Betts2022-10-051-0/+2
| | | | | | | | | | | | | | | | | | | 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/+11
| | | | | | | | | | | | 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
* Ocaml typemap typo fixWilliam S Fulton2022-09-031-1/+1
|
* SWIGTYPE && input typemaps now assume object has been moved - Go and OCamlWilliam S Fulton2022-08-311-2/+3
| | | | | | | | Not fully implemented and Untested. Go's implementation needs fixing to fully support typemaps before this can be done. OCaml implementation does not have support for releasing ownership which is required to add error checking preventing double deletes.
* Cosmetic stray semi-colon removal after %typemap using quotesWilliam S Fulton2022-08-311-3/+3
|
* 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.
* Add OCaml throws typemaps for std::stringWilliam S Fulton2022-07-031-0/+3
|
* Movable and move-only types supported in "out" typemaps.William S Fulton2022-06-302-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Avoid -Wempty-body warnings from SWIG_contract_assertOlly Betts2022-02-111-1/+1
|
* [Ocaml] Fix to work with CAML_SAFE_STRINGOlly Betts2022-02-011-1/+1
| | | | | | | CAML_SAFE_STRING is on by default in current Ocaml versions, and was stopping SWIG-generated wrappers from compiling. Fixes #2083
* [OCaml] Fix compilation errors with OCaml 4.09.0Zackery Spytz2019-12-293-6/+6
| | | | | | | caml_named_value() was modified to return a const value* in OCaml 4.09.0. Closes #1686.
* [OCaml] Move INPUT, OUTPUT, and INOUT typemaps to typemaps.iZackery Spytz2019-02-182-38/+44
|
* [OCaml] Rename typemaps.i to ocaml.swgZackery Spytz2019-02-182-2/+2
|
* [OCaml] Rename ocaml.swg to ocamlrun.swgZackery Spytz2019-02-183-3/+3
| | | | Rename ocamldec.swg to ocamlrundec.swg.
* Merge remote-tracking branch 'upstream/master' into ↵Zackery Spytz2019-02-185-14/+35
|\ | | | | | | OCaml-INPUT-OUTPUT-INOUT-primitives
| * Merge pull request #1473 from ZackerySpytz/OCaml-wrapmacro-testWilliam S Fulton2019-02-183-5/+7
| |\ | | | | | | [OCaml] Fix the wrapmacro test
| | * [OCaml] Fix the wrapmacro testZackery Spytz2019-02-173-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a typecheck typemap for size_t and const size_t &. Add the const qualifier to the typemaps for primitive reference types. Add multiple runtime tests.
| * | [OCaml] Add a typecheck typemap for SWIGTYPEZackery Spytz2019-02-163-9/+28
| |/ | | | | | | | | | | This fixes many of the remaining warnings in the OCaml test suite. Add multiple runtime tests.
* | [OCaml] Add missing INPUT, OUTPUT, and INOUT typemaps for primitivesZackery Spytz2019-02-183-14/+38
|/ | | | The typemaps are based on PHP's.
* Merge pull request #1470 from ZackerySpytz/OCaml-dynamic_cast-testWilliam S Fulton2019-02-151-0/+5
|\ | | | | [OCaml] Fix the dynamic_cast test
| * [OCaml] Fix the dynamic_cast testZackery Spytz2019-02-141-0/+5
| | | | | | | | | | | | Add out typemaps for SWIGTYPE *DYNAMIC and SWIGTYPE &DYNAMIC. Add dynamic_cast_runme.ml.
* | Merge pull request #1461 from ZackerySpytz/OCaml-argout-typemaps-ref-typesWilliam S Fulton2019-02-152-29/+18
|\ \ | | | | | | [OCaml] Don't use argout typemaps by default for some reference types
| * | [OCaml] Don't use argout typemaps by default for some reference typesZackery Spytz2019-02-092-29/+18
| |/ | | | | | | | | | | | | | | | | The OCaml module's typemaps.i supplied argout typemaps for some reference types (e.g. int &) by default, which was unintuitive and inconsistent when compared with other modules. The argout_ref example depended on this, so add a typemap to argout_ref/example.i. Add multiple runtime tests that deal with references.
* | Consistent parameter names for std::pairWilliam S Fulton2019-02-141-2/+2
| |
* | Add STL container copy constructors where missingWilliam S Fulton2019-02-143-4/+4
| | | | | | | | Also provide consistent copy constructor declarations.
* | Add missing typedefs to std::list + typedef correctionsWilliam S Fulton2019-02-141-14/+13
| | | | | | | | | | | | Numerous missing typedefs added. std::list<T*>::const_reference and std::list<T*>::reference specialization typedef fixes.
* | Add missing typedefs to std::vector + typedef correctionsWilliam S Fulton2019-02-131-0/+8
| | | | | | | | | | | | | | Tests for std::vector of pointers added which check std::vector<T*>::const_reference and std::vector<T*>::reference usage which gave compilation errors in Python and Perl which had specialized these vectors incorrectly.
* | Add missing typedefs to std::pairWilliam S Fulton2019-02-131-0/+2
| |
* | Add missing typedefs to std::mapWilliam S Fulton2019-02-131-0/+6
| |
* | Add missing parameter names in STL container wrappersWilliam S Fulton2019-02-133-3/+3
| | | | | | | | | | | | | | Mostly in STL copy constructors. Best to have parameter names as they make their way into the wrappers in some target languages.
* | Create a consistent stl.i library fileWilliam S Fulton2019-02-121-2/+0
|/ | | | | Same file now for all languages except R which is still missing std_map.i. Recent Java changes adding in std_set.i removed.
* Merge branch 'ZackerySpytz-OCaml-exception-improvements'William S Fulton2019-02-093-10/+67
|\ | | | | | | | | * ZackerySpytz-OCaml-exception-improvements: [OCaml] Some exception improvements
| * [OCaml] Some exception improvementsZackery Spytz2019-02-073-10/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The OCaml module's exception handling code was poorly designed, gave confusing exception messages, and was vulnerable to buffer overflows. The OCaml module's SWIG_exception_() was adding a useless newline to the end of the exception message. In some cases, the integer value of f.e. SWIG_TypeError was being added to the exception message. The unneeded else in the OCaml module's SWIG_contract_assert() macro was causing -Wmisleading-indentation warnings. The OCaml module's exception handling code now mirrors that of the Java module. Add Lib/ocaml/std_except.i. Add multiple runtime tests.
* | Merge branch 'ZackerySpytz-OCaml-director-ctors'William S Fulton2019-02-093-0/+13
|\ \ | | | | | | | | | | | | * ZackerySpytz-OCaml-director-ctors: [OCaml] Fix a bug in the ctors of director classes
| * | [OCaml] Fix a bug in the ctors of director classesZackery Spytz2019-02-053-0/+13
| |/ | | | | | | | | | | | | | | If a class was given the director feature, it was not possible to use ctors with multiple parameters. Add director_default_runme.ml (it is based on director_default_runme.java).
* | Merge branch 'ZackerySpytz-OCaml-director_pass_by_value'William S Fulton2019-02-092-53/+34
|\ \ | | | | | | | | | | | | | | | * ZackerySpytz-OCaml-director_pass_by_value: [OCaml] Fix director_pass_by_value [OCaml] Reduce the duplication in typemaps.i
| * | [OCaml] Fix director_pass_by_valueZackery Spytz2019-02-041-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a directorin typemap for SWIGTYPE. Add director_frob_runme.ml, director_pass_by_value_runme.ml, and director_unroll_runme.ml. This commit fixes most of the director-related warnings in the OCaml test suite. Of the director tests that are currently included in the OCaml test suite, director_basic and director_property are the only ones which give warnings (due to issues with typecheck typemaps).
| * | [OCaml] Reduce the duplication in typemaps.iZackery Spytz2019-02-042-53/+23
| |/ | | | | | | | | | | | | Add a SWIG_Ocaml_ptr_to_val() function to reduce some of the duplication in the OCaml typemaps. Remove unused, useless `ArrayCarrier *` typemaps.
* | [OCaml] Cache the result of caml_named_value() in some casesZackery Spytz2019-02-031-10/+11
|/ | | | | | | | | | | The result of caml_named_value() can be cached for (slightly) improved performance. This is mentioned in the OCaml reference manual. https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html#sec453 In addition, fix incorrect use of CAMLreturn() in caml_ptr_val_internal().
* Merge branch 'ZackerySpytz-OCaml-char_binary-test'William S Fulton2019-01-311-0/+4
|\ | | | | | | | | * ZackerySpytz-OCaml-char_binary-test: [OCaml] Fix the char_binary test for OCaml
| * [OCaml] Fix the char_binary test for OCamlZackery Spytz2019-01-291-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | Add %typemap(in) (char *STRING, size_t LENGTH). Fix warnings in char_binary.i. ./../char_binary.i:7: Warning 453: Can't apply (char *STRING,size_t LENGTH). No typemaps are defined. ./../char_binary.i:8: Warning 453: Can't apply (char *STRING,size_t LENGTH). No typemaps are defined. Add a runtime test (it is based on the Python and Go char_binary runtime tests).
* | Merge branch 'ZackerySpytz-OCaml-define-CAML_NAME_SPACE'William S Fulton2019-01-314-4/+5
|\ \ | | | | | | | | | | | | * ZackerySpytz-OCaml-define-CAML_NAME_SPACE: [OCaml] Define CAML_NAME_SPACE before including caml/ headers
| * | [OCaml] Define CAML_NAME_SPACE before including caml/ headersZackery Spytz2019-01-284-4/+5
| |/ | | | | | | | | | | | | | | | | | | | | | | | | When this macro is not defined, the caml/ headers will define macros without the caml_ prefix as aliases for some functions in the OCaml C API. For example, caml/compatibility.h defines `invalid_argument` as an alias for `caml_invalid_argument` when CAML_NAME_SPACE is not defined, which breaks code that uses std::invalid_argument. Rename some functions that were missed in 05589508a6aca2866210dfda27e79d12abd8f5f6.
* | Merge branch 'ZackerySpytz-OCaml-eliminate-wno-write-strings'William S Fulton2019-01-311-1/+1
|\ \ | | | | | | | | | | | | | | | | | | * ZackerySpytz-OCaml-eliminate-wno-write-strings: [OCaml] Remove support for OCaml versions < 3.12.0 [OCaml] Fix toplevel creation for ocamlmktop versions >= 4.04.0 [OCaml] Eliminate use of -Wno-write-strings
| * | [OCaml] Eliminate use of -Wno-write-stringsZackery Spytz2019-01-241-1/+1
| |/ | | | | | | | | | | | | Don't convert string literals to char * in the strings_test example. In constantWrapper(), use SwigType_str() instead of SwigType_lstr() in order to keep const qualifiers.
* | [OCaml] Fix %allowexceptionZackery Spytz2019-01-225-35/+3
|/ | | | | | | | | | | | | OCaml's variableWrapper() wasn't calling emit_action_code() for in/out typemaps, which meant that %allowexception was being ignored. In addition, remove all comments in the typemaps in Lib/ocaml. In the case of the allowexcept test, one of the typemap comments caused compilation to fail because it became nested within another comment in an %exception block. Re-enable the allowexcept test. Add allowexcept_runme.ml.
* [OCaml] Some %typecheck precedence tweaksZackery Spytz2019-01-211-8/+13
| | | | | | | | | | | Fix warnings in overload_numeric.i. ./../overload_numeric.i:36: Warning 509: Overloaded method Nums::over(short) effectively ignored, ./../overload_numeric.i:33: Warning 509: as it is shadowed by Nums::over(signed char). ./../overload_numeric.i:39: Warning 509: Overloaded method Nums::over(int) effectively ignored, ./../overload_numeric.i:33: Warning 509: as it is shadowed by Nums::over(signed char). Add overload_numeric_runme.ml.
* [OCaml] Remove the last remnants of libswigocamlZackery Spytz2019-01-184-23/+1
| | | | | | Parts of it were removed in 79785d403c80eb6c10b23668b07b106251373c1b Remove the oc_bool type.
* [OCaml] Fix the handling of bools in overloaded functionsZackery Spytz2019-01-181-1/+1
| | | | | | | Use the SWIG_TYPECHECK_BOOL precedence level instead of SWIG_TYPECHECK_INTEGER when checking for bools. Add a runtime test in the form of overload_bool_runme.ml.