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

Side by Side Diff: bindings/scripts/idl_validator.py

Issue 959933002: Move IDLs to 39 roll (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 5 years, 10 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
« no previous file with comments | « bindings/scripts/idl_types.py ('k') | bindings/scripts/interface_dependency_resolver.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 raise IDLInvalidExtendedAttributeError( 70 raise IDLInvalidExtendedAttributeError(
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 elif isinstance(values_string, list):
81 values = set(values_string)
80 else: 82 else:
81 values = set(re.split('[|,]', values_string)) 83 values = set([values_string])
82 invalid_values = values - valid_values 84 invalid_values = values - valid_values
83 if invalid_values: 85 if invalid_values:
84 invalid_value = invalid_values.pop() 86 invalid_value = invalid_values.pop()
85 raise IDLInvalidExtendedAttributeError( 87 raise IDLInvalidExtendedAttributeError(
86 'Invalid value "%s" found in extended attribute [%s=%s]' % 88 'Invalid value "%s" found in extended attribute [%s=%s]' %
87 (invalid_value, name, values_string)) 89 (invalid_value, name, values_string))
88 90
89 91
90 def read_extended_attributes_file(): 92 def read_extended_attributes_file():
91 def extended_attribute_name_values(): 93 def extended_attribute_name_values():
92 with open(EXTENDED_ATTRIBUTES_FILENAME) as extended_attributes_file: 94 with open(EXTENDED_ATTRIBUTES_FILENAME) as extended_attributes_file:
93 for line in extended_attributes_file: 95 for line in extended_attributes_file:
94 line = line.strip() 96 line = line.strip()
95 if not line or line.startswith('#'): 97 if not line or line.startswith('#'):
96 continue 98 continue
97 name, _, values_string = map(str.strip, line.partition('=')) 99 name, _, values_string = map(str.strip, line.partition('='))
98 value_list = [value.strip() for value in values_string.split('|' )] 100 value_list = [value.strip() for value in values_string.split('|' )]
99 yield name, value_list 101 yield name, value_list
100 102
101 valid_extended_attributes = {} 103 valid_extended_attributes = {}
102 for name, value_list in extended_attribute_name_values(): 104 for name, value_list in extended_attribute_name_values():
103 if not value_list: 105 if not value_list:
104 valid_extended_attributes[name] = set([None]) 106 valid_extended_attributes[name] = set([None])
105 continue 107 continue
106 valid_extended_attributes[name] = set([value if value else None 108 valid_extended_attributes[name] = set([value if value else None
107 for value in value_list]) 109 for value in value_list])
108 return valid_extended_attributes 110 return valid_extended_attributes
OLDNEW
« no previous file with comments | « bindings/scripts/idl_types.py ('k') | bindings/scripts/interface_dependency_resolver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698