Index: mojo/public/tools/bindings/generators/mojom_cpp_generator.py |
diff --git a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py |
index d8e0491cc309d0f8475e7eab1b2139925e9b03b6..357c831e640c58bae140d72dd43a522efcf8dc0f 100644 |
--- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py |
+++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py |
@@ -383,16 +383,21 @@ def GetArrayValidateParamsCtorArgs(kind): |
if mojom.IsStringKind(kind): |
expected_num_elements = 0 |
element_is_nullable = False |
+ key_validate_params = "nullptr" |
element_validate_params = "nullptr" |
enum_validate_func = "nullptr" |
elif mojom.IsMapKind(kind): |
expected_num_elements = 0 |
- element_is_nullable = mojom.IsNullableKind(kind.value_kind) |
- element_validate_params = GetNewArrayValidateParams(kind.value_kind) |
+ element_is_nullable = False |
+ key_validate_params = GetNewArrayValidateParams(mojom.Array( |
+ kind=kind.key_kind)) |
+ element_validate_params = GetNewArrayValidateParams(mojom.Array( |
+ kind=kind.value_kind)) |
enum_validate_func = "nullptr" |
- else: |
+ else: # mojom.IsArrayKind(kind) |
expected_num_elements = generator.ExpectedArraySize(kind) or 0 |
element_is_nullable = mojom.IsNullableKind(kind.kind) |
+ key_validate_params = "nullptr" |
element_validate_params = GetNewArrayValidateParams(kind.kind) |
if mojom.IsEnumKind(kind.kind): |
enum_validate_func = ("%s::Validate" % |
@@ -401,9 +406,12 @@ def GetArrayValidateParamsCtorArgs(kind): |
enum_validate_func = "nullptr" |
if enum_validate_func == "nullptr": |
- return "%d, %s, %s" % (expected_num_elements, |
- "true" if element_is_nullable else "false", |
- element_validate_params) |
+ if key_validate_params == "nullptr": |
+ return "%d, %s, %s" % (expected_num_elements, |
+ "true" if element_is_nullable else "false", |
+ element_validate_params) |
+ else: |
+ return "%s, %s" % (key_validate_params, element_validate_params) |
else: |
return "%d, %s" % (expected_num_elements, enum_validate_func) |
@@ -415,13 +423,6 @@ def GetNewArrayValidateParams(kind): |
return "new mojo::internal::ArrayValidateParams(%s)" % ( |
GetArrayValidateParamsCtorArgs(kind)) |
-def GetMapValidateParamsCtorArgs(value_kind): |
- # Unlike GetArrayValidateParams, we are given the wrapped kind, instead of |
- # the raw array kind. So we wrap the return value of GetArrayValidateParams. |
- element_is_nullable = mojom.IsNullableKind(value_kind) |
- return "0, %s, %s" % ("true" if element_is_nullable else "false", |
- GetNewArrayValidateParams(value_kind)) |
- |
class Generator(generator.Generator): |
cpp_filters = { |
@@ -435,7 +436,6 @@ class Generator(generator.Generator): |
"default_value": DefaultValue, |
"expression_to_text": ExpressionToText, |
"get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs, |
- "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs, |
"get_name_for_kind": GetNameForKind, |
"get_pad": pack.GetPad, |
"get_qualified_name_for_kind": GetQualifiedNameForKind, |