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

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

Issue 1618963006: Mojo C++ bindings: support enum validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 5cb1dc8b68d1293e50013ac5e27ef1dafea74bb9..99731fb5e0a3bb9d3a959c27283416a950920c71 100644
--- a/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl
+++ b/mojo/public/tools/bindings/generators/cpp_templates/validation_macros.tmpl
@@ -41,6 +41,11 @@ if (!{{field.kind|cpp_wrapper_type}}::Data_::Validate(
}
{%- endmacro -%}
+{%- macro validate_enum(field_expr, field) -%}
+if (!mojo::internal::ValidateEnum(*{{field_expr}}))
+ return false;
+{%- endmacro -%}
+
{%- macro validate_union_field(field, union) %}
{%- set field_expr = "(reinterpret_cast<const "
~ field.kind|cpp_union_field_type
@@ -61,5 +66,9 @@ if (!{{field.kind|cpp_wrapper_type}}::Data_::Validate(
{%- if field.kind|is_any_handle_kind -%}
{{ validate_handle(field_expr, field, union.name) }}
{%- endif %}
+
+{%- if field.kind|is_enum_kind -%}
+{{ validate_enum(field_expr, field) }}
+{%- endif %}
return true;
{%- endmacro %}

Powered by Google App Engine
This is Rietveld 408576698