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

Unified Diff: Source/build/scripts/make_css_value_keywords.py

Issue 1302273005: Minor clean-up to getValueName (i.e. CSSValueID -> string conversion) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/build/scripts/make_css_value_keywords.py
diff --git a/Source/build/scripts/make_css_value_keywords.py b/Source/build/scripts/make_css_value_keywords.py
index 349f2acd6e479bf775872e86f026667bb7668702..cbe89a498fa74e720e0848d1ec4e3d43f57312f1 100755
--- a/Source/build/scripts/make_css_value_keywords.py
+++ b/Source/build/scripts/make_css_value_keywords.py
@@ -29,7 +29,7 @@ enum CSSValueID {
const int numCSSValueKeywords = %(value_keywords_count)d;
const size_t maxCSSValueKeywordLength = %(max_value_keyword_length)d;
-const char* getValueName(unsigned short id);
+const char* getValueName(CSSValueID);
bool isValueAllowedInMode(unsigned short id, CSSParserMode mode);
} // namespace blink
@@ -48,7 +48,6 @@ GPERF_TEMPLATE = """
namespace blink {
static const char valueListStringPool[] = {
-"\\0"
%(value_keyword_strings)s
};
@@ -78,11 +77,10 @@ const Value* findValue(register const char* str, register unsigned int len)
return CSSValueKeywordsHash::findValueImpl(str, len);
}
-const char* getValueName(unsigned short id)
+const char* getValueName(CSSValueID id)
{
- if (id >= numCSSValueKeywords || id <= 0)
- return 0;
- return valueListStringPool + valueListStringOffsets[id];
+ ASSERT(id > 0 && id < numCSSValueKeywords);
+ return valueListStringPool + valueListStringOffsets[id - 1];
}
bool isValueAllowedInMode(unsigned short id, CSSParserMode mode)
@@ -148,8 +146,8 @@ class CSSValueKeywordsWriter(in_generator.Writer):
return filter(lambda property: property['mode'] == mode, self._value_keywords)
def generate_implementation(self):
- keyword_offsets = [0]
- current_offset = 1
+ keyword_offsets = []
+ current_offset = 0
for keyword in self._value_keywords:
keyword_offsets.append(current_offset)
current_offset += len(keyword["name"]) + 1
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698