Added stl example.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4602 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5393751256
commit
2949c006d4
4 changed files with 68 additions and 0 deletions
28
SWIG/Examples/ocaml/stl/Makefile
Normal file
28
SWIG/Examples/ocaml/stl/Makefile
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig -I/usr/include/g++-3
|
||||
SRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
PROGFILE = runme.ml
|
||||
|
||||
all default:: static
|
||||
|
||||
static::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_static_cpp
|
||||
|
||||
director::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_static_cpp_director
|
||||
|
||||
dynamic::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_static_cpp
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
|
||||
|
||||
check: all
|
||||
15
SWIG/Examples/ocaml/stl/example.h
Normal file
15
SWIG/Examples/ocaml/stl/example.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* File : example.h -- stolen from the guile std_vector example */
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
|
||||
double vec_write(std::vector<string> v) {
|
||||
int n = 0;
|
||||
for( std::vector<string>::iterator i = v.begin();
|
||||
i != v.end();
|
||||
i++ )
|
||||
printf( "%04d: %s\n", ++n, i->c_str() );
|
||||
}
|
||||
13
SWIG/Examples/ocaml/stl/example.i
Normal file
13
SWIG/Examples/ocaml/stl/example.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
%module example
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include stl.i
|
||||
|
||||
%feature("director");
|
||||
namespace std {
|
||||
%template(StringVector) std::vector<string>;
|
||||
};
|
||||
|
||||
%include example.h
|
||||
12
SWIG/Examples/ocaml/stl/runme.ml
Normal file
12
SWIG/Examples/ocaml/stl/runme.ml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(* This example was mostly lifted from the guile example directory *)
|
||||
|
||||
open Example
|
||||
|
||||
let v = new_StringVector C_void
|
||||
|
||||
let _ =
|
||||
for i = 0 to (Array.length Sys.argv) - 1 do
|
||||
(invoke v) "push_back" (C_string Sys.argv.(i))
|
||||
done
|
||||
|
||||
let _ = _vec_write v
|
||||
Loading…
Add table
Add a link
Reference in a new issue