summaryrefslogtreecommitdiff
path: root/Lib/go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-03-15 20:30:40 -0700
committerIan Lance Taylor <iant@golang.org>2022-03-15 20:30:53 -0700
commit0c0b93f8e06f362bae5b732460f8aeb9752b1f0c (patch)
tree7d548c70ca569f5f4a6c9745e95cf129276586bd /Lib/go
parentb8193631175d668890d9bcbb0e964f36affa2e12 (diff)
downloadswig-0c0b93f8e06f362bae5b732460f8aeb9752b1f0c.tar.gz
[Go] add typemaps for std::string*
Fixes #2214
Diffstat (limited to 'Lib/go')
-rw-r--r--Lib/go/std_string.i50
1 files changed, 50 insertions, 0 deletions
diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i
index 099ae84d4..c362f5c5e 100644
--- a/Lib/go/std_string.i
+++ b/Lib/go/std_string.i
@@ -88,4 +88,54 @@ class string;
%typemap(godirectorin,fragment="CopyString") const string &
%{ $result = swigCopyString($input) %}
+
+%typemap(gotype) string * "*string"
+
+%typemap(in) string * (string temp)
+%{
+ temp.assign($input->p, $input->n);
+ $1 = &temp;
+%}
+
+%typemap(godirectorout) string *
+%{
+ {
+ p := Swig_malloc(len(*$input))
+ s := (*[1<<30]byte)(unsafe.Pointer(p))[:len(*$input)]
+ copy(s, *$input)
+ $result = (*string)(unsafe.Pointer(&s))
+ }
+%}
+
+%typemap(directorout) string * (string temp)
+%{
+ temp.assign($input->p, $input->n);
+ $result = &temp;
+ free($input.p);
+%}
+
+%typemap(out,fragment="AllocateString") string * (_gostring_ temp)
+%{
+ temp = Swig_AllocateString($1->data(), $1->length());
+ $result = &temp;
+%}
+
+%typemap(goout,fragment="CopyString") string *
+%{ *$result = swigCopyString(*$1) %}
+
+%typemap(directorin,fragment="AllocateString") string * (_gostring_ temp)
+%{
+ temp = Swig_AllocateString($1->data(), $1->length());
+ $input = &temp;
+%}
+
+%typemap(godirectorin,fragment="CopyString") string *
+%{ *$result = swigCopyString(*$input); %}
+
+%typemap(argout,fragment="AllocateString") string *
+%{ *$input = Swig_AllocateString($1->data(), $1->length()); %}
+
+%typemap(goargout,fragment="CopyString") string *
+%{ *$input = swigCopyString(*$1) %}
+
}