@@ -1003,7 +1003,10 @@ func registerMemberMethod(name string, method reflect.Method) error {
10031003 return nil
10041004 }
10051005
1006- Register (fullName , argsAssert , retAssert , buildMemberMethodInst (method , specType ))
1006+ numIn := method .Type .NumIn ()
1007+ numOut := method .Type .NumOut ()
1008+
1009+ Register (fullName , argsAssert , retAssert , buildMemberMethodInst (method , specType , numIn , numOut ))
10071010
10081011 if _ , ok := member_func_registry [name ]; ! ok {
10091012 member_func_registry [name ] = map [string ]MemberFunction {}
@@ -1014,11 +1017,11 @@ func registerMemberMethod(name string, method reflect.Method) error {
10141017 Ret : retAssert ,
10151018 }
10161019
1017- fields := structFieldOrder (specType )
1018- if len (fields ) > 0 && fields [0 ] == "ptr" {
1019- fields = fields [1 :]
1020- }
1021- registerFuncArgLayout (fullName , fields )
1020+ // fields := structFieldOrder(specType)
1021+ // if len(fields) > 0 && fields[0] == "ptr" {
1022+ // fields = fields[1:]
1023+ // }
1024+ // registerFuncArgLayout(fullName, fields)
10221025
10231026 return nil
10241027}
@@ -1225,33 +1228,25 @@ func buildMemberReturnAssert(method reflect.Method) (Assert, error) {
12251228 }
12261229}
12271230
1228- func buildMemberMethodInst (method reflect.Method , specType reflect.Type ) Inst {
1231+ func buildMemberMethodInst (method reflect.Method , specType reflect.Type , numIn int , numOut int ) Inst {
12291232 return func (arg * ArgNode ) (any , error ) {
12301233 specValue := reflect .New (specType )
12311234 if err := arg .unmarshalValue (specValue .Interface ()); err != nil {
12321235 return nil , err
12331236 }
12341237
12351238 val := specValue .Elem ()
1236- recv := val .Field (0 )
1237- if ! recv .IsValid () || recv .IsZero () {
1238- return nil , fmt .Errorf ("ptr is nil" )
1239- }
12401239
1241- receiver := recv .Interface ()
1242- methodValue := reflect .ValueOf (receiver ).MethodByName (method .Name )
1243- if ! methodValue .IsValid () {
1244- return nil , fmt .Errorf ("method %s not found on receiver" , method .Name )
1240+ args := make ([]reflect.Value , numIn )
1241+ for i := 0 ; i < numIn ; i ++ {
1242+ args [i ] = val .Field (i )
12451243 }
12461244
1247- numIn := method .Type .NumIn ()
1248- args := make ([]reflect.Value , numIn - 1 )
1249- for i := 1 ; i < numIn ; i ++ {
1250- args [i - 1 ] = val .Field (i )
1245+ if ! args [0 ].IsValid () || args [0 ].IsZero () {
1246+ return nil , fmt .Errorf ("ptr is nil" )
12511247 }
12521248
1253- result := methodValue .Call (args )
1254- numOut := method .Type .NumOut ()
1249+ result := method .Func .Call (args )
12551250
12561251 if numOut == 1 {
12571252 if errVal , _ := result [0 ].Interface ().(error ); errVal != nil {
0 commit comments