Commit graph

149 commits

Author SHA1 Message Date
Zackery Spytz
1eb9cd3211 [OCaml] Move INPUT, OUTPUT, and INOUT typemaps to typemaps.i 2019-02-18 23:02:20 -07:00
Zackery Spytz
092c51c06e [OCaml] Rename typemaps.i to ocaml.swg 2019-02-18 22:42:20 -07:00
Zackery Spytz
b74b2189e6 [OCaml] Rename ocaml.swg to ocamlrun.swg
Rename ocamldec.swg to ocamlrundec.swg.
2019-02-18 22:35:55 -07:00
Zackery Spytz
5a58f9a87b Merge remote-tracking branch 'upstream/master' into OCaml-INPUT-OUTPUT-INOUT-primitives 2019-02-18 20:41:13 -07:00
William S Fulton
f19882ed51
Merge pull request #1473 from ZackerySpytz/OCaml-wrapmacro-test
[OCaml] Fix the wrapmacro test
2019-02-18 19:33:22 +00:00
Zackery Spytz
470ce2dd31 [OCaml] Add missing INPUT, OUTPUT, and INOUT typemaps for primitives
The typemaps are based on PHP's.
2019-02-18 04:23:40 -07:00
Zackery Spytz
10d62aecd5 [OCaml] Fix the wrapmacro test
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.
2019-02-17 01:41:59 -07:00
Zackery Spytz
b7a400f991 [OCaml] Add a typecheck typemap for SWIGTYPE
This fixes many of the remaining warnings in the OCaml test suite.

Add multiple runtime tests.
2019-02-16 01:07:31 -07:00
William S Fulton
1f4b3a4553
Merge pull request #1470 from ZackerySpytz/OCaml-dynamic_cast-test
[OCaml] Fix the dynamic_cast test
2019-02-15 19:10:15 +00:00
William S Fulton
dd8c3e1466
Merge pull request #1461 from ZackerySpytz/OCaml-argout-typemaps-ref-types
[OCaml] Don't use argout typemaps by default for some reference types
2019-02-15 19:06:05 +00:00
William S Fulton
52063a732b Consistent parameter names for std::pair 2019-02-14 22:44:27 +00:00
William S Fulton
6d27ead9c0 Add STL container copy constructors where missing
Also provide consistent copy constructor declarations.
2019-02-14 18:53:05 +00:00
Zackery Spytz
a159a252dd [OCaml] Fix the dynamic_cast test
Add out typemaps for SWIGTYPE *DYNAMIC and SWIGTYPE &DYNAMIC.

Add dynamic_cast_runme.ml.
2019-02-14 02:21:36 -07:00
William S Fulton
440264e479 Add missing typedefs to std::list + typedef corrections
Numerous missing typedefs added.
std::list<T*>::const_reference and std::list<T*>::reference
specialization typedef fixes.
2019-02-14 07:31:21 +00:00
William S Fulton
e26f6bb4e2 Add missing typedefs to std::vector + typedef corrections
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.
2019-02-13 22:46:28 +00:00
William S Fulton
a47c2553f5 Add missing typedefs to std::pair 2019-02-13 22:46:28 +00:00
William S Fulton
9dd33e6367 Add missing typedefs to std::map 2019-02-13 22:46:27 +00:00
William S Fulton
6d0c495fd0 Add missing parameter names in STL container wrappers
Mostly in STL copy constructors.

Best to have parameter names as they make their way into the wrappers in
some target languages.
2019-02-13 22:45:47 +00:00
William S Fulton
68e86614ff Create a consistent stl.i library file
Same file now for all languages except R which is still missing std_map.i.
Recent Java changes adding in std_set.i removed.
2019-02-12 18:46:05 +00:00
Zackery Spytz
b2d93665fe [OCaml] Don't use argout typemaps by default for some reference types
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.
2019-02-09 22:04:46 -07:00
William S Fulton
6ec798f7ff Merge branch 'ZackerySpytz-OCaml-exception-improvements'
* ZackerySpytz-OCaml-exception-improvements:
  [OCaml] Some exception improvements
2019-02-09 22:35:48 +00:00
William S Fulton
d7bb500315 Merge branch 'ZackerySpytz-OCaml-director-ctors'
* ZackerySpytz-OCaml-director-ctors:
  [OCaml] Fix a bug in the ctors of director classes
2019-02-09 22:28:10 +00:00
William S Fulton
b80b4d5638 Merge branch 'ZackerySpytz-OCaml-director_pass_by_value'
* ZackerySpytz-OCaml-director_pass_by_value:
  [OCaml] Fix director_pass_by_value
  [OCaml] Reduce the duplication in typemaps.i
2019-02-09 22:25:29 +00:00
Zackery Spytz
e5b8b5a164 [OCaml] Some exception improvements
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.
2019-02-07 16:25:10 -07:00
Zackery Spytz
828ce477c8 [OCaml] Fix a bug in the ctors of director classes
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).
2019-02-05 13:35:43 -07:00
Zackery Spytz
9942e6a582 [OCaml] Fix director_pass_by_value
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).
2019-02-04 11:29:54 -07:00
Zackery Spytz
5a28593818 [OCaml] Reduce the duplication in typemaps.i
Add a SWIG_Ocaml_ptr_to_val() function to reduce some of the
duplication in the OCaml typemaps.

Remove unused, useless `ArrayCarrier *` typemaps.
2019-02-04 11:22:10 -07:00
Zackery Spytz
bdc038b578 [OCaml] Cache the result of caml_named_value() in some cases
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().
2019-02-03 17:37:46 -07:00
William S Fulton
054a85c546 Merge branch 'ZackerySpytz-OCaml-char_binary-test'
* ZackerySpytz-OCaml-char_binary-test:
  [OCaml] Fix the char_binary test for OCaml
2019-01-31 07:35:11 +00:00
William S Fulton
1069cfbfd5 Merge branch 'ZackerySpytz-OCaml-define-CAML_NAME_SPACE'
* ZackerySpytz-OCaml-define-CAML_NAME_SPACE:
  [OCaml] Define CAML_NAME_SPACE before including caml/ headers
2019-01-31 07:32:12 +00:00
William S Fulton
528f33e9e5 Merge branch 'ZackerySpytz-OCaml-eliminate-wno-write-strings'
* 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
2019-01-31 07:29:09 +00:00
Zackery Spytz
85860c0a61 [OCaml] Fix the char_binary test for OCaml
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).
2019-01-29 09:18:30 -07:00
Zackery Spytz
0b0b77f343 [OCaml] Define CAML_NAME_SPACE before including caml/ headers
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
05589508a6.
2019-01-28 06:56:18 -07:00
Zackery Spytz
4ca7cd7b27 [OCaml] Eliminate use of -Wno-write-strings
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.
2019-01-24 05:32:35 -07:00
Zackery Spytz
4074f788b3 [OCaml] Fix %allowexception
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.
2019-01-22 07:51:45 -07:00
Zackery Spytz
d5afcab9a6 [OCaml] Some %typecheck precedence tweaks
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.
2019-01-21 23:17:43 -07:00
Zackery Spytz
6da9bd485e [OCaml] Remove the last remnants of libswigocaml
Parts of it were removed in 79785d403c

Remove the oc_bool type.
2019-01-18 23:48:46 -07:00
Zackery Spytz
b879ccdc3e [OCaml] Fix the handling of bools in overloaded functions
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.
2019-01-18 23:42:59 -07:00
Zackery Spytz
05589508a6 [OCaml] Add the caml_ prefix to some OCaml functions
In OCaml 3.08.0, many functions in the OCaml C API were renamed to
include a caml_ prefix. Their previous names were retained as macros
in caml/compatibility.h and were (apparently) deprecated.

Rename occurrences of alloc_string, alloc_tuple, callback, callback2,
callback3, copy_double, copy_int64, copy_string, failwith, and modify
in the OCaml module.

The OCaml module requires OCaml >= 3.08.3, so this change is safe
for all supported OCaml versions.
2019-01-14 20:45:13 -07:00
Zackery Spytz
83df4e8ed6 [OCaml] Fix and re-enable the string_simple, minherit, and unions tests
copy_string() is a macro in the OCaml C API, so rename the function
to copy_str(). Add a runtime test.

The minherit runtime test was fixed by b64d685.

Use the proper syntax for accessing member variables in
unions_runme.ml
2019-01-13 17:28:00 -07:00
William S Fulton
7c4d29ae9a Merge branch 'ZackerySpytz-OCaml_int64_t'
* ZackerySpytz-OCaml_int64_t:
  Add changes entry for fixing OCaml int64_t compile problem
  Fix OCaml version detection if caml/version.h is not available
  [OCaml] Use int64_t instead of int64 for OCaml versions >= 4.03.0

Conflicts:
	CHANGES.current
2019-01-12 13:56:00 +00:00
William S Fulton
48d9e3bc02 Fix OCaml version detection if caml/version.h is not available
Needed for OCaml versions < 4.02.0
Issue #1403
2019-01-12 13:42:29 +00:00
William S Fulton
d6cd52f586 Fix OCAML typemap warnings wrapping C code
Fixes:
Lib/ocaml/typemaps.i:366: Warning 453: Can't apply (SWIGTYPE &). No typemaps are defined.
Lib/ocaml/typemaps.i:367: Warning 453: Can't apply (SWIGTYPE &&). No typemaps are defined.
Lib/ocaml/typemaps.i:372: Warning 453: Can't apply (SWIGTYPE &). No typemaps are defined.
2019-01-11 19:35:17 +00:00
Zackery Spytz
65f2111915 [OCaml] Use int64_t instead of int64 for OCaml versions >= 4.03.0
OCaml's int64 type was replaced with the C99 int64_t in OCaml 4.03.0.
b868c05ec9

Closes #1194.
2019-01-08 21:36:06 -07:00
Zackery Spytz
4a912668fc [OCaml] Fix member var getters and setters
Add `membervariableHandler()` to the `OCAML` class in ocaml.cxx (it is
partly based on the code in python.cxx and octave.cxx).

In Lib/ocaml/class.swg, wrapped classes/structs were not being added
to `class_master_list`. This is fixed by adding a call to
`register_class_byname`.

Add a unit test in the form of struct_value_runme.ml.
2019-01-06 09:40:25 -07:00
Zackery Spytz
5988c3bb24 [OCaml] Replace SWIGSTATIC with SWIGINTERN
Use SWIGINTERN to silence unused function warnings.

In addition, remove the declarations for SWIG_MustGetPtr(),
wrap_delete_void(), enum_to_int(), and int_to_enum() -- these
lacked definitions and caused compiler warnings.
2019-01-01 06:28:35 -07:00
Zackery Spytz
c74ef14bb2 Update a dead link. 2018-12-30 02:51:58 -07:00
Zackery Spytz
701dc125e1 [OCaml] Add missing keywords to ocamlkw.swg
The asr, land, lor, lsl, lsr, lxor, mod, and nonrec keywords were
missing from ocamlkw.swg.
2018-12-30 02:50:46 -07:00
William S Fulton
ca287ae13b Add support for non-default compare template argument in std::map wrappers 2018-10-09 19:44:00 +01:00
William S Fulton
7f9b9db2e0 Fix ocaml warning
Warning 20: this argument will not be used by the function.
2017-03-23 19:11:20 +00:00