Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 1 | // This file was auto-generated by the veyron vdl tool. |
| 2 | // Source: wire.vdl |
| 3 | |
| 4 | package main |
| 5 | |
| 6 | import ( |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 7 | // The non-user imports are prefixed with "__" to prevent collisions. |
| 8 | __veyron2 "veyron.io/veyron/veyron2" |
| 9 | __context "veyron.io/veyron/veyron2/context" |
| 10 | __ipc "veyron.io/veyron/veyron2/ipc" |
| 11 | __vdlutil "veyron.io/veyron/veyron2/vdl/vdlutil" |
| 12 | __wiretype "veyron.io/veyron/veyron2/wiretype" |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 13 | ) |
| 14 | |
Jing Jin | 896d776 | 2014-11-03 11:18:52 -0800 | [diff] [blame] | 15 | // TODO(toddw): Remove this line once the new signature support is done. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 16 | // It corrects a bug where __wiretype is unused in VDL pacakges where only |
Jing Jin | 896d776 | 2014-11-03 11:18:52 -0800 | [diff] [blame] | 17 | // bootstrap types are used on interfaces. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 18 | const _ = __wiretype.TypeIDInvalid |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 19 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 20 | // PingPongClientMethods is the client interface |
| 21 | // containing PingPong methods. |
| 22 | // |
Ryan Brown | f6b9227 | 2014-09-16 13:24:28 -0700 | [diff] [blame] | 23 | // Simple service used in the agent tests. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 24 | type PingPongClientMethods interface { |
| 25 | Ping(ctx __context.T, message string, opts ...__ipc.CallOpt) (string, error) |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 26 | } |
| 27 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 28 | // PingPongClientStub adds universal methods to PingPongClientMethods. |
| 29 | type PingPongClientStub interface { |
| 30 | PingPongClientMethods |
| 31 | __ipc.UniversalServiceMethods |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 34 | // PingPongClient returns a client stub for PingPong. |
| 35 | func PingPongClient(name string, opts ...__ipc.BindOpt) PingPongClientStub { |
| 36 | var client __ipc.Client |
| 37 | for _, opt := range opts { |
| 38 | if clientOpt, ok := opt.(__ipc.Client); ok { |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 39 | client = clientOpt |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 40 | } |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 41 | } |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 42 | return implPingPongClientStub{name, client} |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 45 | type implPingPongClientStub struct { |
| 46 | name string |
| 47 | client __ipc.Client |
| 48 | } |
| 49 | |
| 50 | func (c implPingPongClientStub) c(ctx __context.T) __ipc.Client { |
| 51 | if c.client != nil { |
| 52 | return c.client |
| 53 | } |
| 54 | return __veyron2.RuntimeFromContext(ctx).Client() |
| 55 | } |
| 56 | |
| 57 | func (c implPingPongClientStub) Ping(ctx __context.T, i0 string, opts ...__ipc.CallOpt) (o0 string, err error) { |
| 58 | var call __ipc.Call |
| 59 | if call, err = c.c(ctx).StartCall(ctx, c.name, "Ping", []interface{}{i0}, opts...); err != nil { |
| 60 | return |
| 61 | } |
| 62 | if ierr := call.Finish(&o0, &err); ierr != nil { |
| 63 | err = ierr |
| 64 | } |
| 65 | return |
| 66 | } |
| 67 | |
| 68 | func (c implPingPongClientStub) Signature(ctx __context.T, opts ...__ipc.CallOpt) (o0 __ipc.ServiceSignature, err error) { |
| 69 | var call __ipc.Call |
| 70 | if call, err = c.c(ctx).StartCall(ctx, c.name, "Signature", nil, opts...); err != nil { |
| 71 | return |
| 72 | } |
| 73 | if ierr := call.Finish(&o0, &err); ierr != nil { |
| 74 | err = ierr |
| 75 | } |
| 76 | return |
| 77 | } |
| 78 | |
| 79 | func (c implPingPongClientStub) GetMethodTags(ctx __context.T, method string, opts ...__ipc.CallOpt) (o0 []interface{}, err error) { |
| 80 | var call __ipc.Call |
| 81 | if call, err = c.c(ctx).StartCall(ctx, c.name, "GetMethodTags", []interface{}{method}, opts...); err != nil { |
| 82 | return |
| 83 | } |
| 84 | if ierr := call.Finish(&o0, &err); ierr != nil { |
| 85 | err = ierr |
| 86 | } |
| 87 | return |
| 88 | } |
| 89 | |
| 90 | // PingPongServerMethods is the interface a server writer |
| 91 | // implements for PingPong. |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 92 | // |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 93 | // Simple service used in the agent tests. |
| 94 | type PingPongServerMethods interface { |
| 95 | Ping(ctx __ipc.ServerContext, message string) (string, error) |
| 96 | } |
| 97 | |
| 98 | // PingPongServerStubMethods is the server interface containing |
| 99 | // PingPong methods, as expected by ipc.Server. The difference between |
| 100 | // this interface and PingPongServerMethods is that the first context |
| 101 | // argument for each method is always ipc.ServerCall here, while it is either |
| 102 | // ipc.ServerContext or a typed streaming context there. |
| 103 | type PingPongServerStubMethods interface { |
| 104 | Ping(call __ipc.ServerCall, message string) (string, error) |
| 105 | } |
| 106 | |
| 107 | // PingPongServerStub adds universal methods to PingPongServerStubMethods. |
| 108 | type PingPongServerStub interface { |
| 109 | PingPongServerStubMethods |
| 110 | // GetMethodTags will be replaced with DescribeInterfaces. |
| 111 | GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) |
| 112 | // Signature will be replaced with DescribeInterfaces. |
| 113 | Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) |
| 114 | } |
| 115 | |
| 116 | // PingPongServer returns a server stub for PingPong. |
| 117 | // It converts an implementation of PingPongServerMethods into |
| 118 | // an object that may be used by ipc.Server. |
| 119 | func PingPongServer(impl PingPongServerMethods) PingPongServerStub { |
| 120 | stub := implPingPongServerStub{ |
| 121 | impl: impl, |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 122 | } |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 123 | // Initialize GlobState; always check the stub itself first, to handle the |
| 124 | // case where the user has the Glob method defined in their VDL source. |
| 125 | if gs := __ipc.NewGlobState(stub); gs != nil { |
| 126 | stub.gs = gs |
| 127 | } else if gs := __ipc.NewGlobState(impl); gs != nil { |
| 128 | stub.gs = gs |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame] | 129 | } |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame] | 130 | return stub |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 133 | type implPingPongServerStub struct { |
| 134 | impl PingPongServerMethods |
| 135 | gs *__ipc.GlobState |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 138 | func (s implPingPongServerStub) Ping(call __ipc.ServerCall, i0 string) (string, error) { |
| 139 | return s.impl.Ping(call, i0) |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 142 | func (s implPingPongServerStub) VGlob() *__ipc.GlobState { |
| 143 | return s.gs |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 146 | func (s implPingPongServerStub) GetMethodTags(call __ipc.ServerCall, method string) ([]interface{}, error) { |
| 147 | // TODO(toddw): Replace with new DescribeInterfaces implementation. |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 148 | switch method { |
| 149 | case "Ping": |
| 150 | return []interface{}{}, nil |
| 151 | default: |
| 152 | return nil, nil |
| 153 | } |
| 154 | } |
| 155 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 156 | func (s implPingPongServerStub) Signature(call __ipc.ServerCall) (__ipc.ServiceSignature, error) { |
| 157 | // TODO(toddw) Replace with new DescribeInterfaces implementation. |
| 158 | result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)} |
| 159 | result.Methods["Ping"] = __ipc.MethodSignature{ |
| 160 | InArgs: []__ipc.MethodArgument{ |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 161 | {Name: "message", Type: 3}, |
| 162 | }, |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 163 | OutArgs: []__ipc.MethodArgument{ |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 164 | {Name: "", Type: 3}, |
| 165 | {Name: "", Type: 65}, |
| 166 | }, |
| 167 | } |
| 168 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 169 | result.TypeDefs = []__vdlutil.Any{ |
| 170 | __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 171 | |
| 172 | return result, nil |
| 173 | } |