Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {%- for method in interface.methods %} | 1 {%- for method in interface.methods %} |
| 2 var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}}; | 2 var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}}; |
| 3 {%- endfor %} | 3 {%- endfor %} |
| 4 | 4 |
| 5 function {{interface.name}}Proxy(receiver) { | 5 function {{interface.name}}Proxy(receiver) { |
| 6 this.receiver_ = receiver; | 6 this.receiver_ = receiver; |
| 7 } | 7 } |
| 8 | 8 |
| 9 {%- for method in interface.methods %} | 9 {%- for method in interface.methods %} |
| 10 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( | 10 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 var message = builder.finish(); | 96 var message = builder.finish(); |
| 97 responder.accept(message); | 97 responder.accept(message); |
| 98 }); | 98 }); |
| 99 {%- endif %} | 99 {%- endif %} |
| 100 {%- endfor %} | 100 {%- endfor %} |
| 101 default: | 101 default: |
| 102 return Promise.reject(Error("Unhandled message: " + reader.messageName)); | 102 return Promise.reject(Error("Unhandled message: " + reader.messageName)); |
| 103 } | 103 } |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 function {{interface.name}}DelegatingStub() { | |
| 107 } | |
| 108 | |
| 109 {{interface.name}}DelegatingStub.prototype = | |
| 110 Object.create({{interface.name}}Stub.prototype); | |
|
abarth-chromium
2014/10/10 17:45:07
It would be nice if the main stub was delegating i
| |
| 111 | |
| 112 {{interface.name}}DelegatingStub.prototype.callDelegateMethod$ = function(meth odName, args) { | |
| 113 var method = this.delegate$ && this.delegate$[methodName]; | |
| 114 return method && method.apply(this.delegate$, args); | |
| 115 } | |
| 116 | |
| 117 {%- for method in interface.methods %} | |
| 118 {%- set method_name = method.name|stylize_method %} | |
| 119 {{interface.name}}DelegatingStub.prototype.{{method_name}} = function() { | |
| 120 return this.callDelegateMethod$("{{method_name}}", arguments); | |
| 121 } | |
| 122 {%- endfor %} | |
|
abarth-chromium
2014/10/10 17:45:07
When we merge DelegatingStub into the Sub, we shou
| |
| 123 | |
| 106 {#--- Validation #} | 124 {#--- Validation #} |
| 107 | 125 |
| 108 function validate{{interface.name}}Request(messageValidator) { | 126 function validate{{interface.name}}Request(messageValidator) { |
| 109 {%- if not(interface.methods) %} | 127 {%- if not(interface.methods) %} |
| 110 return validator.validationError.NONE; | 128 return validator.validationError.NONE; |
| 111 {%- else %} | 129 {%- else %} |
| 112 var message = messageValidator.message; | 130 var message = messageValidator.message; |
| 113 var paramsClass = null; | 131 var paramsClass = null; |
| 114 switch (message.getName()) { | 132 switch (message.getName()) { |
| 115 {%- for method in interface.methods %} | 133 {%- for method in interface.methods %} |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 if (paramsClass === null) | 167 if (paramsClass === null) |
| 150 return validator.validationError.NONE; | 168 return validator.validationError.NONE; |
| 151 return paramsClass.validate(messageValidator, messageValidator.message.getHe aderNumBytes()); | 169 return paramsClass.validate(messageValidator, messageValidator.message.getHe aderNumBytes()); |
| 152 {%- endif %} | 170 {%- endif %} |
| 153 } | 171 } |
| 154 | 172 |
| 155 var {{interface.name}} = { | 173 var {{interface.name}} = { |
| 156 name: '{{namespace|replace(".","::")}}::{{interface.name}}', | 174 name: '{{namespace|replace(".","::")}}::{{interface.name}}', |
| 157 proxyClass: {{interface.name}}Proxy, | 175 proxyClass: {{interface.name}}Proxy, |
| 158 stubClass: {{interface.name}}Stub, | 176 stubClass: {{interface.name}}Stub, |
| 177 delegatingStubClass: {{interface.name}}DelegatingStub, | |
| 159 validateRequest: validate{{interface.name}}Request, | 178 validateRequest: validate{{interface.name}}Request, |
| 160 {%- if interface|has_callbacks %} | 179 {%- if interface|has_callbacks %} |
| 161 validateResponse: validate{{interface.name}}Response, | 180 validateResponse: validate{{interface.name}}Response, |
| 162 {%- else %} | 181 {%- else %} |
| 163 validateResponse: null, | 182 validateResponse: null, |
| 164 {%- endif %} | 183 {%- endif %} |
| 165 }; | 184 }; |
| 166 {#--- Interface Constants #} | 185 {#--- Interface Constants #} |
| 167 {%- for constant in interface.constants %} | 186 {%- for constant in interface.constants %} |
| 168 {{interface.name}}.{{constant.name}} = {{constant.value|expression_to_text}}, | 187 {{interface.name}}.{{constant.name}} = {{constant.value|expression_to_text}}, |
| 169 {%- endfor %} | 188 {%- endfor %} |
| 170 {#--- Interface Enums #} | 189 {#--- Interface Enums #} |
| 171 {%- from "enum_definition.tmpl" import enum_def -%} | 190 {%- from "enum_definition.tmpl" import enum_def -%} |
| 172 {%- for enum in interface.enums %} | 191 {%- for enum in interface.enums %} |
| 173 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }} | 192 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }} |
| 174 {%- endfor %} | 193 {%- endfor %} |
| 175 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ; | 194 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request ; |
| 176 {%- if interface|has_callbacks %} | 195 {%- if interface|has_callbacks %} |
| 177 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se; | 196 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon se; |
| 178 {%- else %} | 197 {%- else %} |
| 179 {{interface.name}}Proxy.prototype.validator = null; | 198 {{interface.name}}Proxy.prototype.validator = null; |
| 180 {%- endif %} | 199 {%- endif %} |
| OLD | NEW |