| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Generates dart source files from a mojom.Module.""" | 5 """Generates dart source files from a mojom.Module.""" |
| 6 | 6 |
| 7 import errno | 7 import errno |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import shutil | 10 import shutil |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 name = name + '_' | 312 name = name + '_' |
| 313 return name | 313 return name |
| 314 | 314 |
| 315 def GetInterfaceResponseName(method): | 315 def GetInterfaceResponseName(method): |
| 316 return UpperCamelCase(method.name + 'Response') | 316 return UpperCamelCase(method.name + 'Response') |
| 317 | 317 |
| 318 def GetDartTrueFalse(value): | 318 def GetDartTrueFalse(value): |
| 319 return 'true' if value else 'false' | 319 return 'true' if value else 'false' |
| 320 | 320 |
| 321 def GetArrayNullabilityFlags(kind): | 321 def GetArrayNullabilityFlags(kind): |
| 322 """Returns nullability flags for an array type, see codec.dart. | 322 """Returns nullability flags for an array type, see codec.dart. |
| 323 | 323 |
| 324 As we have dedicated decoding functions for arrays, we have to pass | 324 As we have dedicated decoding functions for arrays, we have to pass |
| 325 nullability information about both the array itself, as well as the array | 325 nullability information about both the array itself, as well as the array |
| 326 element type there. | 326 element type there. |
| 327 """ | 327 """ |
| 328 assert mojom.IsArrayKind(kind) | 328 assert mojom.IsArrayKind(kind) |
| 329 ARRAY_NULLABLE = 'bindings.kArrayNullable' | 329 ARRAY_NULLABLE = 'bindings.kArrayNullable' |
| 330 ELEMENT_NULLABLE = 'bindings.kElementNullable' | 330 ELEMENT_NULLABLE = 'bindings.kElementNullable' |
| 331 NOTHING_NULLABLE = 'bindings.kNothingNullable' | 331 NOTHING_NULLABLE = 'bindings.kNothingNullable' |
| 332 | 332 |
| 333 flags_to_set = [] | 333 flags_to_set = [] |
| 334 if mojom.IsNullableKind(kind): | 334 if mojom.IsNullableKind(kind): |
| 335 flags_to_set.append(ARRAY_NULLABLE) | 335 flags_to_set.append(ARRAY_NULLABLE) |
| 336 if mojom.IsNullableKind(kind.kind): | 336 if mojom.IsNullableKind(kind.kind): |
| 337 flags_to_set.append(ELEMENT_NULLABLE) | 337 flags_to_set.append(ELEMENT_NULLABLE) |
| 338 | 338 |
| 339 if not flags_to_set: | 339 if not flags_to_set: |
| 340 flags_to_set = [NOTHING_NULLABLE] | 340 flags_to_set = [NOTHING_NULLABLE] |
| 341 return ' | '.join(flags_to_set) | 341 return ' | '.join(flags_to_set) |
| 342 | 342 |
| 343 def AppendDecodeParams(initial_params, kind, bit): | 343 def AppendDecodeParams(initial_params, kind, bit): |
| 344 """ Appends standard parameters for decode calls. """ | 344 """ Appends standard parameters for decode calls. """ |
| 345 params = list(initial_params) | 345 params = list(initial_params) |
| 346 if (kind == mojom.BOOL): | 346 if (kind == mojom.BOOL): |
| 347 params.append(str(bit)) | 347 params.append(str(bit)) |
| 348 if mojom.IsReferenceKind(kind): | 348 if mojom.IsReferenceKind(kind): |
| 349 if mojom.IsArrayKind(kind): | 349 if mojom.IsArrayKind(kind): |
| 350 params.append(GetArrayNullabilityFlags(kind)) | 350 params.append(GetArrayNullabilityFlags(kind)) |
| 351 else: | 351 else: |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 interface_to_import[name] = each_import["unique_name"] + "." + name | 648 interface_to_import[name] = each_import["unique_name"] + "." + name |
| 649 return interface_to_import | 649 return interface_to_import |
| 650 | 650 |
| 651 def ImportedFrom(self): | 651 def ImportedFrom(self): |
| 652 interface_to_import = {} | 652 interface_to_import = {} |
| 653 for each_import in self.module.imports: | 653 for each_import in self.module.imports: |
| 654 for each_interface in each_import["module"].interfaces: | 654 for each_interface in each_import["module"].interfaces: |
| 655 name = each_interface.name | 655 name = each_interface.name |
| 656 interface_to_import[name] = each_import["unique_name"] + "." | 656 interface_to_import[name] = each_import["unique_name"] + "." |
| 657 return interface_to_import | 657 return interface_to_import |
| OLD | NEW |