Permalink
Browse files

Added double array example and made the array example more complex

  • Loading branch information...
1 parent bf8a9d7 commit 92a58421d58b909b534548cb4ea18d0e1be2235e @aplusbi committed Nov 6, 2011
Showing with 5,619 additions and 1 deletion.
  1. +3 −1 array/main.ml
  2. +11 −0 array/stubs.c
  3. +38 −0 darray/Makefile
  4. +15 −0 darray/_oasis
  5. +18 −0 darray/_tags
  6. +27 −0 darray/configure
  7. +4 −0 darray/libmain.clib
  8. +8 −0 darray/main.ml
  9. +461 −0 darray/myocamlbuild.ml
  10. +5,005 −0 darray/setup.ml
  11. +29 −0 darray/stubs.c
View
@@ -1,6 +1,8 @@
+external create_array : int -> int array =
+ "caml_create_array"
external print_array : int array -> unit =
"caml_print_array"
let _ =
- let a = [|1; 2; 3; 4; 5|] in
+ let a = create_array 5 in
print_array a
View
@@ -3,6 +3,17 @@
#include <caml/memory.h>
#include <caml/alloc.h>
+CAMLprim value caml_create_array(value size)
+{
+ CAMLparam1(size);
+ CAMLlocal1(ret);
+ int i;
+ ret = caml_alloc_tuple(Int_val(size));
+ for(i=0; i<Int_val(size); ++i)
+ Field(ret, i) = Val_int(i);
+ CAMLreturn(ret);
+}
+
CAMLprim value caml_print_array(value a)
{
CAMLparam1(a);
View
@@ -0,0 +1,38 @@
+# OASIS_START
+# DO NOT EDIT (digest: bc1e05bfc8b39b664f29dae8dbd3ebbb)
+
+SETUP = ocaml setup.ml
+
+build: setup.data
+ $(SETUP) -build $(BUILDFLAGS)
+
+doc: setup.data build
+ $(SETUP) -doc $(DOCFLAGS)
+
+test: setup.data build
+ $(SETUP) -test $(TESTFLAGS)
+
+all:
+ $(SETUP) -all $(ALLFLAGS)
+
+install: setup.data
+ $(SETUP) -install $(INSTALLFLAGS)
+
+uninstall: setup.data
+ $(SETUP) -uninstall $(UNINSTALLFLAGS)
+
+reinstall: setup.data
+ $(SETUP) -reinstall $(REINSTALLFLAGS)
+
+clean:
+ $(SETUP) -clean $(CLEANFLAGS)
+
+distclean:
+ $(SETUP) -distclean $(DISTCLEANFLAGS)
+
+setup.data:
+ $(SETUP) -configure $(CONFIGUREFLAGS)
+
+.PHONY: build doc test all install uninstall reinstall clean distclean configure
+
+# OASIS_STOP
View
@@ -0,0 +1,15 @@
+OASISFormat: 0.2
+Name: double array
+Version: 1
+Synopsis: Example
+Authors: Niki Yoshiuchi
+License: Apache
+Plugins: DevFiles (0.2)
+
+Executable main
+ Path: .
+ BuildTools: ocamlbuild
+ CompiledObject: best
+ MainIs: main.ml
+ CSources: stubs.c
+
View
@@ -0,0 +1,18 @@
+# OASIS_START
+# DO NOT EDIT (digest: d7f28eaa2f243ad6cdeb06fe0dfdedb9)
+# Ignore VCS directories, you can use the same kind of rule outside
+# OASIS_START/STOP if you want to exclude directories that contains
+# useless stuff for the build process
+<**/.svn>: -traverse
+<**/.svn>: not_hygienic
+".bzr": -traverse
+".bzr": not_hygienic
+".hg": -traverse
+".hg": not_hygienic
+".git": -traverse
+".git": not_hygienic
+"_darcs": -traverse
+"_darcs": not_hygienic
+# Executable main
+<main.{native,byte}>: use_libmain
+# OASIS_STOP
View
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# OASIS_START
+# DO NOT EDIT (digest: 425187ed8bfdbdd207fd76392dd243a7)
+set -e
+
+FST=true
+for i in "$@"; do
+ if $FST; then
+ set --
+ FST=false
+ fi
+
+ case $i in
+ --*=*)
+ ARG=${i%%=*}
+ VAL=${i##*=}
+ set -- "$@" "$ARG" "$VAL"
+ ;;
+ *)
+ set -- "$@" "$i"
+ ;;
+ esac
+done
+
+ocaml setup.ml -configure "$@"
+# OASIS_STOP
View
@@ -0,0 +1,4 @@
+# OASIS_START
+# DO NOT EDIT (digest: 2687b44cdd08f24e2e6f85558c5ba9a2)
+stubs.o
+# OASIS_STOP
View
@@ -0,0 +1,8 @@
+external create_array : int -> float -> float array =
+ "caml_create_array"
+external print_array : float array -> unit =
+ "caml_print_array"
+
+let _ =
+ let a = create_array 5 0.5 in
+ print_array a
Oops, something went wrong.

0 comments on commit 92a5842

Please sign in to comment.