From 0b0b77f343f5e6c1788af1063edc5ba5eaebded5 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Mon, 28 Jan 2019 06:56:18 -0700 Subject: [PATCH] [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 05589508a6aca2866210dfda27e79d12abd8f5f6. --- Lib/ocaml/cstring.i | 2 +- Lib/ocaml/director.swg | 4 ++-- Lib/ocaml/ocaml.swg | 2 +- Lib/ocaml/ocamldec.swg | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Lib/ocaml/cstring.i b/Lib/ocaml/cstring.i index 0d6aa4b69..f1190ad5c 100644 --- a/Lib/ocaml/cstring.i +++ b/Lib/ocaml/cstring.i @@ -108,7 +108,7 @@ %define %cstring_mutable(TYPEMAP,...) %typemap(in) TYPEMAP { char *t = String_val($input); - int n = string_length($input); + int n = caml_string_length($input); $1 = ($1_ltype) t; #if #__VA_ARGS__ == "" #ifdef __cplusplus diff --git a/Lib/ocaml/director.swg b/Lib/ocaml/director.swg index 86b2cd4e2..eb91aaf4b 100644 --- a/Lib/ocaml/director.swg +++ b/Lib/ocaml/director.swg @@ -74,12 +74,12 @@ namespace Swig { public: /* wrap a ocaml object. */ Director(CAML_VALUE self) : swig_self(self), swig_disown_flag(false) { - register_global_root(&swig_self); + caml_register_global_root(&swig_self); } /* discard our reference at destruction */ virtual ~Director() { - remove_global_root(&swig_self); + caml_remove_global_root(&swig_self); swig_disown(); // Disown is safe here because we're just divorcing a reference that points to us. } diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index d0007f856..d0a5819bb 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -507,7 +507,7 @@ extern "C" { SWIGINTERN int caml_string_len( CAML_VALUE v ) { switch( SWIG_Tag_val(v) ) { case C_string: - return string_length(SWIG_Field(v,0)); + return caml_string_length(SWIG_Field(v,0)); default: return strlen((char *)caml_ptr_val(v,0)); } diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index aea0ec9e5..f99624373 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -16,6 +16,7 @@ SWIGEXT { #endif #define value caml_value_t #define CAML_VALUE caml_value_t +#define CAML_NAME_SPACE #include #include #include