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

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: More fixes - things build fine at this point. Created 3 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 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 %%struct-type 115 %%struct-type
116 struct Property; 116 struct Property;
117 %%omit-struct-type 117 %%omit-struct-type
118 %%language=C++ 118 %%language=C++
119 %%readonly-tables 119 %%readonly-tables
120 %%global-table 120 %%global-table
121 %%compare-strncmp 121 %%compare-strncmp
122 %%define class-name %(class_name)sHash 122 %%define class-name %(class_name)sHash
123 %%define lookup-function-name findPropertyImpl 123 %%define lookup-function-name findPropertyImpl
124 %%define hash-function-name property_hash_function 124 %%define hash-function-name property_hash_function
125 %%define slot-name nameOffset 125 %%define slot-name name_offset
126 %%define word-array-name property_word_list 126 %%define word-array-name property_word_list
127 %%enum 127 %%enum
128 %%%% 128 %%%%
129 %(property_to_enum_map)s 129 %(property_to_enum_map)s
130 %%%% 130 %%%%
131 131
132 #if defined(__clang__) 132 #if defined(__clang__)
133 #pragma clang diagnostic pop 133 #pragma clang diagnostic pop
134 #endif 134 #endif
135 135
136 const Property* findProperty(const char* str, unsigned int len) { 136 const Property* FindProperty(const char* str, unsigned int len) {
137 return %(class_name)sHash::findPropertyImpl(str, len); 137 return %(class_name)sHash::findPropertyImpl(str, len);
138 } 138 }
139 139
140 const char* getPropertyName(CSSPropertyID id) { 140 const char* getPropertyName(CSSPropertyID id) {
141 DCHECK(isCSSPropertyIDWithName(id)); 141 DCHECK(isCSSPropertyIDWithName(id));
142 int index = id - firstCSSProperty; 142 int index = id - firstCSSProperty;
143 return propertyNameStringsPool + propertyNameStringsOffsets[index]; 143 return propertyNameStringsPool + propertyNameStringsOffsets[index];
144 } 144 }
145 145
146 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) { 146 const AtomicString& getPropertyNameAtomicString(CSSPropertyID id) {
147 DCHECK(isCSSPropertyIDWithName(id)); 147 DCHECK(isCSSPropertyIDWithName(id));
148 int index = id - firstCSSProperty; 148 int index = id - firstCSSProperty;
149 static AtomicString* propertyStrings = 149 static AtomicString* propertyStrings =
150 new AtomicString[lastUnresolvedCSSProperty]; // Leaked. 150 new AtomicString[lastUnresolvedCSSProperty]; // Leaked.
151 AtomicString& propertyString = propertyStrings[index]; 151 AtomicString& propertyString = propertyStrings[index];
152 if (propertyString.isNull()) { 152 if (propertyString.IsNull()) {
153 propertyString = AtomicString(propertyNameStringsPool + 153 propertyString = AtomicString(propertyNameStringsPool +
154 propertyNameStringsOffsets[index]); 154 propertyNameStringsOffsets[index]);
155 } 155 }
156 return propertyString; 156 return propertyString;
157 } 157 }
158 158
159 String getPropertyNameString(CSSPropertyID id) { 159 String getPropertyNameString(CSSPropertyID id) {
160 // We share the StringImpl with the AtomicStrings. 160 // We share the StringImpl with the AtomicStrings.
161 return getPropertyNameAtomicString(id).getString(); 161 return getPropertyNameAtomicString(id).GetString();
162 } 162 }
163 163
164 String getJSPropertyName(CSSPropertyID id) { 164 String getJSPropertyName(CSSPropertyID id) {
165 char result[maxCSSPropertyNameLength + 1]; 165 char result[maxCSSPropertyNameLength + 1];
166 const char* cssPropertyName = getPropertyName(id); 166 const char* cssPropertyName = getPropertyName(id);
167 const char* propertyNamePointer = cssPropertyName; 167 const char* propertyNamePointer = cssPropertyName;
168 if (!propertyNamePointer) 168 if (!propertyNamePointer)
169 return emptyString; 169 return g_empty_string;
170 170
171 char* resultPointer = result; 171 char* resultPointer = result;
172 while (char character = *propertyNamePointer++) { 172 while (char character = *propertyNamePointer++) {
173 if (character == '-') { 173 if (character == '-') {
174 char nextCharacter = *propertyNamePointer++; 174 char nextCharacter = *propertyNamePointer++;
175 if (!nextCharacter) 175 if (!nextCharacter)
176 break; 176 break;
177 character = (propertyNamePointer - 2 != cssPropertyName) 177 character = (propertyNamePointer - 2 != cssPropertyName)
178 ? toASCIIUpper(nextCharacter) : nextCharacter; 178 ? ToASCIIUpper(nextCharacter) : nextCharacter;
179 } 179 }
180 *resultPointer++ = character; 180 *resultPointer++ = character;
181 } 181 }
182 *resultPointer = '\\0'; 182 *resultPointer = '\\0';
183 return String(result); 183 return String(result);
184 } 184 }
185 185
186 CSSPropertyID cssPropertyID(const String& string) 186 CSSPropertyID cssPropertyID(const String& string)
187 { 187 {
188 return resolveCSSPropertyID(unresolvedCSSPropertyID(string)); 188 return resolveCSSPropertyID(unresolvedCSSPropertyID(string));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 # CalledProcessError like subprocess would do when shell=True is set. 248 # CalledProcessError like subprocess would do when shell=True is set.
249 try: 249 try:
250 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s ubprocess.PIPE, universal_newlines=True) 250 gperf = subprocess.Popen(gperf_args, stdin=subprocess.PIPE, stdout=s ubprocess.PIPE, universal_newlines=True)
251 return gperf.communicate(gperf_input)[0] 251 return gperf.communicate(gperf_input)[0]
252 except OSError: 252 except OSError:
253 raise subprocess.CalledProcessError(127, gperf_args, output='Command not found.') 253 raise subprocess.CalledProcessError(127, gperf_args, output='Command not found.')
254 254
255 255
256 if __name__ == "__main__": 256 if __name__ == "__main__":
257 json5_generator.Maker(CSSPropertyNamesWriter).main() 257 json5_generator.Maker(CSSPropertyNamesWriter).main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698