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

Side by Side Diff: Source/bindings/scripts/idl_validator.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 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 'Unknown extended attribute [%s]' % name) 71 'Unknown extended attribute [%s]' % name)
72 valid_values = self.valid_extended_attributes[name] 72 valid_values = self.valid_extended_attributes[name]
73 if values_string is None and None not in valid_values: 73 if values_string is None and None not in valid_values:
74 raise IDLInvalidExtendedAttributeError( 74 raise IDLInvalidExtendedAttributeError(
75 'Missing required argument for extended attribute [%s]' % name) 75 'Missing required argument for extended attribute [%s]' % name)
76 if '*' in valid_values: # wildcard, any (non-empty) value ok 76 if '*' in valid_values: # wildcard, any (non-empty) value ok
77 return 77 return
78 if values_string is None: 78 if values_string is None:
79 values = set([None]) 79 values = set([None])
80 else: 80 else:
81 values = set(re.split('[|&]', values_string)) 81 values = set(re.split('[|,]', values_string))
82 invalid_values = values - valid_values 82 invalid_values = values - valid_values
83 if invalid_values: 83 if invalid_values:
84 invalid_value = invalid_values.pop() 84 invalid_value = invalid_values.pop()
85 raise IDLInvalidExtendedAttributeError( 85 raise IDLInvalidExtendedAttributeError(
86 'Invalid value "%s" found in extended attribute [%s=%s]' % 86 'Invalid value "%s" found in extended attribute [%s=%s]' %
87 (invalid_value, name, values_string)) 87 (invalid_value, name, values_string))
88 88
89 89
90 def read_extended_attributes_file(): 90 def read_extended_attributes_file():
91 def extended_attribute_name_values(): 91 def extended_attribute_name_values():
92 with open(EXTENDED_ATTRIBUTES_FILENAME) as extended_attributes_file: 92 with open(EXTENDED_ATTRIBUTES_FILENAME) as extended_attributes_file:
93 for line in extended_attributes_file: 93 for line in extended_attributes_file:
94 line = line.strip() 94 line = line.strip()
95 if not line or line.startswith('#'): 95 if not line or line.startswith('#'):
96 continue 96 continue
97 name, _, values_string = map(str.strip, line.partition('=')) 97 name, _, values_string = map(str.strip, line.partition('='))
98 value_list = [value.strip() for value in values_string.split('|' )] 98 value_list = [value.strip() for value in values_string.split('|' )]
99 yield name, value_list 99 yield name, value_list
100 100
101 valid_extended_attributes = {} 101 valid_extended_attributes = {}
102 for name, value_list in extended_attribute_name_values(): 102 for name, value_list in extended_attribute_name_values():
103 if not value_list: 103 if not value_list:
104 valid_extended_attributes[name] = set([None]) 104 valid_extended_attributes[name] = set([None])
105 continue 105 continue
106 valid_extended_attributes[name] = set([value if value else None 106 valid_extended_attributes[name] = set([value if value else None
107 for value in value_list]) 107 for value in value_list])
108 return valid_extended_attributes 108 return valid_extended_attributes
OLDNEW
« no previous file with comments | « Source/bindings/scripts/generate_global_constructors.py ('k') | Source/bindings/scripts/utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698