diff options
Diffstat (limited to 'Examples/test-suite')
-rw-r--r-- | Examples/test-suite/go/go_director_inout_runme.go | 32 | ||||
-rw-r--r-- | Examples/test-suite/go_director_inout.i | 25 |
2 files changed, 57 insertions, 0 deletions
diff --git a/Examples/test-suite/go/go_director_inout_runme.go b/Examples/test-suite/go/go_director_inout_runme.go index 171b3c223..f2be9d30b 100644 --- a/Examples/test-suite/go/go_director_inout_runme.go +++ b/Examples/test-suite/go/go_director_inout_runme.go @@ -14,6 +14,26 @@ func (p *GoMyClass) Adjust(m map[string]interface{}) wrap.GoRetStruct { return wrap.GoRetStruct{s} } +func (p *GoMyClass) S1(s string) { + if s != "S1" { + panic(s) + } +} + +func (p *GoMyClass) S2(s *string) { + if *s != "S2" { + panic(s) + } + *s = "R2" +} + +func (p *GoMyClass) S3(s *string) { + if *s != "S3" { + panic(s) + } + *s = "R3" +} + func main() { a := wrap.NewDirectorMyClass(&GoMyClass{}) m := map[string]interface{}{ @@ -24,6 +44,18 @@ func main() { panic(s) } + a.S1("S1") + str := "S2" + a.S2(&str) + if str != "R2" { + panic(str) + } + str = "S3" + a.S3(&str) + if str != "R3" { + panic(str) + } + a = wrap.NewDirectorMyClass(nil) s = a.Adjust(m) if s.Str != `{"first":"second"}` { 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; }; %} |