diff options
Diffstat (limited to 'mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl')
-rw-r--r-- | mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl deleted file mode 100644 index a50a585..0000000 --- a/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl +++ /dev/null @@ -1,82 +0,0 @@ -{#- Validates the specified field, which is supposed to be an object - (struct/array/string/map/union). If it is a union, |union_is_inlined| - indicates whether the union is inlined. (Nested unions are not inlined.) - This macro is expanded by the Validate() method. #} -{%- macro validate_object(field, field_expr, object_name, union_is_inlined) %} -{%- set name = field.name %} -{%- set kind = field.kind %} -{%- if not kind|is_nullable_kind %} -{%- if kind|is_union_kind and union_is_inlined %} - if (!mojo::internal::ValidateInlinedUnionNonNullable( - {{field_expr}}, "null {{name}} field in {{object_name}}", - validation_context)) { - return false; - } -{%- else %} - if (!mojo::internal::ValidatePointerNonNullable( - {{field_expr}}, "null {{name}} field in {{object_name}}", - validation_context)) { - return false; - } -{%- endif %} -{%- endif %} -{%- if kind|is_array_kind or kind|is_string_kind or kind|is_map_kind %} - const mojo::internal::ContainerValidateParams {{name}}_validate_params( - {{kind|get_container_validate_params_ctor_args|indent(6)}}); - if (!mojo::internal::ValidateContainer({{field_expr}}, validation_context, - &{{name}}_validate_params)) { - return false; - } -{%- elif kind|is_struct_kind %} - if (!mojo::internal::ValidateStruct({{field_expr}}, validation_context)) - return false; -{%- elif kind|is_union_kind %} -{%- if union_is_inlined %} - if (!mojo::internal::ValidateInlinedUnion({{field_expr}}, validation_context)) - return false; -{%- else %} - if (!mojo::internal::ValidateNonInlinedUnion({{field_expr}}, - validation_context)) - return false; -{%- endif %} -{%- else %} -#error Not reached! -{%- endif %} -{%- endmacro %} - -{#- Validates the specified field, which is supposed to be a handle, - an interface, an associated interface or an associated interface request. - This macro is expanded by the Validate() method. #} -{%- macro validate_handle_or_interface(field, field_expr, object_name) %} -{%- set name = field.name %} -{%- set kind = field.kind %} -{%- if not kind|is_nullable_kind %} - if (!mojo::internal::ValidateHandleOrInterfaceNonNullable( - {{field_expr}}, - "invalid {{name}} field in {{object_name}}", validation_context)) { - return false; - } -{%- endif %} - if (!mojo::internal::ValidateHandleOrInterface({{field_expr}}, - validation_context)) { - return false; - } -{%- endmacro %} - -{#- Validates the specified field, which is supposed to be an enum. - This macro is expanded by the Validate() method. #} -{%- macro validate_enum(field, field_expr) %} - if (!{{field.kind|get_qualified_name_for_kind(internal=True,flatten_nested_kind=True)}} - ::Validate({{field_expr}}, validation_context)) - return false; -{%- endmacro %} - -{%- macro validate_field(field, field_expr, object_name, union_is_inlined) %} -{%- if field.kind|is_object_kind -%} -{{validate_object(field, field_expr, object_name, union_is_inlined)}} -{%- elif field.kind|is_any_handle_or_interface_kind -%} -{{validate_handle_or_interface(field, field_expr, object_name)}} -{%- elif field.kind|is_enum_kind %} -{{validate_enum(field, field_expr)}} -{%- endif %} -{%- endmacro %} |