| 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 de906690344d6b1db2664376002d81b77bae5c6a..901405bb5398ffbc179e4b0efd9a3ffef7a826d2 100644
|
| --- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
|
| +++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py
|
| @@ -172,6 +172,44 @@ def IsNativeOnlyKind(kind):
|
| return (mojom.IsStructKind(kind) or mojom.IsEnumKind(kind)) and \
|
| kind.native_only
|
|
|
| +
|
| +def IsHashableKind(kind):
|
| + """Check if the kind can be hashed.
|
| +
|
| + Args:
|
| + kind: {Kind} The kind to check.
|
| +
|
| + Returns:
|
| + {bool} True if a value of this kind can be hashed.
|
| + """
|
| + checked = set()
|
| + def Check(kind):
|
| + if kind.spec in checked:
|
| + return True
|
| + checked.add(kind.spec)
|
| + if mojom.IsNullableKind(kind):
|
| + return False
|
| + elif mojom.IsStructKind(kind):
|
| + if (kind.native_only or
|
| + (IsTypemappedKind(kind) and
|
| + not _current_typemap[GetFullMojomNameForKind(kind)]["hashable"])):
|
| + return False
|
| + return all(Check(field.kind) for field in kind.fields)
|
| + elif mojom.IsUnionKind(kind):
|
| + return all(Check(field.kind) for field in kind.fields)
|
| + elif mojom.IsAnyHandleKind(kind):
|
| + return False
|
| + elif mojom.IsAnyInterfaceKind(kind):
|
| + return False
|
| + elif mojom.IsArrayKind(kind):
|
| + return False
|
| + elif mojom.IsMapKind(kind):
|
| + return False
|
| + else:
|
| + return True
|
| + return Check(kind)
|
| +
|
| +
|
| def GetNativeTypeName(typemapped_kind):
|
| return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"]
|
|
|
| @@ -465,6 +503,7 @@ class Generator(generator.Generator):
|
|
|
| cpp_filters = {
|
| "constant_value": ConstantValue,
|
| + "contains_handles": mojom.ContainsHandles,
|
| "contains_move_only_members": ContainsMoveOnlyMembers,
|
| "cpp_wrapper_param_type": GetCppWrapperParamType,
|
| "cpp_data_view_type": GetCppDataViewType,
|
| @@ -493,6 +532,7 @@ class Generator(generator.Generator):
|
| "is_any_interface_kind": mojom.IsAnyInterfaceKind,
|
| "is_any_handle_or_interface_kind": mojom.IsAnyHandleOrInterfaceKind,
|
| "is_associated_kind": mojom.IsAssociatedKind,
|
| + "is_hashable": IsHashableKind,
|
| "is_map_kind": mojom.IsMapKind,
|
| "is_nullable_kind": mojom.IsNullableKind,
|
| "is_object_kind": mojom.IsObjectKind,
|
|
|