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

Side by Side Diff: Source/bindings/scripts/compute_global_objects.py

Issue 434133002: Support WebIDL's ExtendedAttributeIdentList in the Blink parser (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 4 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 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2014 The Chromium Authors. All rights reserved. 3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Compute global objects. 7 """Compute global objects.
8 8
9 Global objects are defined by interfaces with [Global] or [PrimaryGlobal] on 9 Global objects are defined by interfaces with [Global] or [PrimaryGlobal] on
10 their definition: http://heycam.github.io/webidl/#Global 10 their definition: http://heycam.github.io/webidl/#Global
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 extended_attributes.iterkeys()) 66 extended_attributes.iterkeys())
67 if not global_keys: 67 if not global_keys:
68 return 68 return
69 if len(global_keys) > 1: 69 if len(global_keys) > 1:
70 raise ValueError('The [Global] and [PrimaryGlobal] extended attributes ' 70 raise ValueError('The [Global] and [PrimaryGlobal] extended attributes '
71 'MUST NOT be declared on the same interface.') 71 'MUST NOT be declared on the same interface.')
72 global_key = next(iter(global_keys)) 72 global_key = next(iter(global_keys))
73 73
74 global_value = extended_attributes[global_key] 74 global_value = extended_attributes[global_key]
75 if global_value: 75 if global_value:
76 # FIXME: In spec names are comma-separated, which makes parsing very 76 return global_value.strip('()').split(',')
77 # difficult (https://www.w3.org/Bugs/Public/show_bug.cgi?id=24959).
78 return global_value.split('&')
79 return [interface_name] 77 return [interface_name]
80 78
81 79
82 def idl_files_to_interface_name_global_names(idl_files): 80 def idl_files_to_interface_name_global_names(idl_files):
83 """Yields pairs (interface_name, global_names) found in IDL files.""" 81 """Yields pairs (interface_name, global_names) found in IDL files."""
84 for idl_filename in idl_files: 82 for idl_filename in idl_files:
85 interface_name = idl_filename_to_interface_name(idl_filename) 83 interface_name = idl_filename_to_interface_name(idl_filename)
86 global_names = idl_file_to_global_names(idl_filename) 84 global_names = idl_file_to_global_names(idl_filename)
87 if global_names: 85 if global_names:
88 yield interface_name, global_names 86 yield interface_name, global_names
(...skipping 15 matching lines...) Expand all
104 interface_name_global_names.update( 102 interface_name_global_names.update(
105 idl_files_to_interface_name_global_names(idl_files)) 103 idl_files_to_interface_name_global_names(idl_files))
106 104
107 write_pickle_file(output_global_objects_filename, 105 write_pickle_file(output_global_objects_filename,
108 interface_name_global_names, 106 interface_name_global_names,
109 options.write_file_only_if_changed) 107 options.write_file_only_if_changed)
110 108
111 109
112 if __name__ == '__main__': 110 if __name__ == '__main__':
113 sys.exit(main()) 111 sys.exit(main())
OLDNEW
« no previous file with comments | « Source/bindings/scripts/blink_idl_parser.py ('k') | Source/bindings/scripts/generate_global_constructors.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698