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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl
index 8a8c5b0aca20d303addf6a625aabea223009370c..0d556a2d1d8509e5e48aa9811966006b12f42538 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl
@@ -8,12 +8,14 @@
{%- 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}}")) {
+ {{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}}")) {
+ {{field_expr}}, "null {{name}} field in {{object_name}}",
+ validation_context)) {
return false;
}
{%- endif %}
@@ -21,26 +23,27 @@
{%- if kind|is_array_kind or kind|is_string_kind %}
const mojo::internal::ContainerValidateParams {{name}}_validate_params(
{{kind|get_container_validate_params_ctor_args|indent(6)}});
- if (!mojo::internal::ValidateArray({{field_expr}}, bounds_checker,
+ if (!mojo::internal::ValidateArray({{field_expr}}, validation_context,
&{{name}}_validate_params)) {
return false;
}
{%- elif kind|is_map_kind %}
const mojo::internal::ContainerValidateParams {{name}}_validate_params(
{{kind|get_container_validate_params_ctor_args|indent(6)}});
- if (!mojo::internal::ValidateMap({{field_expr}}, bounds_checker,
+ if (!mojo::internal::ValidateMap({{field_expr}}, validation_context,
&{{name}}_validate_params)) {
return false;
}
{%- elif kind|is_struct_kind %}
- if (!mojo::internal::ValidateStruct({{field_expr}}, bounds_checker))
+ 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}}, bounds_checker))
+ if (!mojo::internal::ValidateInlinedUnion({{field_expr}}, validation_context))
return false;
{%- else %}
- if (!mojo::internal::ValidateNonInlinedUnion({{field_expr}}, bounds_checker))
+ if (!mojo::internal::ValidateNonInlinedUnion({{field_expr}},
+ validation_context))
return false;
{%- endif %}
{%- else %}
@@ -62,11 +65,11 @@
{%- if not kind|is_nullable_kind %}
if (!mojo::internal::ValidateHandleNonNullable(
{{name}}_handle,
- "invalid {{name}} field in {{object_name}}")) {
+ "invalid {{name}} field in {{object_name}}", validation_context)) {
return false;
}
{%- endif %}
- if (!mojo::internal::ValidateHandle({{name}}_handle, bounds_checker))
+ if (!mojo::internal::ValidateHandle({{name}}_handle, validation_context))
return false;
{%- endmacro %}
@@ -85,18 +88,21 @@
{%- if not kind|is_nullable_kind %}
if (!mojo::internal::ValidateInterfaceIdNonNullable(
{{name}}_interface_id,
- "invalid {{name}} field in {{object_name}}")) {
+ "invalid {{name}} field in {{object_name}}", validation_context)) {
return false;
}
{%- endif %}
- if (!mojo::internal::ValidateAssociatedInterfaceId({{name}}_interface_id))
+ if (!mojo::internal::ValidateAssociatedInterfaceId({{name}}_interface_id,
+ 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)}}::Validate({{field_expr}}))
+ if (!{{field.kind|get_qualified_name_for_kind(internal=True)}}
+ ::Validate({{field_expr}}, validation_context))
return false;
{%- endmacro %}
« no previous file with comments | « mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698