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

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_css_property_names.py

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: Rebasing the fixes... Created 3 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 import subprocess 3 import subprocess
4 import sys 4 import sys
5 5
6 import css_properties 6 import css_properties
7 import json5_generator 7 import json5_generator
8 import license 8 import license
9 9
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 %%struct-type 108 %%struct-type
109 struct Property; 109 struct Property;
110 %%omit-struct-type 110 %%omit-struct-type
111 %%language=C++ 111 %%language=C++
112 %%readonly-tables 112 %%readonly-tables
113 %%global-table 113 %%global-table
114 %%compare-strncmp 114 %%compare-strncmp
115 %%define class-name %(class_name)sHash 115 %%define class-name %(class_name)sHash
116 %%define lookup-function-name findPropertyImpl 116 %%define lookup-function-name findPropertyImpl
117 %%define hash-function-name property_hash_function 117 %%define hash-function-name property_hash_function
118 %%define slot-name nameOffset 118 %%define slot-name name_offset
119 %%define word-array-name property_word_list 119 %%define word-array-name property_word_list
120 %%enum 120 %%enum
121 %%%% 121 %%%%
122 %(property_to_enum_map)s 122 %(property_to_enum_map)s
123 %%%% 123 %%%%
124 const Property* findProperty(register const char* str, register unsigned int len ) 124 const Property* FindProperty(register const char* str, register unsigned int len )
125 { 125 {
126 return %(class_name)sHash::findPropertyImpl(str, len); 126 return %(class_name)sHash::findPropertyImpl(str, len);
127 } 127 }
128 128
129 const char* getPropertyName(CSSPropertyID id) 129 const char* getPropertyName(CSSPropertyID id)
130 { 130 {
131 DCHECK(isCSSPropertyIDWithName(id)); 131 DCHECK(isCSSPropertyIDWithName(id));
132 int index = id - firstCSSProperty; 132 int index = id - firstCSSProperty;
133 return propertyNameStringsPool + propertyNameStringsOffsets[index]; 133 return propertyNameStringsPool + propertyNameStringsOffsets[index];
134 } 134 }
135 135
136 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) 136 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id)
137 { 137 {
138 DCHECK(isCSSPropertyIDWithName(id)); 138 DCHECK(isCSSPropertyIDWithName(id));
139 int index = id - firstCSSProperty; 139 int index = id - firstCSSProperty;
140 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro perty]; // Intentionally never destroyed. 140 static AtomicString* propertyStrings = new AtomicString[lastUnresolvedCSSPro perty]; // Intentionally never destroyed.
141 AtomicString& propertyString = propertyStrings[index]; 141 AtomicString& propertyString = propertyStrings[index];
142 if (propertyString.isNull()) 142 if (propertyString.IsNull())
143 propertyString = AtomicString(propertyNameStringsPool + propertyNameStri ngsOffsets[index]); 143 propertyString = AtomicString(propertyNameStringsPool + propertyNameStri ngsOffsets[index]);
144 return propertyString; 144 return propertyString;
145 } 145 }
146 146
147 String getPropertyNameString(CSSPropertyID id) 147 String getPropertyNameString(CSSPropertyID id)
148 { 148 {
149 // We share the StringImpl with the AtomicStrings. 149 // We share the StringImpl with the AtomicStrings.
150 return getPropertyNameAtomicString(id).getString(); 150 return getPropertyNameAtomicString(id).GetString();
151 } 151 }
152 152
153 String getJSPropertyName(CSSPropertyID id) 153 String getJSPropertyName(CSSPropertyID id)
154 { 154 {
155 char result[maxCSSPropertyNameLength + 1]; 155 char result[maxCSSPropertyNameLength + 1];
156 const char* cssPropertyName = getPropertyName(id); 156 const char* cssPropertyName = getPropertyName(id);
157 const char* propertyNamePointer = cssPropertyName; 157 const char* propertyNamePointer = cssPropertyName;
158 if (!propertyNamePointer) 158 if (!propertyNamePointer)
159 return emptyString; 159 return g_empty_string;
160 160
161 char* resultPointer = result; 161 char* resultPointer = result;
162 while (char character = *propertyNamePointer++) { 162 while (char character = *propertyNamePointer++) {
163 if (character == '-') { 163 if (character == '-') {
164 char nextCharacter = *propertyNamePointer++; 164 char nextCharacter = *propertyNamePointer++;
165 if (!nextCharacter) 165 if (!nextCharacter)
166 break; 166 break;
167 character = (propertyNamePointer - 2 != cssPropertyName) ? toASCIIUp per(nextCharacter) : nextCharacter; 167 character = (propertyNamePointer - 2 != cssPropertyName) ? ToASCIIUp per(nextCharacter) : nextCharacter;
168 } 168 }
169 *resultPointer++ = character; 169 *resultPointer++ = character;
170 } 170 }
171 *resultPointer = '\\0'; 171 *resultPointer = '\\0';
172 return String(result); 172 return String(result);
173 } 173 }
174 174
175 CSSPropertyID cssPropertyID(const String& string) 175 CSSPropertyID cssPropertyID(const String& string)
176 { 176 {
177 return resolveCSSPropertyID(unresolvedCSSPropertyID(string)); 177 return resolveCSSPropertyID(unresolvedCSSPropertyID(string));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 # CalledProcessError like subprocess would do when shell=True is set. 237 # CalledProcessError like subprocess would do when shell=True is set.
238 try: 238 try:
239 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s ubprocess.PIPE, universal_newlines=True) 239 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s ubprocess.PIPE, universal_newlines=True)
240 return gperf.communicate(gperf_input)[0] 240 return gperf.communicate(gperf_input)[0]
241 except OSError: 241 except OSError:
242 raise subprocess.CalledProcessError(127, gperf_args, output='Command not found.') 242 raise subprocess.CalledProcessError(127, gperf_args, output='Command not found.')
243 243
244 244
245 if __name__ == "__main__": 245 if __name__ == "__main__":
246 json5_generator.Maker(CSSPropertyNamesWriter).main() 246 json5_generator.Maker(CSSPropertyNamesWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698