summaryrefslogtreecommitdiff
path: root/Examples/ocaml/scoped_enum
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/ocaml/scoped_enum')
-rw-r--r--Examples/ocaml/scoped_enum/Makefile33
-rw-r--r--Examples/ocaml/scoped_enum/README1
-rw-r--r--Examples/ocaml/scoped_enum/example.i7
-rw-r--r--Examples/ocaml/scoped_enum/example_prog.ml4
-rw-r--r--Examples/ocaml/scoped_enum/foo.h5
5 files changed, 50 insertions, 0 deletions
diff --git a/Examples/ocaml/scoped_enum/Makefile b/Examples/ocaml/scoped_enum/Makefile
new file mode 100644
index 0000000..45c5edc
--- /dev/null
+++ b/Examples/ocaml/scoped_enum/Makefile
@@ -0,0 +1,33 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+MLFILE = example.ml
+PROGFILE = example_prog.ml
+OBJS =
+
+all:: static
+
+dynamic::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_dynamic_cpp
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp
+
+toplevel::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
+ PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
+ ocaml_static_cpp_toplevel
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
+
+check: all
diff --git a/Examples/ocaml/scoped_enum/README b/Examples/ocaml/scoped_enum/README
new file mode 100644
index 0000000..88b6693
--- /dev/null
+++ b/Examples/ocaml/scoped_enum/README
@@ -0,0 +1 @@
+This tests our handling of scoped enums. Run with argument Tag1 or Tag2. \ No newline at end of file
diff --git a/Examples/ocaml/scoped_enum/example.i b/Examples/ocaml/scoped_enum/example.i
new file mode 100644
index 0000000..de553f8
--- /dev/null
+++ b/Examples/ocaml/scoped_enum/example.i
@@ -0,0 +1,7 @@
+%module example
+
+%{
+#include "foo.h"
+%}
+
+%include "foo.h" \ No newline at end of file
diff --git a/Examples/ocaml/scoped_enum/example_prog.ml b/Examples/ocaml/scoped_enum/example_prog.ml
new file mode 100644
index 0000000..e19bb34
--- /dev/null
+++ b/Examples/ocaml/scoped_enum/example_prog.ml
@@ -0,0 +1,4 @@
+open Swig
+open Example
+
+let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | _ -> ``Tag2)
diff --git a/Examples/ocaml/scoped_enum/foo.h b/Examples/ocaml/scoped_enum/foo.h
new file mode 100644
index 0000000..8238cb6
--- /dev/null
+++ b/Examples/ocaml/scoped_enum/foo.h
@@ -0,0 +1,5 @@
+namespace foo {
+ enum Bar { Tag1, Tag2 };
+ static void f( Bar b ) { printf( "b = %d\n", (int)b ); }
+}
+