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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/generate/module.py

Issue 459873003: Mojom generator: move Is.*Kind() functions into module.py and use them from all mojom_.*_generator.… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/generate/generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/pylib/mojom/generate/module.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/module.py b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
index 4c6e76815079149b49f887d76c69b8d268573b94..72e630735fb9965815a222e59b578e7cd61d4aed 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/module.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/module.py
@@ -317,3 +317,82 @@ class Module(object):
struct=Struct(name, module=self)
self.structs.append(struct)
return struct
+
+
+def IsBoolKind(kind):
+ return kind.spec == BOOL.spec
+
+
+def IsStringKind(kind):
+ return kind.spec == STRING.spec or kind.spec == NULLABLE_STRING.spec
+
+
+def IsHandleKind(kind):
+ return kind.spec == HANDLE.spec or kind.spec == NULLABLE_HANDLE.spec
+
+
+def IsDataPipeConsumerKind(kind):
+ return kind.spec == DCPIPE.spec or kind.spec == NULLABLE_DCPIPE.spec
+
+
+def IsDataPipeProducerKind(kind):
+ return kind.spec == DPPIPE.spec or kind.spec == NULLABLE_DPPIPE.spec
+
+
+def IsMessagePipeKind(kind):
+ return kind.spec == MSGPIPE.spec or kind.spec == NULLABLE_MSGPIPE.spec
+
+
+def IsSharedBufferKind(kind):
+ return (kind.spec == SHAREDBUFFER.spec or
+ kind.spec == NULLABLE_SHAREDBUFFER.spec)
+
+
+def IsStructKind(kind):
+ return isinstance(kind, Struct)
+
+
+def IsArrayKind(kind):
+ return isinstance(kind, Array)
+
+
+def IsFixedArrayKind(kind):
+ return isinstance(kind, FixedArray)
+
+
+def IsInterfaceKind(kind):
+ return isinstance(kind, Interface)
+
+
+def IsInterfaceRequestKind(kind):
+ return isinstance(kind, InterfaceRequest)
+
+
+def IsEnumKind(kind):
+ return isinstance(kind, Enum)
+
+
+def IsNullableKind(kind):
+ return isinstance(kind, ReferenceKind) and kind.is_nullable
+
+
+def IsAnyArrayKind(kind):
+ return IsArrayKind(kind) or IsFixedArrayKind(kind)
+
+
+def IsObjectKind(kind):
+ return IsStructKind(kind) or IsAnyArrayKind(kind) or IsStringKind(kind)
+
+
+def IsAnyHandleKind(kind):
+ return (IsHandleKind(kind) or
Matt Perry 2014/08/11 21:07:07 nit: simply checking that the spec starts with "h"
yzshen1 2014/08/11 21:17:59 I slightly prefer this way because it is more expl
Matt Perry 2014/08/11 21:25:56 Yeah, you're probably right. Sounds good.
+ IsDataPipeConsumerKind(kind) or
+ IsDataPipeProducerKind(kind) or
+ IsMessagePipeKind(kind) or
+ IsSharedBufferKind(kind) or
+ IsInterfaceKind(kind) or
+ IsInterfaceRequestKind(kind))
+
+
+def IsMoveOnlyKind(kind):
+ return IsObjectKind(kind) or IsAnyHandleKind(kind)
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/generate/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698