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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/parse/translate.py

Issue 437643002: Support nullable types in mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/tools/bindings/pylib/mojom/parse/translate.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
index c4798bf0679a2dceea28d371ad37fce709601f60..81806f177d6619a7bc0111f9b40b5e7a2f586e1c 100644
--- a/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
+++ b/mojo/public/tools/bindings/pylib/mojom/parse/translate.py
@@ -35,16 +35,24 @@ def _MapKind(kind):
'handle<data_pipe_producer>': 'h:d:p',
'handle<message_pipe>': 'h:m',
'handle<shared_buffer>': 'h:s'}
+ if kind.endswith('?'):
+ decorated_kind = _MapKind(kind[0:-1])
+ # NOTE: This doesn't rule out enum types. Those will be detected later, when
+ # cross-reference is established.
+ if decorated_kind[0] not in ('s', 'h', 'a', 'r', 'x'):
darin (slow to review) 2014/08/03 05:57:58 nit: might be nice to get this tuple a name, like
yzshen1 2014/08/03 08:27:46 Sounds good.
+ raise Exception(
+ 'A type (spec "%s") cannot be made nullable' % decorated_kind)
+ return '?' + decorated_kind
if kind.endswith('[]'):
typename = kind[0:-2]
if _FIXED_ARRAY_REGEXP.search(typename):
- raise Exception("Arrays of fixed sized arrays not supported")
+ raise Exception('Arrays of fixed sized arrays not supported')
return 'a:' + _MapKind(typename)
if kind.endswith(']'):
lbracket = kind.rfind('[')
typename = kind[0:lbracket]
if typename.find('[') != -1:
- raise Exception("Fixed sized arrays of arrays not supported")
+ raise Exception('Fixed sized arrays of arrays not supported')
return 'a' + kind[lbracket+1:-1] + ':' + _MapKind(typename)
if kind.endswith('&'):
return 'r:' + _MapKind(kind[0:-1])

Powered by Google App Engine
This is Rietveld 408576698