Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {%- for method in interface.methods %} | 1 {%- for method in interface.methods %} |
| 2 const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}}; | 2 const int k{{interface|name}}_{{method|name}}_name = {{method.ordinal}}; |
| 3 {%- endfor %} | 3 {%- endfor %} |
| 4 | 4 |
| 5 const String {{interface|name}}Name = | 5 const String {{interface|name}}Name = |
| 6 '{{namespace|replace(".","::")}}::{{interface|name}}'; | 6 '{{namespace|replace(".","::")}}::{{interface|name}}'; |
| 7 | 7 |
| 8 abstract class {{interface|name}} { | 8 abstract class {{interface|name}} { |
| 9 {%- for method in interface.methods %} | 9 {%- for method in interface.methods %} |
| 10 {%- if method.response_parameters == None %} | 10 {%- if method.response_parameters == None %} |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 {#--- Interface Enums #} | 31 {#--- Interface Enums #} |
| 32 {%- from "enum_definition.tmpl" import enum_def -%} | 32 {%- from "enum_definition.tmpl" import enum_def -%} |
| 33 {%- for enum in interface.enums %} | 33 {%- for enum in interface.enums %} |
| 34 {{ enum_def(" static ", enum) }} | 34 {{ enum_def(" static ", enum) }} |
| 35 {%- endfor %} | 35 {%- endfor %} |
| 36 } | 36 } |
| 37 | 37 |
| 38 | 38 |
| 39 class {{interface|name}}ProxyImpl extends bindings.Proxy { | 39 class {{interface|name}}ProxyImpl extends bindings.Proxy { |
| 40 {{interface|name}}ProxyImpl.fromEndpoint( | 40 {{interface|name}}ProxyImpl.fromEndpoint( |
| 41 core.MojoMessagePipeEndpoint endpoint) : super(endpoint); | 41 core.MojoMessagePipeEndpoint endpoint, |
| 42 {bool doListen: true, Function onClosed}) : | |
| 43 super.fromEndpoint(endpoint, doListen: doListen, onClosed: onClosed); | |
| 42 | 44 |
| 43 {{interface|name}}ProxyImpl.fromHandle(core.MojoHandle handle) : | 45 {{interface|name}}ProxyImpl.fromHandle(core.MojoHandle handle, |
| 44 super.fromHandle(handle); | 46 {bool doListen: true, Function onClosed}) : |
| 47 super.fromHandle(handle, doListen: doListen, onClosed: onClosed); | |
| 45 | 48 |
| 46 {{interface|name}}ProxyImpl.unbound() : super.unbound(); | 49 {{interface|name}}ProxyImpl.unbound() : super.unbound(); |
| 47 | 50 |
| 48 static {{interface|name}}ProxyImpl newFromEndpoint( | 51 static {{interface|name}}ProxyImpl newFromEndpoint( |
| 49 core.MojoMessagePipeEndpoint endpoint) => | 52 core.MojoMessagePipeEndpoint endpoint) => |
| 50 new {{interface|name}}ProxyImpl.fromEndpoint(endpoint); | 53 new {{interface|name}}ProxyImpl.fromEndpoint(endpoint); |
| 51 | 54 |
| 52 String get name => {{interface|name}}Name; | 55 String get name => {{interface|name}}Name; |
| 53 | 56 |
| 54 void handleResponse(bindings.ServiceMessage message) { | 57 void handleResponse(bindings.ServiceMessage message) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 82 _{{interface|name}}ProxyCalls(this._proxyImpl); | 85 _{{interface|name}}ProxyCalls(this._proxyImpl); |
| 83 | 86 |
| 84 {%- for method in interface.methods %} | 87 {%- for method in interface.methods %} |
| 85 {%- if method.response_parameters == None %} | 88 {%- if method.response_parameters == None %} |
| 86 void {{method|name}}( | 89 void {{method|name}}( |
| 87 {%- for parameter in method.parameters -%} | 90 {%- for parameter in method.parameters -%} |
| 88 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %} | 91 {{parameter.kind|dart_type}} {{parameter|name}}{% if not loop.last %}, {% endif %} |
| 89 {%- endfor -%} | 92 {%- endfor -%} |
| 90 {%- set request_struct = method|struct_from_method -%} | 93 {%- set request_struct = method|struct_from_method -%} |
| 91 ) { | 94 ) { |
| 95 assert(_proxyImpl.isBound); | |
| 92 var params = new {{request_struct|name}}(); | 96 var params = new {{request_struct|name}}(); |
| 93 {%- for parameter in method.parameters %} | 97 {%- for parameter in method.parameters %} |
| 94 params.{{parameter|name}} = {{parameter|name}}; | 98 params.{{parameter|name}} = {{parameter|name}}; |
| 95 {%- endfor %} | 99 {%- endfor %} |
| 96 _proxyImpl.sendMessage(params, k{{interface|name}}_{{method|name}}_name); | 100 _proxyImpl.sendMessage(params, k{{interface|name}}_{{method|name}}_name); |
| 97 } | 101 } |
| 98 {% else %} | 102 {% else %} |
| 99 {%- set response_struct = method|response_struct_from_method %} | 103 {%- set response_struct = method|response_struct_from_method %} |
| 100 {%- set request_struct = method|struct_from_method %} | 104 {%- set request_struct = method|struct_from_method %} |
| 101 Future<{{response_struct|name}}> {{method|name}}( | 105 Future<{{response_struct|name}}> {{method|name}}( |
| 102 {%- for parameter in method.parameters -%} | 106 {%- for parameter in method.parameters -%} |
| 103 {{parameter.kind|dart_type}} {{parameter|name}}, | 107 {{parameter.kind|dart_type}} {{parameter|name}}, |
| 104 {%- endfor -%} | 108 {%- endfor -%} |
| 105 [Function responseFactory = null]) { | 109 [Function responseFactory = null]) { |
| 110 assert(_proxyImpl.isBound); | |
| 106 var params = new {{request_struct|name}}(); | 111 var params = new {{request_struct|name}}(); |
| 107 {%- for parameter in method.parameters %} | 112 {%- for parameter in method.parameters %} |
| 108 params.{{parameter|name}} = {{parameter|name}}; | 113 params.{{parameter|name}} = {{parameter|name}}; |
| 109 {%- endfor %} | 114 {%- endfor %} |
| 110 return _proxyImpl.sendMessageWithRequestId( | 115 return _proxyImpl.sendMessageWithRequestId( |
| 111 params, | 116 params, |
| 112 k{{interface|name}}_{{method|name}}_name, | 117 k{{interface|name}}_{{method|name}}_name, |
| 113 -1, | 118 -1, |
| 114 bindings.MessageHeader.kMessageExpectsResponse); | 119 bindings.MessageHeader.kMessageExpectsResponse); |
| 115 } | 120 } |
| 116 {%- endif %} | 121 {%- endif %} |
| 117 {%- endfor %} | 122 {%- endfor %} |
| 118 } | 123 } |
| 119 | 124 |
| 120 | 125 |
| 121 class {{interface|name}}Proxy implements bindings.ProxyBase { | 126 class {{interface|name}}Proxy implements bindings.ProxyBase { |
| 122 final bindings.Proxy impl; | 127 final bindings.Proxy impl; |
| 123 {{interface|name}} ptr; | 128 {{interface|name}} ptr; |
| 124 final String name = {{interface|name}}Name; | 129 final String name = {{interface|name}}Name; |
| 125 | 130 |
| 126 {{interface|name}}Proxy({{interface|name}}ProxyImpl proxyImpl) : | 131 {{interface|name}}Proxy({{interface|name}}ProxyImpl proxyImpl) : |
| 127 impl = proxyImpl, | 132 impl = proxyImpl, |
| 128 ptr = new _{{interface|name}}ProxyCalls(proxyImpl); | 133 ptr = new _{{interface|name}}ProxyCalls(proxyImpl); |
| 129 | 134 |
| 130 {{interface|name}}Proxy.fromEndpoint( | 135 {{interface|name}}Proxy.fromEndpoint( |
| 131 core.MojoMessagePipeEndpoint endpoint) : | 136 core.MojoMessagePipeEndpoint endpoint, |
| 132 impl = new {{interface|name}}ProxyImpl.fromEndpoint(endpoint) { | 137 {bool doListen: true, Function onClosed}) : |
| 138 impl = new {{interface|name}}ProxyImpl.fromEndpoint( | |
| 139 endpoint, doListen: doListen, onClosed: onClosed) { | |
| 133 ptr = new _{{interface|name}}ProxyCalls(impl); | 140 ptr = new _{{interface|name}}ProxyCalls(impl); |
| 134 } | 141 } |
| 135 | 142 |
| 136 {{interface|name}}Proxy.fromHandle(core.MojoHandle handle) : | 143 {{interface|name}}Proxy.fromHandle(core.MojoHandle handle, |
| 137 impl = new {{interface|name}}ProxyImpl.fromHandle(handle) { | 144 {bool doListen: true, Function onClosed}) : |
| 145 impl = new {{interface|name}}ProxyImpl.fromHandle( | |
| 146 handle, doListen: doListen, onClosed: onClosed) { | |
| 138 ptr = new _{{interface|name}}ProxyCalls(impl); | 147 ptr = new _{{interface|name}}ProxyCalls(impl); |
| 139 } | 148 } |
| 140 | 149 |
| 141 {{interface|name}}Proxy.unbound() : | 150 {{interface|name}}Proxy.unbound() : |
| 142 impl = new {{interface|name}}ProxyImpl.unbound() { | 151 impl = new {{interface|name}}ProxyImpl.unbound() { |
| 143 ptr = new _{{interface|name}}ProxyCalls(impl); | 152 ptr = new _{{interface|name}}ProxyCalls(impl); |
| 144 } | 153 } |
| 145 | 154 |
| 146 static {{interface|name}}Proxy newFromEndpoint( | 155 static {{interface|name}}Proxy newFromEndpoint( |
| 147 core.MojoMessagePipeEndpoint endpoint) => | 156 core.MojoMessagePipeEndpoint endpoint) => |
| 148 new {{interface|name}}Proxy.fromEndpoint(endpoint); | 157 new {{interface|name}}Proxy.fromEndpoint(endpoint); |
| 149 | 158 |
| 150 void close() => impl.close(); | 159 void close() => impl.close(); |
| 151 } | 160 } |
| 152 | 161 |
| 153 | 162 |
| 154 class {{interface|name}}Stub extends bindings.Stub { | 163 class {{interface|name}}Binding extends bindings.Stub { |
| 155 {{interface|name}} _delegate = null; | 164 {{interface|name}} _delegate = null; |
| 156 | 165 |
| 157 {{interface|name}}Stub.fromEndpoint(core.MojoMessagePipeEndpoint endpoint) : | 166 {{interface|name}}Binding.fromEndpoint(core.MojoMessagePipeEndpoint endpoint, |
| 158 super(endpoint); | 167 { {{interface|name}} delegate, bool doListen: true, Function onClosed}) : |
|
sky
2015/03/02 20:28:22
Did you consider interfaceImpl or impl over delega
zra
2015/03/02 20:52:45
It has to be optional in at least one constructor
| |
| 168 super.fromEndpoint(endpoint, doListen: false) { | |
| 169 assert(!doListen || (delegate != null)); | |
| 170 if (delegate != null) { | |
| 171 this._delegate = delegate; | |
| 172 } | |
| 173 if (doListen) { | |
| 174 listen(onClosed: onClosed); | |
| 175 } | |
| 176 } | |
| 159 | 177 |
| 160 {{interface|name}}Stub.fromHandle(core.MojoHandle handle) : | 178 {{interface|name}}Binding.fromHandle(core.MojoHandle handle, |
| 161 super.fromHandle(handle); | 179 { {{interface|name}} delegate, bool doListen: true, Function onClosed}) : |
| 180 super.fromHandle(handle, doListen: false) { | |
| 181 assert(!doListen || (delegate != null)); | |
| 182 if (delegate != null) { | |
| 183 this._delegate = delegate; | |
| 184 } | |
| 185 if (doListen) { | |
| 186 listen(onClosed: onClosed); | |
| 187 } | |
| 188 } | |
| 162 | 189 |
| 163 {{interface|name}}Stub.unbound() : super.unbound(); | 190 {{interface|name}}Binding.unbound() : super.unbound(); |
| 164 | 191 |
| 165 static {{interface|name}}Stub newFromEndpoint( | 192 static {{interface|name}}Binding newFromEndpoint( |
| 166 core.MojoMessagePipeEndpoint endpoint) => | 193 core.MojoMessagePipeEndpoint endpoint) => |
| 167 new {{interface|name}}Stub.fromEndpoint(endpoint); | 194 new {{interface|name}}Binding.fromEndpoint(endpoint, doListen: false); |
| 168 | 195 |
| 169 static const String name = {{interface|name}}Name; | 196 static const String name = {{interface|name}}Name; |
| 170 | 197 |
| 171 {% for method in interface.methods %} | 198 {% for method in interface.methods %} |
| 172 {%- if method.response_parameters != None %} | 199 {%- if method.response_parameters != None %} |
| 173 {%- set response_struct = method|response_struct_from_method %} | 200 {%- set response_struct = method|response_struct_from_method %} |
| 174 {{response_struct|name}} _{{response_struct|name}}Factory( | 201 {{response_struct|name}} _{{response_struct|name}}Factory( |
| 175 {%- for param in method.response_parameters -%} | 202 {%- for param in method.response_parameters -%} |
| 176 {{param.kind|dart_type}} {{param|name}}{% if not loop.last %}, {% endif %} | 203 {{param.kind|dart_type}} {{param|name}}{% if not loop.last %}, {% endif %} |
| 177 {%- endfor -%} | 204 {%- endfor -%} |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 } | 250 } |
| 224 return null; | 251 return null; |
| 225 } | 252 } |
| 226 | 253 |
| 227 {{interface|name}} get delegate => _delegate; | 254 {{interface|name}} get delegate => _delegate; |
| 228 set delegate({{interface|name}} d) { | 255 set delegate({{interface|name}} d) { |
| 229 assert(_delegate == null); | 256 assert(_delegate == null); |
| 230 _delegate = d; | 257 _delegate = d; |
| 231 } | 258 } |
| 232 } | 259 } |
| OLD | NEW |