| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 Dart_Handle result = map.get(value); | 163 Dart_Handle result = map.get(value); |
| 164 if (result) | 164 if (result) |
| 165 return result; | 165 return result; |
| 166 | 166 |
| 167 if (value->IsUndefined()) | 167 if (value->IsUndefined()) |
| 168 return Dart_Null(); | 168 return Dart_Null(); |
| 169 if (value->IsNull()) | 169 if (value->IsNull()) |
| 170 return Dart_Null(); | 170 return Dart_Null(); |
| 171 if (value->IsString()) | 171 if (value->IsString()) |
| 172 return map.put(value, stringToDart(value)); | 172 return map.put(value, stringToDart(value)); |
| 173 if (value->IsInt32()) | 173 if (value->IsNumber() && abs(value->IntegerValue()) <= pow(2, 53)) { |
| 174 return Dart_NewInteger(value->Int32Value()); | 174 // JS can store integer values that are no greater than 2^53. |
| 175 return Dart_NewInteger(value->IntegerValue()); |
| 176 } |
| 175 if (value->IsBoolean()) | 177 if (value->IsBoolean()) |
| 176 return Dart_NewBoolean(value->BooleanValue()); | 178 return Dart_NewBoolean(value->BooleanValue()); |
| 177 if (value->IsNumber()) | 179 if (value->IsNumber()) |
| 178 return Dart_NewDouble(value->NumberValue()); | 180 return Dart_NewDouble(value->NumberValue()); |
| 179 if (value->IsArray()) | 181 if (value->IsArray()) |
| 180 return listToDart(value.As<v8::Array>(), map, exception); | 182 return listToDart(value.As<v8::Array>(), map, exception); |
| 181 if (value->IsDate()) | 183 if (value->IsDate()) |
| 182 return dateToDart(value); | 184 return dateToDart(value); |
| 183 if (value->IsObject()) { | 185 if (value->IsObject()) { |
| 184 v8::Handle<v8::Object> object = value.As<v8::Object>(); | 186 v8::Handle<v8::Object> object = value.As<v8::Object>(); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 498 } |
| 497 | 499 |
| 498 Dart_Handle V8Converter::arrayBufferViewToDart(v8::Handle<v8::Object> object, V8
ToDartMap& map, Dart_Handle& exception) | 500 Dart_Handle V8Converter::arrayBufferViewToDart(v8::Handle<v8::Object> object, V8
ToDartMap& map, Dart_Handle& exception) |
| 499 { | 501 { |
| 500 RefPtr<ArrayBufferView> view = V8ArrayBufferView::toNative(object); | 502 RefPtr<ArrayBufferView> view = V8ArrayBufferView::toNative(object); |
| 501 Dart_Handle result = DartUtilities::arrayBufferViewToDart(view.get()); | 503 Dart_Handle result = DartUtilities::arrayBufferViewToDart(view.get()); |
| 502 return map.put(object, result); | 504 return map.put(object, result); |
| 503 } | 505 } |
| 504 | 506 |
| 505 } // namespace WebCore | 507 } // namespace WebCore |
| OLD | NEW |