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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 * C string containing an error message in the case of failures. | 726 * C string containing an error message in the case of failures. |
727 * | 727 * |
728 * \return The embedder returns NULL if the creation and | 728 * \return The embedder returns NULL if the creation and |
729 * initialization was not successful and the isolate if successful. | 729 * initialization was not successful and the isolate if successful. |
730 */ | 730 */ |
731 typedef Dart_Isolate (*Dart_IsolateCreateCallback)(const char* script_uri, | 731 typedef Dart_Isolate (*Dart_IsolateCreateCallback)(const char* script_uri, |
732 const char* main, | 732 const char* main, |
733 void* callback_data, | 733 void* callback_data, |
734 char** error); | 734 char** error); |
735 | 735 |
736 | |
737 /** | |
738 * The service isolate creation and initialization callback function. | |
739 * | |
740 * This callback, provided by the embedder, is called when the vm | |
741 * needs to create the service isolate. The callback should create an isolate | |
742 * by calling Dart_CreateIsolate and prepare the isolate to be used as | |
743 * the service isolate. | |
744 * | |
745 * When the function returns NULL, it is the responsibility of this | |
746 * function to ensure that Dart_ShutdownIsolate has been called if | |
747 * required. | |
748 * | |
749 * When the function returns NULL, the function should set *error to | |
750 * a malloc-allocated buffer containing a useful error message. The | |
751 * caller of this function (the vm) will make sure that the buffer is | |
752 * freed. | |
753 * | |
754 * | |
755 * \param error A structure into which the embedder can place a | |
756 * C string containing an error message in the case of failures. | |
757 * | |
758 * \return The embedder returns NULL if the creation and | |
759 * initialization was not successful and the isolate if successful. | |
760 */ | |
761 typedef Dart_Isolate (*Dart_ServiceIsolateCreateCalback)(void* callback_data, | |
762 char** error); | |
763 | |
764 /** | 736 /** |
765 * An isolate interrupt callback function. | 737 * An isolate interrupt callback function. |
766 * | 738 * |
767 * This callback, provided by the embedder, is called when an isolate | 739 * This callback, provided by the embedder, is called when an isolate |
768 * is interrupted as a result of a call to Dart_InterruptIsolate(). | 740 * is interrupted as a result of a call to Dart_InterruptIsolate(). |
769 * When the callback is called, Dart_CurrentIsolate can be used to | 741 * When the callback is called, Dart_CurrentIsolate can be used to |
770 * figure out which isolate is being interrupted. | 742 * figure out which isolate is being interrupted. |
771 * | 743 * |
772 * \return The embedder returns true if the isolate should continue | 744 * \return The embedder returns true if the isolate should continue |
773 * execution. If the embedder returns false, the isolate will be | 745 * execution. If the embedder returns false, the isolate will be |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 */ | 834 */ |
863 DART_EXPORT bool Dart_Initialize( | 835 DART_EXPORT bool Dart_Initialize( |
864 Dart_IsolateCreateCallback create, | 836 Dart_IsolateCreateCallback create, |
865 Dart_IsolateInterruptCallback interrupt, | 837 Dart_IsolateInterruptCallback interrupt, |
866 Dart_IsolateUnhandledExceptionCallback unhandled_exception, | 838 Dart_IsolateUnhandledExceptionCallback unhandled_exception, |
867 Dart_IsolateShutdownCallback shutdown, | 839 Dart_IsolateShutdownCallback shutdown, |
868 Dart_FileOpenCallback file_open, | 840 Dart_FileOpenCallback file_open, |
869 Dart_FileReadCallback file_read, | 841 Dart_FileReadCallback file_read, |
870 Dart_FileWriteCallback file_write, | 842 Dart_FileWriteCallback file_write, |
871 Dart_FileCloseCallback file_close, | 843 Dart_FileCloseCallback file_close, |
872 Dart_EntropySource entropy_source, | 844 Dart_EntropySource entropy_source); |
873 Dart_ServiceIsolateCreateCalback service_create); | |
874 | 845 |
875 /** | 846 /** |
876 * Cleanup state in the VM before process termination. | 847 * Cleanup state in the VM before process termination. |
877 * | 848 * |
878 * \return True if cleanup is successful. | 849 * \return True if cleanup is successful. |
879 */ | 850 */ |
880 DART_EXPORT bool Dart_Cleanup(); | 851 DART_EXPORT bool Dart_Cleanup(); |
881 | 852 |
882 /** | 853 /** |
883 * Sets command line flags. Should be called before Dart_Initialize. | 854 * Sets command line flags. Should be called before Dart_Initialize. |
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2734 * 'peer'. | 2705 * 'peer'. |
2735 * | 2706 * |
2736 * \param object An object. | 2707 * \param object An object. |
2737 * \param peer A value to store in the peer field. | 2708 * \param peer A value to store in the peer field. |
2738 * | 2709 * |
2739 * \return Returns an error if 'object' is a subtype of Null, num, or | 2710 * \return Returns an error if 'object' is a subtype of Null, num, or |
2740 * bool. | 2711 * bool. |
2741 */ | 2712 */ |
2742 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2713 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
2743 | 2714 |
2744 | |
2745 /* | |
2746 * ======= | |
2747 * Service | |
2748 * ======= | |
2749 */ | |
2750 | |
2751 /** | |
2752 * Returns the Service isolate initialized and with the dart:vmservice library | |
2753 * loaded and booted. | |
2754 * | |
2755 * This will call the embedder provided Dart_ServiceIsolateCreateCalback to | |
2756 * create the isolate. | |
2757 * | |
2758 * After obtaining the service isolate the embedder specific glue code can | |
2759 * be loaded in and the isolate can be run by the embedder. | |
2760 * | |
2761 * NOTE: It is not safe to call this from multiple threads concurrently. | |
2762 * | |
2763 * \return Returns NULL if an error occurred. | |
2764 */ | |
2765 DART_EXPORT Dart_Isolate Dart_GetServiceIsolate(void* callback_data); | |
2766 | |
2767 | |
2768 /** | |
2769 * Returns true if the service is enabled. False otherwise. | |
2770 * | |
2771 * \return Returns true if service is running. | |
2772 */ | |
2773 DART_EXPORT bool Dart_IsServiceRunning(); | |
2774 | |
2775 | |
2776 /** | 2715 /** |
2777 * A service request callback function. | 2716 * A service request callback function. |
2778 * | 2717 * |
2779 * These callbacks, registered by the embedder, are called when the VM receives | 2718 * These callbacks, registered by the embedder, are called when the VM receives |
2780 * a service request it can't handle and the service request command name | 2719 * a service request it can't handle and the service request command name |
2781 * matches one of the embedder registered handlers. | 2720 * matches one of the embedder registered handlers. |
2782 * | 2721 * |
2783 * \param name The service request command name. Always the first entry | 2722 * \param name The service request command name. Always the first entry |
2784 * in the arguments array. Will match the name the callback was | 2723 * in the arguments array. Will match the name the callback was |
2785 * registered with. | 2724 * registered with. |
(...skipping 12 matching lines...) Expand all Loading... |
2798 */ | 2737 */ |
2799 typedef const char* (*Dart_ServiceRequestCallback)( | 2738 typedef const char* (*Dart_ServiceRequestCallback)( |
2800 const char* name, | 2739 const char* name, |
2801 const char** arguments, | 2740 const char** arguments, |
2802 intptr_t num_arguments, | 2741 intptr_t num_arguments, |
2803 const char** option_keys, | 2742 const char** option_keys, |
2804 const char** option_values, | 2743 const char** option_values, |
2805 intptr_t num_options, | 2744 intptr_t num_options, |
2806 void* user_data); | 2745 void* user_data); |
2807 | 2746 |
| 2747 /* |
| 2748 * ======= |
| 2749 * Service |
| 2750 * ======= |
| 2751 */ |
| 2752 |
2808 /** | 2753 /** |
2809 * Register a Dart_ServiceRequestCallback to be called to handle requests | 2754 * Register a Dart_ServiceRequestCallback to be called to handle requests |
2810 * with name on a specific isolate. The callback will be invoked with the | 2755 * with name on a specific isolate. The callback will be invoked with the |
2811 * current isolate set to the request target. | 2756 * current isolate set to the request target. |
2812 * | 2757 * |
2813 * \param name The name of the command that this callback is responsible for. | 2758 * \param name The name of the command that this callback is responsible for. |
2814 * \param callback The callback to invoke. | 2759 * \param callback The callback to invoke. |
2815 * \param user_data The user data passed to the callback. | 2760 * \param user_data The user data passed to the callback. |
2816 * | 2761 * |
2817 * NOTE: If multiple callbacks with the same name are registered, only the | 2762 * NOTE: If multiple callbacks with the same name are registered, only the |
(...skipping 15 matching lines...) Expand all Loading... |
2833 * NOTE: If multiple callbacks with the same name are registered, only the | 2778 * NOTE: If multiple callbacks with the same name are registered, only the |
2834 * last callback registered will be remembered. | 2779 * last callback registered will be remembered. |
2835 */ | 2780 */ |
2836 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 2781 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
2837 const char* name, | 2782 const char* name, |
2838 Dart_ServiceRequestCallback callback, | 2783 Dart_ServiceRequestCallback callback, |
2839 void* user_data); | 2784 void* user_data); |
2840 | 2785 |
2841 | 2786 |
2842 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 2787 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
OLD | NEW |