Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1043)

Unified Diff: third_party/mojo/src/mojo/public/tools/bindings/pylib/mojom/generate/generator.py

Issue 910883002: Update mojo sdk to rev 8af2ccff2eee4bfca1043015abee30482a030b30 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply 9f87aeadbda22441b7d469e596f7bd7d0d73e2a8 (https://codereview.chromium.org/908973002/) Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 401c399e9e62afd9e54de5196d85ea5eb3f97a9c..ffb64e78b22f5bdbdc1f73c55a94f90bdf2b3683 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,14 +12,20 @@ import module as mojom
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)
- struct.packed = pack.PackedStruct(struct)
- return struct
+ return _GetDataHeader(False, struct)
def GetResponseStructFromMethod(method):
"""Converts a method's response_parameters into the fields of a struct."""
@@ -27,14 +33,7 @@ def GetResponseStructFromMethod(method):
struct = mojom.Struct(params_class, module=method.interface.module)
for param in method.response_parameters:
struct.AddField(param.name, param.kind, param.ordinal)
- 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
+ return _GetDataHeader(False, struct)
def ExpectedArraySize(kind):
if mojom.IsArrayKind(kind):
@@ -48,6 +47,10 @@ 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.
full_dir = os.path.dirname(full_path)
@@ -71,10 +74,10 @@ class Generator(object):
result.append(GetStructFromMethod(method))
if method.response_parameters != None:
result.append(GetResponseStructFromMethod(method))
- return map(partial(GetDataHeader, False), result)
+ return 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.

Powered by Google App Engine
This is Rietveld 408576698