summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2011-02-14 07:22:06 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2011-02-14 07:22:06 +0000
commit1fab53b2046b97702e1de4cfab06cb8fa8fc129d (patch)
tree00f38310abed624464c4e529eec9c33d0ce601e4 /Examples
parent7d700cc99996ca32379eeaf0f5c919c39dfa37ba (diff)
downloadswig-1fab53b2046b97702e1de4cfab06cb8fa8fc129d.tar.gz
[Ocaml] Apply patch #3151788 from Joel Reymont. Brings Ocaml support a up to date (ver 3.11 and 3.12), including std::string.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12460 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Examples')
-rw-r--r--Examples/Makefile.in14
-rw-r--r--Examples/ocaml/argout_ref/example.i4
-rw-r--r--Examples/ocaml/shapes/example.c2
-rw-r--r--Examples/ocaml/shapes/example.h3
-rw-r--r--Examples/ocaml/std_string/README6
-rw-r--r--Examples/ocaml/strings_test/example.h18
6 files changed, 32 insertions, 15 deletions
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index b23fccef8..32eaeccd9 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -632,7 +632,7 @@ ocaml_static_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -643,13 +643,13 @@ ocaml_static_cpp: $(SRCS)
$(INTERFACE:%.i=%.cmo) \
$(PROGFILE:%.ml=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX)'
+ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_static_cpp_toplevel: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -657,17 +657,17 @@ ocaml_static_cpp_toplevel: $(SRCS)
$(OCC) $(OCAMLPP) -c $(PROGFILE)
$(NOLINK) || $(OCAMLMKTOP) \
swig.cmo \
- -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
+ -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
$(INTERFACE:%.i=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX)'
+ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_dynamic_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
$(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
@@ -684,7 +684,7 @@ ocaml_dynamic_cpp: $(SRCS)
$(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
-o $(TARGET) \
-package dl -linkpkg \
- $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
+ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings'
ocaml_clean:
rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
diff --git a/Examples/ocaml/argout_ref/example.i b/Examples/ocaml/argout_ref/example.i
index a0be05f24..5ea6777fb 100644
--- a/Examples/ocaml/argout_ref/example.i
+++ b/Examples/ocaml/argout_ref/example.i
@@ -1,4 +1,8 @@
/* File : example.i */
%module example
+%{
+extern "C" void factor(int &x, int &y);
+%}
+
extern "C" void factor(int &x, int &y);
diff --git a/Examples/ocaml/shapes/example.c b/Examples/ocaml/shapes/example.c
index bf0fff937..26c1b8098 100644
--- a/Examples/ocaml/shapes/example.c
+++ b/Examples/ocaml/shapes/example.c
@@ -46,3 +46,5 @@ void draw_depth_map( volume *v, int div_x, int div_y ) {
}
double volume::depth( double x, double y ) { return 0.0; }
+
+volume::~volume() { }
diff --git a/Examples/ocaml/shapes/example.h b/Examples/ocaml/shapes/example.h
index 4b1644494..68cb6ee3e 100644
--- a/Examples/ocaml/shapes/example.h
+++ b/Examples/ocaml/shapes/example.h
@@ -9,7 +9,8 @@ public:
class volume {
public:
- virtual double depth( double x, double y );
+ virtual double depth( double x, double y );
+ virtual ~volume();
};
extern void draw_shape_coverage( shape *s, int div_x, int div_y );
diff --git a/Examples/ocaml/std_string/README b/Examples/ocaml/std_string/README
index 566553083..ccebecbaf 100644
--- a/Examples/ocaml/std_string/README
+++ b/Examples/ocaml/std_string/README
@@ -1,3 +1,9 @@
+--- New ---
+
+It's not possible to access std::(w)string at the moment as it breaks other string examples.
+
+--- Old ---
+
This example shows how to use both std::string and std::wstring in Ocaml,
and also demonstrates that one might use this to make a locale-obedient
Ocaml program.
diff --git a/Examples/ocaml/strings_test/example.h b/Examples/ocaml/strings_test/example.h
index 3417981f0..959404b5d 100644
--- a/Examples/ocaml/strings_test/example.h
+++ b/Examples/ocaml/strings_test/example.h
@@ -1,14 +1,18 @@
/* -*- mode: c++ -*- */
/* File : example.h -- Tests all string typemaps */
+#include <sys/time.h>
+#include <time.h>
+
void takes_std_string( std::string in ) {
cout << "takes_std_string( \"" << in << "\" );" << endl;
}
std::string gives_std_string() {
- time_t t;
-
- return std::string( asctime( localtime( &t ) ) );
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ return std::string( asctime( localtime( &tv.tv_sec ) ) );
}
void takes_char_ptr( char *p ) {
@@ -24,10 +28,10 @@ void takes_and_gives_std_string( std::string &inout ) {
inout.insert( inout.end(), ']' );
}
-void takes_and_gives_char_ptr( char *&ptr ) {
- char *pout = strchr( ptr, '.' );
- if( pout ) ptr = pout + 1;
- else ptr = "foo";
+void takes_and_gives_char_ptr( char *&inout ) {
+ char *pout = strchr( inout, '.' );
+ if( pout ) inout = pout + 1;
+ else inout = "foo";
}
/*