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

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

Issue 611633002: mojom: Add associative arrays to the mojom language. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 def __init__(self, length=-1, kind=None): 222 def __init__(self, length=-1, kind=None):
223 if kind is not None: 223 if kind is not None:
224 ReferenceKind.__init__(self, 'a%d:%s' % (length, kind.spec)) 224 ReferenceKind.__init__(self, 'a%d:%s' % (length, kind.spec))
225 else: 225 else:
226 ReferenceKind.__init__(self) 226 ReferenceKind.__init__(self)
227 self.kind = kind 227 self.kind = kind
228 self.length = length 228 self.length = length
229 229
230 230
231 class Map(ReferenceKind):
232 ReferenceKind.AddSharedProperty('key_kind')
233 ReferenceKind.AddSharedProperty('value_kind')
234
235 def __init__(self, key_kind, value_kind):
236 ReferenceKind.__init__(self,
237 'm[' + key_kind.spec + '][' + value_kind.spec + ']')
238 self.key_kind = key_kind
239 self.value_kind = value_kind
240
241
231 class InterfaceRequest(ReferenceKind): 242 class InterfaceRequest(ReferenceKind):
232 ReferenceKind.AddSharedProperty('kind') 243 ReferenceKind.AddSharedProperty('kind')
233 244
234 def __init__(self, kind=None): 245 def __init__(self, kind=None):
235 if kind is not None: 246 if kind is not None:
236 ReferenceKind.__init__(self, 'r:' + kind.spec) 247 ReferenceKind.__init__(self, 'r:' + kind.spec)
237 else: 248 else:
238 ReferenceKind.__init__(self) 249 ReferenceKind.__init__(self)
239 self.kind = kind 250 self.kind = kind
240 251
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 403
393 404
394 def IsNullableKind(kind): 405 def IsNullableKind(kind):
395 return IsReferenceKind(kind) and kind.is_nullable 406 return IsReferenceKind(kind) and kind.is_nullable
396 407
397 408
398 def IsAnyArrayKind(kind): 409 def IsAnyArrayKind(kind):
399 return IsArrayKind(kind) or IsFixedArrayKind(kind) 410 return IsArrayKind(kind) or IsFixedArrayKind(kind)
400 411
401 412
413 def IsMapKind(kind):
414 return isinstance(kind, Map)
415
416
402 def IsObjectKind(kind): 417 def IsObjectKind(kind):
403 return IsStructKind(kind) or IsAnyArrayKind(kind) or IsStringKind(kind) 418 return (IsStructKind(kind) or IsAnyArrayKind(kind) or IsStringKind(kind) or
404 419 IsMapKind(kind))
405 420
406 def IsNonInterfaceHandleKind(kind): 421 def IsNonInterfaceHandleKind(kind):
407 return (IsHandleKind(kind) or 422 return (IsHandleKind(kind) or
408 IsDataPipeConsumerKind(kind) or 423 IsDataPipeConsumerKind(kind) or
409 IsDataPipeProducerKind(kind) or 424 IsDataPipeProducerKind(kind) or
410 IsMessagePipeKind(kind) or 425 IsMessagePipeKind(kind) or
411 IsSharedBufferKind(kind)) 426 IsSharedBufferKind(kind))
412 427
413 428
414 def IsAnyHandleKind(kind): 429 def IsAnyHandleKind(kind):
415 return (IsNonInterfaceHandleKind(kind) or 430 return (IsNonInterfaceHandleKind(kind) or
416 IsInterfaceKind(kind) or 431 IsInterfaceKind(kind) or
417 IsInterfaceRequestKind(kind)) 432 IsInterfaceRequestKind(kind))
418 433
419 434
420 def IsMoveOnlyKind(kind): 435 def IsMoveOnlyKind(kind):
421 return IsObjectKind(kind) or IsAnyHandleKind(kind) 436 return IsObjectKind(kind) or IsAnyHandleKind(kind)
422 437
423 438
424 def HasCallbacks(interface): 439 def HasCallbacks(interface):
425 for method in interface.methods: 440 for method in interface.methods:
426 if method.response_parameters != None: 441 if method.response_parameters != None:
427 return True 442 return True
428 return False 443 return False
429 444
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698