| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
| 7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
| 8 | 8 |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 | 1197 |
| 1198 DART_EXPORT bool Dart_Initialize( | 1198 DART_EXPORT bool Dart_Initialize( |
| 1199 Dart_IsolateCreateCallback create, | 1199 Dart_IsolateCreateCallback create, |
| 1200 Dart_IsolateInterruptCallback interrupt, | 1200 Dart_IsolateInterruptCallback interrupt, |
| 1201 Dart_IsolateUnhandledExceptionCallback unhandled, | 1201 Dart_IsolateUnhandledExceptionCallback unhandled, |
| 1202 Dart_IsolateShutdownCallback shutdown, | 1202 Dart_IsolateShutdownCallback shutdown, |
| 1203 Dart_FileOpenCallback file_open, | 1203 Dart_FileOpenCallback file_open, |
| 1204 Dart_FileReadCallback file_read, | 1204 Dart_FileReadCallback file_read, |
| 1205 Dart_FileWriteCallback file_write, | 1205 Dart_FileWriteCallback file_write, |
| 1206 Dart_FileCloseCallback file_close, | 1206 Dart_FileCloseCallback file_close, |
| 1207 Dart_EntropySource entropy_source) { | 1207 Dart_EntropySource entropy_source, |
| 1208 Dart_ServiceIsolateCreateCalback service_create) { |
| 1208 const char* err_msg = Dart::InitOnce(create, interrupt, unhandled, shutdown, | 1209 const char* err_msg = Dart::InitOnce(create, interrupt, unhandled, shutdown, |
| 1209 file_open, file_read, file_write, | 1210 file_open, file_read, file_write, |
| 1210 file_close, entropy_source); | 1211 file_close, entropy_source, |
| 1212 service_create); |
| 1211 if (err_msg != NULL) { | 1213 if (err_msg != NULL) { |
| 1212 OS::PrintErr("Dart_Initialize: %s\n", err_msg); | 1214 OS::PrintErr("Dart_Initialize: %s\n", err_msg); |
| 1213 return false; | 1215 return false; |
| 1214 } | 1216 } |
| 1215 return true; | 1217 return true; |
| 1216 } | 1218 } |
| 1217 | 1219 |
| 1218 | 1220 |
| 1219 DART_EXPORT bool Dart_Cleanup() { | 1221 DART_EXPORT bool Dart_Cleanup() { |
| 1220 CHECK_NO_ISOLATE(Isolate::Current()); | 1222 CHECK_NO_ISOLATE(Isolate::Current()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1243 const char* main) { | 1245 const char* main) { |
| 1244 if (script_uri == NULL) { | 1246 if (script_uri == NULL) { |
| 1245 // Just use the main as the name. | 1247 // Just use the main as the name. |
| 1246 if (main == NULL) { | 1248 if (main == NULL) { |
| 1247 return strdup("isolate"); | 1249 return strdup("isolate"); |
| 1248 } else { | 1250 } else { |
| 1249 return strdup(main); | 1251 return strdup(main); |
| 1250 } | 1252 } |
| 1251 } | 1253 } |
| 1252 | 1254 |
| 1253 if (Service::IsServiceIsolateName(script_uri)) { | |
| 1254 return strdup(script_uri); | |
| 1255 } | |
| 1256 | |
| 1257 // Skip past any slashes and backslashes in the script uri. | 1255 // Skip past any slashes and backslashes in the script uri. |
| 1258 const char* last_slash = strrchr(script_uri, '/'); | 1256 const char* last_slash = strrchr(script_uri, '/'); |
| 1259 if (last_slash != NULL) { | 1257 if (last_slash != NULL) { |
| 1260 script_uri = last_slash + 1; | 1258 script_uri = last_slash + 1; |
| 1261 } | 1259 } |
| 1262 const char* last_backslash = strrchr(script_uri, '\\'); | 1260 const char* last_backslash = strrchr(script_uri, '\\'); |
| 1263 if (last_backslash != NULL) { | 1261 if (last_backslash != NULL) { |
| 1264 script_uri = last_backslash + 1; | 1262 script_uri = last_backslash + 1; |
| 1265 } | 1263 } |
| 1266 if (main == NULL) { | 1264 if (main == NULL) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 ml.Wait(); | 1514 ml.Wait(); |
| 1517 } | 1515 } |
| 1518 } | 1516 } |
| 1519 if (isolate->object_store()->sticky_error() != Object::null()) { | 1517 if (isolate->object_store()->sticky_error() != Object::null()) { |
| 1520 Dart_Handle error = Api::NewHandle(isolate, | 1518 Dart_Handle error = Api::NewHandle(isolate, |
| 1521 isolate->object_store()->sticky_error()); | 1519 isolate->object_store()->sticky_error()); |
| 1522 isolate->object_store()->clear_sticky_error(); | 1520 isolate->object_store()->clear_sticky_error(); |
| 1523 return error; | 1521 return error; |
| 1524 } | 1522 } |
| 1525 if (FLAG_print_class_table) { | 1523 if (FLAG_print_class_table) { |
| 1526 HANDLESCOPE(isolate); | |
| 1527 isolate->class_table()->Print(); | 1524 isolate->class_table()->Print(); |
| 1528 } | 1525 } |
| 1529 return Api::Success(); | 1526 return Api::Success(); |
| 1530 } | 1527 } |
| 1531 | 1528 |
| 1532 | 1529 |
| 1533 DART_EXPORT Dart_Handle Dart_HandleMessage() { | 1530 DART_EXPORT Dart_Handle Dart_HandleMessage() { |
| 1534 Isolate* isolate = Isolate::Current(); | 1531 Isolate* isolate = Isolate::Current(); |
| 1535 CHECK_ISOLATE_SCOPE(isolate); | 1532 CHECK_ISOLATE_SCOPE(isolate); |
| 1536 CHECK_CALLBACK_STATE(isolate); | 1533 CHECK_CALLBACK_STATE(isolate); |
| (...skipping 3865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5402 NoGCScope no_gc; | 5399 NoGCScope no_gc; |
| 5403 RawObject* raw_obj = obj.raw(); | 5400 RawObject* raw_obj = obj.raw(); |
| 5404 isolate->heap()->SetPeer(raw_obj, peer); | 5401 isolate->heap()->SetPeer(raw_obj, peer); |
| 5405 } | 5402 } |
| 5406 return Api::Success(); | 5403 return Api::Success(); |
| 5407 } | 5404 } |
| 5408 | 5405 |
| 5409 | 5406 |
| 5410 // --- Service support --- | 5407 // --- Service support --- |
| 5411 | 5408 |
| 5412 DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate) { | 5409 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data) { |
| 5413 Isolate* iso = reinterpret_cast<Isolate*>(isolate); | 5410 return Api::CastIsolate(Service::GetServiceIsolate(callback_data)); |
| 5414 return Service::IsServiceIsolate(iso); | |
| 5415 } | 5411 } |
| 5416 | 5412 |
| 5417 | 5413 |
| 5418 DART_EXPORT Dart_Port Dart_ServiceWaitForLoadPort() { | 5414 DART_EXPORT bool Dart_IsServiceRunning() { |
| 5419 return Service::WaitForLoadPort(); | 5415 return Service::IsRunning(); |
| 5420 } | 5416 } |
| 5421 | 5417 |
| 5422 | 5418 |
| 5423 DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback( | 5419 DART_EXPORT void Dart_RegisterIsolateServiceRequestCallback( |
| 5424 const char* name, | 5420 const char* name, |
| 5425 Dart_ServiceRequestCallback callback, | 5421 Dart_ServiceRequestCallback callback, |
| 5426 void* user_data) { | 5422 void* user_data) { |
| 5427 Service::RegisterIsolateEmbedderCallback(name, callback, user_data); | 5423 Service::RegisterIsolateEmbedderCallback(name, callback, user_data); |
| 5428 } | 5424 } |
| 5429 | 5425 |
| 5430 | 5426 |
| 5431 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 5427 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 5432 const char* name, | 5428 const char* name, |
| 5433 Dart_ServiceRequestCallback callback, | 5429 Dart_ServiceRequestCallback callback, |
| 5434 void* user_data) { | 5430 void* user_data) { |
| 5435 Service::RegisterRootEmbedderCallback(name, callback, user_data); | 5431 Service::RegisterRootEmbedderCallback(name, callback, user_data); |
| 5436 } | 5432 } |
| 5437 | 5433 |
| 5438 } // namespace dart | 5434 } // namespace dart |
| OLD | NEW |