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

Unified Diff: mojo/public/bindings/pylib/generate/mojom_generator.py

Issue 139613005: Support default values for complex objects in mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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: mojo/public/bindings/pylib/generate/mojom_generator.py
diff --git a/mojo/public/bindings/pylib/generate/mojom_generator.py b/mojo/public/bindings/pylib/generate/mojom_generator.py
index 7e89c03e571c56914f4ad5406c0c2e17a08052bf..e8c0fd5ad68241bc150b2ad8dac2567a7ba8d22d 100644
--- a/mojo/public/bindings/pylib/generate/mojom_generator.py
+++ b/mojo/public/bindings/pylib/generate/mojom_generator.py
@@ -25,6 +25,12 @@ def GetStructInfo(exported, struct):
struct.exported = exported
return struct
+def GetStructByName(structs, name):
+ for struct in structs:
+ if struct.name == name:
+ return struct
+ return None
+
def IsStringKind(kind):
return kind.spec == 's'
@@ -41,6 +47,18 @@ def CamelToUnderscores(camel):
def StudlyCapsToCamel(studly):
return studly[0].lower() + studly[1:]
+def VerifyTokenType(token, expected):
+ """Used to check that arrays and objects are used correctly as default
+ values. Arrays are tokens that look like ('ARRAY', element0, element1...).
+ See mojom_parser.py for their representation.
+ """
+ if not isinstance(token, tuple):
+ raise Exception("Expected token type '%s'. Invalid token '%s'." %
+ (expected, token))
+ if token[0] != expected:
+ raise Exception("Expected token type '%s'. Got '%s'." %
+ (expected, token[0]))
+
class Generator(object):
# Pass |output_dir| to emit files to disk. Omit |output_dir| to echo all
# files to stdout.
« no previous file with comments | « mojo/public/bindings/generators/mojom_js_generator.py ('k') | mojo/public/bindings/pylib/parse/mojo_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698