| Index: third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
|
| diff --git a/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py b/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
|
| index ffb64e78b22f5bdbdc1f73c55a94f90bdf2b3683..401c399e9e62afd9e54de5196d85ea5eb3f97a9c 100644
|
| --- a/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
|
| +++ b/third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py
|
| @@ -12,20 +12,14 @@
|
| import mojom.fileutil as fileutil
|
| import pack
|
|
|
| -def _GetDataHeader(exported, struct):
|
| - struct.packed = pack.PackedStruct(struct)
|
| - struct.bytes = pack.GetByteLayout(struct.packed)
|
| - struct.versions = pack.GetVersionInfo(struct.packed)
|
| - struct.exported = exported
|
| - return struct
|
| -
|
| def GetStructFromMethod(method):
|
| """Converts a method's parameters into the fields of a struct."""
|
| params_class = "%s_%s_Params" % (method.interface.name, method.name)
|
| struct = mojom.Struct(params_class, module=method.interface.module)
|
| for param in method.parameters:
|
| struct.AddField(param.name, param.kind, param.ordinal)
|
| - return _GetDataHeader(False, struct)
|
| + struct.packed = pack.PackedStruct(struct)
|
| + return struct
|
|
|
| def GetResponseStructFromMethod(method):
|
| """Converts a method's response_parameters into the fields of a struct."""
|
| @@ -33,7 +27,14 @@
|
| struct = mojom.Struct(params_class, module=method.interface.module)
|
| for param in method.response_parameters:
|
| struct.AddField(param.name, param.kind, param.ordinal)
|
| - return _GetDataHeader(False, struct)
|
| + struct.packed = pack.PackedStruct(struct)
|
| + return struct
|
| +
|
| +def GetDataHeader(exported, struct):
|
| + struct.packed = pack.PackedStruct(struct)
|
| + struct.bytes = pack.GetByteLayout(struct.packed)
|
| + struct.exported = exported
|
| + return struct
|
|
|
| def ExpectedArraySize(kind):
|
| if mojom.IsArrayKind(kind):
|
| @@ -46,10 +47,6 @@
|
| def CamelCaseToAllCaps(camel_case):
|
| return '_'.join(
|
| word for word in re.split(r'([A-Z][^A-Z]+)', camel_case) if word).upper()
|
| -
|
| -def UnderToCamel(under):
|
| - """Converts underscore_separated strings to CamelCase strings."""
|
| - return ''.join(word.capitalize() for word in under.split('_'))
|
|
|
| def WriteFile(contents, full_path):
|
| # Make sure the containing directory exists.
|
| @@ -74,10 +71,10 @@
|
| result.append(GetStructFromMethod(method))
|
| if method.response_parameters != None:
|
| result.append(GetResponseStructFromMethod(method))
|
| - return result
|
| + return map(partial(GetDataHeader, False), result)
|
|
|
| def GetStructs(self):
|
| - return map(partial(_GetDataHeader, True), self.module.structs)
|
| + return map(partial(GetDataHeader, True), self.module.structs)
|
|
|
| # Prepend the filename with a directory that matches the directory of the
|
| # original .mojom file, relative to the import root.
|
|
|