Chromium Code Reviews| Index: mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl |
| diff --git a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl |
| index d46f8eeac9ce86a90c5dc48f7c162ff9f61aac02..544b0e29354fec006bfe7437c87a65d408bb0130 100644 |
| --- a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl |
| +++ b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl |
| @@ -108,6 +108,55 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%} |
| } |
| }; |
| +{#--- Validation #} |
| + |
| + function validate{{interface.name}}Request(messageValidator) { |
| +{%- if not(interface.methods) %} |
| + return validator.validationError.NONE; |
| +{%- else %} |
| + var message = messageValidator.message; |
| + var paramsClass = null; |
| + switch (message.getName()) { |
| +{%- for method in interface.methods %} |
|
yzshen1
2014/08/14 18:02:21
Please consider the following way of indentation:
hansmuller
2014/08/14 23:51:46
Done.
|
| + case k{{interface.name}}_{{method.name}}_Name: |
| +{%- if method.response_parameters == None %} |
| + if (!message.expectsResponse() && !message.isResponse()) |
| + paramsClass = {{interface.name}}_{{method.name}}_Params; |
| +{%- else %} |
|
yzshen1
2014/08/14 18:02:21
Inconsistent indent, this else corresponds to line
hansmuller
2014/08/14 23:51:45
Done.
|
| + if (message.expectsResponse()) |
| + paramsClass = {{interface.name}}_{{method.name}}_Params; |
| +{%- endif %} |
| + break; |
| +{%- endfor %} |
| + } |
| + if (paramsClass === null) |
| + return validator.validationError.NONE; |
| + return paramsClass.validate(messageValidator, codec.kMessageHeaderSize); |
|
yzshen1
2014/08/14 18:02:21
This is incorrect:
The message header may contain
hansmuller
2014/08/14 23:51:45
Done.
|
| +{%- endif %} |
| + } |
| + |
| + function validate{{interface.name}}Response(messageValidator) { |
| +{%- if not(interface|has_callbacks) %} |
| + return validator.validationError.NONE; |
| +{%- else %} |
| + var message = messageValidator.message; |
| + var paramsClass = null; |
| + switch (message.getName()) { |
| +{%- for method in interface.methods %} |
| +{%- if method.response_parameters != None %} |
| + case k{{interface.name}}_{{method.name}}_Name: |
| + if (message.isResponse()) |
| + paramsClass = {{interface.name}}_{{method.name}}_ResponseParams; |
| + break; |
| +{%- endif %} |
| +{%- endfor %} |
| + } |
| + if (paramsClass === null) |
| + return validator.validationError.NONE; |
| + return paramsClass.validate(messageValidator, codec.kMessageWithRequestIDHeaderSize); |
|
yzshen1
2014/08/14 18:02:21
- 80 chars?
- The offset is incorrect, please see
hansmuller
2014/08/14 23:51:45
The existing templates don't strictly adhere to th
|
| +{%- endif %} |
| + } |
| + |
| {#--- Enums #} |
| {% from "enum_definition.tmpl" import enum_def -%} |
| {% for enum in interface.enums %} |