blob: 8909d177cbfc06018272101b46134e41a2ab40fd [file] [log] [blame]
////////////////////////////////////////////////////////////////////////////////
// Do not modify!
// Generated by codergen
////////////////////////////////////////////////////////////////////////////////
package test
import (
"fmt"
"io"
"runtime/debug"
"android.googlesource.com/platform/tools/gpu/binary"
"android.googlesource.com/platform/tools/gpu/config"
"android.googlesource.com/platform/tools/gpu/log"
"android.googlesource.com/platform/tools/gpu/rpc"
)
func BindServer(r io.Reader, w io.Writer, c io.Closer, mtu int, l log.Logger, server RPC) {
rpc.Serve(r, w, c, mtu, l, func(in interface{}) (res binary.Object) {
l := log.Enter(log.Fork(l), fmt.Sprintf("%T", in))
defer func() {
if err := recover(); err == nil {
if config.DebugRPCCalls {
log.Infof(l, "returned: %v", res)
}
} else {
msg := fmt.Sprintf("Panic: %v\n%v", err, string(debug.Stack()))
log.Errorf(l, msg)
res = rpc.NewError(msg)
}
}()
switch call := in.(type) {
case *callAdd:
if res, err := server.Add(call.a, call.b, l); err == nil {
return &resultAdd{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callEnumToString:
if res, err := server.EnumToString(call.e, l); err == nil {
return &resultEnumToString{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callGetListNodeChain:
if res, err := server.GetListNodeChain(l); err == nil {
return &resultGetListNodeChain{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callGetListNodeChainArray:
if res, err := server.GetListNodeChainArray(l); err == nil {
return &resultGetListNodeChainArray{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callGetResource:
if res, err := server.GetResource(l); err == nil {
return &resultGetResource{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callGetSingleListNode:
if res, err := server.GetSingleListNode(l); err == nil {
return &resultGetSingleListNode{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callGetStruct:
if res, err := server.GetStruct(l); err == nil {
return &resultGetStruct{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callResolveResource:
if res, err := server.ResolveResource(call.r, l); err == nil {
return &resultResolveResource{value: res}
} else {
return rpc.NewError(err.Error())
}
case *callSetStruct:
if err := server.SetStruct(call.s, l); err == nil {
return &resultSetStruct{}
} else {
return rpc.NewError(err.Error())
}
case *callUseResource:
if err := server.UseResource(call.r, l); err == nil {
return &resultUseResource{}
} else {
return rpc.NewError(err.Error())
}
default:
return rpc.NewError("Unexpected RPC function: %T", call)
}
})
}