| Index: mojo/public/tools/bindings/pylib/mojom/generate/module.py
|
| diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/module.py b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
|
| index ec03b7f32fe930cfcf57c977685f712730633dda..8dde90509510e56795f96a10834a8ee90c2ae9d9 100644
|
| --- a/mojo/public/tools/bindings/pylib/mojom/generate/module.py
|
| +++ b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
|
| @@ -228,6 +228,31 @@ class FixedArray(ReferenceKind):
|
| self.length = length
|
|
|
|
|
| +class Map(ReferenceKind):
|
| + ReferenceKind.AddSharedProperty('key_kind')
|
| + ReferenceKind.AddSharedProperty('value_kind')
|
| +
|
| + def __init__(self, key_kind=None, value_kind=None):
|
| + if (key_kind is not None and value_kind is not None):
|
| + ReferenceKind.__init__(self,
|
| + 'm[' + key_kind.spec + '][' + value_kind.spec +
|
| + ']')
|
| + if IsNullableKind(key_kind):
|
| + raise Exception("Nullable kinds can not be keys in maps.")
|
| + if IsStructKind(key_kind):
|
| + # TODO(erg): It would sometimes be nice if we could key on struct
|
| + # values. However, what happens if the struct has a handle in it? Or
|
| + # non-copyable data like an array?
|
| + raise Exception("Structs can not be keys in maps.")
|
| + if IsHandleKind(key_kind):
|
| + raise Exception("Handles can not be keys in maps.")
|
| + else:
|
| + ReferenceKind.__init__(self)
|
| +
|
| + self.key_kind = key_kind
|
| + self.value_kind = value_kind
|
| +
|
| +
|
| class InterfaceRequest(ReferenceKind):
|
| ReferenceKind.AddSharedProperty('kind')
|
|
|
| @@ -399,10 +424,14 @@ def IsAnyArrayKind(kind):
|
| return IsArrayKind(kind) or IsFixedArrayKind(kind)
|
|
|
|
|
| -def IsObjectKind(kind):
|
| - return IsStructKind(kind) or IsAnyArrayKind(kind) or IsStringKind(kind)
|
| +def IsMapKind(kind):
|
| + return isinstance(kind, Map)
|
|
|
|
|
| +def IsObjectKind(kind):
|
| + return (IsStructKind(kind) or IsAnyArrayKind(kind) or IsStringKind(kind) or
|
| + IsMapKind(kind))
|
| +
|
| def IsNonInterfaceHandleKind(kind):
|
| return (IsHandleKind(kind) or
|
| IsDataPipeConsumerKind(kind) or
|
|
|