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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 if (minJSInteger <= value && value <= maxJSInteger) { | 432 if (minJSInteger <= value && value <= maxJSInteger) { |
433 int64_t intValue = static_cast<int64_t>(value); | 433 int64_t intValue = static_cast<int64_t>(value); |
434 if (value == intValue) | 434 if (value == intValue) |
435 return intToDart(intValue); | 435 return intToDart(intValue); |
436 } | 436 } |
437 return doubleToDart(value); | 437 return doubleToDart(value); |
438 } | 438 } |
439 | 439 |
440 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object) | 440 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object) |
441 { | 441 { |
| 442 // TODO(terry): Added bug per JacobR - he thinks it would be better to use |
| 443 // DartHandleProxy probably pressing pause crashes Dartium 45. |
| 444 // See issue: https://github.com/dart-lang/sdk/issues/25589 |
442 Dart_Handle exception = 0; | 445 Dart_Handle exception = 0; |
443 ScriptState* v8ScriptState = currentDartScriptState()->v8ScriptState(); | 446 ScriptState* v8ScriptState = currentDartScriptState()->v8ScriptState(); |
444 v8::Handle<v8::Value> value = V8Converter::toV8(object, exception); | 447 v8::Handle<v8::Value> value = V8Converter::toV8(object, exception); |
445 if (exception) | 448 if (exception) |
446 return ScriptValue(v8ScriptState, v8::Undefined(v8ScriptState->isolate()
)); | 449 return ScriptValue(v8ScriptState, v8::Undefined(v8ScriptState->isolate()
)); |
447 ASSERT(!value.IsEmpty()); | 450 ASSERT(!value.IsEmpty()); |
448 | 451 |
449 return ScriptValue(v8ScriptState, value); | 452 return ScriptValue(v8ScriptState, value); |
450 } | 453 } |
451 | 454 |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 if (!dartDOMData->rootScriptState()) { | 1099 if (!dartDOMData->rootScriptState()) { |
1097 DartController* controller = DartController::retrieve(dartDOMData->scrip
tExecutionContext()); | 1100 DartController* controller = DartController::retrieve(dartDOMData->scrip
tExecutionContext()); |
1098 intptr_t libraryId = DartUtilities::libraryHandleToLibraryId(Dart_RootLi
brary()); | 1101 intptr_t libraryId = DartUtilities::libraryHandleToLibraryId(Dart_RootLi
brary()); |
1099 DartScriptState* scriptState = controller->lookupScriptState(Dart_Curren
tIsolate(), currentV8Context(), libraryId); | 1102 DartScriptState* scriptState = controller->lookupScriptState(Dart_Curren
tIsolate(), currentV8Context(), libraryId); |
1100 dartDOMData->setRootScriptState(scriptState); | 1103 dartDOMData->setRootScriptState(scriptState); |
1101 return scriptState; | 1104 return scriptState; |
1102 } | 1105 } |
1103 return dartDOMData->rootScriptState(); | 1106 return dartDOMData->rootScriptState(); |
1104 } | 1107 } |
1105 | 1108 |
1106 PassRefPtr<ScriptArguments> DartUtilities::createScriptArguments(Dart_Handle arg
ument, Dart_Handle& exception) | |
1107 { | |
1108 Vector<ScriptValue> arguments; | |
1109 arguments.append(DartUtilities::dartToScriptValue(argument)); | |
1110 return ScriptArguments::create(DartUtilities::currentDartScriptState()->v8Sc
riptState(), arguments); | |
1111 } | |
1112 | |
1113 static PassRefPtr<ScriptCallStack> createScriptCallStackFromStackTrace(Dart_Stac
kTrace stackTrace) | 1109 static PassRefPtr<ScriptCallStack> createScriptCallStackFromStackTrace(Dart_Stac
kTrace stackTrace) |
1114 { | 1110 { |
1115 uintptr_t frameCount = 0; | 1111 uintptr_t frameCount = 0; |
1116 Dart_Handle result = Dart_StackTraceLength(stackTrace, reinterpret_cast<intp
tr_t*>(&frameCount)); | 1112 Dart_Handle result = Dart_StackTraceLength(stackTrace, reinterpret_cast<intp
tr_t*>(&frameCount)); |
1117 if (Dart_IsError(result)) | 1113 if (Dart_IsError(result)) |
1118 return nullptr; | 1114 return nullptr; |
1119 | 1115 |
1120 if (frameCount > ScriptCallStack::maxCallStackSizeToCapture) | 1116 if (frameCount > ScriptCallStack::maxCallStackSizeToCapture) |
1121 frameCount = ScriptCallStack::maxCallStackSizeToCapture; | 1117 frameCount = ScriptCallStack::maxCallStackSizeToCapture; |
1122 | 1118 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 if (!v) { | 1393 if (!v) { |
1398 return 0; | 1394 return 0; |
1399 } | 1395 } |
1400 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); | 1396 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); |
1401 strncpy(value, v, valueLen); | 1397 strncpy(value, v, valueLen); |
1402 value[valueLen - 1] = '\0'; | 1398 value[valueLen - 1] = '\0'; |
1403 return strlen(value); | 1399 return strlen(value); |
1404 #endif | 1400 #endif |
1405 } | 1401 } |
1406 } | 1402 } |
OLD | NEW |