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

Side by Side Diff: src/extensions/i18n/overrides.js

Issue 18075004: Mark i18n functions as native and set proper names (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/extensions/i18n/number-format.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 var locales = arguments[1]; 85 var locales = arguments[1];
86 var options = arguments[2]; 86 var options = arguments[2];
87 var collator = cachedOrNewService('collator', locales, options); 87 var collator = cachedOrNewService('collator', locales, options);
88 return compare(collator, this, that); 88 return compare(collator, this, that);
89 }, 89 },
90 writable: true, 90 writable: true,
91 configurable: true, 91 configurable: true,
92 enumerable: false 92 enumerable: false
93 }); 93 });
94 %FunctionSetName(String.prototype.localeCompare, 'localeCompare');
94 %FunctionRemovePrototype(String.prototype.localeCompare); 95 %FunctionRemovePrototype(String.prototype.localeCompare);
96 %SetNativeFlag(String.prototype.localeCompare);
95 97
96 98
97 /** 99 /**
98 * Formats a Number object (this) using locale and options values. 100 * Formats a Number object (this) using locale and options values.
99 * If locale or options are omitted, defaults are used. 101 * If locale or options are omitted, defaults are used.
100 */ 102 */
101 Object.defineProperty(Number.prototype, 'toLocaleString', { 103 Object.defineProperty(Number.prototype, 'toLocaleString', {
102 value: function() { 104 value: function() {
103 if (%_IsConstructCall()) { 105 if (%_IsConstructCall()) {
104 throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); 106 throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
105 } 107 }
106 108
107 if (!(this instanceof Number) && typeof(this) !== 'number') { 109 if (!(this instanceof Number) && typeof(this) !== 'number') {
108 throw new TypeError('Method invoked on an object that is not Number.'); 110 throw new TypeError('Method invoked on an object that is not Number.');
109 } 111 }
110 112
111 var locales = arguments[0]; 113 var locales = arguments[0];
112 var options = arguments[1]; 114 var options = arguments[1];
113 var numberFormat = cachedOrNewService('numberformat', locales, options); 115 var numberFormat = cachedOrNewService('numberformat', locales, options);
114 return formatNumber(numberFormat, this); 116 return formatNumber(numberFormat, this);
115 }, 117 },
116 writable: true, 118 writable: true,
117 configurable: true, 119 configurable: true,
118 enumerable: false 120 enumerable: false
119 }); 121 });
122 %FunctionSetName(Number.prototype.toLocaleString, 'toLocaleString');
120 %FunctionRemovePrototype(Number.prototype.toLocaleString); 123 %FunctionRemovePrototype(Number.prototype.toLocaleString);
124 %SetNativeFlag(Number.prototype.toLocaleString);
121 125
122 126
123 /** 127 /**
124 * Returns actual formatted date or fails if date parameter is invalid. 128 * Returns actual formatted date or fails if date parameter is invalid.
125 */ 129 */
126 function toLocaleDateTime(date, locales, options, required, defaults, service) { 130 function toLocaleDateTime(date, locales, options, required, defaults, service) {
127 if (!(date instanceof Date)) { 131 if (!(date instanceof Date)) {
128 throw new TypeError('Method invoked on an object that is not Date.'); 132 throw new TypeError('Method invoked on an object that is not Date.');
129 } 133 }
130 134
(...skipping 23 matching lines...) Expand all
154 158
155 var locales = arguments[0]; 159 var locales = arguments[0];
156 var options = arguments[1]; 160 var options = arguments[1];
157 return toLocaleDateTime( 161 return toLocaleDateTime(
158 this, locales, options, 'any', 'all', 'dateformatall'); 162 this, locales, options, 'any', 'all', 'dateformatall');
159 }, 163 },
160 writable: true, 164 writable: true,
161 configurable: true, 165 configurable: true,
162 enumerable: false 166 enumerable: false
163 }); 167 });
168 %FunctionSetName(Date.prototype.toLocaleString, 'toLocaleString');
164 %FunctionRemovePrototype(Date.prototype.toLocaleString); 169 %FunctionRemovePrototype(Date.prototype.toLocaleString);
170 %SetNativeFlag(Date.prototype.toLocaleString);
165 171
166 172
167 /** 173 /**
168 * Formats a Date object (this) using locale and options values. 174 * Formats a Date object (this) using locale and options values.
169 * If locale or options are omitted, defaults are used - only date is present 175 * If locale or options are omitted, defaults are used - only date is present
170 * in the output. 176 * in the output.
171 */ 177 */
172 Object.defineProperty(Date.prototype, 'toLocaleDateString', { 178 Object.defineProperty(Date.prototype, 'toLocaleDateString', {
173 value: function() { 179 value: function() {
174 if (%_IsConstructCall()) { 180 if (%_IsConstructCall()) {
175 throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); 181 throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
176 } 182 }
177 183
178 var locales = arguments[0]; 184 var locales = arguments[0];
179 var options = arguments[1]; 185 var options = arguments[1];
180 return toLocaleDateTime( 186 return toLocaleDateTime(
181 this, locales, options, 'date', 'date', 'dateformatdate'); 187 this, locales, options, 'date', 'date', 'dateformatdate');
182 }, 188 },
183 writable: true, 189 writable: true,
184 configurable: true, 190 configurable: true,
185 enumerable: false 191 enumerable: false
186 }); 192 });
193 %FunctionSetName(Date.prototype.toLocaleDateString, 'toLocaleDateString');
187 %FunctionRemovePrototype(Date.prototype.toLocaleDateString); 194 %FunctionRemovePrototype(Date.prototype.toLocaleDateString);
195 %SetNativeFlag(Date.prototype.toLocaleDateString);
188 196
189 197
190 /** 198 /**
191 * Formats a Date object (this) using locale and options values. 199 * Formats a Date object (this) using locale and options values.
192 * If locale or options are omitted, defaults are used - only time is present 200 * If locale or options are omitted, defaults are used - only time is present
193 * in the output. 201 * in the output.
194 */ 202 */
195 Object.defineProperty(Date.prototype, 'toLocaleTimeString', { 203 Object.defineProperty(Date.prototype, 'toLocaleTimeString', {
196 value: function() { 204 value: function() {
197 if (%_IsConstructCall()) { 205 if (%_IsConstructCall()) {
198 throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR); 206 throw new TypeError(ORDINARY_FUNCTION_CALLED_AS_CONSTRUCTOR);
199 } 207 }
200 208
201 var locales = arguments[0]; 209 var locales = arguments[0];
202 var options = arguments[1]; 210 var options = arguments[1];
203 return toLocaleDateTime( 211 return toLocaleDateTime(
204 this, locales, options, 'time', 'time', 'dateformattime'); 212 this, locales, options, 'time', 'time', 'dateformattime');
205 }, 213 },
206 writable: true, 214 writable: true,
207 configurable: true, 215 configurable: true,
208 enumerable: false 216 enumerable: false
209 }); 217 });
218 %FunctionSetName(Date.prototype.toLocaleTimeString, 'toLocaleTimeString');
210 %FunctionRemovePrototype(Date.prototype.toLocaleTimeString); 219 %FunctionRemovePrototype(Date.prototype.toLocaleTimeString);
220 %SetNativeFlag(Date.prototype.toLocaleTimeString);
OLDNEW
« no previous file with comments | « src/extensions/i18n/number-format.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698