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

Unified Diff: core/scripts/make_css_property_names.py

Issue 22498002: Roll IDL to multivm@1329 (Closed) Base URL: https://dart.googlecode.com/svn/third_party/WebCore
Patch Set: Created 7 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 | « core/scripts/list_idl_files_with_partial_interface.py ('k') | core/scripts/make_css_value_keywords.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/scripts/make_css_property_names.py
diff --git a/core/scripts/make_css_property_names.py b/core/scripts/make_css_property_names.py
index 58f85f2ad8e1526291e74acaaad61939795d5b2b..f775462be93ea1ee7789646ec8ab9ca6eeeebb79 100755
--- a/core/scripts/make_css_property_names.py
+++ b/core/scripts/make_css_property_names.py
@@ -78,10 +78,14 @@ GPERF_TEMPLATE = """
#include "wtf/text/WTFString.h"
namespace WebCore {
-const char* const propertyNameStrings[numCSSProperties] = {
+static const char propertyNameStringsPool[] = {
%(property_name_strings)s
};
+static const unsigned short propertyNameStringsOffsets[] = {
+%(property_name_offsets)s
+};
+
%%}
%%struct-type
struct Property;
@@ -93,6 +97,7 @@ struct Property;
%%define class-name %(class_name)sHash
%%define lookup-function-name findPropertyImpl
%%define hash-function-name propery_hash_function
+%%define slot-name nameOffset
%%define word-array-name property_wordlist
%%enum
%%%%
@@ -110,7 +115,7 @@ const char* getPropertyName(CSSPropertyID id)
int index = id - firstCSSProperty;
if (index >= numCSSProperties)
return 0;
- return propertyNameStrings[index];
+ return propertyNameStringsPool + propertyNameStringsOffsets[index];
}
const AtomicString& getPropertyNameAtomicString(CSSPropertyID id)
@@ -124,7 +129,7 @@ const AtomicString& getPropertyNameAtomicString(CSSPropertyID id)
static AtomicString* propertyStrings = new AtomicString[numCSSProperties]; // Intentionally never destroyed.
AtomicString& propertyString = propertyStrings[index];
if (propertyString.isNull()) {
- const char* propertyName = propertyNameStrings[index];
+ const char* propertyName = propertyNameStringsPool + propertyNameStringsOffsets[index];
propertyString = AtomicString(propertyName, strlen(propertyName), AtomicString::ConstructFromLiteral);
}
return propertyString;
@@ -210,14 +215,21 @@ class CSSPropertiesWriter(in_generator.Writer):
}
def generate_implementation(self):
+ property_offsets = []
+ current_offset = 0
+ for property in self._properties:
+ property_offsets.append(current_offset)
+ current_offset += len(property["name"]) + 1
+
gperf_input = GPERF_TEMPLATE % {
'license': license.license_for_generated_cpp(),
'class_name': self.class_name,
- 'property_name_strings': '\n'.join(map(lambda property: ' "%(name)s",' % property, self._properties)),
+ 'property_name_strings': '\n'.join(map(lambda property: ' "%(name)s\\0"' % property, self._properties)),
+ 'property_name_offsets': '\n'.join(map(lambda offset: ' %d,' % offset, property_offsets)),
'property_to_enum_map': '\n'.join(map(lambda property: '%(name)s, %(enum_name)s' % property, self._properties + self._aliases)),
}
# FIXME: If we could depend on Python 2.7, we would use subprocess.check_output
- gperf_args = ['gperf', '--key-positions=*', '-D', '-n', '-s', '2']
+ gperf_args = ['gperf', '--key-positions=*', '-P', '-D', '-n', '-s', '2']
gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return gperf.communicate(gperf_input)[0]
« no previous file with comments | « core/scripts/list_idl_files_with_partial_interface.py ('k') | core/scripts/make_css_value_keywords.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698