[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
|
|
@ -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
|
||||
%{
|
||||
|
||||
|
|
@ -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 {
|
||||
};
|
||||
%}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue