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. |
Jiri Simsa | 764efb7 | 2014-12-25 20:57:03 -0800 | [diff] [blame] | 8 | __veyron2 "v.io/core/veyron2" |
| 9 | __context "v.io/core/veyron2/context" |
| 10 | __ipc "v.io/core/veyron2/ipc" |
| 11 | __vdlutil "v.io/core/veyron2/vdl/vdlutil" |
| 12 | __wiretype "v.io/core/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 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 79 | // PingPongServerMethods is the interface a server writer |
| 80 | // implements for PingPong. |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 81 | // |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 82 | // Simple service used in the agent tests. |
| 83 | type PingPongServerMethods interface { |
| 84 | Ping(ctx __ipc.ServerContext, message string) (string, error) |
| 85 | } |
| 86 | |
| 87 | // PingPongServerStubMethods is the server interface containing |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 88 | // PingPong methods, as expected by ipc.Server. |
| 89 | // There is no difference between this interface and PingPongServerMethods |
| 90 | // since there are no streaming methods. |
| 91 | type PingPongServerStubMethods PingPongServerMethods |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 92 | |
| 93 | // PingPongServerStub adds universal methods to PingPongServerStubMethods. |
| 94 | type PingPongServerStub interface { |
| 95 | PingPongServerStubMethods |
Todd Wang | 5739dda | 2014-11-16 22:44:02 -0800 | [diff] [blame] | 96 | // Describe the PingPong interfaces. |
| 97 | Describe__() []__ipc.InterfaceDesc |
| 98 | // Signature will be replaced with Describe__. |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 99 | Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | // PingPongServer returns a server stub for PingPong. |
| 103 | // It converts an implementation of PingPongServerMethods into |
| 104 | // an object that may be used by ipc.Server. |
| 105 | func PingPongServer(impl PingPongServerMethods) PingPongServerStub { |
| 106 | stub := implPingPongServerStub{ |
| 107 | impl: impl, |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 108 | } |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 109 | // Initialize GlobState; always check the stub itself first, to handle the |
| 110 | // case where the user has the Glob method defined in their VDL source. |
| 111 | if gs := __ipc.NewGlobState(stub); gs != nil { |
| 112 | stub.gs = gs |
| 113 | } else if gs := __ipc.NewGlobState(impl); gs != nil { |
| 114 | stub.gs = gs |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame] | 115 | } |
Robin Thellend | 94bc464 | 2014-11-05 18:05:08 -0800 | [diff] [blame] | 116 | return stub |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 119 | type implPingPongServerStub struct { |
| 120 | impl PingPongServerMethods |
| 121 | gs *__ipc.GlobState |
Ken Ashcraft | e027b5c | 2014-09-16 14:20:20 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 124 | func (s implPingPongServerStub) Ping(ctx __ipc.ServerContext, i0 string) (string, error) { |
| 125 | return s.impl.Ping(ctx, i0) |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Robin Thellend | 39ac323 | 2014-12-02 09:50:41 -0800 | [diff] [blame] | 128 | func (s implPingPongServerStub) Globber() *__ipc.GlobState { |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 129 | return s.gs |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 130 | } |
| 131 | |
Todd Wang | 5739dda | 2014-11-16 22:44:02 -0800 | [diff] [blame] | 132 | func (s implPingPongServerStub) Describe__() []__ipc.InterfaceDesc { |
| 133 | return []__ipc.InterfaceDesc{PingPongDesc} |
| 134 | } |
| 135 | |
| 136 | // PingPongDesc describes the PingPong interface. |
| 137 | var PingPongDesc __ipc.InterfaceDesc = descPingPong |
| 138 | |
| 139 | // descPingPong hides the desc to keep godoc clean. |
| 140 | var descPingPong = __ipc.InterfaceDesc{ |
| 141 | Name: "PingPong", |
Jiri Simsa | 764efb7 | 2014-12-25 20:57:03 -0800 | [diff] [blame] | 142 | PkgPath: "v.io/core/veyron/security/agent/pingpong", |
Todd Wang | 5739dda | 2014-11-16 22:44:02 -0800 | [diff] [blame] | 143 | Doc: "// Simple service used in the agent tests.", |
| 144 | Methods: []__ipc.MethodDesc{ |
| 145 | { |
| 146 | Name: "Ping", |
| 147 | InArgs: []__ipc.ArgDesc{ |
| 148 | {"message", ``}, // string |
| 149 | }, |
| 150 | OutArgs: []__ipc.ArgDesc{ |
| 151 | {"", ``}, // string |
| 152 | {"", ``}, // error |
| 153 | }, |
| 154 | }, |
| 155 | }, |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Todd Wang | 1fe7cdd | 2014-11-12 12:51:49 -0800 | [diff] [blame] | 158 | func (s implPingPongServerStub) Signature(ctx __ipc.ServerContext) (__ipc.ServiceSignature, error) { |
Todd Wang | 5739dda | 2014-11-16 22:44:02 -0800 | [diff] [blame] | 159 | // TODO(toddw): Replace with new Describe__ implementation. |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 160 | result := __ipc.ServiceSignature{Methods: make(map[string]__ipc.MethodSignature)} |
| 161 | result.Methods["Ping"] = __ipc.MethodSignature{ |
| 162 | InArgs: []__ipc.MethodArgument{ |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 163 | {Name: "message", Type: 3}, |
| 164 | }, |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 165 | OutArgs: []__ipc.MethodArgument{ |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 166 | {Name: "", Type: 3}, |
| 167 | {Name: "", Type: 65}, |
| 168 | }, |
| 169 | } |
| 170 | |
Todd Wang | 702385a | 2014-11-07 01:54:08 -0800 | [diff] [blame] | 171 | result.TypeDefs = []__vdlutil.Any{ |
| 172 | __wiretype.NamedPrimitiveType{Type: 0x1, Name: "error", Tags: []string(nil)}} |
Ryan Brown | fed691e | 2014-09-15 13:09:40 -0700 | [diff] [blame] | 173 | |
| 174 | return result, nil |
| 175 | } |