OLD | NEW |
1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
2 // All rights reserved. | 2 // 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 if (-kJSMaxInteger <= value && value <= kJSMaxInteger) { | 367 if (-kJSMaxInteger <= value && value <= kJSMaxInteger) { |
368 int64_t intValue = static_cast<int64_t>(value); | 368 int64_t intValue = static_cast<int64_t>(value); |
369 if (value == intValue) | 369 if (value == intValue) |
370 return intToDart(intValue); | 370 return intToDart(intValue); |
371 } | 371 } |
372 return doubleToDart(value); | 372 return doubleToDart(value); |
373 } | 373 } |
374 | 374 |
375 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object, Dart_Handle& ex
ception) | 375 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object, Dart_Handle& ex
ception) |
376 { | 376 { |
377 return ScriptValue(V8Converter::toV8(object, exception), v8::Isolate::GetCur
rent()); | 377 return ScriptValue(DartScriptValue::create(object)); |
378 } | 378 } |
379 | 379 |
380 Dart_Handle DartUtilities::scriptValueToDart(const ScriptValue& value) | 380 Dart_Handle DartUtilities::scriptValueToDart(const ScriptValue& value) |
381 { | 381 { |
382 if (value.hasNoValue()) { | 382 if (value.hasNoValue()) { |
383 return Dart_Null(); | 383 return Dart_Null(); |
384 } | 384 } |
| 385 AbstractScriptValue* scriptValue = value.scriptValue(); |
| 386 if (scriptValue->isDart()) { |
| 387 DartScriptValue* dartScriptValue = static_cast<DartScriptValue*>(scriptV
alue); |
| 388 return dartScriptValue->dartValue(); |
| 389 } |
| 390 // FIXMEMULTIVM: Should not be converting from V8 values. Major culprit is I
DB. |
385 // FIXME: better error handling. | 391 // FIXME: better error handling. |
386 Dart_Handle exception = 0; | 392 Dart_Handle exception = 0; |
387 return V8Converter::toDart(value.v8Value(), exception); | 393 return V8Converter::toDart(value.v8Value(), exception); |
388 } | 394 } |
389 | 395 |
390 Dart_Handle DartUtilities::scriptValueToDart(const ScriptPromise& promise) | 396 Dart_Handle DartUtilities::scriptValueToDart(const ScriptPromise& promise) |
391 { | 397 { |
392 // FIXME: support promises. | 398 // FIXME: support promises. |
393 ASSERT_NOT_REACHED(); | 399 ASSERT_NOT_REACHED(); |
394 return Dart_Null(); | 400 return Dart_Null(); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 if (!v) { | 1153 if (!v) { |
1148 return 0; | 1154 return 0; |
1149 } | 1155 } |
1150 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); | 1156 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); |
1151 strncpy(value, v, valueLen); | 1157 strncpy(value, v, valueLen); |
1152 value[valueLen - 1] = '\0'; | 1158 value[valueLen - 1] = '\0'; |
1153 return strlen(value); | 1159 return strlen(value); |
1154 #endif | 1160 #endif |
1155 } | 1161 } |
1156 } | 1162 } |
OLD | NEW |