| 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 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 * | 730 * |
| 731 * \return The embedder returns NULL if the creation and | 731 * \return The embedder returns NULL if the creation and |
| 732 * initialization was not successful and the isolate if successful. | 732 * initialization was not successful and the isolate if successful. |
| 733 */ | 733 */ |
| 734 typedef Dart_Isolate (*Dart_IsolateCreateCallback)(const char* script_uri, | 734 typedef Dart_Isolate (*Dart_IsolateCreateCallback)(const char* script_uri, |
| 735 const char* main, | 735 const char* main, |
| 736 const char* package_root, | 736 const char* package_root, |
| 737 void* callback_data, | 737 void* callback_data, |
| 738 char** error); | 738 char** error); |
| 739 | 739 |
| 740 |
| 741 /** |
| 742 * The service isolate creation and initialization callback function. |
| 743 * |
| 744 * This callback, provided by the embedder, is called when the vm |
| 745 * needs to create the service isolate. The callback should create an isolate |
| 746 * by calling Dart_CreateIsolate and prepare the isolate to be used as |
| 747 * the service isolate. |
| 748 * |
| 749 * When the function returns NULL, it is the responsibility of this |
| 750 * function to ensure that Dart_ShutdownIsolate has been called if |
| 751 * required. |
| 752 * |
| 753 * When the function returns NULL, the function should set *error to |
| 754 * a malloc-allocated buffer containing a useful error message. The |
| 755 * caller of this function (the vm) will make sure that the buffer is |
| 756 * freed. |
| 757 * |
| 758 * |
| 759 * \param error A structure into which the embedder can place a |
| 760 * C string containing an error message in the case of failures. |
| 761 * |
| 762 * \return The embedder returns NULL if the creation and |
| 763 * initialization was not successful and the isolate if successful. |
| 764 */ |
| 765 typedef Dart_Isolate (*Dart_ServiceIsolateCreateCalback)(void* callback_data, |
| 766 char** error); |
| 767 |
| 740 /** | 768 /** |
| 741 * An isolate interrupt callback function. | 769 * An isolate interrupt callback function. |
| 742 * | 770 * |
| 743 * This callback, provided by the embedder, is called when an isolate | 771 * This callback, provided by the embedder, is called when an isolate |
| 744 * is interrupted as a result of a call to Dart_InterruptIsolate(). | 772 * is interrupted as a result of a call to Dart_InterruptIsolate(). |
| 745 * When the callback is called, Dart_CurrentIsolate can be used to | 773 * When the callback is called, Dart_CurrentIsolate can be used to |
| 746 * figure out which isolate is being interrupted. | 774 * figure out which isolate is being interrupted. |
| 747 * | 775 * |
| 748 * \return The embedder returns true if the isolate should continue | 776 * \return The embedder returns true if the isolate should continue |
| 749 * execution. If the embedder returns false, the isolate will be | 777 * execution. If the embedder returns false, the isolate will be |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 */ | 866 */ |
| 839 DART_EXPORT bool Dart_Initialize( | 867 DART_EXPORT bool Dart_Initialize( |
| 840 Dart_IsolateCreateCallback create, | 868 Dart_IsolateCreateCallback create, |
| 841 Dart_IsolateInterruptCallback interrupt, | 869 Dart_IsolateInterruptCallback interrupt, |
| 842 Dart_IsolateUnhandledExceptionCallback unhandled_exception, | 870 Dart_IsolateUnhandledExceptionCallback unhandled_exception, |
| 843 Dart_IsolateShutdownCallback shutdown, | 871 Dart_IsolateShutdownCallback shutdown, |
| 844 Dart_FileOpenCallback file_open, | 872 Dart_FileOpenCallback file_open, |
| 845 Dart_FileReadCallback file_read, | 873 Dart_FileReadCallback file_read, |
| 846 Dart_FileWriteCallback file_write, | 874 Dart_FileWriteCallback file_write, |
| 847 Dart_FileCloseCallback file_close, | 875 Dart_FileCloseCallback file_close, |
| 848 Dart_EntropySource entropy_source); | 876 Dart_EntropySource entropy_source, |
| 877 Dart_ServiceIsolateCreateCalback service_create); |
| 849 | 878 |
| 850 /** | 879 /** |
| 851 * Cleanup state in the VM before process termination. | 880 * Cleanup state in the VM before process termination. |
| 852 * | 881 * |
| 853 * \return True if cleanup is successful. | 882 * \return True if cleanup is successful. |
| 854 */ | 883 */ |
| 855 DART_EXPORT bool Dart_Cleanup(); | 884 DART_EXPORT bool Dart_Cleanup(); |
| 856 | 885 |
| 857 /** | 886 /** |
| 858 * Sets command line flags. Should be called before Dart_Initialize. | 887 * Sets command line flags. Should be called before Dart_Initialize. |
| (...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2721 */ | 2750 */ |
| 2722 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2751 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
| 2723 | 2752 |
| 2724 | 2753 |
| 2725 /* | 2754 /* |
| 2726 * ======= | 2755 * ======= |
| 2727 * Service | 2756 * Service |
| 2728 * ======= | 2757 * ======= |
| 2729 */ | 2758 */ |
| 2730 | 2759 |
| 2731 | |
| 2732 #define DART_VM_SERVICE_ISOLATE_NAME "vm-service" | |
| 2733 | |
| 2734 /** | 2760 /** |
| 2735 * Returns true if isolate is the service isolate. | 2761 * Returns the Service isolate initialized and with the dart:vmservice library |
| 2762 * loaded and booted. |
| 2736 * | 2763 * |
| 2737 * \param isolate An isolate | 2764 * This will call the embedder provided Dart_ServiceIsolateCreateCalback to |
| 2765 * create the isolate. |
| 2738 * | 2766 * |
| 2739 * \return Returns true if 'isolate' is the service isolate. | 2767 * After obtaining the service isolate the embedder specific glue code can |
| 2768 * be loaded in and the isolate can be run by the embedder. |
| 2769 * |
| 2770 * NOTE: It is not safe to call this from multiple threads concurrently. |
| 2771 * |
| 2772 * \return Returns NULL if an error occurred. |
| 2740 */ | 2773 */ |
| 2741 DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate); | 2774 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data); |
| 2742 | 2775 |
| 2743 | 2776 |
| 2744 /** | 2777 /** |
| 2745 * Returns the port that script load requests should be sent on. | 2778 * Returns true if the service is enabled. False otherwise. |
| 2746 * | 2779 * |
| 2747 * \return Returns the port for load requests or ILLEGAL_PORT if the service | 2780 * \return Returns true if service is running. |
| 2748 * isolate failed to startup or does not support load requests. | |
| 2749 */ | 2781 */ |
| 2750 DART_EXPORT Dart_Port Dart_ServiceWaitForLoadPort(); | 2782 DART_EXPORT bool Dart_IsServiceRunning(); |
| 2751 | 2783 |
| 2752 | 2784 |
| 2753 /** | 2785 /** |
| 2754 * A service request callback function. | 2786 * A service request callback function. |
| 2755 * | 2787 * |
| 2756 * These callbacks, registered by the embedder, are called when the VM receives | 2788 * These callbacks, registered by the embedder, are called when the VM receives |
| 2757 * a service request it can't handle and the service request command name | 2789 * a service request it can't handle and the service request command name |
| 2758 * matches one of the embedder registered handlers. | 2790 * matches one of the embedder registered handlers. |
| 2759 * | 2791 * |
| 2760 * \param name The service request command name. Always the first entry | 2792 * \param name The service request command name. Always the first entry |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2810 * NOTE: If multiple callbacks with the same name are registered, only the | 2842 * NOTE: If multiple callbacks with the same name are registered, only the |
| 2811 * last callback registered will be remembered. | 2843 * last callback registered will be remembered. |
| 2812 */ | 2844 */ |
| 2813 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 2845 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 2814 const char* name, | 2846 const char* name, |
| 2815 Dart_ServiceRequestCallback callback, | 2847 Dart_ServiceRequestCallback callback, |
| 2816 void* user_data); | 2848 void* user_data); |
| 2817 | 2849 |
| 2818 | 2850 |
| 2819 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 2851 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
| OLD | NEW |