| 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 52d380aa2e7964b2b853ce7675eec3d96c923e3a..6b7492d5bccd9f3b43cc4872b713e95aea2b3e96 100644 | 
| --- a/mojo/public/tools/bindings/generators/mojom_cpp_generator.py | 
| +++ b/mojo/public/tools/bindings/generators/mojom_cpp_generator.py | 
| @@ -37,8 +37,8 @@ def GetNameForKind(kind, internal = False): | 
| parts = [] | 
| if kind.imported_from: | 
| parts.extend(NamespaceToArray(kind.imported_from["namespace"])) | 
| -    if internal: | 
| -      parts.append("internal") | 
| +  if internal: | 
| +    parts.append("internal") | 
| if kind.parent_kind: | 
| parts.append(kind.parent_kind.name) | 
| parts.append(kind.name) | 
| @@ -63,21 +63,35 @@ def GetCppPodType(kind): | 
| return _kind_to_cpp_type[kind] | 
|  | 
| def GetCppArrayArgWrapperType(kind): | 
| -  if isinstance(kind, (mojom.Struct, mojom.Enum)): | 
| +  if isinstance(kind, mojom.Enum): | 
| return GetNameForKind(kind) | 
| +  if isinstance(kind, mojom.Struct): | 
| +    return "%sPtr" % GetNameForKind(kind) | 
| if isinstance(kind, mojom.Array): | 
| -    return "mojo::Array<%s >" % GetCppArrayArgWrapperType(kind.kind) | 
| +    return "mojo::Array<%s> " % GetCppArrayArgWrapperType(kind.kind) | 
| if isinstance(kind, mojom.Interface): | 
| raise Exception("Arrays of interfaces not yet supported!") | 
| if kind.spec == 's': | 
| return "mojo::String" | 
| +  if kind.spec == 'h': | 
| +    return "mojo::ScopedHandle" | 
| +  if kind.spec == 'h:d:c': | 
| +    return "mojo::ScopedDataPipeConsumerHandle" | 
| +  if kind.spec == 'h:d:p': | 
| +    return "mojo::ScopedDataPipeProducerHandle" | 
| +  if kind.spec == 'h:m': | 
| +    return "mojo::ScopedMessagePipeHandle" | 
| +  if kind.spec == 'h:s': | 
| +    return "mojo::ScopedSharedBufferHandle" | 
| return _kind_to_cpp_type[kind] | 
|  | 
| def GetCppResultWrapperType(kind): | 
| -  if isinstance(kind, (mojom.Struct, mojom.Enum)): | 
| +  if isinstance(kind, mojom.Enum): | 
| return GetNameForKind(kind) | 
| +  if isinstance(kind, mojom.Struct): | 
| +    return "%sPtr" % GetNameForKind(kind) | 
| if isinstance(kind, mojom.Array): | 
| -    return "mojo::Array<%s >" % GetCppArrayArgWrapperType(kind.kind) | 
| +    return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) | 
| if isinstance(kind, mojom.Interface): | 
| return "%sPtr" % kind.name | 
| if kind.spec == 's': | 
| @@ -95,23 +109,33 @@ def GetCppResultWrapperType(kind): | 
| return _kind_to_cpp_type[kind] | 
|  | 
| def GetCppWrapperType(kind): | 
| -  if isinstance(kind, (mojom.Struct, mojom.Enum)): | 
| +  if isinstance(kind, mojom.Enum): | 
| return GetNameForKind(kind) | 
| +  if isinstance(kind, mojom.Struct): | 
| +    return "%sPtr" % GetNameForKind(kind) | 
| if isinstance(kind, mojom.Array): | 
| -    return "mojo::Array<%s >" % GetCppArrayArgWrapperType(kind.kind) | 
| +    return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) | 
| if isinstance(kind, mojom.Interface): | 
| -    return "mojo::Passable<mojo::MessagePipeHandle>" | 
| +    return "mojo::ScopedMessagePipeHandle" | 
| if kind.spec == 's': | 
| return "mojo::String" | 
| -  if generator.IsHandleKind(kind): | 
| -    return "mojo::Passable<%s>" % _kind_to_cpp_type[kind] | 
| +  if kind.spec == 'h': | 
| +    return "mojo::ScopedHandle" | 
| +  if kind.spec == 'h:d:c': | 
| +    return "mojo::ScopedDataPipeConsumerHandle" | 
| +  if kind.spec == 'h:d:p': | 
| +    return "mojo::ScopedDataPipeProducerHandle" | 
| +  if kind.spec == 'h:m': | 
| +    return "mojo::ScopedMessagePipeHandle" | 
| +  if kind.spec == 'h:s': | 
| +    return "mojo::ScopedSharedBufferHandle" | 
| return _kind_to_cpp_type[kind] | 
|  | 
| def GetCppConstWrapperType(kind): | 
| if isinstance(kind, mojom.Struct): | 
| -    return "const %s&" % GetNameForKind(kind) | 
| +    return "%sPtr" % GetNameForKind(kind) | 
| if isinstance(kind, mojom.Array): | 
| -    return "const mojo::Array<%s >&" % GetCppArrayArgWrapperType(kind.kind) | 
| +    return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) | 
| if isinstance(kind, mojom.Interface): | 
| return "%sPtr" % kind.name | 
| if isinstance(kind, mojom.Enum): | 
| @@ -177,6 +201,15 @@ def HasCallbacks(interface): | 
| return True | 
| return False | 
|  | 
| +def ShouldInlineStruct(struct): | 
| +  # TODO(darin): Base this on the size of the wrapper class. | 
| +  if len(struct.fields) > 4: | 
| +    return False | 
| +  for field in struct.fields: | 
| +    if generator.IsHandleKind(field.kind) or generator.IsObjectKind(field.kind): | 
| +      return False | 
| +  return True | 
| + | 
| _HEADER_SIZE = 8 | 
|  | 
| class Generator(generator.Generator): | 
| @@ -191,7 +224,9 @@ class Generator(generator.Generator): | 
| "expression_to_text": ExpressionToText, | 
| "get_pad": pack.GetPad, | 
| "has_callbacks": HasCallbacks, | 
| +    "should_inline": ShouldInlineStruct, | 
| "is_enum_kind": generator.IsEnumKind, | 
| +    "is_move_only_kind": generator.IsMoveOnlyKind, | 
| "is_handle_kind": generator.IsHandleKind, | 
| "is_interface_kind": generator.IsInterfaceKind, | 
| "is_object_kind": generator.IsObjectKind, | 
|  |