OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 | 521 |
522 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object) { | 522 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object) { |
523 UNIMPLEMENTED(); | 523 UNIMPLEMENTED(); |
524 return NULL; | 524 return NULL; |
525 } | 525 } |
526 | 526 |
527 | 527 |
528 // --- Initialization and Globals --- | 528 // --- Initialization and Globals --- |
529 | 529 |
530 | 530 |
531 // TODO(iposva): This is a placeholder for the eventual external Dart API. | 531 DART_EXPORT bool Dart_Initialize(Dart_IsolateCreateCallback create, |
532 DART_EXPORT bool Dart_Initialize(Dart_IsolateCreateCallback callback) { | 532 Dart_IsolateInterruptCallback interrupt) { |
533 return Dart::InitOnce(callback); | 533 return Dart::InitOnce(create, interrupt); |
534 } | 534 } |
535 | 535 |
536 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { | 536 DART_EXPORT bool Dart_SetVMFlags(int argc, const char** argv) { |
537 return Flags::ProcessCommandLineFlags(argc, argv); | 537 return Flags::ProcessCommandLineFlags(argc, argv); |
538 } | 538 } |
539 | 539 |
540 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { | 540 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) { |
541 if (Flags::Lookup(flag_name) != NULL) { | 541 if (Flags::Lookup(flag_name) != NULL) { |
542 return true; | 542 return true; |
543 } | 543 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 if (msg != NULL) { | 656 if (msg != NULL) { |
657 return Api::Error(msg); | 657 return Api::Error(msg); |
658 } | 658 } |
659 ScriptSnapshotWriter writer(root_lib, buffer, ApiAllocator); | 659 ScriptSnapshotWriter writer(root_lib, buffer, ApiAllocator); |
660 writer.WriteScriptSnapshot(); | 660 writer.WriteScriptSnapshot(); |
661 *size = writer.Size(); | 661 *size = writer.Size(); |
662 return Api::Success(); | 662 return Api::Success(); |
663 } | 663 } |
664 | 664 |
665 | 665 |
| 666 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) { |
| 667 if (isolate == NULL) { |
| 668 FATAL1("%s expects argument 'isolate' to be non-null.", CURRENT_FUNC); |
| 669 } |
| 670 Isolate* iso = reinterpret_cast<Isolate*>(isolate); |
| 671 iso->ScheduleInterrupts(Isolate::kApiInterrupt); |
| 672 } |
| 673 |
| 674 |
666 // --- Messages and Ports --- | 675 // --- Messages and Ports --- |
667 | 676 |
668 | 677 |
669 DART_EXPORT void Dart_SetMessageCallbacks( | 678 DART_EXPORT void Dart_SetMessageCallbacks( |
670 Dart_PostMessageCallback post_message_callback, | 679 Dart_PostMessageCallback post_message_callback, |
671 Dart_ClosePortCallback close_port_callback) { | 680 Dart_ClosePortCallback close_port_callback) { |
672 Isolate* isolate = Isolate::Current(); | 681 Isolate* isolate = Isolate::Current(); |
673 CHECK_ISOLATE(isolate); | 682 CHECK_ISOLATE(isolate); |
674 ASSERT(post_message_callback != NULL); | 683 ASSERT(post_message_callback != NULL); |
675 ASSERT(close_port_callback != NULL); | 684 ASSERT(close_port_callback != NULL); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 DARTSCOPE(Isolate::Current()); | 1224 DARTSCOPE(Isolate::Current()); |
1216 const String& str = Api::UnwrapStringHandle(object); | 1225 const String& str = Api::UnwrapStringHandle(object); |
1217 if (str.IsNull()) { | 1226 if (str.IsNull()) { |
1218 RETURN_TYPE_ERROR(object, String); | 1227 RETURN_TYPE_ERROR(object, String); |
1219 } | 1228 } |
1220 if (!str.IsExternal()) { | 1229 if (!str.IsExternal()) { |
1221 return Api::Error("%s expects argument 'object' to be an external String.", | 1230 return Api::Error("%s expects argument 'object' to be an external String.", |
1222 CURRENT_FUNC); | 1231 CURRENT_FUNC); |
1223 } | 1232 } |
1224 if (peer == NULL) { | 1233 if (peer == NULL) { |
1225 return Api::Error("%s expects argument 'peer' to be non-NULL.", | 1234 return Api::Error("%s expects argument 'peer' to be non-null.", |
1226 CURRENT_FUNC); | 1235 CURRENT_FUNC); |
1227 } | 1236 } |
1228 *peer = str.GetPeer(); | 1237 *peer = str.GetPeer(); |
1229 return Api::Success(); | 1238 return Api::Success(); |
1230 } | 1239 } |
1231 | 1240 |
1232 | 1241 |
1233 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints, | 1242 DART_EXPORT Dart_Handle Dart_NewExternalString8(const uint8_t* codepoints, |
1234 intptr_t length, | 1243 intptr_t length, |
1235 void* peer, | 1244 void* peer, |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 } | 2512 } |
2504 delete debug_region; | 2513 delete debug_region; |
2505 } else { | 2514 } else { |
2506 *buffer = NULL; | 2515 *buffer = NULL; |
2507 *buffer_size = 0; | 2516 *buffer_size = 0; |
2508 } | 2517 } |
2509 } | 2518 } |
2510 | 2519 |
2511 | 2520 |
2512 } // namespace dart | 2521 } // namespace dart |
OLD | NEW |