rpc: simplify suitableCallbacks

This commit is contained in:
Delweng Zheng 2018-11-11 15:53:35 +08:00
parent 1ff152f3a4
commit 1af79d14dd

View file

@ -133,10 +133,12 @@ METHODS:
firstArg = 2 firstArg = 2
} }
if h.isSubscribe { // determine method arguments, ignore first arg since it's the receiver type
h.argTypes = make([]reflect.Type, numIn-firstArg) // skip rcvr type h.argTypes = make([]reflect.Type, numIn-firstArg)
for i := firstArg; i < numIn; i++ { for i := firstArg; i < numIn; i++ {
argType := mtype.In(i) argType := mtype.In(i)
// Arguments must be exported or builtin types
if isExportedOrBuiltinType(argType) { if isExportedOrBuiltinType(argType) {
h.argTypes[i-firstArg] = argType h.argTypes[i-firstArg] = argType
} else { } else {
@ -144,21 +146,11 @@ METHODS:
} }
} }
if h.isSubscribe {
subscriptions[mname] = &h subscriptions[mname] = &h
continue METHODS continue METHODS
} }
// determine method arguments, ignore first arg since it's the receiver type
// Arguments must be exported or builtin types
h.argTypes = make([]reflect.Type, numIn-firstArg)
for i := firstArg; i < numIn; i++ {
argType := mtype.In(i)
if !isExportedOrBuiltinType(argType) {
continue METHODS
}
h.argTypes[i-firstArg] = argType
}
// check that all returned values are exported or builtin types // check that all returned values are exported or builtin types
for i := 0; i < mtype.NumOut(); i++ { for i := 0; i < mtype.NumOut(); i++ {
if !isExportedOrBuiltinType(mtype.Out(i)) { if !isExportedOrBuiltinType(mtype.Out(i)) {