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
5 # found in the LICENSE file.
11 module_basename = os.path.basename(__file__)
12 module_pyname = os.path.splitext(module_basename)[0] + '.py'
15 // Copyright 2014 The Chromium Authors. All rights reserved.
16 // Use of this source code is governed by a BSD-style license that can be
17 // found in the LICENSE file.
19 // Auto-generated by {module_pyname}
21 const MediaQueryTokenizer::CodePoint MediaQueryTokenizer::codePoints[{array_size}] = {{
24 const unsigned codePointsNumber = {array_size};
29 codepoints = {'(': 'leftParenthesis',
30 ')': 'rightParenthesis',
35 '+': 'plusOrFullStop',
36 '.': 'plusOrFullStop',
41 '\\': 'reverseSolidus',
45 whitespace = '\n\r\t\f '
52 if c.isalpha() or c == '_':
58 return codepoints.get(c)
61 class MakeMediaQueryTokenizerCodePointsWriter(in_generator.Writer):
64 'RuntimeEnabled': None,
65 'ImplementedAs': None,
69 default_parameters = {
74 def __init__(self, in_file_path):
75 super(MakeMediaQueryTokenizerCodePointsWriter, self).__init__(in_file_path)
78 ('MediaQueryTokenizerCodepoints.cpp'): self.generate,
80 self._template_context = {
86 array_size = 128 # SCHAR_MAX + 1
87 token_lines = [' &MediaQueryTokenizer::%s,' % token_type(i)
88 if token_type(i) else ' 0,'
89 for i in range(array_size)]
90 return CPP_TEMPLATE.format(array_size=array_size, token_lines='\n'.join(token_lines), module_pyname=module_pyname)
92 if __name__ == '__main__':
93 in_generator.Maker(MakeMediaQueryTokenizerCodePointsWriter).main(sys.argv)