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 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build
. | 5 """Utility functions (file reading, simple IDL parsing by regexes) for IDL build
. |
6 | 6 |
7 Design doc: http://www.chromium.org/developers/design-documents/idl-build | 7 Design doc: http://www.chromium.org/developers/design-documents/idl-build |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 arguments = [] | 405 arguments = [] |
406 for argument in map(string.strip, match.group(1).split(',')): | 406 for argument in map(string.strip, match.group(1).split(',')): |
407 exposed, runtime_enabled = argument.split() | 407 exposed, runtime_enabled = argument.split() |
408 arguments.append({'exposed': exposed, 'runtime_enabled': runtime_enabled
}) | 408 arguments.append({'exposed': exposed, 'runtime_enabled': runtime_enabled
}) |
409 | 409 |
410 return arguments | 410 return arguments |
411 | 411 |
412 | 412 |
413 # Workaround for http://crbug.com/611437 | 413 # Workaround for http://crbug.com/611437 |
414 # TODO(bashi): Remove this hack once we resolve too-long generated file names. | 414 # TODO(bashi): Remove this hack once we resolve too-long generated file names. |
| 415 # pylint: disable=line-too-long |
415 def shorten_union_name(union_type): | 416 def shorten_union_name(union_type): |
416 aliases = { | 417 aliases = { |
417 'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext
OrImageBitmapRenderingContext': 'RenderingContext', | 418 'CanvasRenderingContext2DOrWebGLRenderingContextOrWebGL2RenderingContext
OrImageBitmapRenderingContext': 'RenderingContext', |
| 419 'HTMLImageElementOrSVGImageElementOrHTMLVideoElementOrHTMLCanvasElementO
rBlobOrImageDataOrImageBitmapOrOffscreenCanvas': 'ImageBitmapSource', |
418 } | 420 } |
419 | 421 |
420 idl_type = union_type | 422 idl_type = union_type |
421 if union_type.is_nullable: | 423 if union_type.is_nullable: |
422 idl_type = union_type.inner_type | 424 idl_type = union_type.inner_type |
423 name = idl_type.cpp_type or idl_type.name | 425 name = idl_type.cpp_type or idl_type.name |
424 alias = aliases.get(name) | 426 alias = aliases.get(name) |
425 if alias: | 427 if alias: |
426 return alias | 428 return alias |
427 return name | 429 return name |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 516 |
515 # Remember an open brace. | 517 # Remember an open brace. |
516 match = re_last_brace.search(line) | 518 match = re_last_brace.search(line) |
517 was_open_brace = (match and match.group('last') == '{' and 'namespace' n
ot in line) | 519 was_open_brace = (match and match.group('last') == '{' and 'namespace' n
ot in line) |
518 | 520 |
519 # Let |'\n'.join| emit the last newline. | 521 # Let |'\n'.join| emit the last newline. |
520 if output: | 522 if output: |
521 output.append('') | 523 output.append('') |
522 | 524 |
523 return '\n'.join(output) | 525 return '\n'.join(output) |
OLD | NEW |