diff --git a/example/golang/remote.go b/example/golang/remote.go index 822f359..3dc744e 100644 --- a/example/golang/remote.go +++ b/example/golang/remote.go @@ -17,7 +17,7 @@ func (self *TsIpcApi) Div( ) ( int, error, ) { - results, err := self.Ipc.Call("TsIpcApi.Div", self.Ipc.Serialize(a), self.Ipc.Serialize(b)) + results, err := self.Ipc.Call("TsIpcApi.Div", a, b) if err != nil { return 0, fmt.Errorf("call to TsIpcApi.Div failed: %w", err) } @@ -30,7 +30,7 @@ func (self *TsIpcApi) XorData( ) ( []byte, error, ) { - results, err := self.Ipc.Call("TsIpcApi.XorData", self.Ipc.Serialize(data1), self.Ipc.Serialize(data2)) + results, err := self.Ipc.Call("TsIpcApi.XorData", data1, data2) if err != nil { return []byte{}, fmt.Errorf("call to TsIpcApi.XorData failed: %w", err) } diff --git a/kitcom/internal/golang/gogen.tmpl b/kitcom/internal/golang/gogen.tmpl index 2ca8834..89299f5 100644 --- a/kitcom/internal/golang/gogen.tmpl +++ b/kitcom/internal/golang/gogen.tmpl @@ -22,7 +22,7 @@ func ({{ $e.Name | receiver }} *{{ $e.Name }}) {{ $mtd.Name }}( ) ( {{ range $mtd.Ret }}{{ .Type | typedef }}, {{ end }}error, ) { - results, err := {{ $e.Name | receiver }}.Ipc.Call("{{ $e.Name }}.{{ $mtd.Name }}"{{ range $mtd.Params }}, self.Ipc.Serialize({{ .Name }}){{ end }}) + results, err := {{ $e.Name | receiver }}.Ipc.Call("{{ $e.Name }}.{{ $mtd.Name }}"{{ range $mtd.Params }}, {{ .Name }}{{ end }}) if err != nil { return {{ range $mtd.Ret }}{{ .Type | zerovalue }}, {{ end }} fmt.Errorf("call to {{ $e.Name }}.{{ $mtd.Name }} failed: %w", err) } diff --git a/lib/golang/lib.go b/lib/golang/lib.go index 8a152fb..55367d7 100644 --- a/lib/golang/lib.go +++ b/lib/golang/lib.go @@ -49,7 +49,6 @@ type Message struct { type IpcCommon interface { Call(method string, params ...any) (Vals, error) ConvType(needType reflect.Type, gotType reflect.Type, arg any) any - Serialize(arg any) any } type pendingCall struct { @@ -236,6 +235,10 @@ func (ipc *ipcCommon) Call(method string, params ...any) (Vals, error) { ipc.pendingCalls[id] = call ipc.mu.Unlock() + for i := range params { + params[i] = ipc.serialize(params[i]) + } + msg := Message{ Type: MsgCall, Id: id, @@ -295,7 +298,7 @@ func (ipc *ipcCommon) ConvType(needType reflect.Type, gotType reflect.Type, arg return arg } -func (ipc *ipcCommon) Serialize(arg any) any { +func (ipc *ipcCommon) serialize(arg any) any { t := reflect.TypeOf(arg) switch t.Kind() { case reflect.Slice: