This commit is contained in:
crusader 2018-04-11 14:53:49 +09:00
parent 9b0d093216
commit 42c364434c

View File

@ -101,7 +101,8 @@ func (rr *rpcRegistry) Invoke(codec protocol.RegistryCodec, leadingParams ...int
var in []reflect.Value var in []reflect.Value
pValues, pInstances := methodSpec.ParamValues() pValues, pInstances := methodSpec.ParamValues()
var lParamLen int
lParamLen := 0
if nil != leadingParams { if nil != leadingParams {
lParamLen = len(leadingParams) lParamLen = len(leadingParams)
} }
@ -111,22 +112,10 @@ func (rr *rpcRegistry) Invoke(codec protocol.RegistryCodec, leadingParams ...int
return nil, errRead return nil, errRead
} }
for indexI := 0; indexI < lParamLen; indexI++ {
i := pInstances[indexI]
rv := reflect.ValueOf(i)
iv := reflect.ValueOf(leadingParams[indexI])
switch reflect.TypeOf(i).Elem().Kind() {
case reflect.Struct:
rv.Elem().Set(iv.Elem())
default:
rv.Elem().Set(iv)
}
}
pCount := len(pInstances) pCount := len(pInstances)
in = make([]reflect.Value, pCount+1) in = make([]reflect.Value, pCount+1)
for indexI := 0; indexI < pCount; indexI++ { for indexI := lParamLen; indexI < pCount; indexI++ {
if pValues[indexI].Type().Kind() == reflect.Ptr && pValues[indexI].Type().Elem().Kind() != reflect.Struct { if pValues[indexI].Type().Kind() == reflect.Ptr && pValues[indexI].Type().Elem().Kind() != reflect.Struct {
in[indexI+1] = reflect.Indirect(pValues[indexI]) in[indexI+1] = reflect.Indirect(pValues[indexI])
} else { } else {
@ -138,6 +127,10 @@ func (rr *rpcRegistry) Invoke(codec protocol.RegistryCodec, leadingParams ...int
} }
in[0] = serviceSpec.ReceiverValue() in[0] = serviceSpec.ReceiverValue()
for indexI := 0; indexI < lParamLen; indexI++ {
in[indexI+1] = reflect.ValueOf(leadingParams[indexI])
}
// Call the service method. // Call the service method.
returnValues := methodSpec.Call(in) returnValues := methodSpec.Call(in)