This is an automated email from the git hooks/post-receive script.

glondu pushed a commit to branch master
in repository ocaml-ctypes.

commit 23f8fb8e2f321e700a67094724532cdd8e0c3d30
Author: Stephane Glondu <st...@glondu.net>
Date:   Sat Feb 28 17:58:12 2015 +0100

    Imported Upstream version 0.3.1
---
 META                                               | 10 +--
 Makefile                                           |  4 +-
 Makefile.rules                                     |  6 +-
 Makefile.tests                                     | 86 +++++++++++-----------
 src/cstubs/cstubs_generate_c.ml                    |  1 +
 src/cstubs/cstubs_generate_ml.ml                   |  8 ++
 src/cstubs/cstubs_internals.mli                    |  1 +
 src/ctypes-foreign-base/ffi.ml                     |  1 +
 src/ctypes-foreign-base/ffi_call_stubs.c           |  5 +-
 src/ctypes/ctypes.mli                              |  7 ++
 src/ctypes/memory.ml                               |  3 +
 src/ctypes/static.ml                               |  2 +
 src/ctypes/static.mli                              |  2 +
 src/ctypes/type_printing.ml                        |  1 +
 src/ctypes/value_printing.ml                       |  1 +
 src/libffi-abigen/libffi_abigen.ml                 |  2 +-
 tests/test-passing-ocaml-values/stubs/functions.ml |  3 +
 .../test_passing_ocaml_values.ml                   | 10 +++
 18 files changed, 97 insertions(+), 56 deletions(-)

diff --git a/META b/META
index 9faa17e..303a75e 100644
--- a/META
+++ b/META
@@ -1,4 +1,4 @@
-version = "0.3"
+version = "0.3.1"
 description = "Combinators for binding to C libraries without writing any C."
 requires = "unix bigarray str"
 archive(byte) = "ctypes.cma"
@@ -8,7 +8,7 @@ archive(native, plugin) = "ctypes.cmxs"
 exists_if = "ctypes.cma"
 
 package "top" (
-  version = "0.3"
+  version = "0.3.1"
   description = "Toplevel printers for C types"
   requires = "ctypes"
   archive(byte) = "ctypes-top.cma"
@@ -19,7 +19,7 @@ package "top" (
 )
 
 package "stubs" (
-  version = "0.3"
+  version = "0.3.1"
   description = "Stub generation from C types"
   requires = "ctypes"
   archive(byte) = "cstubs.cma"
@@ -30,7 +30,7 @@ package "stubs" (
 )
 
 package "foreign-base" (
- version = "0.3"
+ version = "0.3.1"
  description = "Dynamic linking of C functions"
  requires = "ctypes"
  archive(byte) = "ctypes-foreign-base.cma"
@@ -41,7 +41,7 @@ package "foreign-base" (
 )
 
 package "foreign" (
- version = "0.3"
+ version = "0.3.1"
  description = "Dynamic linking of C functions"
  requires = "ctypes ctypes.foreign-base"
  requires(mt) = "threads ctypes ctypes.foreign-base"
diff --git a/Makefile b/Makefile
index b623c42..48af4c5 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ distclean: clean
 ctypes.public = static primitives unsigned signed structs ctypes posixTypes
 ctypes.dir = src/ctypes
 ctypes.extra_mls = ctypes_primitives.ml
-ctypes.deps = str bigarray
+ctypes.deps = str bigarray bytes
 ctypes.install = yes
 ctypes.install_native_objects = yes
 
@@ -38,7 +38,7 @@ ctypes: $(ctypes.dir)/$(ctypes.extra_mls) $$(LIB_TARGETS)
 cstubs.public = cstubs_internals cstubs cstubs_inverted
 cstubs.dir = src/cstubs
 cstubs.subproject_deps = ctypes
-cstubs.deps = str
+cstubs.deps = str bytes
 cstubs.install = yes
 
 cstubs: PROJECT=cstubs
diff --git a/Makefile.rules b/Makefile.rules
index 765b3d7..9a867e8 100644
--- a/Makefile.rules
+++ b/Makefile.rules
@@ -45,7 +45,7 @@ THREAD_FLAG = $(if $(filter 
yes,$($(PROJECT).threads)),-thread)
 LINK_FLAGS = $($(PROJECT).link_flags)
 OCAML_LINK_FLAGS=$(LINK_FLAGS:%=-cclib %)
 OCAMLFIND_PACKAGE_FLAGS=$(patsubst %,-package %,$($(PROJECT).deps)) \
-                        $(patsubst %,-package threads,$(THREAD_FLAG))
+                        $(patsubst %,-thread -package threads,$(THREAD_FLAG))
 
 $(BUILDDIR)/%.cmxa: $$(NATIVE_OBJECTS)
        $(OCAMLFIND) opt -a -linkall $(OCAMLFLAGS) $(THREAD_FLAG) 
$(OCAMLFIND_PACKAGE_FLAGS) $(CMXA_OPTS) -o $@ $(NATIVE_OBJECTS) 
$(OCAML_LINK_FLAGS)
@@ -65,7 +65,7 @@ $(BUILDDIR)/%.cmo : %.ml
 
 $(BUILDDIR)/%.cmx : %.ml
        @mkdir -p $(@D)
-       $(OCAMLFIND) opt -c -o $@ $(OCAMLFLAGS) $(THREAD_FLAG) 
$(OCAMLFIND_PACKAGE_FLAGS) $(CMX_OPTS) $(OCAMLINCLUDES) $(filter %.ml,$<)
+       $(OCAMLFIND) opt -c -o $@ $(OCAMLFIND_PACKAGE_FLAGS) $(OCAMLFLAGS) 
$(THREAD_FLAG) $(OCAMLFIND_PACKAGE_FLAGS) $(CMX_OPTS) $(OCAMLINCLUDES) $(filter 
%.ml,$<)
 
 $(BUILDDIR)/%.o : %.c
        @mkdir -p $(@D)
@@ -73,7 +73,7 @@ $(BUILDDIR)/%.o : %.c
 
 $(BUILDDIR)/%.cmi : %.mli
        @mkdir -p $(@D)
-       $(OCAMLFIND) ocamlc -c -o $@ $(OCAMLFLAGS) $(OCAMLINCLUDES) $<
+       $(OCAMLFIND) ocamlc -c -o $@ $(OCAMLFIND_PACKAGE_FLAGS) $(OCAMLFLAGS) 
$(OCAMLINCLUDES) $<
 
 $(BUILDDIR)/%.native : $$(NATIVE_OBJECTS) $$(C_OBJECTS)
        $(OCAMLFIND) opt -I $(BUILDDIR) -linkpkg $(OCAMLFLAGS) $(THREAD_FLAG) 
$(OCAMLFIND_PACKAGE_FLAGS) $(LOCAL_CMXAS) -o $@ $^ $(OCAML_LINK_FLAGS) 
diff --git a/Makefile.tests b/Makefile.tests
index 28a2f1f..7c6d68c 100644
--- a/Makefile.tests
+++ b/Makefile.tests
@@ -17,7 +17,7 @@ tests-common: $$(LIB_TARGETS)
 
 test-raw.dir = tests/test-raw
 test-raw.threads = yes
-test-raw.deps = bigarray oUnit str
+test-raw.deps = bigarray oUnit str bytes
 test-raw.subproject_deps = ctypes ctypes-foreign-base ctypes-foreign-unthreaded
 test-raw: PROJECT=test-raw
 test-raw: $$(NATIVE_TARGET)
@@ -33,13 +33,13 @@ test-pointers-stub-generator.dir = 
tests/test-pointers/stub-generator
 test-pointers-stub-generator.threads = yes
 test-pointers-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-pointers-stubs 
tests-common
-test-pointers-stub-generator.deps = str bigarray
+test-pointers-stub-generator.deps = str bigarray bytes
 test-pointers-stub-generator: PROJECT=test-pointers-stub-generator
 test-pointers-stub-generator: $$(NATIVE_TARGET)
 
 test-pointers.dir = tests/test-pointers
 test-pointers.threads = yes
-test-pointers.deps = str bigarray oUnit
+test-pointers.deps = str bigarray oUnit bytes
 test-pointers.subproject_deps = ctypes ctypes-foreign-base \
   ctypes-foreign-unthreaded cstubs tests-common test-pointers-stubs
 test-pointers.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -66,13 +66,13 @@ test-variadic-stub-generator.dir = 
tests/test-variadic/stub-generator
 test-variadic-stub-generator.threads = yes
 test-variadic-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-variadic-stubs 
tests-common
-test-variadic-stub-generator.deps = str bigarray
+test-variadic-stub-generator.deps = str bigarray bytes
 test-variadic-stub-generator: PROJECT=test-variadic-stub-generator
 test-variadic-stub-generator: $$(NATIVE_TARGET)
 
 test-variadic.dir = tests/test-variadic
 test-variadic.threads = yes
-test-variadic.deps = str bigarray oUnit
+test-variadic.deps = str bigarray oUnit bytes
 test-variadic.subproject_deps = ctypes ctypes-foreign-base \
   ctypes-foreign-unthreaded cstubs tests-common test-variadic-stubs
 test-variadic.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -99,13 +99,13 @@ test-builtins-stub-generator.dir = 
tests/test-builtins/stub-generator
 test-builtins-stub-generator.threads = yes
 test-builtins-stub-generator.subproject_deps = ctypes cstubs \
   test-builtins-stubs ctypes-foreign-base ctypes-foreign-unthreaded 
tests-common
-test-builtins-stub-generator.deps = str bigarray
+test-builtins-stub-generator.deps = str bigarray bytes
 test-builtins-stub-generator: PROJECT=test-builtins-stub-generator
 test-builtins-stub-generator: $$(NATIVE_TARGET)
 
 test-builtins.dir = tests/test-builtins
 test-builtins.threads = yes
-test-builtins.deps = str bigarray oUnit
+test-builtins.deps = str bigarray oUnit bytes
 test-builtins.subproject_deps = ctypes cstubs test-builtins-stubs \
   ctypes-foreign-base ctypes-foreign-unthreaded tests-common
 test-builtins.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -132,13 +132,13 @@ test-macros-stub-generator.dir = 
tests/test-macros/stub-generator
 test-macros-stub-generator.threads = yes
 test-macros-stub-generator.subproject_deps = ctypes cstubs \
   test-macros-stubs ctypes-foreign-base ctypes-foreign-unthreaded tests-common
-test-macros-stub-generator.deps = str bigarray
+test-macros-stub-generator.deps = str bigarray bytes
 test-macros-stub-generator: PROJECT=test-macros-stub-generator
 test-macros-stub-generator: $$(NATIVE_TARGET)
 
 test-macros.dir = tests/test-macros
 test-macros.threads = yes
-test-macros.deps = str bigarray oUnit
+test-macros.deps = str bigarray oUnit bytes
 test-macros.subproject_deps = ctypes cstubs test-macros-stubs \
   ctypes-foreign-base ctypes-foreign-unthreaded tests-common
 test-macros.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -166,13 +166,13 @@ test-higher_order-stub-generator.dir = 
tests/test-higher_order/stub-generator
 test-higher_order-stub-generator.threads = yes
 test-higher_order-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-higher_order-stubs 
tests-common
-test-higher_order-stub-generator.deps = str bigarray
+test-higher_order-stub-generator.deps = str bigarray bytes
 test-higher_order-stub-generator: PROJECT=test-higher_order-stub-generator
 test-higher_order-stub-generator: $$(NATIVE_TARGET)
 
 test-higher_order.dir = tests/test-higher_order
 test-higher_order.threads = yes
-test-higher_order.deps = str bigarray oUnit
+test-higher_order.deps = str bigarray oUnit bytes
 test-higher_order.subproject_deps = ctypes ctypes-foreign-base \
   ctypes-foreign-unthreaded cstubs test-higher_order-stubs tests-common
 test-higher_order.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -199,13 +199,13 @@ test-structs-stub-generator.dir = 
tests/test-structs/stub-generator
 test-structs-stub-generator.threads = yes
 test-structs-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-structs-stubs 
tests-common
-test-structs-stub-generator.deps = str bigarray
+test-structs-stub-generator.deps = str bigarray bytes
 test-structs-stub-generator: PROJECT=test-structs-stub-generator
 test-structs-stub-generator: $$(NATIVE_TARGET)
 
 test-structs.dir = tests/test-structs
 test-structs.threads = yes
-test-structs.deps = str bigarray oUnit
+test-structs.deps = str bigarray oUnit bytes
 test-structs.subproject_deps = ctypes ctypes-foreign-base \
   ctypes-foreign-unthreaded cstubs test-structs-stubs tests-common
 test-structs.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -223,7 +223,7 @@ tests/test-structs/generated_bindings.ml: 
$(BUILDDIR)/test-structs-stub-generato
 
 test-finalisers.dir = tests/test-finalisers
 test-finalisers.threads = yes
-test-finalisers.deps = str bigarray oUnit
+test-finalisers.deps = str bigarray oUnit bytes
 test-finalisers.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-finalisers: PROJECT=test-finalisers
 test-finalisers: $$(NATIVE_TARGET)
@@ -239,13 +239,13 @@ test-cstdlib-stub-generator.dir = 
tests/test-cstdlib/stub-generator
 test-cstdlib-stub-generator.threads = yes
 test-cstdlib-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-cstdlib-stubs 
tests-common
-test-cstdlib-stub-generator.deps = str bigarray
+test-cstdlib-stub-generator.deps = str bigarray bytes
 test-cstdlib-stub-generator: PROJECT=test-cstdlib-stub-generator
 test-cstdlib-stub-generator: $$(NATIVE_TARGET)
 
 test-cstdlib.dir = tests/test-cstdlib
 test-cstdlib.threads = yes
-test-cstdlib.deps = str bigarray oUnit
+test-cstdlib.deps = str bigarray oUnit bytes
 test-cstdlib.subproject_deps = ctypes ctypes-foreign-base \
    ctypes-foreign-unthreaded cstubs test-cstdlib-stubs tests-common
 test-cstdlib.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -263,7 +263,7 @@ tests/test-cstdlib/generated_bindings.ml: 
$(BUILDDIR)/test-cstdlib-stub-generato
 
 test-sizeof.dir = tests/test-sizeof
 test-sizeof.threads = yes
-test-sizeof.deps = str bigarray oUnit
+test-sizeof.deps = str bigarray oUnit bytes
 test-sizeof.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-sizeof: PROJECT=test-sizeof
 test-sizeof: $$(NATIVE_TARGET)
@@ -279,13 +279,13 @@ test-unions-stub-generator.dir = 
tests/test-unions/stub-generator
 test-unions-stub-generator.threads = yes
 test-unions-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-unions-stubs 
tests-common
-test-unions-stub-generator.deps = str bigarray
+test-unions-stub-generator.deps = str bigarray bytes
 test-unions-stub-generator: PROJECT=test-unions-stub-generator
 test-unions-stub-generator: $$(NATIVE_TARGET)
 
 test-unions.dir = tests/test-unions
 test-unions.threads = yes
-test-unions.deps = str bigarray oUnit
+test-unions.deps = str bigarray oUnit bytes
 test-unions.subproject_deps = ctypes ctypes-foreign-base \
    ctypes-foreign-unthreaded cstubs test-unions-stubs tests-common
 test-unions.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -303,7 +303,7 @@ tests/test-unions/generated_bindings.ml: 
$(BUILDDIR)/test-unions-stub-generator.
 
 test-custom_ops.dir = tests/test-custom_ops
 test-custom_ops.threads = yes
-test-custom_ops.deps = str bigarray oUnit
+test-custom_ops.deps = str bigarray oUnit bytes
 test-custom_ops.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-custom_ops: PROJECT=test-custom_ops
 test-custom_ops: $$(NATIVE_TARGET)
@@ -319,13 +319,13 @@ test-arrays-stub-generator.dir = 
tests/test-arrays/stub-generator
 test-arrays-stub-generator.threads = yes
 test-arrays-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-arrays-stubs 
tests-common
-test-arrays-stub-generator.deps = str bigarray
+test-arrays-stub-generator.deps = str bigarray bytes
 test-arrays-stub-generator: PROJECT=test-arrays-stub-generator
 test-arrays-stub-generator: $$(NATIVE_TARGET)
 
 test-arrays.dir = tests/test-arrays
 test-arrays.threads = yes
-test-arrays.deps = str bigarray oUnit
+test-arrays.deps = str bigarray oUnit bytes
 test-arrays.subproject_deps = ctypes ctypes-foreign-base \
   ctypes-foreign-unthreaded cstubs test-arrays-stubs tests-common
 test-arrays.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -343,21 +343,21 @@ tests/test-arrays/generated_bindings.ml: 
$(BUILDDIR)/test-arrays-stub-generator.
 
 test-errno.dir = tests/test-errno
 test-errno.threads = yes
-test-errno.deps = str bigarray oUnit
+test-errno.deps = str bigarray oUnit bytes
 test-errno.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-errno: PROJECT=test-errno
 test-errno: $$(NATIVE_TARGET)
 
 test-passable.dir = tests/test-passable
 test-passable.threads = yes
-test-passable.deps = str bigarray oUnit
+test-passable.deps = str bigarray oUnit bytes
 test-passable.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-passable: PROJECT=test-passable
 test-passable: $$(NATIVE_TARGET)
 
 test-alignment.dir = tests/test-alignment
 test-alignment.threads = yes
-test-alignment.deps = str bigarray oUnit
+test-alignment.deps = str bigarray oUnit bytes
 test-alignment.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-alignment: PROJECT=test-alignment
 test-alignment: $$(NATIVE_TARGET)
@@ -373,13 +373,13 @@ test-views-stub-generator.dir = 
tests/test-views/stub-generator
 test-views-stub-generator.threads = yes
 test-views-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-views-stubs 
tests-common
-test-views-stub-generator.deps = str bigarray
+test-views-stub-generator.deps = str bigarray bytes
 test-views-stub-generator: PROJECT=test-views-stub-generator
 test-views-stub-generator: $$(NATIVE_TARGET)
 
 test-views.dir = tests/test-views
 test-views.threads = yes
-test-views.deps = str bigarray oUnit
+test-views.deps = str bigarray oUnit bytes
 test-views.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded cstubs test-views-stubs tests-common
 test-views.link_flags = -L$(BUILDDIR)/clib -ltest_functions
 test-views: PROJECT=test-views
@@ -405,13 +405,13 @@ test-oo_style-stub-generator.dir = 
tests/test-oo_style/stub-generator
 test-oo_style-stub-generator.threads = yes
 test-oo_style-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-oo_style-stubs 
tests-common
-test-oo_style-stub-generator.deps = str bigarray
+test-oo_style-stub-generator.deps = str bigarray bytes
 test-oo_style-stub-generator: PROJECT=test-oo_style-stub-generator
 test-oo_style-stub-generator: $$(NATIVE_TARGET)
 
 test-oo_style.dir = tests/test-oo_style
 test-oo_style.threads = yes
-test-oo_style.deps = str bigarray oUnit
+test-oo_style.deps = str bigarray oUnit bytes
 test-oo_style.subproject_deps = ctypes ctypes-foreign-base \
    ctypes-foreign-unthreaded cstubs test-oo_style-stubs tests-common
 test-oo_style.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -429,7 +429,7 @@ tests/test-oo_style/generated_bindings.ml: 
$(BUILDDIR)/test-oo_style-stub-genera
 
 test-type_printing.dir = tests/test-type_printing
 test-type_printing.threads = yes
-test-type_printing.deps = str bigarray oUnit
+test-type_printing.deps = str bigarray oUnit bytes
 test-type_printing.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-type_printing: PROJECT=test-type_printing
 test-type_printing: $$(NATIVE_TARGET)
@@ -445,13 +445,13 @@ test-value_printing-stub-generator.dir = 
tests/test-value_printing/stub-generato
 test-value_printing-stub-generator.threads = yes
 test-value_printing-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-value_printing-stubs 
tests-common
-test-value_printing-stub-generator.deps = str bigarray
+test-value_printing-stub-generator.deps = str bigarray bytes
 test-value_printing-stub-generator: PROJECT=test-value_printing-stub-generator
 test-value_printing-stub-generator: $$(NATIVE_TARGET)
 
 test-value_printing.dir = tests/test-value_printing
 test-value_printing.threads = yes
-test-value_printing.deps = str bigarray oUnit
+test-value_printing.deps = str bigarray oUnit bytes
 test-value_printing.subproject_deps = ctypes ctypes-foreign-base \
    ctypes-foreign-unthreaded cstubs tests-common test-value_printing-stubs
 test-value_printing.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -478,13 +478,13 @@ test-complex-stub-generator.dir = 
tests/test-complex/stub-generator
 test-complex-stub-generator.threads = yes
 test-complex-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-complex-stubs 
tests-common
-test-complex-stub-generator.deps = str bigarray
+test-complex-stub-generator.deps = str bigarray bytes
 test-complex-stub-generator: PROJECT=test-complex-stub-generator
 test-complex-stub-generator: $$(NATIVE_TARGET)
 
 test-complex.dir = tests/test-complex
 test-complex.threads = yes
-test-complex.deps = str bigarray oUnit
+test-complex.deps = str bigarray oUnit bytes
 test-complex.subproject_deps = ctypes ctypes-foreign-base \
   ctypes-foreign-unthreaded cstubs tests-common test-complex-stubs
 test-complex.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -511,13 +511,13 @@ test-callback_lifetime-stub-generator.dir = 
tests/test-callback_lifetime/stub-ge
 test-callback_lifetime-stub-generator.threads = yes
 test-callback_lifetime-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded 
test-callback_lifetime-stubs tests-common
-test-callback_lifetime-stub-generator.deps = str bigarray
+test-callback_lifetime-stub-generator.deps = str bigarray bytes
 test-callback_lifetime-stub-generator: 
PROJECT=test-callback_lifetime-stub-generator
 test-callback_lifetime-stub-generator: $$(NATIVE_TARGET)
 
 test-callback_lifetime.dir = tests/test-callback_lifetime
 test-callback_lifetime.threads = yes
-test-callback_lifetime.deps = str bigarray oUnit
+test-callback_lifetime.deps = str bigarray oUnit bytes
 test-callback_lifetime.subproject_deps = ctypes ctypes-foreign-base \
   ctypes-foreign-unthreaded cstubs test-callback_lifetime-stubs tests-common
 test-callback_lifetime.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -535,7 +535,7 @@ tests/test-callback_lifetime/generated_bindings.ml: 
$(BUILDDIR)/test-callback_li
 
 test-stubs.dir = tests/test-stubs
 test-stubs.threads = yes
-test-stubs.deps = str bigarray oUnit
+test-stubs.deps = str bigarray oUnit bytes
 test-stubs.subproject_deps = ctypes ctypes-foreign-base 
ctypes-foreign-unthreaded
 test-stubs: PROJECT=test-stubs
 test-stubs: $$(NATIVE_TARGET)
@@ -551,13 +551,13 @@ test-bigarrays-stub-generator.dir = 
tests/test-bigarrays/stub-generator
 test-bigarrays-stub-generator.threads = yes
 test-bigarrays-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-bigarrays-stubs 
tests-common
-test-bigarrays-stub-generator.deps = str bigarray
+test-bigarrays-stub-generator.deps = str bigarray bytes
 test-bigarrays-stub-generator: PROJECT=test-bigarrays-stub-generator
 test-bigarrays-stub-generator: $$(NATIVE_TARGET)
 
 test-bigarrays.dir = tests/test-bigarrays
 test-bigarrays.threads = yes
-test-bigarrays.deps = str bigarray oUnit
+test-bigarrays.deps = str bigarray oUnit bytes
 test-bigarrays.subproject_deps = ctypes ctypes-foreign-base \
    ctypes-foreign-unthreaded cstubs tests-common test-bigarrays-stubs
 test-bigarrays.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -584,13 +584,13 @@ test-coercions-stub-generator.dir = 
tests/test-coercions/stub-generator
 test-coercions-stub-generator.threads = yes
 test-coercions-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded test-coercions-stubs 
tests-common
-test-coercions-stub-generator.deps = str bigarray
+test-coercions-stub-generator.deps = str bigarray bytes
 test-coercions-stub-generator: PROJECT=test-coercions-stub-generator
 test-coercions-stub-generator: $$(NATIVE_TARGET)
 
 test-coercions.dir = tests/test-coercions
 test-coercions.threads = yes
-test-coercions.deps = str bigarray oUnit
+test-coercions.deps = str bigarray oUnit bytes
 test-coercions.subproject_deps = ctypes ctypes-foreign-base \
    ctypes-foreign-unthreaded cstubs tests-common test-coercions-stubs
 test-coercions.link_flags = -L$(BUILDDIR)/clib -ltest_functions
@@ -617,13 +617,13 @@ test-passing-ocaml-values-stub-generator.dir = 
tests/test-passing-ocaml-values/s
 test-passing-ocaml-values-stub-generator.threads = yes
 test-passing-ocaml-values-stub-generator.subproject_deps = ctypes cstubs \
      ctypes-foreign-base ctypes-foreign-unthreaded 
test-passing-ocaml-values-stubs tests-common
-test-passing-ocaml-values-stub-generator.deps = str bigarray
+test-passing-ocaml-values-stub-generator.deps = str bigarray bytes
 test-passing-ocaml-values-stub-generator: 
PROJECT=test-passing-ocaml-values-stub-generator
 test-passing-ocaml-values-stub-generator: $$(NATIVE_TARGET)
 
 test-passing-ocaml-values.dir = tests/test-passing-ocaml-values
 test-passing-ocaml-values.threads = yes
-test-passing-ocaml-values.deps = str bigarray oUnit
+test-passing-ocaml-values.deps = str bigarray oUnit bytes
 test-passing-ocaml-values.subproject_deps = ctypes ctypes-foreign-base \
    ctypes-foreign-unthreaded cstubs tests-common 
test-passing-ocaml-values-stubs
 test-passing-ocaml-values.link_flags = -L$(BUILDDIR)/clib -ltest_functions
diff --git a/src/cstubs/cstubs_generate_c.ml b/src/cstubs/cstubs_generate_c.ml
index e68bab6..e3923a2 100644
--- a/src/cstubs/cstubs_generate_c.ml
+++ b/src/cstubs/cstubs_generate_c.ml
@@ -396,6 +396,7 @@ struct
     | Array _ -> report_unpassable "arrays"
     | Bigarray _ -> report_unpassable "bigarrays"
     | OCaml String -> Some (string_to_ptr x)
+    | OCaml Bytes -> Some (string_to_ptr x)
     | OCaml FloatArray -> Some (float_array_to_ptr x)
 
   let rec inj : type a. a typ -> cexp -> ceff =
diff --git a/src/cstubs/cstubs_generate_ml.ml b/src/cstubs/cstubs_generate_ml.ml
index 1615719..ec33a6a 100644
--- a/src/cstubs/cstubs_generate_ml.ml
+++ b/src/cstubs/cstubs_generate_ml.ml
@@ -212,6 +212,8 @@ let rec ml_typ_of_return_typ : type a. a typ -> ml_type =
     "Unexpected bigarray type in the return type: %s" (Ctypes.string_of_typ a)
   | OCaml String -> Static.unsupported
     "cstubs does not support OCaml strings as return values"
+  | OCaml Bytes -> Static.unsupported
+    "cstubs does not support OCaml bytes values as return values"
   | OCaml FloatArray -> Static.unsupported
     "cstubs does not support OCaml float arrays as return values"
 
@@ -230,6 +232,9 @@ let rec ml_typ_of_arg_typ : type a. a typ -> ml_type = 
function
   | OCaml String ->
     `Appl (path_of_string "CI.ocaml",
            [`Ident (path_of_string "string")])
+  | OCaml Bytes ->
+    `Appl (path_of_string "CI.ocaml",
+           [`Ident (path_of_string "Bytes.t")])
   | OCaml FloatArray ->
     `Appl (path_of_string "CI.ocaml",
            [`Appl (path_of_string "array",
@@ -325,9 +330,12 @@ let rec pattern_and_exp_of_typ :
   | OCaml ty ->
     begin match pol, ty with
     | In, String -> (static_con "OCaml" [static_con "String" []], None)
+    | In, Bytes -> (static_con "OCaml" [static_con "Bytes" []], None)
     | In, FloatArray -> (static_con "OCaml" [static_con "FloatArray" []], None)
     | Out, String -> Static.unsupported
       "cstubs does not support OCaml strings as return values"
+    | Out, Bytes -> Static.unsupported
+      "cstubs does not support OCaml bytes values as return values"
     | Out, FloatArray -> Static.unsupported
       "cstubs does not support OCaml float arrays as return values"
     end
diff --git a/src/cstubs/cstubs_internals.mli b/src/cstubs/cstubs_internals.mli
index 087176e..e7f31e9 100644
--- a/src/cstubs/cstubs_internals.mli
+++ b/src/cstubs/cstubs_internals.mli
@@ -24,6 +24,7 @@ val raw_ptr : 'a ptr -> voidp
 
 type 'a ocaml_type = 'a Static.ocaml_type =
   String     : string ocaml_type
+| Bytes      : Bytes.t ocaml_type
 | FloatArray : float array ocaml_type
 
 type 'a typ = 'a Static.typ =
diff --git a/src/ctypes-foreign-base/ffi.ml b/src/ctypes-foreign-base/ffi.ml
index 0a062b6..44df403 100644
--- a/src/ctypes-foreign-base/ffi.ml
+++ b/src/ctypes-foreign-base/ffi.ml
@@ -148,6 +148,7 @@ struct
         mov.(idx) <- (Obj.repr obj, disp * elt_size)
     in function
     | OCaml String     -> ocaml_arg 1
+    | OCaml Bytes      -> ocaml_arg 1
     | OCaml FloatArray -> ocaml_arg (Ctypes_primitives.sizeof 
Primitives.Double)
     | ty -> (fun ~offset ~idx v dst mov -> Memory.write ty ~offset v dst)
 
diff --git a/src/ctypes-foreign-base/ffi_call_stubs.c 
b/src/ctypes-foreign-base/ffi_call_stubs.c
index d6bc555..e18008c 100644
--- a/src/ctypes-foreign-base/ffi_call_stubs.c
+++ b/src/ctypes-foreign-base/ffi_call_stubs.c
@@ -284,6 +284,7 @@ value ctypes_call(value function, value callspec_, value 
argwriter, value rvread
 
   struct callspec *callspec = Data_custom_val(callspec_);
   int roffset = callspec->roffset;
+  size_t nelements = callspec->nelements;
 
   assert(callspec->state == CALLSPEC);
 
@@ -297,10 +298,10 @@ value ctypes_call(value function, value callspec_, value 
argwriter, value rvread
                      (void **)(callbuffer + arg_array_offset));
   callback_arg_buf = CTYPES_FROM_PTR(callbuffer);
 
-  callback_val_arr = caml_alloc_tuple(callspec->nelements);
+  callback_val_arr = caml_alloc_tuple(nelements);
   caml_callback2(argwriter, callback_arg_buf, callback_val_arr);
 
-  void **val_refs = alloca(sizeof(void*) * callspec->nelements);
+  void **val_refs = alloca(sizeof(void*) * nelements);
 
   int arg_idx;
   for(arg_idx = 0; arg_idx < Wosize_val(callback_val_arr); arg_idx++) {
diff --git a/src/ctypes/ctypes.mli b/src/ctypes/ctypes.mli
index 19b17bf..54f5e85 100644
--- a/src/ctypes/ctypes.mli
+++ b/src/ctypes/ctypes.mli
@@ -199,6 +199,9 @@ type 'a ocaml = 'a Static.ocaml
 val ocaml_string : string ocaml typ
 (** Value representing the directly mapped storage of an OCaml string. *)
 
+val ocaml_bytes : Bytes.t ocaml typ
+(** Value representing the directly mapped storage of an OCaml byte array. *)
+
 (** {3 Array types} *)
 
 (** {4 C array types} *)
@@ -491,6 +494,10 @@ val ocaml_string_start : string -> string ocaml
 (** [ocaml_string_start s] allows to pass a pointer to the contents of an OCaml
     string directly to a C function. *)
 
+val ocaml_bytes_start : Bytes.t -> Bytes.t ocaml
+(** [ocaml_bytes_start s] allows to pass a pointer to the contents of an OCaml
+    byte array directly to a C function. *)
+
 (** {3 Array values} *)
 
 (** {4 C array values} *)
diff --git a/src/ctypes/memory.ml b/src/ctypes/memory.ml
index ac2fd90..ddd39a6 100644
--- a/src/ctypes/memory.ml
+++ b/src/ctypes/memory.ml
@@ -346,5 +346,8 @@ let string_from_ptr (CPointer { raw_ptr; pbyte_offset = 
offset }) ~length:len =
 let ocaml_string_start str =
   OCamlRef (0, str, String)
 
+let ocaml_bytes_start str =
+  OCamlRef (0, str, Bytes)
+
 let ocaml_float_array_start arr =
   OCamlRef (0, arr, FloatArray)
diff --git a/src/ctypes/static.ml b/src/ctypes/static.ml
index b84600b..b2b9ae2 100644
--- a/src/ctypes/static.ml
+++ b/src/ctypes/static.ml
@@ -29,6 +29,7 @@ type abstract_type = {
 
 type _ ocaml_type =
   String     : string ocaml_type
+| Bytes      : Bytes.t ocaml_type
 | FloatArray : float array ocaml_type
 
 type _ typ =
@@ -188,6 +189,7 @@ let ulong = Primitive Primitives.Ulong
 let ullong = Primitive Primitives.Ullong
 let array i t = Array (t, i)
 let ocaml_string = OCaml String
+let ocaml_bytes = OCaml Bytes
 let ocaml_float_array = OCaml FloatArray
 let ptr t = Pointer t
 let ( @->) f t =
diff --git a/src/ctypes/static.mli b/src/ctypes/static.mli
index f9e56bb..3fc7979 100644
--- a/src/ctypes/static.mli
+++ b/src/ctypes/static.mli
@@ -15,6 +15,7 @@ type abstract_type = {
 
 type _ ocaml_type =
   String     : string ocaml_type
+| Bytes      : Bytes.t ocaml_type
 | FloatArray : float array ocaml_type
 
 type incomplete_size = { mutable isize: int }
@@ -139,6 +140,7 @@ val ulong : Unsigned.ulong typ
 val ullong : Unsigned.ullong typ
 val array : int -> 'a typ -> 'a carray typ
 val ocaml_string : string ocaml typ
+val ocaml_bytes : Bytes.t ocaml typ
 val ocaml_float_array : float array ocaml typ
 val ptr : 'a typ -> 'a ptr typ
 val ( @-> ) : 'a typ -> 'b fn -> ('a -> 'b) fn
diff --git a/src/ctypes/type_printing.ml b/src/ctypes/type_printing.ml
index 75c78e6..4cfc89c 100644
--- a/src/ctypes/type_printing.ml
+++ b/src/ctypes/type_printing.ml
@@ -63,6 +63,7 @@ let rec format_typ' : type a. a typ ->
       fprintf fmt "%s%t%t" name (k `array)
         (fun fmt -> (Array.iter (Format.fprintf fmt "[%d]") dims))
     | OCaml String -> format_typ' (ptr char) k context fmt
+    | OCaml Bytes -> format_typ' (ptr char) k context fmt
     | OCaml FloatArray -> format_typ' (ptr double) k context fmt
 
 and format_fields : type a. a boxed_field list -> Format.formatter -> unit =
diff --git a/src/ctypes/value_printing.ml b/src/ctypes/value_printing.ml
index 6512008..4162298 100644
--- a/src/ctypes/value_printing.ml
+++ b/src/ctypes/value_printing.ml
@@ -64,6 +64,7 @@ and format_ocaml : type a. Format.formatter -> a ocaml -> 
unit =
   in
   fun fmt (OCamlRef (off, obj, ty)) -> match ty with
   | String -> Format.fprintf fmt "%S%a" obj offset off
+  | Bytes -> Format.fprintf fmt "%S%a" (Bytes.to_string obj) offset off
   | FloatArray -> Format.fprintf fmt "%a%a" float_array obj offset off
 and format_fields : type a b. string -> (a, b) structured boxed_field list ->
                               Format.formatter -> (a, b) structured -> unit
diff --git a/src/libffi-abigen/libffi_abigen.ml 
b/src/libffi-abigen/libffi_abigen.ml
index 064ccbd..d69c70e 100644
--- a/src/libffi-abigen/libffi_abigen.ml
+++ b/src/libffi-abigen/libffi_abigen.ml
@@ -95,7 +95,7 @@ let determine_code symbol =
   let result = read_output_int input_file output_file in
   begin
     Sys.remove input_file;
-    Sys.remove output_file;
+    if Sys.file_exists output_file then Sys.remove output_file;
     result
   end
 
diff --git a/tests/test-passing-ocaml-values/stubs/functions.ml 
b/tests/test-passing-ocaml-values/stubs/functions.ml
index 5d89f7b..58cb3b4 100644
--- a/tests/test-passing-ocaml-values/stubs/functions.ml
+++ b/tests/test-passing-ocaml-values/stubs/functions.ml
@@ -16,6 +16,9 @@ struct
   let memcpy_string_string = foreign "memcpy"
     (ocaml_string @-> ocaml_string @-> size_t @-> returning (ptr void))
 
+  let memcpy_bytes_bytes = foreign "memcpy"
+    (ocaml_bytes @-> ocaml_bytes @-> size_t @-> returning (ptr void))
+
   let memcpy_string_ptr = foreign "memcpy"
     (ocaml_string @-> ptr void @-> size_t @-> returning (ptr void))
 
diff --git a/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml 
b/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml
index 30ff18d..a558373 100644
--- a/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml
+++ b/tests/test-passing-ocaml-values/test_passing_ocaml_values.ml
@@ -31,6 +31,16 @@ struct
     in begin
       assert_equal buf input
     end;
+
+    let bbuf = Bytes.create len in
+    let binput = Bytes.unsafe_of_string (String.copy input) in
+    let _ = memcpy_bytes_bytes
+      (ocaml_bytes_start bbuf)
+      (ocaml_bytes_start binput)
+      (Unsigned.Size_t.of_int len)
+    in begin
+      assert_equal bbuf binput
+    end;
     
     let arr = CArray.make char len in
     let () = String.iteri (CArray.set arr) input in

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-ocaml-maint/packages/ocaml-ctypes.git

_______________________________________________
Pkg-ocaml-maint-commits mailing list
Pkg-ocaml-maint-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-ocaml-maint-commits

Reply via email to