| 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 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2646 Dart_NativeEntryResolver resolver, | 2646 Dart_NativeEntryResolver resolver, |
| 2647 Dart_NativeEntrySymbol symbol); | 2647 Dart_NativeEntrySymbol symbol); |
| 2648 /* TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? */ | 2648 /* TODO(turnidge): Rename to Dart_LibrarySetNativeResolver? */ |
| 2649 | 2649 |
| 2650 | 2650 |
| 2651 /* | 2651 /* |
| 2652 * ===================== | 2652 * ===================== |
| 2653 * Scripts and Libraries | 2653 * Scripts and Libraries |
| 2654 * ===================== | 2654 * ===================== |
| 2655 */ | 2655 */ |
| 2656 /* TODO(turnidge): Finish documenting this section. */ | |
| 2657 | 2656 |
| 2658 typedef enum { | 2657 typedef enum { |
| 2659 Dart_kCanonicalizeUrl = 0, | 2658 Dart_kCanonicalizeUrl = 0, |
| 2660 Dart_kScriptTag, | 2659 Dart_kScriptTag, |
| 2661 Dart_kSourceTag, | 2660 Dart_kSourceTag, |
| 2662 Dart_kImportTag, | 2661 Dart_kImportTag, |
| 2663 } Dart_LibraryTag; | 2662 } Dart_LibraryTag; |
| 2664 | 2663 |
| 2665 /* TODO(turnidge): Document. */ | 2664 /** |
| 2665 * The library tag handler is a multi-purpose callback provided by the |
| 2666 * embedder to the Dart VM. The embedder implements the tag handler to |
| 2667 * provide the ability to load Dart scripts and imports. |
| 2668 * |
| 2669 * -- TAGS -- |
| 2670 * |
| 2671 * Dart_kCanonicalizeUrl |
| 2672 * |
| 2673 * This tag indicates that the embedder should canonicalize 'url' with |
| 2674 * respect to 'library'. For most embedders, the |
| 2675 * Dart_DefaultCanonicalizeUrl function is a sufficient implementation |
| 2676 * of this tag. The return value should be a string holding the |
| 2677 * canonicalized url. |
| 2678 * |
| 2679 * Dart_kScriptTag |
| 2680 * |
| 2681 * This tag indicates that the root script should be loaded from |
| 2682 * 'url'. The 'library' parameter will always be null. Once the root |
| 2683 * script is loaded, the embedder should call Dart_LoadScript to |
| 2684 * install the root script in the VM. The return value should be an |
| 2685 * error or null. |
| 2686 * |
| 2687 * Dart_kSourceTag |
| 2688 * |
| 2689 * This tag is used to load a file referenced by Dart language "part |
| 2690 * of" directive. Once the file's source is loaded, the embedder |
| 2691 * should call Dart_LoadSource to provide the file contents to the VM. |
| 2692 * The return value should be an error or null. |
| 2693 * |
| 2694 * Dart_kImportTag |
| 2695 * |
| 2696 * This tag is used to load a script referenced by Dart language |
| 2697 * "import" directive. Once the script is loaded, the embedder should |
| 2698 * call Dart_LoadLibrary to provide the script source to the VM. The |
| 2699 * return value should be an error or null. |
| 2700 */ |
| 2666 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, | 2701 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, |
| 2667 Dart_Handle library, | 2702 Dart_Handle library, |
| 2668 Dart_Handle url); | 2703 Dart_Handle url); |
| 2669 | 2704 |
| 2670 /** | 2705 /** |
| 2671 * Sets library tag handler for the current isolate. This handler is | 2706 * Sets library tag handler for the current isolate. This handler is |
| 2672 * used to handle the various tags encountered while loading libraries | 2707 * used to handle the various tags encountered while loading libraries |
| 2673 * or scripts in the isolate. | 2708 * or scripts in the isolate. |
| 2674 * | 2709 * |
| 2675 * \param handler Handler code to be used for handling the various tags | 2710 * \param handler Handler code to be used for handling the various tags |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2697 * \param url The url being resolved and canonicalized. This | 2732 * \param url The url being resolved and canonicalized. This |
| 2698 * parameter is a string handle. | 2733 * parameter is a string handle. |
| 2699 * | 2734 * |
| 2700 * \return If no error occurs, a String object is returned. Otherwise | 2735 * \return If no error occurs, a String object is returned. Otherwise |
| 2701 * an error handle is returned. | 2736 * an error handle is returned. |
| 2702 */ | 2737 */ |
| 2703 DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle base_url, | 2738 DART_EXPORT Dart_Handle Dart_DefaultCanonicalizeUrl(Dart_Handle base_url, |
| 2704 Dart_Handle url); | 2739 Dart_Handle url); |
| 2705 | 2740 |
| 2706 /** | 2741 /** |
| 2707 * Loads the root script for the current isolate. The script can be | 2742 * Called by the embedder to provide the source for the root script to |
| 2708 * embedded in another file, for example in an html file. | 2743 * the VM. This function should be called in response to a |
| 2744 * Dart_kScriptTag tag handler request (See Dart_LibraryTagHandler, |
| 2745 * above). |
| 2709 * | 2746 * |
| 2710 * TODO(turnidge): Document. | 2747 * \param url The original url requested for the script. |
| 2748 * |
| 2749 * \param resolved_url The actual url which was loaded. This parameter |
| 2750 * is optionally provided to support isolate reloading. A value of |
| 2751 * Dart_Null() indicates that the resolved url was the same as the |
| 2752 * requested url. |
| 2753 * |
| 2754 * \param source The contents of the url. |
| 2711 * | 2755 * |
| 2712 * \param line_offset is the number of text lines before the | 2756 * \param line_offset is the number of text lines before the |
| 2713 * first line of the Dart script in the containing file. | 2757 * first line of the Dart script in the containing file. |
| 2714 * | 2758 * |
| 2715 * \param col_offset is the number of characters before the first character | 2759 * \param col_offset is the number of characters before the first character |
| 2716 * in the first line of the Dart script. | 2760 * in the first line of the Dart script. |
| 2761 * |
| 2762 * \return A valid handle if no error occurs during the operation. |
| 2717 */ | 2763 */ |
| 2718 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, | 2764 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, |
| 2765 Dart_Handle resolved_url, |
| 2719 Dart_Handle source, | 2766 Dart_Handle source, |
| 2720 intptr_t line_offset, | 2767 intptr_t line_offset, |
| 2721 intptr_t col_offset); | 2768 intptr_t col_offset); |
| 2722 | 2769 |
| 2723 /** | 2770 /** |
| 2724 * Loads the root script for current isolate from a snapshot. | 2771 * Loads the root script for current isolate from a snapshot. |
| 2725 * | 2772 * |
| 2726 * \param buffer A buffer which contains a snapshot of the script. | 2773 * \param buffer A buffer which contains a snapshot of the script. |
| 2727 * \param length Length of the passed in buffer. | 2774 * \param length Length of the passed in buffer. |
| 2728 * | 2775 * |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2801 * \param error The Dart error instance containing the load error. | 2848 * \param error The Dart error instance containing the load error. |
| 2802 * | 2849 * |
| 2803 * \return If the VM handles the error, the return value is | 2850 * \return If the VM handles the error, the return value is |
| 2804 * a null handle. If it doesn't handle the error, the error | 2851 * a null handle. If it doesn't handle the error, the error |
| 2805 * object is returned. | 2852 * object is returned. |
| 2806 */ | 2853 */ |
| 2807 DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library, | 2854 DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library, |
| 2808 Dart_Handle error); | 2855 Dart_Handle error); |
| 2809 | 2856 |
| 2810 | 2857 |
| 2858 /** |
| 2859 * Called by the embedder to provide the source for an "import" |
| 2860 * directive. This function should be called in response to a |
| 2861 * Dart_kImportTag tag handler request (See Dart_LibraryTagHandler, |
| 2862 * above). |
| 2863 * |
| 2864 * \param library The library where the "import" directive occurs. |
| 2865 * |
| 2866 * \param url The original url requested for the import. |
| 2867 * |
| 2868 * \param resolved_url The actual url which was loaded. This parameter |
| 2869 * is optionally provided to support isolate reloading. A value of |
| 2870 * Dart_Null() indicates that the resolved url was the same as the |
| 2871 * requested url. |
| 2872 * |
| 2873 * \param source The contents of the url. |
| 2874 * |
| 2875 * \param line_offset is the number of text lines before the |
| 2876 * first line of the Dart script in the containing file. |
| 2877 * |
| 2878 * \param col_offset is the number of characters before the first character |
| 2879 * in the first line of the Dart script. |
| 2880 * |
| 2881 * \return A valid handle if no error occurs during the operation. |
| 2882 */ |
| 2811 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, | 2883 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, |
| 2884 Dart_Handle resolved_url, |
| 2812 Dart_Handle source, | 2885 Dart_Handle source, |
| 2813 intptr_t line_offset, | 2886 intptr_t line_offset, |
| 2814 intptr_t column_offset); | 2887 intptr_t column_offset); |
| 2815 | 2888 |
| 2816 /** | 2889 /** |
| 2817 * Imports a library into another library, optionally with a prefix. | 2890 * Imports a library into another library, optionally with a prefix. |
| 2818 * If no prefix is required, an empty string or Dart_Null() can be | 2891 * If no prefix is required, an empty string or Dart_Null() can be |
| 2819 * supplied. | 2892 * supplied. |
| 2820 * | 2893 * |
| 2821 * \param library The library into which to import another library. | 2894 * \param library The library into which to import another library. |
| 2822 * \param import The library to import. | 2895 * \param import The library to import. |
| 2823 * \param prefix The prefix under which to import. | 2896 * \param prefix The prefix under which to import. |
| 2824 * | 2897 * |
| 2825 * \return A valid handle if no error occurs during the operation. | 2898 * \return A valid handle if no error occurs during the operation. |
| 2826 */ | 2899 */ |
| 2827 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, | 2900 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, |
| 2828 Dart_Handle import, | 2901 Dart_Handle import, |
| 2829 Dart_Handle prefix); | 2902 Dart_Handle prefix); |
| 2830 | 2903 |
| 2831 /** | 2904 /** |
| 2832 * Loads a source string into a library. | 2905 * Called by the embedder to provide the source for a "part of" |
| 2906 * directive. This function should be called in response to a |
| 2907 * Dart_kSourceTag tag handler request (See Dart_LibraryTagHandler, |
| 2908 * above). |
| 2833 * | 2909 * |
| 2834 * \param library A library | 2910 * \param library The library where the "part of" directive occurs. |
| 2835 * \param url A url identifying the origin of the source | 2911 * |
| 2836 * \param source A string of Dart source | 2912 * \param url The original url requested for the part. |
| 2913 * |
| 2914 * \param resolved_url The actual url which was loaded. This parameter |
| 2915 * is optionally provided to support isolate reloading. A value of |
| 2916 * Dart_Null() indicates that the resolved url was the same as the |
| 2917 * requested url. |
| 2918 * |
| 2919 * \param source The contents of the url. |
| 2920 * |
| 2921 * \param line_offset is the number of text lines before the |
| 2922 * first line of the Dart script in the containing file. |
| 2923 * |
| 2924 * \param col_offset is the number of characters before the first character |
| 2925 * in the first line of the Dart script. |
| 2837 * | 2926 * |
| 2838 * \return A valid handle if no error occurs during the operation. | 2927 * \return A valid handle if no error occurs during the operation. |
| 2839 */ | 2928 */ |
| 2840 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, | 2929 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, |
| 2841 Dart_Handle url, | 2930 Dart_Handle url, |
| 2931 Dart_Handle resolved_url, |
| 2842 Dart_Handle source, | 2932 Dart_Handle source, |
| 2843 intptr_t line_offset, | 2933 intptr_t line_offset, |
| 2844 intptr_t column_offset); | 2934 intptr_t column_offset); |
| 2845 /* TODO(turnidge): Rename to Dart_LibraryLoadSource? */ | 2935 /* TODO(turnidge): Rename to Dart_LibraryLoadSource? */ |
| 2846 | 2936 |
| 2847 | 2937 |
| 2848 /** | 2938 /** |
| 2849 * Loads a patch source string into a library. | 2939 * Loads a patch source string into a library. |
| 2850 * | 2940 * |
| 2851 * \param library A library | 2941 * \param library A library |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3071 /** | 3161 /** |
| 3072 * Returns whether the VM was initialized with a precompiled snapshot. Only | 3162 * Returns whether the VM was initialized with a precompiled snapshot. Only |
| 3073 * valid after Dart_Initialize. | 3163 * valid after Dart_Initialize. |
| 3074 * DEPRECATED. This is currently used to disable Platform.executable and | 3164 * DEPRECATED. This is currently used to disable Platform.executable and |
| 3075 * Platform.resolvedExecutable under precompilation to prevent process | 3165 * Platform.resolvedExecutable under precompilation to prevent process |
| 3076 * spawning tests from becoming fork-bombs. | 3166 * spawning tests from becoming fork-bombs. |
| 3077 */ | 3167 */ |
| 3078 DART_EXPORT bool Dart_IsRunningPrecompiledCode(); | 3168 DART_EXPORT bool Dart_IsRunningPrecompiledCode(); |
| 3079 | 3169 |
| 3080 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 3170 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
| OLD | NEW |