diff options
author | Ian Lance Taylor <iant@google.com> | 2010-06-10 01:13:31 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@google.com> | 2010-06-10 01:13:31 +0000 |
commit | 5af2978f77cad0eec048ba1ea09b07e8ad7abbfa (patch) | |
tree | 2a7c8d569dde6570e0a5baa907bb5b3084697a52 /Lib/go/std_string.i | |
parent | 09f14197ac1df83e9b428d84782238abec0500bd (diff) | |
download | swig-5af2978f77cad0eec048ba1ea09b07e8ad7abbfa.tar.gz |
Add support for the Go programming language.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12108 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/go/std_string.i')
-rw-r--r-- | Lib/go/std_string.i | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i new file mode 100644 index 000000000..3c94cbe10 --- /dev/null +++ b/Lib/go/std_string.i @@ -0,0 +1,55 @@ +/* ----------------------------------------------------------------------------- + * std_string.i + * + * Typemaps for std::string and const std::string& + * These are mapped to a Go string and are passed around by value. + * + * To use non-const std::string references use the following %apply. Note + * that they are passed by value. + * %apply const std::string & {std::string &}; + * ----------------------------------------------------------------------------- */ + +%{ +#include <string> +%} + +namespace std { + +%naturalvar string; + +class string; + +%typemap(go) string, const string & "string" + +%typemap(in) string +%{ $1.assign($input.p, $input.n); %} + +%typemap(directorout) string +%{ $result.assign($input.p, $input.n); %} + +%typemap(out) string +%{ $result = _swig_makegostring($1.data(), $1.length()); %} + +%typemap(directorin) string +%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %} + +%typemap(in) const string & +%{ + std::string $1_str($input.p, $input.n); + $1 = &$1_str; +%} + +%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & +%{ + static std::string $1_str; + $1_str.assign($input.p, $input.n); + $result = &$1_str; +%} + +%typemap(out) const string & +%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %} + +%typemap(directorin) const string & +%{ $input = _swig_makegostring($1_name.data(), $1_name.length()); %} + +} |