| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return handle; | 265 return handle; |
| 266 | 266 |
| 267 // Unwrap objects passed from Dart to JS that are being passed back to | 267 // Unwrap objects passed from Dart to JS that are being passed back to |
| 268 // Dart. FIXME: we do not yet handle unwrapping JS functions passed | 268 // Dart. FIXME: we do not yet handle unwrapping JS functions passed |
| 269 // from Dart to JS as we have to wrap them with true JS Function objects. | 269 // from Dart to JS as we have to wrap them with true JS Function objects. |
| 270 // If this use case is important we can support it at the cost of hanging | 270 // If this use case is important we can support it at the cost of hanging |
| 271 // an extra expando off the JS function wrapping the Dart function. | 271 // an extra expando off the JS function wrapping the Dart function. |
| 272 if (DartHandleProxy::isDartProxy(v8Handle)) { | 272 if (DartHandleProxy::isDartProxy(v8Handle)) { |
| 273 DartPersistentValue* scriptValue = DartHandleProxy::readPointerFromProxy
(v8Handle); | 273 DartPersistentValue* scriptValue = DartHandleProxy::readPointerFromProxy
(v8Handle); |
| 274 ASSERT(scriptValue->isIsolateAlive()); | 274 ASSERT(scriptValue->isIsolateAlive()); |
| 275 return scriptValue->value(); | 275 // If the isolate does not match we fall back to using the existing JS |
| 276 // wrapper for the Dart object so that simple cases that would work in |
| 277 // Dart2Js work. We could alternately throw an exception here. |
| 278 if (scriptValue->isolate() == Dart_CurrentIsolate()) { |
| 279 return scriptValue->value(); |
| 280 } |
| 276 } | 281 } |
| 277 | 282 |
| 278 return JsObject::toDart(object); | 283 return JsObject::toDart(object); |
| 279 } | 284 } |
| 280 | 285 |
| 281 Dart_Handle JsObject::toDart(v8::Local<v8::Object> object) | 286 Dart_Handle JsObject::toDart(v8::Local<v8::Object> object) |
| 282 { | 287 { |
| 283 // FIXME: perform caching so that === can be used. | 288 // FIXME: perform caching so that === can be used. |
| 284 if (object->IsFunction()) { | 289 if (object->IsFunction()) { |
| 285 RefPtr<JsFunction> jsFunction = JsFunction::create(object.As<v8::Functio
n>()); | 290 RefPtr<JsFunction> jsFunction = JsFunction::create(object.As<v8::Functio
n>()); |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 { | 1049 { |
| 1045 for (intptr_t i = 0; nativeEntries[i].nativeFunction != 0; i++) { | 1050 for (intptr_t i = 0; nativeEntries[i].nativeFunction != 0; i++) { |
| 1046 if (nf == nativeEntries[i].nativeFunction) { | 1051 if (nf == nativeEntries[i].nativeFunction) { |
| 1047 return reinterpret_cast<const uint8_t*>(nativeEntries[i].name); | 1052 return reinterpret_cast<const uint8_t*>(nativeEntries[i].name); |
| 1048 } | 1053 } |
| 1049 } | 1054 } |
| 1050 return 0; | 1055 return 0; |
| 1051 } | 1056 } |
| 1052 | 1057 |
| 1053 } | 1058 } |
| OLD | NEW |