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

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

Issue 268363003: Mojo: Add support for constants to the IDL compiler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: JS export constants Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # This module's classes provide an interface to mojo modules. Modules are 5 # This module's classes provide an interface to mojo modules. Modules are
6 # collections of interfaces and structs to be used by mojo ipc clients and 6 # collections of interfaces and structs to be used by mojo ipc clients and
7 # servers. 7 # servers.
8 # 8 #
9 # A simple interface would be created this way: 9 # A simple interface would be created this way:
10 # module = mojom.generate.module.Module('Foo') 10 # module = mojom.generate.module.Module('Foo')
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DOUBLE, 53 DOUBLE,
54 STRING, 54 STRING,
55 HANDLE, 55 HANDLE,
56 DCPIPE, 56 DCPIPE,
57 DPPIPE, 57 DPPIPE,
58 MSGPIPE, 58 MSGPIPE,
59 SHAREDBUFFER 59 SHAREDBUFFER
60 ) 60 )
61 61
62 62
63 class Constant(object): 63 class NamedValue(object):
64 def __init__(self, module, enum, field): 64 def __init__(self, module, parent_kind, name):
65 self.module = module 65 self.module = module
66 self.namespace = module.namespace 66 self.namespace = module.namespace
67 self.parent_kind = enum.parent_kind 67 self.parent_kind = parent_kind
68 self.name = [enum.name, field.name] 68 self.name = name
69 self.imported_from = None 69 self.imported_from = None
70 70
71 def GetSpec(self): 71 def GetSpec(self):
72 return (self.namespace + '.' + 72 return (self.namespace + '.' +
73 (self.parent_kind and (self.parent_kind.name + '.') or "") + \ 73 (self.parent_kind and (self.parent_kind.name + '.') or "") +
74 self.name[1]) 74 self.name)
75
76
77 class EnumValue(NamedValue):
78 def __init__(self, module, enum, field):
79 NamedValue.__init__(self, module, enum.parent_kind, field.name)
80 self.enum_name = enum.name
81
82
83 class Constant(object):
84 def __init__(self, name=None, kind=None, value=None):
85 self.name = name
86 self.kind = kind
87 self.value = value
75 88
76 89
77 class Field(object): 90 class Field(object):
78 def __init__(self, name=None, kind=None, ordinal=None, default=None): 91 def __init__(self, name=None, kind=None, ordinal=None, default=None):
79 self.name = name 92 self.name = name
80 self.kind = kind 93 self.kind = kind
81 self.ordinal = ordinal 94 self.ordinal = ordinal
82 self.default = default 95 self.default = default
83 96
84 97
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 197
185 def AddInterface(self, name): 198 def AddInterface(self, name):
186 interface=Interface(name, module=self); 199 interface=Interface(name, module=self);
187 self.interfaces.append(interface) 200 self.interfaces.append(interface)
188 return interface 201 return interface
189 202
190 def AddStruct(self, name): 203 def AddStruct(self, name):
191 struct=Struct(name, module=self) 204 struct=Struct(name, module=self)
192 self.structs.append(struct) 205 self.structs.append(struct)
193 return struct 206 return struct
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/generate/data.py ('k') | mojo/public/tools/bindings/pylib/mojom/parse/lexer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698