[Go] Fix use of goout typemap when calling base method by
forcing the "type" attribute to the value we need.
This commit is contained in:
parent
9cd3e28c4e
commit
0f54384ee3
4 changed files with 55 additions and 0 deletions
|
|
@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.9 (in progress)
|
Version 3.0.9 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2016-04-18: ianlancetaylor
|
||||||
|
[Go] Fix use of goout typemap when calling base method by
|
||||||
|
forcing the "type" attribute to the value we need.
|
||||||
|
|
||||||
2016-04-17: ianlancetaylor
|
2016-04-17: ianlancetaylor
|
||||||
[Go] Fixes for Go 1.6: avoid returning Go pointers from
|
[Go] Fixes for Go 1.6: avoid returning Go pointers from
|
||||||
directors that return string values; add a trailing 0 byte
|
directors that return string values; add a trailing 0 byte
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,14 @@ func main() {
|
||||||
fmt.Println("got", a, "want", dwant)
|
fmt.Println("got", a, "want", dwant)
|
||||||
panic(a)
|
panic(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c2 := go_inout.NewC2()
|
||||||
|
pm := c2.M()
|
||||||
|
want = map[string]interface{}{
|
||||||
|
"ID": float64(1),
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(*pm, want) {
|
||||||
|
fmt.Println("for c2.M got", pm, "want", want)
|
||||||
|
panic(pm)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,26 @@ type In json.Marshaler
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%typemap(gotype) RetStruct* "*map[string]interface{}"
|
||||||
|
|
||||||
|
%typemap(imtype) RetStruct* "*string"
|
||||||
|
|
||||||
|
%typemap(out,fragment="AllocateString") RetStruct*
|
||||||
|
%{
|
||||||
|
$result = (_gostring_*)malloc(sizeof(_gostring_));
|
||||||
|
*$result = Swig_AllocateString($1->str.data(), $1->str.length());
|
||||||
|
%}
|
||||||
|
|
||||||
|
%typemap(goout,fragment="CopyString") RetStruct*
|
||||||
|
%{
|
||||||
|
defer Swig_free(uintptr(unsafe.Pointer($1)))
|
||||||
|
var rm map[string]interface{}
|
||||||
|
if err := json.Unmarshal([]byte(swigCopyString(*$1)), &rm); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
$result = &rm
|
||||||
|
%}
|
||||||
|
|
||||||
%inline
|
%inline
|
||||||
%{
|
%{
|
||||||
|
|
||||||
|
|
@ -206,3 +226,18 @@ void DoubleArray(MyArray* v) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%inline
|
||||||
|
%{
|
||||||
|
class C1 {
|
||||||
|
public:
|
||||||
|
RetStruct* M() {
|
||||||
|
RetStruct* r = new RetStruct;
|
||||||
|
r->str = "{\"ID\":1}";
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class C2 : public C1 {
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -1362,6 +1362,10 @@ private:
|
||||||
goargout(info->parms);
|
goargout(info->parms);
|
||||||
|
|
||||||
if (SwigType_type(info->result) != T_VOID) {
|
if (SwigType_type(info->result) != T_VOID) {
|
||||||
|
|
||||||
|
Swig_save("cgoGoWrapper", info->n, "type", "tmap:goout", NULL);
|
||||||
|
Setattr(info->n, "type", info->result);
|
||||||
|
|
||||||
String *goout = goTypemapLookup("goout", info->n, "swig_r");
|
String *goout = goTypemapLookup("goout", info->n, "swig_r");
|
||||||
if (goout == NULL) {
|
if (goout == NULL) {
|
||||||
Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
|
Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
|
||||||
|
|
@ -1374,6 +1378,8 @@ private:
|
||||||
Printv(f_go_wrappers, goout, "\n", NULL);
|
Printv(f_go_wrappers, goout, "\n", NULL);
|
||||||
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
|
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Swig_restore(info->n);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printv(f_go_wrappers, "}\n\n", NULL);
|
Printv(f_go_wrappers, "}\n\n", NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue