OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return null; | 273 return null; |
274 } | 274 } |
275 return o.toISOString(); | 275 return o.toISOString(); |
276 } | 276 } |
277 | 277 |
278 // Set up non-enumerable functions of the Date prototype object. | 278 // Set up non-enumerable functions of the Date prototype object. |
279 utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [ | 279 utils.InstallFunctions(GlobalDate.prototype, DONT_ENUM, [ |
280 "toJSON", DateToJSON | 280 "toJSON", DateToJSON |
281 ]); | 281 ]); |
282 | 282 |
283 // ------------------------------------------------------------------- | |
284 // JSON Builtins | |
285 | |
286 function JsonSerializeAdapter(key, object, indent, gap) { | |
287 var holder = {}; | |
288 holder[key] = object; | |
289 // No need to pass the actual holder since there is no replacer function. | |
290 var current_indent = ""; | |
291 for (var i = 0; i < indent; i++) current_indent += gap; | |
292 return JSONSerialize( | |
293 key, holder, UNDEFINED, new Stack(), current_indent, gap); | |
294 } | |
295 | |
296 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); | |
297 | |
298 }) | 283 }) |
OLD | NEW |