This example both shows the new enum literal facility, and is a regression
test against the enum scoping problem I had. Ocaml.cxx: Accidentally reintroduced the enum scoping problem, so I added an example that will fail if this is ever broken again. I encountered the actual problem in avifile.h git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5478 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fbb9c8481d
commit
87f4bcef2e
6 changed files with 67 additions and 6 deletions
33
SWIG/Examples/ocaml/scoped_enum/Makefile
Normal file
33
SWIG/Examples/ocaml/scoped_enum/Makefile
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../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
|
||||
1
SWIG/Examples/ocaml/scoped_enum/README
Normal file
1
SWIG/Examples/ocaml/scoped_enum/README
Normal file
|
|
@ -0,0 +1 @@
|
|||
This tests our handling of scoped enums. Run with argument Tag1 or Tag2.
|
||||
7
SWIG/Examples/ocaml/scoped_enum/example.i
Normal file
7
SWIG/Examples/ocaml/scoped_enum/example.i
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
%module example
|
||||
|
||||
%{
|
||||
#include "foo.h"
|
||||
%}
|
||||
|
||||
%include "foo.h"
|
||||
4
SWIG/Examples/ocaml/scoped_enum/example_prog.ml
Normal file
4
SWIG/Examples/ocaml/scoped_enum/example_prog.ml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
open Swig
|
||||
open Example
|
||||
|
||||
let _ = _f (match Sys.argv.(1) with "Tag1" -> ``Tag1 | "Tag2" -> ``Tag2)
|
||||
5
SWIG/Examples/ocaml/scoped_enum/foo.h
Normal file
5
SWIG/Examples/ocaml/scoped_enum/foo.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
namespace foo {
|
||||
enum Bar { Tag1, Tag2 };
|
||||
static void f( Bar b ) { printf( "b = %d\n", (int)b ); }
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue