summaryrefslogtreecommitdiff
path: root/Examples/test-suite/go_director_inout.i
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-03-05 21:57:36 -0800
committerIan Lance Taylor <iant@golang.org>2022-03-05 21:57:36 -0800
commit27bdbc1f05c7c656c9d0cafdea225ab3cf017f89 (patch)
tree4875419260c4fe04c98efd0696d24ab06949f96e /Examples/test-suite/go_director_inout.i
parent4499422308b9fdb7c93b10c51a828285cb614d34 (diff)
downloadswig-27bdbc1f05c7c656c9d0cafdea225ab3cf017f89.tar.gz
swig -go: treat non-const references as pointers
Also clean up the handling of int* and int& to convert between the C type int and the Go type int, which are often different sizes. Fixes #2210
Diffstat (limited to 'Examples/test-suite/go_director_inout.i')
-rw-r--r--Examples/test-suite/go_director_inout.i25
1 files changed, 25 insertions, 0 deletions
diff --git a/Examples/test-suite/go_director_inout.i b/Examples/test-suite/go_director_inout.i
index 5a7fbdf89..708bd7c87 100644
--- a/Examples/test-suite/go_director_inout.i
+++ b/Examples/test-suite/go_director_inout.i
@@ -2,6 +2,8 @@
%module(directors="1") go_director_inout
+%include <std_string.i>
+
%{
#include <string>
%}
@@ -108,6 +110,25 @@ type GoRetStruct struct {
$1.str.assign($input.p, $input.n);
%}
+%typemap(directorin) std::string & (_gostring_ temp) {
+ $input = &temp;
+ temp.p = (char *) $1.data();
+ temp.n = $1.size();
+}
+%typemap(directorargout) std::string & {
+ _gostring_ *tmp = $input;
+ $1.assign(tmp->p, tmp->p + tmp->n);
+}
+
+%typemap(directorin) std::string * (_gostring_ temp) {
+ $input = &temp;
+ $input->p = (char *) $1->data();
+ $input->n = $1->size();
+}
+%typemap(directorargout) std::string * {
+ $1->assign($input->p, $input->p + $input->n);
+}
+
%feature("director") MyClass;
%inline
@@ -121,6 +142,10 @@ class MyClass {
r.str = s.str;
return r;
}
+
+ virtual void S1(std::string s) = 0;
+ virtual void S2(std::string& s) = 0;
+ virtual void S3(std::string* s) = 0;
};
%}