diff options
author | Art Yerkes <ayerkes@speakeasy.net> | 2003-03-08 20:14:31 +0000 |
---|---|---|
committer | Art Yerkes <ayerkes@speakeasy.net> | 2003-03-08 20:14:31 +0000 |
commit | ade9d25284319d7634d0fac9010eaf964179bb71 (patch) | |
tree | 0bd32b706a47c894a6aef0af6ab39b9a1e222ad5 /Lib/ocaml/std_string.i | |
parent | 8dd475f93e2c8c97e39b8895648c9782b003d49e (diff) | |
download | swig-ade9d25284319d7634d0fac9010eaf964179bb71.tar.gz |
Director: added disown. It now mutates the reference held by the object.
mlheading and mliheading: Added C_director_core, which holds the state needed
by the director to disown.
std_string and std_vector: Added specific support for the common case of
a zero-terminated char **.
typemaps.i: Withdraw default argout for SWIGTYPE &
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4481 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/ocaml/std_string.i')
-rw-r--r-- | Lib/ocaml/std_string.i | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i index d789f5161..becdb2b29 100644 --- a/Lib/ocaml/std_string.i +++ b/Lib/ocaml/std_string.i @@ -17,8 +17,11 @@ %{ #include <string> +#include <vector> %} +%include std_vector.i + namespace std { template <class charT> class basic_string { public: @@ -113,3 +116,32 @@ namespace std { } } +%template (StringVector) std::vector<string >; + +char **c_charptr_array( const std::vector <string > &str_v ); + +%{ + SWIGEXT char **c_charptr_array( const std::vector <string > &str_v ) { + char **out = new char *[str_v.size() + 1]; + out[str_v.size()] = 0; + for( int i = 0; i < str_v.size(); i++ ) { + out[i] = (char *)str_v[i].c_str(); + } + return out; + } +%} + +%insert(ml) %{ + (* Some STL convenience items *) + + let string_array_to_vector sa = + let nv = _new_StringVector C_void in + array_to_vector nv (fun x -> C_string x) sa ; nv + + let c_string_array ar = + _c_charptr_array (string_array_to_vector ar) +%} + +%insert(mli) %{ + val c_string_array: string array -> c_obj +%} |