Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
| 4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #ifndef INCLUDE_DART_API_H_ | 7 #ifndef INCLUDE_DART_API_H_ |
| 8 #define INCLUDE_DART_API_H_ | 8 #define INCLUDE_DART_API_H_ |
| 9 | 9 |
| 10 /** \mainpage Dart Embedding API Reference | 10 /** \mainpage Dart Embedding API Reference |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 * required (for example, if the isolate was created successfully by | 626 * required (for example, if the isolate was created successfully by |
| 627 * Dart_CreateIsolate() but the root library fails to load | 627 * Dart_CreateIsolate() but the root library fails to load |
| 628 * successfully, then the function should call Dart_ShutdownIsolate | 628 * successfully, then the function should call Dart_ShutdownIsolate |
| 629 * before returning). | 629 * before returning). |
| 630 * | 630 * |
| 631 * When the function returns false, the function should set *error to | 631 * When the function returns false, the function should set *error to |
| 632 * a malloc-allocated buffer containing a useful error message. The | 632 * a malloc-allocated buffer containing a useful error message. The |
| 633 * caller of this function (the vm) will make sure that the buffer is | 633 * caller of this function (the vm) will make sure that the buffer is |
| 634 * freed. | 634 * freed. |
| 635 * | 635 * |
| 636 * \param load_script A flag that when false results in no script | |
| 637 * being loaded in the created isolate. | |
|
siva
2014/01/10 00:01:54
Comment needs to be removed.
Cutch
2014/01/10 21:01:42
Done.
| |
| 636 * \param script_uri The uri of the script to load. | 638 * \param script_uri The uri of the script to load. |
| 637 * This uri is non NULL if the isolate is being created using the | 639 * This uri is non NULL if the isolate is being created using the |
| 638 * spawnUri isolate API. This uri has been canonicalized by the | 640 * spawnUri isolate API. This uri has been canonicalized by the |
| 639 * library tag handler from the parent isolate. | 641 * library tag handler from the parent isolate. |
| 640 * The callback is responsible for loading this script by a call to | 642 * The callback is responsible for loading this script by a call to |
| 641 * Dart_LoadScript or Dart_LoadScriptFromSnapshot. | 643 * Dart_LoadScript or Dart_LoadScriptFromSnapshot. |
| 642 * This uri will be NULL if the isolate is being created using the | 644 * This uri will be NULL if the isolate is being created using the |
| 643 * spawnFunction isolate API. | 645 * spawnFunction isolate API. |
| 644 * The callback is responsible for loading the script used in the | 646 * The callback is responsible for loading the script used in the |
| 645 * parent isolate by a call to Dart_LoadScript or | 647 * parent isolate by a call to Dart_LoadScript or |
| 646 * Dart_LoadScriptFromSnapshot. | 648 * Dart_LoadScriptFromSnapshot. |
| 647 * \param main The name of the main entry point this isolate will | 649 * \param main The name of the main entry point this isolate will |
| 648 * eventually run. This is provided for advisory purposes only to | 650 * eventually run. This is provided for advisory purposes only to |
| 649 * improve debugging messages. The main function is not invoked by | 651 * improve debugging messages. The main function is not invoked by |
| 650 * this function. | 652 * this function. |
| 651 * \param callback_data The callback data which was passed to the | 653 * \param callback_data The callback data which was passed to the |
| 652 * parent isolate when it was created by calling Dart_CreateIsolate(). | 654 * parent isolate when it was created by calling Dart_CreateIsolate(). |
| 653 * \param error A structure into which the embedder can place a | 655 * \param error A structure into which the embedder can place a |
| 654 * C string containing an error message in the case of failures. | 656 * C string containing an error message in the case of failures. |
| 655 * | 657 * |
| 656 * \return The embedder returns NULL if the creation and | 658 * \return The embedder returns NULL if the creation and |
| 657 * initialization was not successful and the isolate if successful. | 659 * initialization was not successful and the isolate if successful. |
| 658 */ | 660 */ |
| 659 typedef Dart_Isolate (*Dart_IsolateCreateCallback)(const char* script_uri, | 661 typedef Dart_Isolate (*Dart_IsolateCreateCallback)(const char* script_uri, |
| 660 const char* main, | 662 const char* main, |
| 661 void* callback_data, | 663 void* callback_data, |
| 662 char** error); | 664 char** error); |
| 663 | 665 |
| 666 | |
| 667 /** | |
| 668 * The service isolate creation and initialization callback function. | |
| 669 * | |
| 670 * This callback, provided by the embedder, is called when the vm | |
| 671 * needs to create the service isolate. The callback should create an isolate | |
| 672 * by calling Dart_CreateIsolate and prepare the isolate to be used as | |
| 673 * the service isolate. | |
| 674 * | |
| 675 * When the function returns NULL, it is the responsibility of this | |
| 676 * function to ensure that Dart_ShutdownIsolate has been called if | |
| 677 * required. | |
| 678 * | |
| 679 * When the function returns NULL, the function should set *error to | |
| 680 * a malloc-allocated buffer containing a useful error message. The | |
| 681 * caller of this function (the vm) will make sure that the buffer is | |
| 682 * freed. | |
| 683 * | |
| 684 * | |
| 685 * \param error A structure into which the embedder can place a | |
| 686 * C string containing an error message in the case of failures. | |
| 687 * | |
| 688 * \return The embedder returns NULL if the creation and | |
| 689 * initialization was not successful and the isolate if successful. | |
| 690 */ | |
| 691 typedef Dart_Isolate (*Dart_ServiceIsolateCreateCallback)(void* callback_data, | |
| 692 char** error); | |
|
siva
2014/01/10 00:01:54
I am still debating whether it makes sense to have
| |
| 693 | |
| 664 /** | 694 /** |
| 665 * An isolate interrupt callback function. | 695 * An isolate interrupt callback function. |
| 666 * | 696 * |
| 667 * This callback, provided by the embedder, is called when an isolate | 697 * This callback, provided by the embedder, is called when an isolate |
| 668 * is interrupted as a result of a call to Dart_InterruptIsolate(). | 698 * is interrupted as a result of a call to Dart_InterruptIsolate(). |
| 669 * When the callback is called, Dart_CurrentIsolate can be used to | 699 * When the callback is called, Dart_CurrentIsolate can be used to |
| 670 * figure out which isolate is being interrupted. | 700 * figure out which isolate is being interrupted. |
| 671 * | 701 * |
| 672 * \return The embedder returns true if the isolate should continue | 702 * \return The embedder returns true if the isolate should continue |
| 673 * execution. If the embedder returns false, the isolate will be | 703 * execution. If the embedder returns false, the isolate will be |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 */ | 792 */ |
| 763 DART_EXPORT bool Dart_Initialize( | 793 DART_EXPORT bool Dart_Initialize( |
| 764 Dart_IsolateCreateCallback create, | 794 Dart_IsolateCreateCallback create, |
| 765 Dart_IsolateInterruptCallback interrupt, | 795 Dart_IsolateInterruptCallback interrupt, |
| 766 Dart_IsolateUnhandledExceptionCallback unhandled_exception, | 796 Dart_IsolateUnhandledExceptionCallback unhandled_exception, |
| 767 Dart_IsolateShutdownCallback shutdown, | 797 Dart_IsolateShutdownCallback shutdown, |
| 768 Dart_FileOpenCallback file_open, | 798 Dart_FileOpenCallback file_open, |
| 769 Dart_FileReadCallback file_read, | 799 Dart_FileReadCallback file_read, |
| 770 Dart_FileWriteCallback file_write, | 800 Dart_FileWriteCallback file_write, |
| 771 Dart_FileCloseCallback file_close, | 801 Dart_FileCloseCallback file_close, |
| 772 Dart_EntropySource entropy_source); | 802 Dart_EntropySource entropy_source, |
| 803 Dart_ServiceIsolateCreateCallback service_create); | |
| 773 | 804 |
| 774 /** | 805 /** |
| 775 * Cleanup state in the VM before process termination. | 806 * Cleanup state in the VM before process termination. |
| 776 * | 807 * |
| 777 * \return True if cleanup is successful. | 808 * \return True if cleanup is successful. |
| 778 */ | 809 */ |
| 779 DART_EXPORT bool Dart_Cleanup(); | 810 DART_EXPORT bool Dart_Cleanup(); |
| 780 | 811 |
| 781 /** | 812 /** |
| 782 * Sets command line flags. Should be called before Dart_Initialize. | 813 * Sets command line flags. Should be called before Dart_Initialize. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1058 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); | 1089 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); |
| 1059 | 1090 |
| 1060 /** | 1091 /** |
| 1061 * Gets the ReceivePort for the provided port id, creating it if necessary. | 1092 * Gets the ReceivePort for the provided port id, creating it if necessary. |
| 1062 * | 1093 * |
| 1063 * Note that there is at most one ReceivePort for a given port id. | 1094 * Note that there is at most one ReceivePort for a given port id. |
| 1064 */ | 1095 */ |
| 1065 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id); | 1096 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id); |
| 1066 | 1097 |
| 1067 | 1098 |
| 1099 /** | |
| 1100 * Returns true if handle is a SendPort. | |
| 1101 * | |
| 1102 * \return True if send_port is a SendPort. | |
| 1103 */ | |
| 1104 DART_EXPORT bool Dart_IsSendPort(Dart_Handle send_port); | |
|
siva
2014/01/10 00:01:54
Do we need this call if it is only to ensure that
Cutch
2014/01/10 21:01:42
Killed it.
| |
| 1105 | |
| 1106 /** | |
| 1107 * Posts an object to the send port. | |
| 1108 * | |
| 1109 * \param send_port A Dart SendPort. | |
| 1110 * \param object An object from the current isolate. | |
| 1111 * | |
| 1112 * \return True if the message was posted. | |
| 1113 */ | |
| 1114 DART_EXPORT bool Dart_SendPortSend(Dart_Handle send_port, Dart_Handle object); | |
|
siva
2014/01/10 00:01:54
Dart_SendPortSend seems like an odd name why not c
Cutch
2014/01/10 21:01:42
Done.
| |
| 1115 | |
| 1116 | |
| 1068 /* | 1117 /* |
| 1069 * ====== | 1118 * ====== |
| 1070 * Scopes | 1119 * Scopes |
| 1071 * ====== | 1120 * ====== |
| 1072 */ | 1121 */ |
| 1073 | 1122 |
| 1074 /** | 1123 /** |
| 1075 * Enters a new scope. | 1124 * Enters a new scope. |
| 1076 * | 1125 * |
| 1077 * All new local handles will be created in this scope. Additionally, | 1126 * All new local handles will be created in this scope. Additionally, |
| (...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2386 * 'peer'. | 2435 * 'peer'. |
| 2387 * | 2436 * |
| 2388 * \param object An object. | 2437 * \param object An object. |
| 2389 * \param peer A value to store in the peer field. | 2438 * \param peer A value to store in the peer field. |
| 2390 * | 2439 * |
| 2391 * \return Returns an error if 'object' is a subtype of Null, num, or | 2440 * \return Returns an error if 'object' is a subtype of Null, num, or |
| 2392 * bool. | 2441 * bool. |
| 2393 */ | 2442 */ |
| 2394 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2443 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
| 2395 | 2444 |
| 2445 | |
| 2446 /* | |
| 2447 * ======= | |
| 2448 * Service | |
| 2449 * ======= | |
| 2450 */ | |
| 2451 | |
| 2452 /** | |
| 2453 * Returns the Service isolate initialized and with the dart:vmservice library | |
| 2454 * loaded and booted. | |
| 2455 * | |
| 2456 * This will call the embedder provided Dart_ServiceIsolateCreateCallback to | |
| 2457 * create the isolate. | |
| 2458 * | |
| 2459 * After obtaining the service isolate the embedder specific glue code can | |
| 2460 * be loaded in and the isolate can be run by the embedder. | |
| 2461 * | |
| 2462 * \param callbacK_data A pointer passed to Dart_ServiceIsolateCreateCallback. | |
| 2463 * | |
| 2464 * \return Returns NULL if an error occurred. | |
| 2465 */ | |
| 2466 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data); | |
|
siva
2014/01/10 00:01:54
Per offline discussion we should move towards
Dart
| |
| 2467 | |
| 2468 /** | |
| 2469 * Register the current isolate with the service. Typically the embedder | |
| 2470 * will call this function in its Dart_IsolateCreateCallback. | |
| 2471 * | |
| 2472 * Requires there to be a current isolate. | |
| 2473 */ | |
| 2474 DART_EXPORT void Dart_RegisterWithService(); | |
| 2475 | |
| 2476 /** | |
| 2477 * Unregister the current isolate from the service. Typically an embedder will | |
| 2478 * call this function in its Dart_IsolateShutdownCallback. | |
| 2479 * | |
| 2480 * Requires there to be a current isolate. | |
| 2481 */ | |
| 2482 DART_EXPORT void Dart_UnregisterFromService(); | |
|
siva
2014/01/10 00:01:54
Todd and I were discussing this, we were wondering
Cutch
2014/01/10 21:01:42
I've removed these methods for now and auto-regist
| |
| 2483 | |
| 2396 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 2484 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
| OLD | NEW |