diff --git a/blueprints/base/services.go b/blueprints/base/services.go index 7b0bd33..283bbcd 100644 --- a/blueprints/base/services.go +++ b/blueprints/base/services.go @@ -27,6 +27,7 @@ var ( IOReadCloser = &cg.GoRef{PkgPath: "io", Name: "ReadCloser"} IOEOF = &cg.GoRef{PkgPath: "io", Name: "EOF"} IOErrUnexpectedEOF = &cg.GoRef{PkgPath: "io", Name: "ErrUnexpectedEOF"} + IOUtilReadAll = &cg.GoRef{PkgPath: "io/ioutil", Name: "ReadAll"} ) const EdelweissServicesPkg = services.PkgPath diff --git a/blueprints/services/dagjson-over-http/client.go b/blueprints/services/dagjson-over-http/client.go index 3b679fe..876ed0a 100644 --- a/blueprints/services/dagjson-over-http/client.go +++ b/blueprints/services/dagjson-over-http/client.go @@ -230,9 +230,6 @@ func (c *{{.Type}}) {{.AsyncMethodDecl}} { // encode request in URL u := *c.endpoint - q := {{.URLValues}}{} - q.Set("q", string(buf)) - u.RawQuery = q.Encode() httpReq, err := {{.HTTPNewRequestWithContext}}(ctx, "POST", u.String(), {{.BytesNewReader}}(buf)) if err != nil { return nil, err diff --git a/blueprints/services/dagjson-over-http/server.go b/blueprints/services/dagjson-over-http/server.go index cf8d777..df1f88e 100644 --- a/blueprints/services/dagjson-over-http/server.go +++ b/blueprints/services/dagjson-over-http/server.go @@ -121,6 +121,7 @@ func (x GoServerImpl) GoDef() cg.Blueprint { "HTTPResponseWriter": base.HTTPResponseWriter, "IPLDDecode": base.IPLDDecode, "DAGJSONDecode": base.DAGJSONDecode, + "IOUtilReadAll": base.IOUtilReadAll, // "Interface": x.Ref.Append("_Server"), "AsyncHandler": x.Ref.Append("_AsyncHandler"), @@ -150,8 +151,13 @@ type {{.Interface}} interface { func {{.AsyncHandler}}(s {{.Interface}}) {{.HTTPHandlerFunc}} { return func(writer {{.HTTPResponseWriter}}, request *{{.HTTPRequest}}) { // parse request - msg := request.URL.Query().Get("q") - n, err := {{.IPLDDecode}}([]byte(msg), {{.DAGJSONDecode}}) + msg, err := {{.IOUtilReadAll}}(request.Body) + if err != nil { + {{.LoggerVar}}.Errorf("reading request body (%v)", err) + writer.WriteHeader(400) + return + } + n, err := {{.IPLDDecode}}(msg, {{.DAGJSONDecode}}) if err != nil { {{.LoggerVar}}.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) diff --git a/examples/gen-routing-api/proto/proto_edelweiss.go b/examples/gen-routing-api/proto/proto_edelweiss.go index 60d1959..d87222f 100644 --- a/examples/gen-routing-api/proto/proto_edelweiss.go +++ b/examples/gen-routing-api/proto/proto_edelweiss.go @@ -1,20 +1,23 @@ +// Code generated by edelweiss. DO NOT EDIT. + package proto import ( - pd11 "bytes" - pd10 "context" - pd12 "errors" + pd12 "bytes" + pd8 "context" + pd11 "errors" pd2 "fmt" - pd5 "io" - pd9 "net/http" - pd7 "net/url" - pd13 "sync" - - pd4 "github.com/ipfs/go-log" - pd14 "github.com/ipld/edelweiss/services" + pd9 "io" + pd15 "io/ioutil" + pd4 "net/http" + pd10 "net/url" + pd5 "sync" + + pd14 "github.com/ipfs/go-log" + pd7 "github.com/ipld/edelweiss/services" pd3 "github.com/ipld/edelweiss/values" pd6 "github.com/ipld/go-ipld-prime" - pd8 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd13 "github.com/ipld/go-ipld-prime/codec/dagjson" pd1 "github.com/ipld/go-ipld-prime/datamodel" ) @@ -953,16 +956,16 @@ func (x AnonInductive5) Prototype() pd1.NodePrototype { return nil } -var logger_client_DelegatedRouting = pd4.Logger("service/client/delegatedrouting") +var logger_client_DelegatedRouting = pd14.Logger("service/client/delegatedrouting") type DelegatedRouting_Client interface { - Identify(ctx pd10.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) + Identify(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) - GetP2PProvide(ctx pd10.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) + GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) - Identify_Async(ctx pd10.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) + Identify_Async(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) - GetP2PProvide_Async(ctx pd10.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) + GetP2PProvide_Async(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) } type DelegatedRouting_Identify_AsyncResult struct { @@ -978,13 +981,13 @@ type DelegatedRouting_GetP2PProvide_AsyncResult struct { type DelegatedRouting_ClientOption func(*client_DelegatedRouting) error type client_DelegatedRouting struct { - httpClient *pd9.Client - endpoint *pd7.URL - ulk pd13.Mutex + httpClient *pd4.Client + endpoint *pd10.URL + ulk pd5.Mutex unsupported map[string]bool // cache of methods not supported by server } -func DelegatedRouting_Client_WithHTTPClient(hc *pd9.Client) DelegatedRouting_ClientOption { +func DelegatedRouting_Client_WithHTTPClient(hc *pd4.Client) DelegatedRouting_ClientOption { return func(c *client_DelegatedRouting) error { c.httpClient = hc return nil @@ -992,11 +995,11 @@ func DelegatedRouting_Client_WithHTTPClient(hc *pd9.Client) DelegatedRouting_Cli } func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_ClientOption) (*client_DelegatedRouting, error) { - u, err := pd7.Parse(endpoint) + u, err := pd10.Parse(endpoint) if err != nil { return nil, err } - c := &client_DelegatedRouting{endpoint: u, httpClient: pd9.DefaultClient, unsupported: make(map[string]bool)} + c := &client_DelegatedRouting{endpoint: u, httpClient: pd4.DefaultClient, unsupported: make(map[string]bool)} for _, o := range opts { if err := o(c); err != nil { return nil, err @@ -1005,8 +1008,8 @@ func New_DelegatedRouting_Client(endpoint string, opts ...DelegatedRouting_Clien return c, nil } -func (c *client_DelegatedRouting) Identify(ctx pd10.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { - ctx, cancel := pd10.WithCancel(ctx) +func (c *client_DelegatedRouting) Identify(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) ([]*DelegatedRouting_IdentifyResult, error) { + ctx, cancel := pd8.WithCancel(ctx) defer cancel() ch, err := c.Identify_Async(ctx, req) if err != nil { @@ -1034,30 +1037,27 @@ func (c *client_DelegatedRouting) Identify(ctx pd10.Context, req *DelegatedRouti } } -func (c *client_DelegatedRouting) Identify_Async(ctx pd10.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) { +func (c *client_DelegatedRouting) Identify_Async(ctx pd8.Context, req *DelegatedRouting_IdentifyArg) (<-chan DelegatedRouting_Identify_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["Identify"] c.ulk.Unlock() if notSupported { - return nil, pd14.ErrSchema + return nil, pd7.ErrSchema } envelope := &AnonInductive4{ Identify: req, } - buf, err := pd6.Encode(envelope, pd8.Encode) + buf, err := pd6.Encode(envelope, pd13.Encode) if err != nil { return nil, pd2.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - q := pd7.Values{} - q.Set("q", string(buf)) - u.RawQuery = q.Encode() - httpReq, err := pd9.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) + httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd12.NewReader(buf)) if err != nil { return nil, err } @@ -1079,7 +1079,7 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd10.Context, req *Delegate c.ulk.Lock() c.unsupported["Identify"] = true c.ulk.Unlock() - return nil, pd14.ErrSchema + return nil, pd7.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1087,7 +1087,7 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd10.Context, req *Delegate resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd14.ErrService{Cause: pd2.Errorf("%s", errValues[0])} + err = pd7.ErrService{Cause: pd2.Errorf("%s", errValues[0])} } else { err = pd2.Errorf("service rejected the call, no cause provided") } @@ -1102,41 +1102,42 @@ func (c *client_DelegatedRouting) Identify_Async(ctx pd10.Context, req *Delegate return ch, nil } -func process_DelegatedRouting_Identify_AsyncResult(ctx pd10.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd5.Reader) { +func process_DelegatedRouting_Identify_AsyncResult(ctx pd8.Context, ch chan<- DelegatedRouting_Identify_AsyncResult, r pd9.ReadCloser) { defer close(ch) + defer r.Close() for { - if ctx.Err() != nil { - ch <- DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrContext{Cause: ctx.Err()}} // context cancelled - return - } + var out DelegatedRouting_Identify_AsyncResult - n, err := pd6.DecodeStreaming(r, pd8.Decode) - if pd12.Is(err, pd5.EOF) || pd12.Is(err, pd5.ErrUnexpectedEOF) { + n, err := pd6.DecodeStreaming(r, pd13.Decode) + if pd11.Is(err, pd9.EOF) || pd11.Is(err, pd9.ErrUnexpectedEOF) { return } + if err != nil { - ch <- DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error - return - } - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - ch <- DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error - return + out = DelegatedRouting_Identify_AsyncResult{Err: pd7.ErrProto{Cause: err}} // IPLD decode error + } else { + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = DelegatedRouting_Identify_AsyncResult{Err: pd7.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_Identify_AsyncResult{Err: pd7.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error + } else if env.Identify != nil { + out = DelegatedRouting_Identify_AsyncResult{Resp: env.Identify} + } else { + continue + } } - if env.Error != nil { - ch <- DelegatedRouting_Identify_AsyncResult{Err: pd14.ErrService{Cause: pd12.New(string(env.Error.Code))}} // service-level error + select { + case <-ctx.Done(): return + case ch <- out: } - if env.Identify == nil { - continue - } - ch <- DelegatedRouting_Identify_AsyncResult{Resp: env.Identify} } } -func (c *client_DelegatedRouting) GetP2PProvide(ctx pd10.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { - ctx, cancel := pd10.WithCancel(ctx) +func (c *client_DelegatedRouting) GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) ([]*GetP2PProvideResponse, error) { + ctx, cancel := pd8.WithCancel(ctx) defer cancel() ch, err := c.GetP2PProvide_Async(ctx, req) if err != nil { @@ -1164,30 +1165,27 @@ func (c *client_DelegatedRouting) GetP2PProvide(ctx pd10.Context, req *GetP2PPro } } -func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd10.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) { +func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan DelegatedRouting_GetP2PProvide_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["GetP2PProvide"] c.ulk.Unlock() if notSupported { - return nil, pd14.ErrSchema + return nil, pd7.ErrSchema } envelope := &AnonInductive4{ GetP2PProvide: req, } - buf, err := pd6.Encode(envelope, pd8.Encode) + buf, err := pd6.Encode(envelope, pd13.Encode) if err != nil { return nil, pd2.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - q := pd7.Values{} - q.Set("q", string(buf)) - u.RawQuery = q.Encode() - httpReq, err := pd9.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) + httpReq, err := pd4.NewRequestWithContext(ctx, "POST", u.String(), pd12.NewReader(buf)) if err != nil { return nil, err } @@ -1209,7 +1207,7 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd10.Context, req *Get c.ulk.Lock() c.unsupported["GetP2PProvide"] = true c.ulk.Unlock() - return nil, pd14.ErrSchema + return nil, pd7.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1217,7 +1215,7 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd10.Context, req *Get resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd14.ErrService{Cause: pd2.Errorf("%s", errValues[0])} + err = pd7.ErrService{Cause: pd2.Errorf("%s", errValues[0])} } else { err = pd2.Errorf("service rejected the call, no cause provided") } @@ -1232,50 +1230,56 @@ func (c *client_DelegatedRouting) GetP2PProvide_Async(ctx pd10.Context, req *Get return ch, nil } -func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd10.Context, ch chan<- DelegatedRouting_GetP2PProvide_AsyncResult, r pd5.Reader) { +func process_DelegatedRouting_GetP2PProvide_AsyncResult(ctx pd8.Context, ch chan<- DelegatedRouting_GetP2PProvide_AsyncResult, r pd9.ReadCloser) { defer close(ch) + defer r.Close() for { - if ctx.Err() != nil { - ch <- DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd14.ErrContext{Cause: ctx.Err()}} // context cancelled - return - } + var out DelegatedRouting_GetP2PProvide_AsyncResult - n, err := pd6.DecodeStreaming(r, pd8.Decode) - if pd12.Is(err, pd5.EOF) || pd12.Is(err, pd5.ErrUnexpectedEOF) { + n, err := pd6.DecodeStreaming(r, pd13.Decode) + if pd11.Is(err, pd9.EOF) || pd11.Is(err, pd9.ErrUnexpectedEOF) { return } + if err != nil { - ch <- DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error - return - } - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - ch <- DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error - return + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd7.ErrProto{Cause: err}} // IPLD decode error + } else { + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd7.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd7.ErrService{Cause: pd11.New(string(env.Error.Code))}} // service-level error + } else if env.GetP2PProvide != nil { + out = DelegatedRouting_GetP2PProvide_AsyncResult{Resp: env.GetP2PProvide} + } else { + continue + } } - if env.Error != nil { - ch <- DelegatedRouting_GetP2PProvide_AsyncResult{Err: pd14.ErrService{Cause: pd12.New(string(env.Error.Code))}} // service-level error + select { + case <-ctx.Done(): return + case ch <- out: } - if env.GetP2PProvide == nil { - continue - } - ch <- DelegatedRouting_GetP2PProvide_AsyncResult{Resp: env.GetP2PProvide} } } -var logger_server_DelegatedRouting = pd4.Logger("service/server/delegatedrouting") +var logger_server_DelegatedRouting = pd14.Logger("service/server/delegatedrouting") type DelegatedRouting_Server interface { - GetP2PProvide(ctx pd10.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) + GetP2PProvide(ctx pd8.Context, req *GetP2PProvideRequest) (<-chan *DelegatedRouting_GetP2PProvide_AsyncResult, error) } -func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd9.HandlerFunc { - return func(writer pd9.ResponseWriter, request *pd9.Request) { +func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd4.HandlerFunc { + return func(writer pd4.ResponseWriter, request *pd4.Request) { // parse request - msg := request.URL.Query().Get("q") - n, err := pd6.Decode([]byte(msg), pd8.Decode) + msg, err := pd15.ReadAll(request.Body) + if err != nil { + logger_server_DelegatedRouting.Errorf("reading request body (%v)", err) + writer.WriteHeader(400) + return + } + n, err := pd6.Decode(msg, pd13.Decode) if err != nil { logger_server_DelegatedRouting.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) @@ -1296,7 +1300,7 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd9.HandlerFunc { switch { case env.GetP2PProvide != nil: - ch, err := s.GetP2PProvide(pd10.Background(), env.GetP2PProvide) + ch, err := s.GetP2PProvide(pd8.Background(), env.GetP2PProvide) if err != nil { logger_server_DelegatedRouting.Errorf("service rejected request (%v)", err) writer.Header()["Error"] = []string{err.Error()} @@ -1310,8 +1314,8 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd9.HandlerFunc { } else { env = &AnonInductive5{GetP2PProvide: resp.Resp} } - var buf pd11.Buffer - if err = pd6.EncodeStreaming(&buf, env, pd8.Encode); err != nil { + var buf pd12.Buffer + if err = pd6.EncodeStreaming(&buf, env, pd13.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode response (%v)", err) continue } @@ -1328,8 +1332,8 @@ func DelegatedRouting_AsyncHandler(s DelegatedRouting_Server) pd9.HandlerFunc { }, }, } - var buf pd11.Buffer - if err = pd6.EncodeStreaming(&buf, env, pd8.Encode); err != nil { + var buf pd12.Buffer + if err = pd6.EncodeStreaming(&buf, env, pd13.Encode); err != nil { logger_server_DelegatedRouting.Errorf("cannot encode identify response (%v)", err) writer.WriteHeader(500) return diff --git a/examples/greeting-service/api/.gitignore b/examples/greeting-service/api/.gitignore new file mode 100644 index 0000000..eedd89b --- /dev/null +++ b/examples/greeting-service/api/.gitignore @@ -0,0 +1 @@ +api diff --git a/examples/greeting-service/api/api b/examples/greeting-service/api/api deleted file mode 100755 index 5d08c70..0000000 Binary files a/examples/greeting-service/api/api and /dev/null differ diff --git a/examples/greeting-service/api/proto/proto_edelweiss.go b/examples/greeting-service/api/proto/proto_edelweiss.go index e862996..7d508be 100644 --- a/examples/greeting-service/api/proto/proto_edelweiss.go +++ b/examples/greeting-service/api/proto/proto_edelweiss.go @@ -1,21 +1,24 @@ +// Code generated by edelweiss. DO NOT EDIT. + package proto import ( - pd10 "bytes" - pd8 "context" - pd7 "errors" + pd11 "bytes" + pd6 "context" + pd9 "errors" pd3 "fmt" - pd4 "io" - pd6 "net/http" - pd11 "net/url" + pd8 "io" + pd15 "io/ioutil" + pd5 "net/http" + pd10 "net/url" pd12 "sync" - pd14 "github.com/ipfs/go-log" - pd13 "github.com/ipld/edelweiss/services" - pd2 "github.com/ipld/edelweiss/values" - pd5 "github.com/ipld/go-ipld-prime" - pd9 "github.com/ipld/go-ipld-prime/codec/dagjson" - pd1 "github.com/ipld/go-ipld-prime/datamodel" + pd13 "github.com/ipfs/go-log" + pd14 "github.com/ipld/edelweiss/services" + pd1 "github.com/ipld/edelweiss/values" + pd4 "github.com/ipld/go-ipld-prime" + pd7 "github.com/ipld/go-ipld-prime/codec/dagjson" + pd2 "github.com/ipld/go-ipld-prime/datamodel" ) // -- protocol type GreetingService_IdentifyArg -- @@ -23,16 +26,16 @@ import ( type GreetingService_IdentifyArg struct { } -func (x GreetingService_IdentifyArg) Node() pd1.Node { +func (x GreetingService_IdentifyArg) Node() pd2.Node { return x } -func (x *GreetingService_IdentifyArg) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *GreetingService_IdentifyArg) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{} + fieldMap := map[string]pd1.ParseFunc{} for !iter.Done() { if kn, vn, err := iter.Next(); err != nil { return err @@ -48,7 +51,7 @@ func (x *GreetingService_IdentifyArg) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -60,66 +63,66 @@ type GreetingService_IdentifyArg_MapIterator struct { s *GreetingService_IdentifyArg } -func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GreetingService_IdentifyArg_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *GreetingService_IdentifyArg_MapIterator) Done() bool { return x.i+1 >= 0 } -func (x GreetingService_IdentifyArg) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GreetingService_IdentifyArg) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x GreetingService_IdentifyArg) LookupByString(key string) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupByString(key string) (pd2.Node, error) { switch key { } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GreetingService_IdentifyArg) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) MapIterator() pd1.MapIterator { +func (x GreetingService_IdentifyArg) MapIterator() pd2.MapIterator { return &GreetingService_IdentifyArg_MapIterator{-1, &x} } -func (x GreetingService_IdentifyArg) ListIterator() pd1.ListIterator { +func (x GreetingService_IdentifyArg) ListIterator() pd2.ListIterator { return nil } @@ -136,54 +139,54 @@ func (x GreetingService_IdentifyArg) IsNull() bool { } func (x GreetingService_IdentifyArg) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x GreetingService_IdentifyArg) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyArg) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyArg) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x GreetingService_IdentifyArg) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x GreetingService_IdentifyArg) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyArg) Prototype() pd1.NodePrototype { +func (x GreetingService_IdentifyArg) Prototype() pd2.NodePrototype { return nil } // -- protocol type AnonList1 -- -type AnonList1 []pd2.String +type AnonList1 []pd1.String -func (v AnonList1) Node() pd1.Node { +func (v AnonList1) Node() pd2.Node { return v } -func (v *AnonList1) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AnonList1) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd2.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AnonList1, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd2.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -192,39 +195,39 @@ func (v *AnonList1) Parse(n pd1.Node) error { } } -func (AnonList1) Kind() pd1.Kind { - return pd1.Kind_List +func (AnonList1) Kind() pd2.Kind { + return pd2.Kind_List } -func (AnonList1) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AnonList1) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AnonList1) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AnonList1) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AnonList1) LookupByIndex(i int64) (pd1.Node, error) { +func (v AnonList1) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd2.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AnonList1) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AnonList1) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AnonList1) MapIterator() pd1.MapIterator { +func (AnonList1) MapIterator() pd2.MapIterator { return nil } -func (v AnonList1) ListIterator() pd1.ListIterator { +func (v AnonList1) ListIterator() pd2.ListIterator { return &AnonList1_ListIterator{v, 0} } @@ -241,30 +244,30 @@ func (AnonList1) IsNull() bool { } func (v AnonList1) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (AnonList1) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AnonList1) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AnonList1) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (AnonList1) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (AnonList1) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (AnonList1) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AnonList1) Prototype() pd1.NodePrototype { +func (AnonList1) Prototype() pd2.NodePrototype { return nil // not needed } @@ -273,9 +276,9 @@ type AnonList1_ListIterator struct { at int64 } -func (iter *AnonList1_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AnonList1_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd2.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -293,16 +296,16 @@ type GreetingService_IdentifyResult struct { Methods AnonList1 } -func (x GreetingService_IdentifyResult) Node() pd1.Node { +func (x GreetingService_IdentifyResult) Node() pd2.Node { return x } -func (x *GreetingService_IdentifyResult) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *GreetingService_IdentifyResult) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Methods": x.Methods.Parse, } for !iter.Done() { @@ -328,7 +331,7 @@ func (x *GreetingService_IdentifyResult) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -340,74 +343,74 @@ type GreetingService_IdentifyResult_MapIterator struct { s *GreetingService_IdentifyResult } -func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GreetingService_IdentifyResult_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd2.String("Methods"), x.s.Methods.Node(), nil + return pd1.String("Methods"), x.s.Methods.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *GreetingService_IdentifyResult_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x GreetingService_IdentifyResult) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GreetingService_IdentifyResult) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x GreetingService_IdentifyResult) LookupByString(key string) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupByString(key string) (pd2.Node, error) { switch key { case "Methods": return x.Methods.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Methods.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GreetingService_IdentifyResult) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Methods": return x.Methods.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) MapIterator() pd1.MapIterator { +func (x GreetingService_IdentifyResult) MapIterator() pd2.MapIterator { return &GreetingService_IdentifyResult_MapIterator{-1, &x} } -func (x GreetingService_IdentifyResult) ListIterator() pd1.ListIterator { +func (x GreetingService_IdentifyResult) ListIterator() pd2.ListIterator { return nil } @@ -424,49 +427,49 @@ func (x GreetingService_IdentifyResult) IsNull() bool { } func (x GreetingService_IdentifyResult) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x GreetingService_IdentifyResult) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyResult) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_IdentifyResult) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x GreetingService_IdentifyResult) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x GreetingService_IdentifyResult) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x GreetingService_IdentifyResult) Prototype() pd1.NodePrototype { +func (x GreetingService_IdentifyResult) Prototype() pd2.NodePrototype { return nil } // -- protocol type GreetingService_Error -- type GreetingService_Error struct { - Code pd2.String + Code pd1.String } -func (x GreetingService_Error) Node() pd1.Node { +func (x GreetingService_Error) Node() pd2.Node { return x } -func (x *GreetingService_Error) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *GreetingService_Error) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Code": x.Code.Parse, } for !iter.Done() { @@ -492,7 +495,7 @@ func (x *GreetingService_Error) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -504,74 +507,74 @@ type GreetingService_Error_MapIterator struct { s *GreetingService_Error } -func (x *GreetingService_Error_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *GreetingService_Error_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd2.String("Code"), x.s.Code.Node(), nil + return pd1.String("Code"), x.s.Code.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *GreetingService_Error_MapIterator) Done() bool { return x.i+1 >= 1 } -func (x GreetingService_Error) Kind() pd1.Kind { - return pd1.Kind_Map +func (x GreetingService_Error) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x GreetingService_Error) LookupByString(key string) (pd1.Node, error) { +func (x GreetingService_Error) LookupByString(key string) (pd2.Node, error) { switch key { case "Code": return x.Code.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x GreetingService_Error) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) LookupByIndex(idx int64) (pd1.Node, error) { +func (x GreetingService_Error) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Code.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x GreetingService_Error) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Code": return x.Code.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) MapIterator() pd1.MapIterator { +func (x GreetingService_Error) MapIterator() pd2.MapIterator { return &GreetingService_Error_MapIterator{-1, &x} } -func (x GreetingService_Error) ListIterator() pd1.ListIterator { +func (x GreetingService_Error) ListIterator() pd2.ListIterator { return nil } @@ -588,30 +591,30 @@ func (x GreetingService_Error) IsNull() bool { } func (x GreetingService_Error) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x GreetingService_Error) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_Error) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x GreetingService_Error) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x GreetingService_Error) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x GreetingService_Error) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x GreetingService_Error) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x GreetingService_Error) Prototype() pd1.NodePrototype { +func (x GreetingService_Error) Prototype() pd2.NodePrototype { return nil } @@ -622,10 +625,10 @@ type AnonInductive4 struct { Hello *HelloRequest } -func (x *AnonInductive4) Parse(n pd1.Node) error { +func (x *AnonInductive4) Parse(n pd2.Node) error { *x = AnonInductive4{} - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -663,16 +666,16 @@ type AnonInductive4_MapIterator struct { s *AnonInductive4 } -func (x *AnonInductive4_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *AnonInductive4_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { if x.done { - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { case x.s.Identify != nil: - return pd2.String("IdentifyRequest"), x.s.Identify.Node(), nil + return pd1.String("IdentifyRequest"), x.s.Identify.Node(), nil case x.s.Hello != nil: - return pd2.String("HelloRequest"), x.s.Hello.Node(), nil + return pd1.String("HelloRequest"), x.s.Hello.Node(), nil default: return nil, nil, pd3.Errorf("no inductive cases are set") @@ -684,15 +687,15 @@ func (x *AnonInductive4_MapIterator) Done() bool { return x.done } -func (x AnonInductive4) Node() pd1.Node { +func (x AnonInductive4) Node() pd2.Node { return x } -func (x AnonInductive4) Kind() pd1.Kind { - return pd1.Kind_Map +func (x AnonInductive4) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x AnonInductive4) LookupByString(key string) (pd1.Node, error) { +func (x AnonInductive4) LookupByString(key string) (pd2.Node, error) { switch { case x.Identify != nil && key == "IdentifyRequest": return x.Identify.Node(), nil @@ -700,12 +703,12 @@ func (x AnonInductive4) LookupByString(key string) (pd1.Node, error) { return x.Hello.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd2.ErrNA +func (x AnonInductive4) LookupByNode(key pd2.Node) (pd2.Node, error) { + if key.Kind() != pd2.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -714,11 +717,11 @@ func (x AnonInductive4) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x AnonInductive4) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (x AnonInductive4) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (x AnonInductive4) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x AnonInductive4) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "IdentifyRequest": return x.Identify.Node(), nil @@ -726,14 +729,14 @@ func (x AnonInductive4) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.Hello.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) MapIterator() pd1.MapIterator { +func (x AnonInductive4) MapIterator() pd2.MapIterator { return &AnonInductive4_MapIterator{false, &x} } -func (x AnonInductive4) ListIterator() pd1.ListIterator { +func (x AnonInductive4) ListIterator() pd2.ListIterator { return nil } @@ -750,30 +753,30 @@ func (x AnonInductive4) IsNull() bool { } func (x AnonInductive4) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x AnonInductive4) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive4) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive4) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x AnonInductive4) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive4) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x AnonInductive4) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x AnonInductive4) Prototype() pd1.NodePrototype { +func (x AnonInductive4) Prototype() pd2.NodePrototype { return nil } @@ -785,10 +788,10 @@ type AnonInductive5 struct { Error *GreetingService_Error } -func (x *AnonInductive5) Parse(n pd1.Node) error { +func (x *AnonInductive5) Parse(n pd2.Node) error { *x = AnonInductive5{} - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -833,18 +836,18 @@ type AnonInductive5_MapIterator struct { s *AnonInductive5 } -func (x *AnonInductive5_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *AnonInductive5_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { if x.done { - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { case x.s.Identify != nil: - return pd2.String("IdentifyResponse"), x.s.Identify.Node(), nil + return pd1.String("IdentifyResponse"), x.s.Identify.Node(), nil case x.s.Hello != nil: - return pd2.String("HelloResponse"), x.s.Hello.Node(), nil + return pd1.String("HelloResponse"), x.s.Hello.Node(), nil case x.s.Error != nil: - return pd2.String("Error"), x.s.Error.Node(), nil + return pd1.String("Error"), x.s.Error.Node(), nil default: return nil, nil, pd3.Errorf("no inductive cases are set") @@ -856,15 +859,15 @@ func (x *AnonInductive5_MapIterator) Done() bool { return x.done } -func (x AnonInductive5) Node() pd1.Node { +func (x AnonInductive5) Node() pd2.Node { return x } -func (x AnonInductive5) Kind() pd1.Kind { - return pd1.Kind_Map +func (x AnonInductive5) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x AnonInductive5) LookupByString(key string) (pd1.Node, error) { +func (x AnonInductive5) LookupByString(key string) (pd2.Node, error) { switch { case x.Identify != nil && key == "IdentifyResponse": return x.Identify.Node(), nil @@ -874,12 +877,12 @@ func (x AnonInductive5) LookupByString(key string) (pd1.Node, error) { return x.Error.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd2.ErrNA +func (x AnonInductive5) LookupByNode(key pd2.Node) (pd2.Node, error) { + if key.Kind() != pd2.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -888,11 +891,11 @@ func (x AnonInductive5) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x AnonInductive5) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (x AnonInductive5) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (x AnonInductive5) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x AnonInductive5) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "IdentifyResponse": return x.Identify.Node(), nil @@ -902,14 +905,14 @@ func (x AnonInductive5) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.Error.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) MapIterator() pd1.MapIterator { +func (x AnonInductive5) MapIterator() pd2.MapIterator { return &AnonInductive5_MapIterator{false, &x} } -func (x AnonInductive5) ListIterator() pd1.ListIterator { +func (x AnonInductive5) ListIterator() pd2.ListIterator { return nil } @@ -926,43 +929,43 @@ func (x AnonInductive5) IsNull() bool { } func (x AnonInductive5) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x AnonInductive5) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive5) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x AnonInductive5) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x AnonInductive5) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x AnonInductive5) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x AnonInductive5) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x AnonInductive5) Prototype() pd1.NodePrototype { +func (x AnonInductive5) Prototype() pd2.NodePrototype { return nil } -var logger_client_GreetingService = pd14.Logger("service/client/greetingservice") +var logger_client_GreetingService = pd13.Logger("service/client/greetingservice") type GreetingService_Client interface { - Identify(ctx pd8.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) + Identify(ctx pd6.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) - Hello(ctx pd8.Context, req *HelloRequest) ([]*HelloResponse, error) + Hello(ctx pd6.Context, req *HelloRequest) ([]*HelloResponse, error) - Identify_Async(ctx pd8.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) + Identify_Async(ctx pd6.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) - Hello_Async(ctx pd8.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) + Hello_Async(ctx pd6.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) } type GreetingService_Identify_AsyncResult struct { @@ -978,13 +981,13 @@ type GreetingService_Hello_AsyncResult struct { type GreetingService_ClientOption func(*client_GreetingService) error type client_GreetingService struct { - httpClient *pd6.Client - endpoint *pd11.URL + httpClient *pd5.Client + endpoint *pd10.URL ulk pd12.Mutex unsupported map[string]bool // cache of methods not supported by server } -func GreetingService_Client_WithHTTPClient(hc *pd6.Client) GreetingService_ClientOption { +func GreetingService_Client_WithHTTPClient(hc *pd5.Client) GreetingService_ClientOption { return func(c *client_GreetingService) error { c.httpClient = hc return nil @@ -992,11 +995,11 @@ func GreetingService_Client_WithHTTPClient(hc *pd6.Client) GreetingService_Clien } func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientOption) (*client_GreetingService, error) { - u, err := pd11.Parse(endpoint) + u, err := pd10.Parse(endpoint) if err != nil { return nil, err } - c := &client_GreetingService{endpoint: u, httpClient: pd6.DefaultClient, unsupported: make(map[string]bool)} + c := &client_GreetingService{endpoint: u, httpClient: pd5.DefaultClient, unsupported: make(map[string]bool)} for _, o := range opts { if err := o(c); err != nil { return nil, err @@ -1005,8 +1008,8 @@ func New_GreetingService_Client(endpoint string, opts ...GreetingService_ClientO return c, nil } -func (c *client_GreetingService) Identify(ctx pd8.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { - ctx, cancel := pd8.WithCancel(ctx) +func (c *client_GreetingService) Identify(ctx pd6.Context, req *GreetingService_IdentifyArg) ([]*GreetingService_IdentifyResult, error) { + ctx, cancel := pd6.WithCancel(ctx) defer cancel() ch, err := c.Identify_Async(ctx, req) if err != nil { @@ -1034,30 +1037,27 @@ func (c *client_GreetingService) Identify(ctx pd8.Context, req *GreetingService_ } } -func (c *client_GreetingService) Identify_Async(ctx pd8.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) { +func (c *client_GreetingService) Identify_Async(ctx pd6.Context, req *GreetingService_IdentifyArg) (<-chan GreetingService_Identify_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["Identify"] c.ulk.Unlock() if notSupported { - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } envelope := &AnonInductive4{ Identify: req, } - buf, err := pd5.Encode(envelope, pd9.Encode) + buf, err := pd4.Encode(envelope, pd7.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - q := pd11.Values{} - q.Set("q", string(buf)) - u.RawQuery = q.Encode() - httpReq, err := pd6.NewRequestWithContext(ctx, "POST", u.String(), pd10.NewReader(buf)) + httpReq, err := pd5.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) if err != nil { return nil, err } @@ -1079,7 +1079,7 @@ func (c *client_GreetingService) Identify_Async(ctx pd8.Context, req *GreetingSe c.ulk.Lock() c.unsupported["Identify"] = true c.ulk.Unlock() - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1087,7 +1087,7 @@ func (c *client_GreetingService) Identify_Async(ctx pd8.Context, req *GreetingSe resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1102,41 +1102,42 @@ func (c *client_GreetingService) Identify_Async(ctx pd8.Context, req *GreetingSe return ch, nil } -func process_GreetingService_Identify_AsyncResult(ctx pd8.Context, ch chan<- GreetingService_Identify_AsyncResult, r pd4.Reader) { +func process_GreetingService_Identify_AsyncResult(ctx pd6.Context, ch chan<- GreetingService_Identify_AsyncResult, r pd8.ReadCloser) { defer close(ch) + defer r.Close() for { - if ctx.Err() != nil { - ch <- GreetingService_Identify_AsyncResult{Err: pd13.ErrContext{Cause: ctx.Err()}} // context cancelled - return - } + var out GreetingService_Identify_AsyncResult - n, err := pd5.DecodeStreaming(r, pd9.Decode) - if pd7.Is(err, pd4.EOF) || pd7.Is(err, pd4.ErrUnexpectedEOF) { + n, err := pd4.DecodeStreaming(r, pd7.Decode) + if pd9.Is(err, pd8.EOF) || pd9.Is(err, pd8.ErrUnexpectedEOF) { return } + if err != nil { - ch <- GreetingService_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error - return - } - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - ch <- GreetingService_Identify_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error - return + out = GreetingService_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error + } else { + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = GreetingService_Identify_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = GreetingService_Identify_AsyncResult{Err: pd14.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error + } else if env.Identify != nil { + out = GreetingService_Identify_AsyncResult{Resp: env.Identify} + } else { + continue + } } - if env.Error != nil { - ch <- GreetingService_Identify_AsyncResult{Err: pd13.ErrService{Cause: pd7.New(string(env.Error.Code))}} // service-level error + select { + case <-ctx.Done(): return + case ch <- out: } - if env.Identify == nil { - continue - } - ch <- GreetingService_Identify_AsyncResult{Resp: env.Identify} } } -func (c *client_GreetingService) Hello(ctx pd8.Context, req *HelloRequest) ([]*HelloResponse, error) { - ctx, cancel := pd8.WithCancel(ctx) +func (c *client_GreetingService) Hello(ctx pd6.Context, req *HelloRequest) ([]*HelloResponse, error) { + ctx, cancel := pd6.WithCancel(ctx) defer cancel() ch, err := c.Hello_Async(ctx, req) if err != nil { @@ -1164,30 +1165,27 @@ func (c *client_GreetingService) Hello(ctx pd8.Context, req *HelloRequest) ([]*H } } -func (c *client_GreetingService) Hello_Async(ctx pd8.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) { +func (c *client_GreetingService) Hello_Async(ctx pd6.Context, req *HelloRequest) (<-chan GreetingService_Hello_AsyncResult, error) { // check if we have memoized that this method is not supported by the server c.ulk.Lock() notSupported := c.unsupported["Hello"] c.ulk.Unlock() if notSupported { - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } envelope := &AnonInductive4{ Hello: req, } - buf, err := pd5.Encode(envelope, pd9.Encode) + buf, err := pd4.Encode(envelope, pd7.Encode) if err != nil { return nil, pd3.Errorf("unexpected serialization error (%v)", err) } // encode request in URL u := *c.endpoint - q := pd11.Values{} - q.Set("q", string(buf)) - u.RawQuery = q.Encode() - httpReq, err := pd6.NewRequestWithContext(ctx, "POST", u.String(), pd10.NewReader(buf)) + httpReq, err := pd5.NewRequestWithContext(ctx, "POST", u.String(), pd11.NewReader(buf)) if err != nil { return nil, err } @@ -1209,7 +1207,7 @@ func (c *client_GreetingService) Hello_Async(ctx pd8.Context, req *HelloRequest) c.ulk.Lock() c.unsupported["Hello"] = true c.ulk.Unlock() - return nil, pd13.ErrSchema + return nil, pd14.ErrSchema } // HTTP codes other than 200 correspond to service implementation rejecting the call when it is received // for reasons unrelated to protocol schema @@ -1217,7 +1215,7 @@ func (c *client_GreetingService) Hello_Async(ctx pd8.Context, req *HelloRequest) resp.Body.Close() if resp.Header != nil { if errValues, ok := resp.Header["Error"]; ok && len(errValues) == 1 { - err = pd13.ErrService{Cause: pd3.Errorf("%s", errValues[0])} + err = pd14.ErrService{Cause: pd3.Errorf("%s", errValues[0])} } else { err = pd3.Errorf("service rejected the call, no cause provided") } @@ -1232,50 +1230,56 @@ func (c *client_GreetingService) Hello_Async(ctx pd8.Context, req *HelloRequest) return ch, nil } -func process_GreetingService_Hello_AsyncResult(ctx pd8.Context, ch chan<- GreetingService_Hello_AsyncResult, r pd4.Reader) { +func process_GreetingService_Hello_AsyncResult(ctx pd6.Context, ch chan<- GreetingService_Hello_AsyncResult, r pd8.ReadCloser) { defer close(ch) + defer r.Close() for { - if ctx.Err() != nil { - ch <- GreetingService_Hello_AsyncResult{Err: pd13.ErrContext{Cause: ctx.Err()}} // context cancelled - return - } + var out GreetingService_Hello_AsyncResult - n, err := pd5.DecodeStreaming(r, pd9.Decode) - if pd7.Is(err, pd4.EOF) || pd7.Is(err, pd4.ErrUnexpectedEOF) { + n, err := pd4.DecodeStreaming(r, pd7.Decode) + if pd9.Is(err, pd8.EOF) || pd9.Is(err, pd8.ErrUnexpectedEOF) { return } + if err != nil { - ch <- GreetingService_Hello_AsyncResult{Err: pd13.ErrProto{Cause: err}} // IPLD decode error - return - } - env := &AnonInductive5{} - if err = env.Parse(n); err != nil { - ch <- GreetingService_Hello_AsyncResult{Err: pd13.ErrProto{Cause: err}} // schema decode error - return + out = GreetingService_Hello_AsyncResult{Err: pd14.ErrProto{Cause: err}} // IPLD decode error + } else { + env := &AnonInductive5{} + if err = env.Parse(n); err != nil { + out = GreetingService_Hello_AsyncResult{Err: pd14.ErrProto{Cause: err}} // schema decode error + } else if env.Error != nil { + out = GreetingService_Hello_AsyncResult{Err: pd14.ErrService{Cause: pd9.New(string(env.Error.Code))}} // service-level error + } else if env.Hello != nil { + out = GreetingService_Hello_AsyncResult{Resp: env.Hello} + } else { + continue + } } - if env.Error != nil { - ch <- GreetingService_Hello_AsyncResult{Err: pd13.ErrService{Cause: pd7.New(string(env.Error.Code))}} // service-level error + select { + case <-ctx.Done(): return + case ch <- out: } - if env.Hello == nil { - continue - } - ch <- GreetingService_Hello_AsyncResult{Resp: env.Hello} } } -var logger_server_GreetingService = pd14.Logger("service/server/greetingservice") +var logger_server_GreetingService = pd13.Logger("service/server/greetingservice") type GreetingService_Server interface { - Hello(ctx pd8.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) + Hello(ctx pd6.Context, req *HelloRequest) (<-chan *GreetingService_Hello_AsyncResult, error) } -func GreetingService_AsyncHandler(s GreetingService_Server) pd6.HandlerFunc { - return func(writer pd6.ResponseWriter, request *pd6.Request) { +func GreetingService_AsyncHandler(s GreetingService_Server) pd5.HandlerFunc { + return func(writer pd5.ResponseWriter, request *pd5.Request) { // parse request - msg := request.URL.Query().Get("q") - n, err := pd5.Decode([]byte(msg), pd9.Decode) + msg, err := pd15.ReadAll(request.Body) + if err != nil { + logger_server_GreetingService.Errorf("reading request body (%v)", err) + writer.WriteHeader(400) + return + } + n, err := pd4.Decode(msg, pd7.Decode) if err != nil { logger_server_GreetingService.Errorf("received request not decodeable (%v)", err) writer.WriteHeader(400) @@ -1296,7 +1300,7 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd6.HandlerFunc { switch { case env.Hello != nil: - ch, err := s.Hello(pd8.Background(), env.Hello) + ch, err := s.Hello(pd6.Background(), env.Hello) if err != nil { logger_server_GreetingService.Errorf("service rejected request (%v)", err) writer.Header()["Error"] = []string{err.Error()} @@ -1306,12 +1310,12 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd6.HandlerFunc { for resp := range ch { var env *AnonInductive5 if resp.Err != nil { - env = &AnonInductive5{Error: &GreetingService_Error{Code: pd2.String(resp.Err.Error())}} + env = &AnonInductive5{Error: &GreetingService_Error{Code: pd1.String(resp.Err.Error())}} } else { env = &AnonInductive5{Hello: resp.Resp} } - var buf pd10.Buffer - if err = pd5.EncodeStreaming(&buf, env, pd9.Encode); err != nil { + var buf pd11.Buffer + if err = pd4.EncodeStreaming(&buf, env, pd7.Encode); err != nil { logger_server_GreetingService.Errorf("cannot encode response (%v)", err) continue } @@ -1323,13 +1327,13 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd6.HandlerFunc { var env *AnonInductive5 env = &AnonInductive5{ Identify: &GreetingService_IdentifyResult{ - Methods: []pd2.String{ + Methods: []pd1.String{ "Hello", }, }, } - var buf pd10.Buffer - if err = pd5.EncodeStreaming(&buf, env, pd9.Encode); err != nil { + var buf pd11.Buffer + if err = pd4.EncodeStreaming(&buf, env, pd7.Encode); err != nil { logger_server_GreetingService.Errorf("cannot encode identify response (%v)", err) writer.WriteHeader(500) return @@ -1347,20 +1351,20 @@ func GreetingService_AsyncHandler(s GreetingService_Server) pd6.HandlerFunc { // -- protocol type HelloRequest -- type HelloRequest struct { - Name pd2.String + Name pd1.String Address Address } -func (x HelloRequest) Node() pd1.Node { +func (x HelloRequest) Node() pd2.Node { return x } -func (x *HelloRequest) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *HelloRequest) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "Name": x.Name.Parse, "Address": x.Address.Parse, } @@ -1395,7 +1399,7 @@ func (x *HelloRequest) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -1407,27 +1411,27 @@ type HelloRequest_MapIterator struct { s *HelloRequest } -func (x *HelloRequest_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *HelloRequest_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd2.String("Name"), x.s.Name.Node(), nil + return pd1.String("Name"), x.s.Name.Node(), nil case 1: - return pd2.String("Address"), x.s.Address.Node(), nil + return pd1.String("Address"), x.s.Address.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *HelloRequest_MapIterator) Done() bool { return x.i+1 >= 2 } -func (x HelloRequest) Kind() pd1.Kind { - return pd1.Kind_Map +func (x HelloRequest) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x HelloRequest) LookupByString(key string) (pd1.Node, error) { +func (x HelloRequest) LookupByString(key string) (pd2.Node, error) { switch key { case "Name": return x.Name.Node(), nil @@ -1435,28 +1439,28 @@ func (x HelloRequest) LookupByString(key string) (pd1.Node, error) { return x.Address.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x HelloRequest) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) LookupByIndex(idx int64) (pd1.Node, error) { +func (x HelloRequest) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Name.Node(), nil @@ -1464,10 +1468,10 @@ func (x HelloRequest) LookupByIndex(idx int64) (pd1.Node, error) { return x.Address.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x HelloRequest) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "Name": return x.Name.Node(), nil @@ -1475,14 +1479,14 @@ func (x HelloRequest) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.Address.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) MapIterator() pd1.MapIterator { +func (x HelloRequest) MapIterator() pd2.MapIterator { return &HelloRequest_MapIterator{-1, &x} } -func (x HelloRequest) ListIterator() pd1.ListIterator { +func (x HelloRequest) ListIterator() pd2.ListIterator { return nil } @@ -1499,54 +1503,54 @@ func (x HelloRequest) IsNull() bool { } func (x HelloRequest) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x HelloRequest) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x HelloRequest) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x HelloRequest) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x HelloRequest) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x HelloRequest) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x HelloRequest) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x HelloRequest) Prototype() pd1.NodePrototype { +func (x HelloRequest) Prototype() pd2.NodePrototype { return nil } // -- protocol type AddressLines -- -type AddressLines []pd2.String +type AddressLines []pd1.String -func (v AddressLines) Node() pd1.Node { +func (v AddressLines) Node() pd2.Node { return v } -func (v *AddressLines) Parse(n pd1.Node) error { - if n.Kind() == pd1.Kind_Null { +func (v *AddressLines) Parse(n pd2.Node) error { + if n.Kind() == pd2.Kind_Null { *v = nil return nil } - if n.Kind() != pd1.Kind_List { - return pd2.ErrNA + if n.Kind() != pd2.Kind_List { + return pd1.ErrNA } else { *v = make(AddressLines, n.Length()) iter := n.ListIterator() for !iter.Done() { if i, n, err := iter.Next(); err != nil { - return pd2.ErrNA + return pd1.ErrNA } else if err = (*v)[i].Parse(n); err != nil { return err } @@ -1555,39 +1559,39 @@ func (v *AddressLines) Parse(n pd1.Node) error { } } -func (AddressLines) Kind() pd1.Kind { - return pd1.Kind_List +func (AddressLines) Kind() pd2.Kind { + return pd2.Kind_List } -func (AddressLines) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AddressLines) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (AddressLines) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (AddressLines) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (v AddressLines) LookupByIndex(i int64) (pd1.Node, error) { +func (v AddressLines) LookupByIndex(i int64) (pd2.Node, error) { if i < 0 || i >= v.Length() { - return nil, pd2.ErrBounds + return nil, pd1.ErrBounds } else { return v[i].Node(), nil } } -func (v AddressLines) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (v AddressLines) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if i, err := seg.Index(); err != nil { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } else { return v.LookupByIndex(i) } } -func (AddressLines) MapIterator() pd1.MapIterator { +func (AddressLines) MapIterator() pd2.MapIterator { return nil } -func (v AddressLines) ListIterator() pd1.ListIterator { +func (v AddressLines) ListIterator() pd2.ListIterator { return &AddressLines_ListIterator{v, 0} } @@ -1604,30 +1608,30 @@ func (AddressLines) IsNull() bool { } func (v AddressLines) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (AddressLines) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AddressLines) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (AddressLines) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (AddressLines) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (AddressLines) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (AddressLines) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (AddressLines) Prototype() pd1.NodePrototype { +func (AddressLines) Prototype() pd2.NodePrototype { return nil // not needed } @@ -1636,9 +1640,9 @@ type AddressLines_ListIterator struct { at int64 } -func (iter *AddressLines_ListIterator) Next() (int64, pd1.Node, error) { +func (iter *AddressLines_ListIterator) Next() (int64, pd2.Node, error) { if iter.Done() { - return -1, nil, pd2.ErrBounds + return -1, nil, pd1.ErrBounds } v := iter.list[iter.at] i := int64(iter.at) @@ -1660,10 +1664,10 @@ type Address struct { OtherAddress *AddressLines } -func (x *Address) Parse(n pd1.Node) error { +func (x *Address) Parse(n pd2.Node) error { *x = Address{} - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() kn, vn, err := iter.Next() @@ -1708,19 +1712,19 @@ type Address_MapIterator struct { s *Address } -func (x *Address_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *Address_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { if x.done { - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } else { x.done = true switch { case x.s.US != nil: - return pd2.String("US"), x.s.US.Node(), nil + return pd1.String("US"), x.s.US.Node(), nil case x.s.SK != nil: - return pd2.String("SouthKorea"), x.s.SK.Node(), nil + return pd1.String("SouthKorea"), x.s.SK.Node(), nil case x.s.OtherAddress != nil: - return pd2.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil + return pd1.String(x.s.OtherCountry), x.s.OtherAddress.Node(), nil default: return nil, nil, pd3.Errorf("no inductive cases are set") @@ -1732,15 +1736,15 @@ func (x *Address_MapIterator) Done() bool { return x.done } -func (x Address) Node() pd1.Node { +func (x Address) Node() pd2.Node { return x } -func (x Address) Kind() pd1.Kind { - return pd1.Kind_Map +func (x Address) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x Address) LookupByString(key string) (pd1.Node, error) { +func (x Address) LookupByString(key string) (pd2.Node, error) { switch { case x.US != nil && key == "US": return x.US.Node(), nil @@ -1751,12 +1755,12 @@ func (x Address) LookupByString(key string) (pd1.Node, error) { return x.OtherAddress.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x Address) LookupByNode(key pd1.Node) (pd1.Node, error) { - if key.Kind() != pd1.Kind_String { - return nil, pd2.ErrNA +func (x Address) LookupByNode(key pd2.Node) (pd2.Node, error) { + if key.Kind() != pd2.Kind_String { + return nil, pd1.ErrNA } if s, err := key.AsString(); err != nil { return nil, err @@ -1765,11 +1769,11 @@ func (x Address) LookupByNode(key pd1.Node) (pd1.Node, error) { } } -func (x Address) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (x Address) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (x Address) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x Address) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "US": return x.US.Node(), nil @@ -1780,14 +1784,14 @@ func (x Address) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.OtherAddress.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x Address) MapIterator() pd1.MapIterator { +func (x Address) MapIterator() pd2.MapIterator { return &Address_MapIterator{false, &x} } -func (x Address) ListIterator() pd1.ListIterator { +func (x Address) ListIterator() pd2.ListIterator { return nil } @@ -1804,52 +1808,52 @@ func (x Address) IsNull() bool { } func (x Address) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x Address) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x Address) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x Address) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x Address) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x Address) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x Address) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x Address) Prototype() pd1.NodePrototype { +func (x Address) Prototype() pd2.NodePrototype { return nil } // -- protocol type USAddress -- type USAddress struct { - Street pd2.String - City pd2.String + Street pd1.String + City pd1.String State State - ZIP pd2.Int + ZIP pd1.Int } -func (x USAddress) Node() pd1.Node { +func (x USAddress) Node() pd2.Node { return x } -func (x *USAddress) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *USAddress) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "street": x.Street.Parse, "city": x.City.Parse, "state": x.State.Parse, @@ -1902,7 +1906,7 @@ func (x *USAddress) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -1914,31 +1918,31 @@ type USAddress_MapIterator struct { s *USAddress } -func (x *USAddress_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *USAddress_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd2.String("street"), x.s.Street.Node(), nil + return pd1.String("street"), x.s.Street.Node(), nil case 1: - return pd2.String("city"), x.s.City.Node(), nil + return pd1.String("city"), x.s.City.Node(), nil case 2: - return pd2.String("state"), x.s.State.Node(), nil + return pd1.String("state"), x.s.State.Node(), nil case 3: - return pd2.String("zip"), x.s.ZIP.Node(), nil + return pd1.String("zip"), x.s.ZIP.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *USAddress_MapIterator) Done() bool { return x.i+1 >= 4 } -func (x USAddress) Kind() pd1.Kind { - return pd1.Kind_Map +func (x USAddress) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x USAddress) LookupByString(key string) (pd1.Node, error) { +func (x USAddress) LookupByString(key string) (pd2.Node, error) { switch key { case "street": return x.Street.Node(), nil @@ -1950,28 +1954,28 @@ func (x USAddress) LookupByString(key string) (pd1.Node, error) { return x.ZIP.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x USAddress) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) LookupByIndex(idx int64) (pd1.Node, error) { +func (x USAddress) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Street.Node(), nil @@ -1983,10 +1987,10 @@ func (x USAddress) LookupByIndex(idx int64) (pd1.Node, error) { return x.ZIP.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x USAddress) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "street": return x.Street.Node(), nil @@ -1998,14 +2002,14 @@ func (x USAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.ZIP.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) MapIterator() pd1.MapIterator { +func (x USAddress) MapIterator() pd2.MapIterator { return &USAddress_MapIterator{-1, &x} } -func (x USAddress) ListIterator() pd1.ListIterator { +func (x USAddress) ListIterator() pd2.ListIterator { return nil } @@ -2022,30 +2026,30 @@ func (x USAddress) IsNull() bool { } func (x USAddress) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x USAddress) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x USAddress) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x USAddress) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x USAddress) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x USAddress) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x USAddress) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x USAddress) Prototype() pd1.NodePrototype { +func (x USAddress) Prototype() pd2.NodePrototype { return nil } @@ -2053,49 +2057,49 @@ func (x USAddress) Prototype() pd1.NodePrototype { type StateCA struct{} -func (StateCA) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_String { - return pd2.ErrNA +func (StateCA) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_String { + return pd1.ErrNA } v, err := n.AsString() if err != nil { return err } if v != "CA" { - return pd2.ErrNA + return pd1.ErrNA } return nil } -func (v StateCA) Node() pd1.Node { +func (v StateCA) Node() pd2.Node { return v } -func (StateCA) Kind() pd1.Kind { - return pd1.Kind_String +func (StateCA) Kind() pd2.Kind { + return pd2.Kind_String } -func (StateCA) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) LookupBySegment(_ pd1.PathSegment) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateCA) LookupBySegment(_ pd2.PathSegment) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateCA) MapIterator() pd1.MapIterator { +func (StateCA) MapIterator() pd2.MapIterator { return nil } -func (StateCA) ListIterator() pd1.ListIterator { +func (StateCA) ListIterator() pd2.ListIterator { return nil } @@ -2112,15 +2116,15 @@ func (StateCA) IsNull() bool { } func (v StateCA) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (StateCA) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateCA) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateCA) AsString() (string, error) { @@ -2128,14 +2132,14 @@ func (StateCA) AsString() (string, error) { } func (StateCA) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (StateCA) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (StateCA) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (StateCA) Prototype() pd1.NodePrototype { +func (StateCA) Prototype() pd2.NodePrototype { return nil } @@ -2143,49 +2147,49 @@ func (StateCA) Prototype() pd1.NodePrototype { type StateNY struct{} -func (StateNY) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_String { - return pd2.ErrNA +func (StateNY) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_String { + return pd1.ErrNA } v, err := n.AsString() if err != nil { return err } if v != "NY" { - return pd2.ErrNA + return pd1.ErrNA } return nil } -func (v StateNY) Node() pd1.Node { +func (v StateNY) Node() pd2.Node { return v } -func (StateNY) Kind() pd1.Kind { - return pd1.Kind_String +func (StateNY) Kind() pd2.Kind { + return pd2.Kind_String } -func (StateNY) LookupByString(string) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupByString(string) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) LookupByNode(key pd1.Node) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupByNode(key pd2.Node) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) LookupByIndex(idx int64) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupByIndex(idx int64) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) LookupBySegment(_ pd1.PathSegment) (pd1.Node, error) { - return nil, pd2.ErrNA +func (StateNY) LookupBySegment(_ pd2.PathSegment) (pd2.Node, error) { + return nil, pd1.ErrNA } -func (StateNY) MapIterator() pd1.MapIterator { +func (StateNY) MapIterator() pd2.MapIterator { return nil } -func (StateNY) ListIterator() pd1.ListIterator { +func (StateNY) ListIterator() pd2.ListIterator { return nil } @@ -2202,15 +2206,15 @@ func (StateNY) IsNull() bool { } func (v StateNY) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (StateNY) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateNY) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (StateNY) AsString() (string, error) { @@ -2218,14 +2222,14 @@ func (StateNY) AsString() (string, error) { } func (StateNY) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (StateNY) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (StateNY) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (StateNY) Prototype() pd1.NodePrototype { +func (StateNY) Prototype() pd2.NodePrototype { return nil } @@ -2234,10 +2238,10 @@ func (StateNY) Prototype() pd1.NodePrototype { type State struct { CA *StateCA NY *StateNY - Other *pd2.String + Other *pd1.String } -func (x *State) Parse(n pd1.Node) error { +func (x *State) Parse(n pd2.Node) error { *x = State{} var CA StateCA @@ -2252,7 +2256,7 @@ func (x *State) Parse(n pd1.Node) error { return nil } - var Other pd2.String + var Other pd1.String if err := Other.Parse(n); err == nil { x.Other = &Other return nil @@ -2261,7 +2265,7 @@ func (x *State) Parse(n pd1.Node) error { return pd3.Errorf("no union cases parses") } -func (x State) Node() pd1.Node { +func (x State) Node() pd2.Node { if x.CA != nil { return x.CA } @@ -2277,7 +2281,7 @@ func (x State) Node() pd1.Node { // proxy Node methods to active case -func (x State) Kind() pd1.Kind { +func (x State) Kind() pd2.Kind { if x.CA != nil { return x.CA.Kind() } @@ -2288,10 +2292,10 @@ func (x State) Kind() pd1.Kind { return x.Other.Kind() } - return pd1.Kind_Invalid + return pd2.Kind_Invalid } -func (x State) LookupByString(key string) (pd1.Node, error) { +func (x State) LookupByString(key string) (pd2.Node, error) { if x.CA != nil { return x.CA.LookupByString(key) } @@ -2305,7 +2309,7 @@ func (x State) LookupByString(key string) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x State) LookupByNode(key pd2.Node) (pd2.Node, error) { if x.CA != nil { return x.CA.LookupByNode(key) } @@ -2319,7 +2323,7 @@ func (x State) LookupByNode(key pd1.Node) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) LookupByIndex(idx int64) (pd1.Node, error) { +func (x State) LookupByIndex(idx int64) (pd2.Node, error) { if x.CA != nil { return x.CA.LookupByIndex(idx) } @@ -2333,7 +2337,7 @@ func (x State) LookupByIndex(idx int64) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x State) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if x.CA != nil { return x.CA.LookupBySegment(seg) } @@ -2347,7 +2351,7 @@ func (x State) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) MapIterator() pd1.MapIterator { +func (x State) MapIterator() pd2.MapIterator { if x.CA != nil { return x.CA.MapIterator() } @@ -2361,7 +2365,7 @@ func (x State) MapIterator() pd1.MapIterator { return nil } -func (x State) ListIterator() pd1.ListIterator { +func (x State) ListIterator() pd2.ListIterator { if x.CA != nil { return x.CA.ListIterator() } @@ -2487,7 +2491,7 @@ func (x State) AsBytes() ([]byte, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) AsLink() (pd1.Link, error) { +func (x State) AsLink() (pd2.Link, error) { if x.CA != nil { return x.CA.AsLink() } @@ -2501,29 +2505,29 @@ func (x State) AsLink() (pd1.Link, error) { return nil, pd3.Errorf("no active union case found") } -func (x State) Prototype() pd1.NodePrototype { +func (x State) Prototype() pd2.NodePrototype { return nil } // -- protocol type SKAddress -- type SKAddress struct { - Street pd2.String - City pd2.String - Province pd2.String - PostalCode pd2.Int + Street pd1.String + City pd1.String + Province pd1.String + PostalCode pd1.Int } -func (x SKAddress) Node() pd1.Node { +func (x SKAddress) Node() pd2.Node { return x } -func (x *SKAddress) Parse(n pd1.Node) error { - if n.Kind() != pd1.Kind_Map { - return pd2.ErrNA +func (x *SKAddress) Parse(n pd2.Node) error { + if n.Kind() != pd2.Kind_Map { + return pd1.ErrNA } iter := n.MapIterator() - fieldMap := map[string]pd2.ParseFunc{ + fieldMap := map[string]pd1.ParseFunc{ "street": x.Street.Parse, "city": x.City.Parse, "province": x.Province.Parse, @@ -2576,7 +2580,7 @@ func (x *SKAddress) Parse(n pd1.Node) error { } } for _, fieldParse := range fieldMap { - if err := fieldParse(pd1.Null); err != nil { + if err := fieldParse(pd2.Null); err != nil { return err } } @@ -2588,31 +2592,31 @@ type SKAddress_MapIterator struct { s *SKAddress } -func (x *SKAddress_MapIterator) Next() (key pd1.Node, value pd1.Node, err error) { +func (x *SKAddress_MapIterator) Next() (key pd2.Node, value pd2.Node, err error) { x.i++ switch x.i { case 0: - return pd2.String("street"), x.s.Street.Node(), nil + return pd1.String("street"), x.s.Street.Node(), nil case 1: - return pd2.String("city"), x.s.City.Node(), nil + return pd1.String("city"), x.s.City.Node(), nil case 2: - return pd2.String("province"), x.s.Province.Node(), nil + return pd1.String("province"), x.s.Province.Node(), nil case 3: - return pd2.String("postal_code"), x.s.PostalCode.Node(), nil + return pd1.String("postal_code"), x.s.PostalCode.Node(), nil } - return nil, nil, pd2.ErrNA + return nil, nil, pd1.ErrNA } func (x *SKAddress_MapIterator) Done() bool { return x.i+1 >= 4 } -func (x SKAddress) Kind() pd1.Kind { - return pd1.Kind_Map +func (x SKAddress) Kind() pd2.Kind { + return pd2.Kind_Map } -func (x SKAddress) LookupByString(key string) (pd1.Node, error) { +func (x SKAddress) LookupByString(key string) (pd2.Node, error) { switch key { case "street": return x.Street.Node(), nil @@ -2624,28 +2628,28 @@ func (x SKAddress) LookupByString(key string) (pd1.Node, error) { return x.PostalCode.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x SKAddress) LookupByNode(key pd2.Node) (pd2.Node, error) { switch key.Kind() { - case pd1.Kind_String: + case pd2.Kind_String: if s, err := key.AsString(); err != nil { return nil, err } else { return x.LookupByString(s) } - case pd1.Kind_Int: + case pd2.Kind_Int: if i, err := key.AsInt(); err != nil { return nil, err } else { return x.LookupByIndex(i) } } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) LookupByIndex(idx int64) (pd1.Node, error) { +func (x SKAddress) LookupByIndex(idx int64) (pd2.Node, error) { switch idx { case 0: return x.Street.Node(), nil @@ -2657,10 +2661,10 @@ func (x SKAddress) LookupByIndex(idx int64) (pd1.Node, error) { return x.PostalCode.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x SKAddress) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { switch seg.String() { case "0", "street": return x.Street.Node(), nil @@ -2672,14 +2676,14 @@ func (x SKAddress) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return x.PostalCode.Node(), nil } - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) MapIterator() pd1.MapIterator { +func (x SKAddress) MapIterator() pd2.MapIterator { return &SKAddress_MapIterator{-1, &x} } -func (x SKAddress) ListIterator() pd1.ListIterator { +func (x SKAddress) ListIterator() pd2.ListIterator { return nil } @@ -2696,50 +2700,50 @@ func (x SKAddress) IsNull() bool { } func (x SKAddress) AsBool() (bool, error) { - return false, pd2.ErrNA + return false, pd1.ErrNA } func (x SKAddress) AsInt() (int64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x SKAddress) AsFloat() (float64, error) { - return 0, pd2.ErrNA + return 0, pd1.ErrNA } func (x SKAddress) AsString() (string, error) { - return "", pd2.ErrNA + return "", pd1.ErrNA } func (x SKAddress) AsBytes() ([]byte, error) { - return nil, pd2.ErrNA + return nil, pd1.ErrNA } -func (x SKAddress) AsLink() (pd1.Link, error) { - return nil, pd2.ErrNA +func (x SKAddress) AsLink() (pd2.Link, error) { + return nil, pd1.ErrNA } -func (x SKAddress) Prototype() pd1.NodePrototype { +func (x SKAddress) Prototype() pd2.NodePrototype { return nil } // -- protocol type HelloResponse -- type HelloResponse struct { - English *pd2.String - Korean *pd2.String + English *pd1.String + Korean *pd1.String } -func (x *HelloResponse) Parse(n pd1.Node) error { +func (x *HelloResponse) Parse(n pd2.Node) error { *x = HelloResponse{} - var English pd2.String + var English pd1.String if err := English.Parse(n); err == nil { x.English = &English return nil } - var Korean pd2.String + var Korean pd1.String if err := Korean.Parse(n); err == nil { x.Korean = &Korean return nil @@ -2748,7 +2752,7 @@ func (x *HelloResponse) Parse(n pd1.Node) error { return pd3.Errorf("no union cases parses") } -func (x HelloResponse) Node() pd1.Node { +func (x HelloResponse) Node() pd2.Node { if x.English != nil { return x.English } @@ -2761,7 +2765,7 @@ func (x HelloResponse) Node() pd1.Node { // proxy Node methods to active case -func (x HelloResponse) Kind() pd1.Kind { +func (x HelloResponse) Kind() pd2.Kind { if x.English != nil { return x.English.Kind() } @@ -2769,10 +2773,10 @@ func (x HelloResponse) Kind() pd1.Kind { return x.Korean.Kind() } - return pd1.Kind_Invalid + return pd2.Kind_Invalid } -func (x HelloResponse) LookupByString(key string) (pd1.Node, error) { +func (x HelloResponse) LookupByString(key string) (pd2.Node, error) { if x.English != nil { return x.English.LookupByString(key) } @@ -2783,7 +2787,7 @@ func (x HelloResponse) LookupByString(key string) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) LookupByNode(key pd1.Node) (pd1.Node, error) { +func (x HelloResponse) LookupByNode(key pd2.Node) (pd2.Node, error) { if x.English != nil { return x.English.LookupByNode(key) } @@ -2794,7 +2798,7 @@ func (x HelloResponse) LookupByNode(key pd1.Node) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) LookupByIndex(idx int64) (pd1.Node, error) { +func (x HelloResponse) LookupByIndex(idx int64) (pd2.Node, error) { if x.English != nil { return x.English.LookupByIndex(idx) } @@ -2805,7 +2809,7 @@ func (x HelloResponse) LookupByIndex(idx int64) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { +func (x HelloResponse) LookupBySegment(seg pd2.PathSegment) (pd2.Node, error) { if x.English != nil { return x.English.LookupBySegment(seg) } @@ -2816,7 +2820,7 @@ func (x HelloResponse) LookupBySegment(seg pd1.PathSegment) (pd1.Node, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) MapIterator() pd1.MapIterator { +func (x HelloResponse) MapIterator() pd2.MapIterator { if x.English != nil { return x.English.MapIterator() } @@ -2827,7 +2831,7 @@ func (x HelloResponse) MapIterator() pd1.MapIterator { return nil } -func (x HelloResponse) ListIterator() pd1.ListIterator { +func (x HelloResponse) ListIterator() pd2.ListIterator { if x.English != nil { return x.English.ListIterator() } @@ -2926,7 +2930,7 @@ func (x HelloResponse) AsBytes() ([]byte, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) AsLink() (pd1.Link, error) { +func (x HelloResponse) AsLink() (pd2.Link, error) { if x.English != nil { return x.English.AsLink() } @@ -2937,6 +2941,6 @@ func (x HelloResponse) AsLink() (pd1.Link, error) { return nil, pd3.Errorf("no active union case found") } -func (x HelloResponse) Prototype() pd1.NodePrototype { +func (x HelloResponse) Prototype() pd2.NodePrototype { return nil } diff --git a/test/harness.go b/test/harness.go index 881a08d..99cafb2 100644 --- a/test/harness.go +++ b/test/harness.go @@ -40,7 +40,7 @@ module test go 1.16 require ( - github.com/ipld/edelweiss 2134034b3e8123a5642a9f6c1967ef04fe0e3fa8 + github.com/ipld/edelweiss e8b466dd5c436d901f6098836a2ab42c9e18d485 github.com/ipld/go-ipld-prime v0.14.4 github.com/ipfs/go-cid v0.0.4 )