OLD | NEW |
1 {%- set namespace_as_string = namespace|replace(".","::") %} | |
2 {%- for method in interface.methods %} | 1 {%- for method in interface.methods %} |
3 var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}}; | 2 var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}}; |
4 {%- endfor %} | 3 {%- endfor %} |
5 | 4 |
6 function {{interface.name}}Proxy(receiver) { | 5 function {{interface.name}}Proxy(receiver) { |
7 this.receiver_ = receiver; | 6 this.receiver_ = receiver; |
8 } | 7 } |
9 | 8 |
10 {{interface.name}}Proxy.NAME_ = '{{namespace_as_string}}::{{interface.name}}'; | |
11 | |
12 {%- for method in interface.methods %} | 9 {%- for method in interface.methods %} |
13 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( | 10 {{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function( |
14 {%- for parameter in method.parameters -%} | 11 {%- for parameter in method.parameters -%} |
15 {{parameter.name}}{% if not loop.last %}, {% endif %} | 12 {{parameter.name}}{% if not loop.last %}, {% endif %} |
16 {%- endfor -%} | 13 {%- endfor -%} |
17 ) { | 14 ) { |
18 var params = new {{interface.name}}_{{method.name}}_Params(); | 15 var params = new {{interface.name}}_{{method.name}}_Params(); |
19 {%- for parameter in method.parameters %} | 16 {%- for parameter in method.parameters %} |
20 params.{{parameter.name}} = {{parameter.name}}; | 17 params.{{parameter.name}} = {{parameter.name}}; |
21 {%- endfor %} | 18 {%- endfor %} |
(...skipping 25 matching lines...) Expand all Loading... |
47 }, | 44 }, |
48 }).catch(reject); | 45 }).catch(reject); |
49 }.bind(this)); | 46 }.bind(this)); |
50 {%- endif %} | 47 {%- endif %} |
51 }; | 48 }; |
52 {%- endfor %} | 49 {%- endfor %} |
53 | 50 |
54 function {{interface.name}}Stub() { | 51 function {{interface.name}}Stub() { |
55 } | 52 } |
56 | 53 |
57 {{interface.name}}Stub.NAME_ = '{{namespace_as_string}}::{{interface.name}}'; | |
58 | |
59 {{interface.name}}Stub.prototype.accept = function(message) { | 54 {{interface.name}}Stub.prototype.accept = function(message) { |
60 var reader = new codec.MessageReader(message); | 55 var reader = new codec.MessageReader(message); |
61 switch (reader.messageName) { | 56 switch (reader.messageName) { |
62 {%- for method in interface.methods %} | 57 {%- for method in interface.methods %} |
63 {%- if method.response_parameters == None %} | 58 {%- if method.response_parameters == None %} |
64 case k{{interface.name}}_{{method.name}}_Name: | 59 case k{{interface.name}}_{{method.name}}_Name: |
65 var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params
); | 60 var params = reader.decodeStruct({{interface.name}}_{{method.name}}_Params
); |
66 this.{{method.name|stylize_method}}( | 61 this.{{method.name|stylize_method}}( |
67 {%- for parameter in method.parameters -%} | 62 {%- for parameter in method.parameters -%} |
68 params.{{parameter.name}}{% if not loop.last %}, {% endif %} | 63 params.{{parameter.name}}{% if not loop.last %}, {% endif %} |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 break; | 145 break; |
151 {%- endif %} | 146 {%- endif %} |
152 {%- endfor %} | 147 {%- endfor %} |
153 } | 148 } |
154 if (paramsClass === null) | 149 if (paramsClass === null) |
155 return validator.validationError.NONE; | 150 return validator.validationError.NONE; |
156 return paramsClass.validate(messageValidator, messageValidator.message.getHe
aderNumBytes()); | 151 return paramsClass.validate(messageValidator, messageValidator.message.getHe
aderNumBytes()); |
157 {%- endif %} | 152 {%- endif %} |
158 } | 153 } |
159 | 154 |
| 155 var {{interface.name}} = { |
| 156 name: '{{namespace|replace(".","::")}}::{{interface.name}}', |
| 157 proxyClass: {{interface.name}}Proxy, |
| 158 stubClass: {{interface.name}}Stub, |
| 159 validateRequest: validate{{interface.name}}Request, |
| 160 {%- if interface|has_callbacks %} |
| 161 validateResponse: validate{{interface.name}}Response, |
| 162 {%- else %} |
| 163 validateResponse: null, |
| 164 {%- endif %} |
| 165 }; |
| 166 {#--- Interface Constants #} |
| 167 {%- for constant in interface.constants %} |
| 168 {{interface.name}}.{{constant.name}} = {{constant.value|expression_to_text}}, |
| 169 {%- endfor %} |
| 170 {#--- Interface Enums #} |
| 171 {%- from "enum_definition.tmpl" import enum_def -%} |
| 172 {%- for enum in interface.enums %} |
| 173 {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }} |
| 174 {%- endfor %} |
160 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request
; | 175 {{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request
; |
161 {%- if interface|has_callbacks %} | 176 {%- if interface|has_callbacks %} |
162 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon
se; | 177 {{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Respon
se; |
163 {%- else %} | 178 {%- else %} |
164 {{interface.name}}Proxy.prototype.validator = null; | 179 {{interface.name}}Proxy.prototype.validator = null; |
165 {%- endif -%} | 180 {%- endif %} |
166 | |
167 {#--- Enums #} | |
168 {% from "enum_definition.tmpl" import enum_def -%} | |
169 {% for enum in interface.enums %} | |
170 {{enum_def("%sProxy.%s"|format(interface.name, enum.name), enum, module)}} | |
171 {{interface.name}}Stub.{{enum.name}} = {{interface.name}}Proxy.{{enum.name}}; | |
172 {%- endfor %} | |
173 | |
174 {#--- Constants. #} | |
175 {% for constant in interface.constants %} | |
176 {{interface.name}}Proxy.{{constant.name}} = {{constant.value|expression_to_tex
t}}; | |
177 {{interface.name}}Stub.{{constant.name}} = {{interface.name}}Proxy.{{constant.
name}}; | |
178 {%- endfor %} | |
OLD | NEW |