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

Unified Diff: third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py

Issue 1938343002: Generate a series of nested switch statements to parse CSSPrimitiveValue units. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py
diff --git a/third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py b/third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py
new file mode 100755
index 0000000000000000000000000000000000000000..e8b4c15f4717e3ac561c96c1a47182d0872701bd
--- /dev/null
+++ b/third_party/WebKit/Source/build/scripts/make_css_primitive_value_unit_trie.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from collections import OrderedDict
+from itertools import groupby
+import sys
+
+import in_generator
+import template_expander
+
+import make_element_lookup_trie
+
+
+class UnitTrieWriter(in_generator.Writer):
+ defaults = {
+ 'unit_type': None
+ }
+ default_parameters = {}
+
+ def __init__(self, in_file_paths):
+ super(UnitTrieWriter, self).__init__(in_file_paths)
+
+ self._dict = {}
+ self._empty_case_return_value = None
+ for entry in self.in_file.name_dictionaries:
+ name = entry["name"].strip('"')
+ if name:
+ self._dict[name] = entry["unit_type"]
+ else:
+ # There should only be one of these.
+ self._empty_case_return_value = entry["unit_type"]
+
+ self._outputs = {
+ 'CSSPrimitiveValueUnitTrie.cpp': self.generate_implementation
+ }
+
+ @template_expander.use_jinja('CSSPrimitiveValueUnitTrie.h.tmpl')
+ def generate_header(self):
Timothy Loh 2016/05/03 07:40:25 unused
meade_UTC10 2016/05/04 07:24:54 Done.
+ return {}
+
+ @template_expander.use_jinja('CSSPrimitiveValueUnitTrie.cpp.tmpl')
+ def generate_implementation(self):
+ # BAR
+ return {
+ 'empty_case_return_value': self._empty_case_return_value,
+ 'length_tries': make_element_lookup_trie._trie_list(self._dict)
+ }
+
+
+if __name__ == '__main__':
+ in_generator.Maker(UnitTrieWriter).main(sys.argv)

Powered by Google App Engine
This is Rietveld 408576698