OLD | NEW |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // DateTimeFormat.format needs to be 0 arg method, but can stil | 66 // DateTimeFormat.format needs to be 0 arg method, but can stil |
67 // receive optional dateValue param. If one was provided, pass it | 67 // receive optional dateValue param. If one was provided, pass it |
68 // along. | 68 // along. |
69 if (arguments.length > 0) { | 69 if (arguments.length > 0) { |
70 return implementation(that, arguments[0]); | 70 return implementation(that, arguments[0]); |
71 } else { | 71 } else { |
72 return implementation(that); | 72 return implementation(that); |
73 } | 73 } |
74 } | 74 } |
75 } | 75 } |
| 76 %FunctionSetName(boundMethod, internalName); |
76 %FunctionRemovePrototype(boundMethod); | 77 %FunctionRemovePrototype(boundMethod); |
| 78 %SetNativeFlag(boundMethod); |
77 this[internalName] = boundMethod; | 79 this[internalName] = boundMethod; |
78 } | 80 } |
79 return this[internalName]; | 81 return this[internalName]; |
80 } | 82 } |
81 | 83 |
| 84 %FunctionSetName(getter, methodName); |
82 %FunctionRemovePrototype(getter); | 85 %FunctionRemovePrototype(getter); |
| 86 %SetNativeFlag(getter); |
83 | 87 |
84 Object.defineProperty(obj.prototype, methodName, { | 88 Object.defineProperty(obj.prototype, methodName, { |
85 get: getter, | 89 get: getter, |
86 enumerable: false, | 90 enumerable: false, |
87 configurable: true | 91 configurable: true |
88 }); | 92 }); |
89 } | 93 } |
90 | 94 |
91 | 95 |
92 /** | 96 /** |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 * Returns a getOption function that extracts property value for given | 182 * Returns a getOption function that extracts property value for given |
179 * options object. If property is missing it returns defaultValue. If value | 183 * options object. If property is missing it returns defaultValue. If value |
180 * is out of range for that property it throws RangeError. | 184 * is out of range for that property it throws RangeError. |
181 */ | 185 */ |
182 function getGetOption(options, caller) { | 186 function getGetOption(options, caller) { |
183 if (options === undefined) { | 187 if (options === undefined) { |
184 throw new Error('Internal ' + caller + ' error. ' + | 188 throw new Error('Internal ' + caller + ' error. ' + |
185 'Default options are missing.'); | 189 'Default options are missing.'); |
186 } | 190 } |
187 | 191 |
188 function getOption(property, type, values, defaultValue) { | 192 var getOption = function getOption(property, type, values, defaultValue) { |
189 if (options[property] !== undefined) { | 193 if (options[property] !== undefined) { |
190 var value = options[property]; | 194 var value = options[property]; |
191 switch (type) { | 195 switch (type) { |
192 case 'boolean': | 196 case 'boolean': |
193 value = Boolean(value); | 197 value = Boolean(value); |
194 break; | 198 break; |
195 case 'string': | 199 case 'string': |
196 value = String(value); | 200 value = String(value); |
197 break; | 201 break; |
198 case 'number': | 202 case 'number': |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 * Returns filtered extension (number and date format constructors use | 359 * Returns filtered extension (number and date format constructors use |
356 * Unicode extensions for passing parameters to ICU). | 360 * Unicode extensions for passing parameters to ICU). |
357 * It's used for extension-option pairs only, e.g. kn-normalization, but not | 361 * It's used for extension-option pairs only, e.g. kn-normalization, but not |
358 * for 'sensitivity' since it doesn't have extension equivalent. | 362 * for 'sensitivity' since it doesn't have extension equivalent. |
359 * Extensions like nu and ca don't have options equivalent, so we place | 363 * Extensions like nu and ca don't have options equivalent, so we place |
360 * undefined in the map.property to denote that. | 364 * undefined in the map.property to denote that. |
361 */ | 365 */ |
362 function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) { | 366 function setOptions(inOptions, extensionMap, keyValues, getOption, outOptions) { |
363 var extension = ''; | 367 var extension = ''; |
364 | 368 |
365 function updateExtension(key, value) { | 369 var updateExtension = function updateExtension(key, value) { |
366 return '-' + key + '-' + String(value); | 370 return '-' + key + '-' + String(value); |
367 } | 371 } |
368 | 372 |
369 function updateProperty(property, type, value) { | 373 var updateProperty = function updateProperty(property, type, value) { |
370 if (type === 'boolean' && (typeof value === 'string')) { | 374 if (type === 'boolean' && (typeof value === 'string')) { |
371 value = (value === 'true') ? true : false; | 375 value = (value === 'true') ? true : false; |
372 } | 376 } |
373 | 377 |
374 if (property !== undefined) { | 378 if (property !== undefined) { |
375 defineWEProperty(outOptions, property, value); | 379 defineWEProperty(outOptions, property, value); |
376 } | 380 } |
377 } | 381 } |
378 | 382 |
379 for (var key in keyValues) { | 383 for (var key in keyValues) { |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } | 532 } |
529 } | 533 } |
530 | 534 |
531 | 535 |
532 /** | 536 /** |
533 * Returns titlecased word, aMeRricA -> America. | 537 * Returns titlecased word, aMeRricA -> America. |
534 */ | 538 */ |
535 function toTitleCaseWord(word) { | 539 function toTitleCaseWord(word) { |
536 return word.substr(0, 1).toUpperCase() + word.substr(1).toLowerCase(); | 540 return word.substr(0, 1).toUpperCase() + word.substr(1).toLowerCase(); |
537 } | 541 } |
OLD | NEW |