Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: mojo/public/tools/bindings/generators/js_templates/validation_macros.tmpl

Issue 2864753002: Mojo code generator: simplify how imported types and values are handled. (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {% macro _check_err() -%} 1 {% macro _check_err() -%}
2 if (err !== validator.validationError.NONE) 2 if (err !== validator.validationError.NONE)
3 return err; 3 return err;
4 {%- endmacro %} 4 {%- endmacro %}
5 5
6 {%- macro _validate_field(field, offset, name) %} 6 {%- macro _validate_field(field, offset, name) %}
7 {%- if field|is_string_pointer_field %} 7 {%- if field.kind|is_string_kind %}
8 // validate {{name}} 8 // validate {{name}}
9 err = messageValidator.validateStringPointer({{offset}}, {{field|validate_nullab le_params}}) 9 err = messageValidator.validateStringPointer({{offset}}, {{field|validate_nullab le_params}})
10 {{_check_err()}} 10 {{_check_err()}}
11 {%- elif field|is_array_pointer_field %} 11 {%- elif field.kind|is_array_kind %}
12 // validate {{name}} 12 // validate {{name}}
13 err = messageValidator.validateArrayPointer({{offset}}, {{field|validate_array_p arams}}); 13 err = messageValidator.validateArrayPointer({{offset}}, {{field|validate_array_p arams}});
14 {{_check_err()}} 14 {{_check_err()}}
15 {%- elif field|is_struct_pointer_field %} 15 {%- elif field.kind|is_struct_kind %}
16 // validate {{name}} 16 // validate {{name}}
17 err = messageValidator.validateStructPointer({{offset}}, {{field|validate_struct _params}}); 17 err = messageValidator.validateStructPointer({{offset}}, {{field|validate_struct _params}});
18 {{_check_err()}} 18 {{_check_err()}}
19 {%- elif field|is_map_pointer_field %} 19 {%- elif field.kind|is_map_kind %}
20 // validate {{name}} 20 // validate {{name}}
21 err = messageValidator.validateMapPointer({{offset}}, {{field|validate_map_param s}}); 21 err = messageValidator.validateMapPointer({{offset}}, {{field|validate_map_param s}});
22 {{_check_err()}} 22 {{_check_err()}}
23 {%- elif field|is_interface_field %} 23 {%- elif field.kind|is_interface_kind %}
24 // validate {{name}} 24 // validate {{name}}
25 err = messageValidator.validateInterface({{offset}}, {{field|validate_nullable_p arams}}); 25 err = messageValidator.validateInterface({{offset}}, {{field|validate_nullable_p arams}});
26 {{_check_err()}} 26 {{_check_err()}}
27 {%- elif field|is_interface_request_field %} 27 {%- elif field.kind|is_interface_request_kind %}
28 // validate {{name}} 28 // validate {{name}}
29 err = messageValidator.validateInterfaceRequest({{offset}}, {{field|validate_nul lable_params}}) 29 err = messageValidator.validateInterfaceRequest({{offset}}, {{field|validate_nul lable_params}})
30 {{_check_err()}} 30 {{_check_err()}}
31 {%- elif field|is_associated_interface_field %} 31 {%- elif field.kind|is_associated_interface_kind %}
32 // validate {{name}} 32 // validate {{name}}
33 err = messageValidator.validateAssociatedInterface({{offset}}, {{field|validate_ nullable_params}}); 33 err = messageValidator.validateAssociatedInterface({{offset}}, {{field|validate_ nullable_params}});
34 {{_check_err()}} 34 {{_check_err()}}
35 {%- elif field|is_associated_interface_request_field %} 35 {%- elif field.kind|is_associated_interface_request_kind %}
36 // validate {{name}} 36 // validate {{name}}
37 err = messageValidator.validateAssociatedInterfaceRequest({{offset}}, {{field|va lidate_nullable_params}}) 37 err = messageValidator.validateAssociatedInterfaceRequest({{offset}}, {{field|va lidate_nullable_params}})
38 {{_check_err()}} 38 {{_check_err()}}
39 {%- elif field|is_handle_field %} 39 {%- elif field.kind|is_any_handle_kind %}
40 // validate {{name}} 40 // validate {{name}}
41 err = messageValidator.validateHandle({{offset}}, {{field|validate_nullable_para ms}}) 41 err = messageValidator.validateHandle({{offset}}, {{field|validate_nullable_para ms}})
42 {{_check_err()}} 42 {{_check_err()}}
43 {%- elif field|is_enum_field %} 43 {%- elif field.kind|is_enum_kind %}
44 // validate {{name}} 44 // validate {{name}}
45 err = messageValidator.validateEnum({{offset}}, {{field|validate_enum_params}}); 45 err = messageValidator.validateEnum({{offset}}, {{field|validate_enum_params}});
46 {{_check_err()}} 46 {{_check_err()}}
47 {%- endif %} 47 {%- endif %}
48 {%- endmacro %} 48 {%- endmacro %}
49 49
50 {%- macro validate_struct_field(field, offset, name) %} 50 {%- macro validate_struct_field(field, offset, name) %}
51 {%- if field|is_union_field %} 51 {%- if field.kind|is_union_kind %}
52 // validate {{name}} 52 // validate {{name}}
53 err = messageValidator.validateUnion({{offset}}, {{field|validate_union_params}} ); 53 err = messageValidator.validateUnion({{offset}}, {{field|validate_union_params}} );
54 {{_check_err()}} 54 {{_check_err()}}
55 {%- else %} 55 {%- else %}
56 {{_validate_field(field, offset, name)}} 56 {{_validate_field(field, offset, name)}}
57 {%- endif %} 57 {%- endif %}
58 {%- endmacro %} 58 {%- endmacro %}
59 59
60 {%- macro validate_union_field(field, offset, name) %} 60 {%- macro validate_union_field(field, offset, name) %}
61 {%- if field|is_union_field %} 61 {%- if field.kind|is_union_kind %}
62 // validate {{name}} 62 // validate {{name}}
63 err = messageValidator.validateNestedUnion({{offset}}, {{field|validate_union_pa rams}}); 63 err = messageValidator.validateNestedUnion({{offset}}, {{field|validate_union_pa rams}});
64 {{_check_err()}} 64 {{_check_err()}}
65 {%- else %} 65 {%- else %}
66 {{_validate_field(field, offset, name)}} 66 {{_validate_field(field, offset, name)}}
67 {%- endif %} 67 {%- endif %}
68 {%- endmacro %} 68 {%- endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698