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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 return Api::Success(); | 1256 return Api::Success(); |
1257 } | 1257 } |
1258 | 1258 |
1259 | 1259 |
1260 // --- Initialization and Globals --- | 1260 // --- Initialization and Globals --- |
1261 | 1261 |
1262 DART_EXPORT const char* Dart_VersionString() { | 1262 DART_EXPORT const char* Dart_VersionString() { |
1263 return Version::String(); | 1263 return Version::String(); |
1264 } | 1264 } |
1265 | 1265 |
1266 DART_EXPORT char* Dart_Initialize( | 1266 DART_EXPORT bool Dart_Initialize( |
1267 const uint8_t* vm_isolate_snapshot, | 1267 const uint8_t* vm_isolate_snapshot, |
1268 Dart_IsolateCreateCallback create, | 1268 Dart_IsolateCreateCallback create, |
1269 Dart_IsolateInterruptCallback interrupt, | 1269 Dart_IsolateInterruptCallback interrupt, |
1270 Dart_IsolateUnhandledExceptionCallback unhandled, | 1270 Dart_IsolateUnhandledExceptionCallback unhandled, |
1271 Dart_IsolateShutdownCallback shutdown, | 1271 Dart_IsolateShutdownCallback shutdown, |
1272 Dart_FileOpenCallback file_open, | 1272 Dart_FileOpenCallback file_open, |
1273 Dart_FileReadCallback file_read, | 1273 Dart_FileReadCallback file_read, |
1274 Dart_FileWriteCallback file_write, | 1274 Dart_FileWriteCallback file_write, |
1275 Dart_FileCloseCallback file_close, | 1275 Dart_FileCloseCallback file_close, |
1276 Dart_EntropySource entropy_source) { | 1276 Dart_EntropySource entropy_source) { |
1277 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot, | 1277 const char* err_msg = Dart::InitOnce(vm_isolate_snapshot, |
1278 create, interrupt, unhandled, shutdown, | 1278 create, interrupt, unhandled, shutdown, |
1279 file_open, file_read, file_write, | 1279 file_open, file_read, file_write, |
1280 file_close, entropy_source); | 1280 file_close, entropy_source); |
1281 if (err_msg != NULL) { | 1281 if (err_msg != NULL) { |
1282 return strdup(err_msg); | 1282 OS::PrintErr("Dart_Initialize: %s\n", err_msg); |
| 1283 return false; |
1283 } | 1284 } |
1284 return NULL; | 1285 return true; |
1285 } | 1286 } |
1286 | 1287 |
1287 | 1288 |
1288 DART_EXPORT char* Dart_Cleanup() { | 1289 DART_EXPORT bool Dart_Cleanup() { |
1289 CHECK_NO_ISOLATE(Isolate::Current()); | 1290 CHECK_NO_ISOLATE(Isolate::Current()); |
1290 const char* err_msg = Dart::Cleanup(); | 1291 const char* err_msg = Dart::Cleanup(); |
1291 if (err_msg != NULL) { | 1292 if (err_msg != NULL) { |
1292 return strdup(err_msg); | 1293 OS::PrintErr("Dart_Cleanup: %s\n", err_msg); |
| 1294 return false; |
1293 } | 1295 } |
1294 return NULL; | 1296 return true; |
1295 } | 1297 } |
1296 | 1298 |
1297 | 1299 |
1298 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { | 1300 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { |
1299 return Flags::ProcessCommandLineFlags(argc, argv); | 1301 return Flags::ProcessCommandLineFlags(argc, argv); |
1300 } | 1302 } |
1301 | 1303 |
1302 | 1304 |
1303 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { | 1305 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { |
1304 return Flags::IsSet(flag_name); | 1306 return Flags::IsSet(flag_name); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 | 1357 |
1356 // Setup default flags in case none were passed. | 1358 // Setup default flags in case none were passed. |
1357 Dart_IsolateFlags api_flags; | 1359 Dart_IsolateFlags api_flags; |
1358 if (flags == NULL) { | 1360 if (flags == NULL) { |
1359 Isolate::Flags vm_flags; | 1361 Isolate::Flags vm_flags; |
1360 vm_flags.CopyTo(&api_flags); | 1362 vm_flags.CopyTo(&api_flags); |
1361 flags = &api_flags; | 1363 flags = &api_flags; |
1362 } | 1364 } |
1363 Isolate* isolate = Dart::CreateIsolate(isolate_name, *flags); | 1365 Isolate* isolate = Dart::CreateIsolate(isolate_name, *flags); |
1364 free(isolate_name); | 1366 free(isolate_name); |
1365 if (isolate == NULL) { | |
1366 *error = strdup("Isolate creation failed"); | |
1367 return reinterpret_cast<Dart_Isolate>(NULL); | |
1368 } | |
1369 { | 1367 { |
1370 StackZone zone(isolate); | 1368 StackZone zone(isolate); |
1371 HANDLESCOPE(isolate); | 1369 HANDLESCOPE(isolate); |
1372 // We enter an API scope here as InitializeIsolate could compile some | 1370 // We enter an API scope here as InitializeIsolate could compile some |
1373 // bootstrap library files which call out to a tag handler that may create | 1371 // bootstrap library files which call out to a tag handler that may create |
1374 // Api Handles when an error is encountered. | 1372 // Api Handles when an error is encountered. |
1375 Dart_EnterScope(); | 1373 Dart_EnterScope(); |
1376 const Error& error_obj = | 1374 const Error& error_obj = |
1377 Error::Handle(isolate, | 1375 Error::Handle(isolate, |
1378 Dart::InitializeIsolate(snapshot, callback_data)); | 1376 Dart::InitializeIsolate(snapshot, callback_data)); |
(...skipping 4483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5862 ASSERT(stream != NULL); | 5860 ASSERT(stream != NULL); |
5863 TimelineEvent* event = stream->StartEvent(); | 5861 TimelineEvent* event = stream->StartEvent(); |
5864 if (event != NULL) { | 5862 if (event != NULL) { |
5865 event->AsyncEnd(label, async_id); | 5863 event->AsyncEnd(label, async_id); |
5866 event->Complete(); | 5864 event->Complete(); |
5867 } | 5865 } |
5868 return Api::Success(); | 5866 return Api::Success(); |
5869 } | 5867 } |
5870 | 5868 |
5871 } // namespace dart | 5869 } // namespace dart |
OLD | NEW |