Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 self.interfaces = [] | 310 self.interfaces = [] |
| 311 | 311 |
| 312 def AddInterface(self, name): | 312 def AddInterface(self, name): |
| 313 self.interfaces.append(Interface(name, module=self)) | 313 self.interfaces.append(Interface(name, module=self)) |
| 314 return interface | 314 return interface |
| 315 | 315 |
| 316 def AddStruct(self, name): | 316 def AddStruct(self, name): |
| 317 struct=Struct(name, module=self) | 317 struct=Struct(name, module=self) |
| 318 self.structs.append(struct) | 318 self.structs.append(struct) |
| 319 return struct | 319 return struct |
| 320 | |
| 321 | |
| 322 def IsBoolKind(kind): | |
| 323 return kind.spec == BOOL.spec | |
| 324 | |
| 325 | |
| 326 def IsStringKind(kind): | |
| 327 return kind.spec == STRING.spec or kind.spec == NULLABLE_STRING.spec | |
| 328 | |
| 329 | |
| 330 def IsHandleKind(kind): | |
| 331 return kind.spec == HANDLE.spec or kind.spec == NULLABLE_HANDLE.spec | |
| 332 | |
| 333 | |
| 334 def IsDataPipeConsumerKind(kind): | |
| 335 return kind.spec == DCPIPE.spec or kind.spec == NULLABLE_DCPIPE.spec | |
| 336 | |
| 337 | |
| 338 def IsDataPipeProducerKind(kind): | |
| 339 return kind.spec == DPPIPE.spec or kind.spec == NULLABLE_DPPIPE.spec | |
| 340 | |
| 341 | |
| 342 def IsMessagePipeKind(kind): | |
| 343 return kind.spec == MSGPIPE.spec or kind.spec == NULLABLE_MSGPIPE.spec | |
| 344 | |
| 345 | |
| 346 def IsSharedBufferKind(kind): | |
| 347 return (kind.spec == SHAREDBUFFER.spec or | |
| 348 kind.spec == NULLABLE_SHAREDBUFFER.spec) | |
| 349 | |
| 350 | |
| 351 def IsStructKind(kind): | |
| 352 return isinstance(kind, Struct) | |
| 353 | |
| 354 | |
| 355 def IsArrayKind(kind): | |
| 356 return isinstance(kind, Array) | |
| 357 | |
| 358 | |
| 359 def IsFixedArrayKind(kind): | |
| 360 return isinstance(kind, FixedArray) | |
| 361 | |
| 362 | |
| 363 def IsInterfaceKind(kind): | |
| 364 return isinstance(kind, Interface) | |
| 365 | |
| 366 | |
| 367 def IsInterfaceRequestKind(kind): | |
| 368 return isinstance(kind, InterfaceRequest) | |
| 369 | |
| 370 | |
| 371 def IsEnumKind(kind): | |
| 372 return isinstance(kind, Enum) | |
| 373 | |
| 374 | |
| 375 def IsNullableKind(kind): | |
| 376 return isinstance(kind, ReferenceKind) and kind.is_nullable | |
| 377 | |
| 378 | |
| 379 def IsAnyArrayKind(kind): | |
| 380 return IsArrayKind(kind) or IsFixedArrayKind(kind) | |
| 381 | |
| 382 | |
| 383 def IsObjectKind(kind): | |
| 384 return IsStructKind(kind) or IsAnyArrayKind(kind) or IsStringKind(kind) | |
| 385 | |
| 386 | |
| 387 def IsAnyHandleKind(kind): | |
| 388 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.
| |
| 389 IsDataPipeConsumerKind(kind) or | |
| 390 IsDataPipeProducerKind(kind) or | |
| 391 IsMessagePipeKind(kind) or | |
| 392 IsSharedBufferKind(kind) or | |
| 393 IsInterfaceKind(kind) or | |
| 394 IsInterfaceRequestKind(kind)) | |
| 395 | |
| 396 | |
| 397 def IsMoveOnlyKind(kind): | |
| 398 return IsObjectKind(kind) or IsAnyHandleKind(kind) | |
| OLD | NEW |