| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef INCLUDE_DART_API_H_ | 5 #ifndef INCLUDE_DART_API_H_ |
| 6 #define INCLUDE_DART_API_H_ | 6 #define INCLUDE_DART_API_H_ |
| 7 | 7 |
| 8 /** \mainpage Dart Embedding API Reference | 8 /** \mainpage Dart Embedding API Reference |
| 9 * | 9 * |
| 10 * Dart is a class-based programming language for creating structured | 10 * Dart is a class-based programming language for creating structured |
| (...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 // --- Closures --- | 1945 // --- Closures --- |
| 1946 | 1946 |
| 1947 /** | 1947 /** |
| 1948 * Is this object a Closure? | 1948 * Is this object a Closure? |
| 1949 */ | 1949 */ |
| 1950 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); | 1950 DART_EXPORT bool Dart_IsClosure(Dart_Handle object); |
| 1951 | 1951 |
| 1952 /** | 1952 /** |
| 1953 * Retrieves the function of a closure. | 1953 * Retrieves the function of a closure. |
| 1954 * | 1954 * |
| 1955 * \return A handle on the function of the closure, or an error handle if the | 1955 * \return A handle to the function of the closure, or an error handle if the |
| 1956 * argument is not a closure. | 1956 * argument is not a closure. |
| 1957 */ | 1957 */ |
| 1958 DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure); | 1958 DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure); |
| 1959 | 1959 |
| 1960 /** | 1960 /** |
| 1961 * Invokes a Closure with the given arguments. | 1961 * Invokes a Closure with the given arguments. |
| 1962 * | 1962 * |
| 1963 * May generate an unhandled exception error. | 1963 * May generate an unhandled exception error. |
| 1964 * | 1964 * |
| 1965 * \return If no error occurs during execution, then the result of | 1965 * \return If no error occurs during execution, then the result of |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 | 2033 |
| 2034 /** | 2034 /** |
| 2035 * Returns the interface at some index in the list of interfaces some | 2035 * Returns the interface at some index in the list of interfaces some |
| 2036 * class or inteface. | 2036 * class or inteface. |
| 2037 * | 2037 * |
| 2038 * TODO(turnidge): Finish documentation. | 2038 * TODO(turnidge): Finish documentation. |
| 2039 */ | 2039 */ |
| 2040 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceAt(Dart_Handle clazz, | 2040 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceAt(Dart_Handle clazz, |
| 2041 intptr_t index); | 2041 intptr_t index); |
| 2042 | 2042 |
| 2043 /** |
| 2044 * Is this class defined by a typedef? |
| 2045 * |
| 2046 * Typedef definitions from the main program are represented as a |
| 2047 * special kind of class handle. See Dart_ClassGetTypedefReferent. |
| 2048 * |
| 2049 * TODO(turnidge): Finish documentation. |
| 2050 */ |
| 2051 DART_EXPORT bool Dart_ClassIsTypedef(Dart_Handle clazz); |
| 2052 |
| 2053 /** |
| 2054 * Returns a handle to the type to which a typedef refers. |
| 2055 * |
| 2056 * It is an error to call this function on a handle for which |
| 2057 * Dart_ClassIsTypedef is not true. |
| 2058 * |
| 2059 * TODO(turnidge): Finish documentation. |
| 2060 */ |
| 2061 DART_EXPORT Dart_Handle Dart_ClassGetTypedefReferent(Dart_Handle clazz); |
| 2062 |
| 2063 /** |
| 2064 * Does this class represent the type of a function? |
| 2065 */ |
| 2066 DART_EXPORT bool Dart_ClassIsFunctionType(Dart_Handle clazz); |
| 2067 |
| 2068 /** |
| 2069 * Returns a function handle representing the signature associated |
| 2070 * with a function type. |
| 2071 * |
| 2072 * The return value is a function handle (See Dart_IsFunction, etc.). |
| 2073 * |
| 2074 * TODO(turnidge): Finish documentation. |
| 2075 */ |
| 2076 DART_EXPORT Dart_Handle Dart_ClassGetFunctionTypeSignature(Dart_Handle clazz); |
| 2077 |
| 2078 |
| 2043 // --- Function and Variable Declarations --- | 2079 // --- Function and Variable Declarations --- |
| 2044 | 2080 |
| 2045 /** | 2081 /** |
| 2046 * Returns a list of the names of all functions or methods declared in | 2082 * Returns a list of the names of all functions or methods declared in |
| 2047 * a library or class. | 2083 * a library or class. |
| 2048 * | 2084 * |
| 2049 * \param target A library or class. | 2085 * \param target A library or class. |
| 2050 * | 2086 * |
| 2051 * \return If no error occurs, a list of strings is returned. | 2087 * \return If no error occurs, a list of strings is returned. |
| 2052 * Otherwise an erorr handle is returned. | 2088 * Otherwise an error handle is returned. |
| 2053 */ | 2089 */ |
| 2054 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target); | 2090 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target); |
| 2055 | 2091 |
| 2056 /** | 2092 /** |
| 2057 * Looks up a function or method declaration by name from a library or | 2093 * Looks up a function or method declaration by name from a library or |
| 2058 * class. | 2094 * class. |
| 2059 * | 2095 * |
| 2060 * \param target The library or class containing the function. | 2096 * \param target The library or class containing the function. |
| 2061 * \param function_name The name of the function. | 2097 * \param function_name The name of the function. |
| 2062 * | 2098 * |
| 2063 * \return If an error is encountered, returns an error handle. | 2099 * \return If an error is encountered, returns an error handle. |
| 2064 * Otherwise returns a function handle if the function is found of | 2100 * Otherwise returns a function handle if the function is found of |
| 2065 * Dart_Null() if the function is not found. | 2101 * Dart_Null() if the function is not found. |
| 2066 */ | 2102 */ |
| 2067 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, | 2103 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, |
| 2068 Dart_Handle function_name); | 2104 Dart_Handle function_name); |
| 2069 | 2105 |
| 2070 /** | 2106 /** |
| 2071 * Is this a function or method declaration handle? | 2107 * Is this a function or method declaration handle? |
| 2072 */ | 2108 */ |
| 2073 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); | 2109 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); |
| 2074 | 2110 |
| 2075 /** | 2111 /** |
| 2076 * Returns the name for the provided function or method. | 2112 * Returns the name for the provided function or method. |
| 2077 * | 2113 * |
| 2078 * \return A valid string handle if no error occurs during the | 2114 * \return A valid string handle if no error occurs during the |
| 2079 * operation. | 2115 * operation. |
| 2080 */ | 2116 */ |
| 2081 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); | 2117 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); |
| 2082 | 2118 |
| 2083 /** | 2119 /** |
| 2084 * Returns a handle to the owner of a function. The owner of an instance method | 2120 * Returns a handle to the owner of a function. |
| 2085 * or a static method is its defining class. The owner of a top-level function | 2121 * |
| 2086 * is its defining library. The owner of the function of a non-implicit closure | 2122 * The owner of an instance method or a static method is its defining |
| 2087 * is the function of the method or closure that defines the non-implicit | 2123 * class. The owner of a top-level function is its defining |
| 2124 * library. The owner of the function of a non-implicit closure is the |
| 2125 * function of the method or closure that defines the non-implicit |
| 2088 * closure. | 2126 * closure. |
| 2089 * | 2127 * |
| 2090 * \return A valid handle on the owner of the function, or an error handle if | 2128 * \return A valid handle to the owner of the function, or an error |
| 2091 * the argument is not a valid handle to a function. | 2129 * handle if the argument is not a valid handle to a function. |
| 2092 */ | 2130 */ |
| 2093 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); | 2131 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); |
| 2094 | 2132 |
| 2095 /** | 2133 /** |
| 2096 * Determines whether a function handle refers to an abstract method. | 2134 * Determines whether a function handle refers to an abstract method. |
| 2097 * | 2135 * |
| 2098 * \param function A handle to a function or method declaration. | 2136 * \param function A handle to a function or method declaration. |
| 2099 * \param is_static Returns whether the handle refers to an abstract method. | 2137 * \param is_static Returns whether the handle refers to an abstract method. |
| 2100 * | 2138 * |
| 2101 * \return A valid handle if no error occurs during the operation. | 2139 * \return A valid handle if no error occurs during the operation. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 * | 2184 * |
| 2147 * \param function A handle to a function or method declaration. | 2185 * \param function A handle to a function or method declaration. |
| 2148 * \param is_static Returns whether the function or method is a setter. | 2186 * \param is_static Returns whether the function or method is a setter. |
| 2149 * | 2187 * |
| 2150 * \return A valid handle if no error occurs during the operation. | 2188 * \return A valid handle if no error occurs during the operation. |
| 2151 */ | 2189 */ |
| 2152 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, | 2190 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, |
| 2153 bool* is_setter); | 2191 bool* is_setter); |
| 2154 | 2192 |
| 2155 /** | 2193 /** |
| 2194 * Returns a handle to the return type of a function. |
| 2195 * |
| 2196 * \return A valid handle to a type or an error handle if the argument |
| 2197 * is not valid. |
| 2198 */ |
| 2199 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function); |
| 2200 |
| 2201 /** |
| 2156 * Determines the number of required and optional parameters. | 2202 * Determines the number of required and optional parameters. |
| 2157 * | 2203 * |
| 2158 * \param function A handle to a function or method declaration. | 2204 * \param function A handle to a function or method declaration. |
| 2159 * \param fixed_param_count Returns the number of required parameters. | 2205 * \param fixed_param_count Returns the number of required parameters. |
| 2160 * \param opt_param_count Returns the number of optional parameters. | 2206 * \param opt_param_count Returns the number of optional parameters. |
| 2161 * | 2207 * |
| 2162 * \return A valid handle if no error occurs during the operation. | 2208 * \return A valid handle if no error occurs during the operation. |
| 2163 */ | 2209 */ |
| 2164 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( | 2210 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( |
| 2165 Dart_Handle function, | 2211 Dart_Handle function, |
| 2166 int64_t* fixed_param_count, | 2212 int64_t* fixed_param_count, |
| 2167 int64_t* opt_param_count); | 2213 int64_t* opt_param_count); |
| 2168 | 2214 |
| 2169 /** | 2215 /** |
| 2216 * Returns a handle to the type of a function parameter. |
| 2217 * |
| 2218 * \return A valid handle to a type or an error handle if the argument |
| 2219 * is not valid. |
| 2220 */ |
| 2221 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function, |
| 2222 int parameter_index); |
| 2223 |
| 2224 /** |
| 2170 * Returns a list of the names of all variables declared in a library | 2225 * Returns a list of the names of all variables declared in a library |
| 2171 * or class. | 2226 * or class. |
| 2172 * | 2227 * |
| 2173 * \param target A library or class. | 2228 * \param target A library or class. |
| 2174 * | 2229 * |
| 2175 * \return If no error occurs, a list of strings is returned. | 2230 * \return If no error occurs, a list of strings is returned. |
| 2176 * Otherwise an erorr handle is returned. | 2231 * Otherwise an error handle is returned. |
| 2177 */ | 2232 */ |
| 2178 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target); | 2233 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target); |
| 2179 | 2234 |
| 2180 /** | 2235 /** |
| 2181 * Looks up a variable declaration by name from a library or class. | 2236 * Looks up a variable declaration by name from a library or class. |
| 2182 * | 2237 * |
| 2183 * \param library The library or class containing the variable. | 2238 * \param target The library or class containing the variable. |
| 2184 * \param variable_name The name of the variable. | 2239 * \param variable_name The name of the variable. |
| 2185 * | 2240 * |
| 2186 * \return If an error is encountered, returns an error handle. | 2241 * \return If an error is encountered, returns an error handle. |
| 2187 * Otherwise returns a variable handle if the variable is found or | 2242 * Otherwise returns a variable handle if the variable is found or |
| 2188 * Dart_Null() if the variable is not found. | 2243 * Dart_Null() if the variable is not found. |
| 2189 */ | 2244 */ |
| 2190 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target, | 2245 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target, |
| 2191 Dart_Handle variable_name); | 2246 Dart_Handle variable_name); |
| 2192 | 2247 |
| 2193 /** | 2248 /** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2218 * Determines whether a variable is declared final. | 2273 * Determines whether a variable is declared final. |
| 2219 * | 2274 * |
| 2220 * \param variable A handle to a variable declaration. | 2275 * \param variable A handle to a variable declaration. |
| 2221 * \param is_final Returns whether the variable is declared final. | 2276 * \param is_final Returns whether the variable is declared final. |
| 2222 * | 2277 * |
| 2223 * \return A valid handle if no error occurs during the operation. | 2278 * \return A valid handle if no error occurs during the operation. |
| 2224 */ | 2279 */ |
| 2225 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable, | 2280 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable, |
| 2226 bool* is_final); | 2281 bool* is_final); |
| 2227 | 2282 |
| 2283 /** |
| 2284 * Returns a handle to the type of a variable. |
| 2285 * |
| 2286 * \return A valid handle to a type of or an error handle if the |
| 2287 * argument is not valid. |
| 2288 */ |
| 2289 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle function); |
| 2290 |
| 2291 /** |
| 2292 * Returns a list of the names of all type variables declared in a class. |
| 2293 * |
| 2294 * The type variables list preserves the original declaration order. |
| 2295 * |
| 2296 * \param clazz A class. |
| 2297 * |
| 2298 * \return If no error occurs, a list of strings is returned. |
| 2299 * Otherwise an error handle is returned. |
| 2300 */ |
| 2301 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle clazz); |
| 2302 |
| 2303 /** |
| 2304 * Looks up a type variable declaration by name from a class. |
| 2305 * |
| 2306 * \param clazz The class containing the type variable. |
| 2307 * \param variable_name The name of the type variable. |
| 2308 * |
| 2309 * \return If an error is encountered, returns an error handle. |
| 2310 * Otherwise returns a type variable handle if the type variable is |
| 2311 * found or Dart_Null() if the type variable is not found. |
| 2312 */ |
| 2313 DART_EXPORT Dart_Handle Dart_LookupTypeVariable(Dart_Handle clazz, |
| 2314 Dart_Handle type_variable_name); |
| 2315 |
| 2316 /** |
| 2317 * Is this a type variable handle? |
| 2318 */ |
| 2319 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle); |
| 2320 |
| 2321 /** |
| 2322 * Returns the name for the provided type variable. |
| 2323 */ |
| 2324 DART_EXPORT Dart_Handle Dart_TypeVariableName(Dart_Handle type_variable); |
| 2325 |
| 2326 /** |
| 2327 * Returns a handle to the owner of a function. |
| 2328 * |
| 2329 * The owner of a type variable is its defining class. |
| 2330 * |
| 2331 * \return A valid handle to the owner of the type variable, or an error |
| 2332 * handle if the argument is not a valid handle to a type variable. |
| 2333 */ |
| 2334 DART_EXPORT Dart_Handle Dart_TypeVariableOwner(Dart_Handle type_variable); |
| 2335 |
| 2336 /** |
| 2337 * Returns a handle to the upper bound of a type variable. |
| 2338 * |
| 2339 * The upper bound of a type variable is ... |
| 2340 * |
| 2341 * \return A valid handle to a type, or an error handle if the |
| 2342 * argument is not a valid handle. |
| 2343 */ |
| 2344 DART_EXPORT Dart_Handle Dart_TypeVariableUpperBound(Dart_Handle type_variable); |
| 2345 // TODO(turnidge): Finish documentation. |
| 2346 |
| 2228 // --- Constructors, Methods, and Fields --- | 2347 // --- Constructors, Methods, and Fields --- |
| 2229 | 2348 |
| 2230 /** | 2349 /** |
| 2231 * Invokes a constructor, creating a new object. | 2350 * Invokes a constructor, creating a new object. |
| 2232 * | 2351 * |
| 2233 * This function allows hidden constructors (constructors with leading | 2352 * This function allows hidden constructors (constructors with leading |
| 2234 * underscores) to be called. | 2353 * underscores) to be called. |
| 2235 * | 2354 * |
| 2236 * \param clazz A class or an interface. | 2355 * \param clazz A class or an interface. |
| 2237 * \param constructor_name The name of the constructor to invoke. Use | 2356 * \param constructor_name The name of the constructor to invoke. Use |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 /** | 2654 /** |
| 2536 * Returns the url from which a library was loaded. | 2655 * Returns the url from which a library was loaded. |
| 2537 */ | 2656 */ |
| 2538 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); | 2657 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); |
| 2539 | 2658 |
| 2540 /** | 2659 /** |
| 2541 * Returns a list of the names of all classes and interfaces declared | 2660 * Returns a list of the names of all classes and interfaces declared |
| 2542 * in a library. | 2661 * in a library. |
| 2543 * | 2662 * |
| 2544 * \return If no error occurs, a list of strings is returned. | 2663 * \return If no error occurs, a list of strings is returned. |
| 2545 * Otherwise an erorr handle is returned. | 2664 * Otherwise an error handle is returned. |
| 2546 */ | 2665 */ |
| 2547 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library); | 2666 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library); |
| 2548 | 2667 |
| 2549 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); | 2668 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); |
| 2550 // TODO(turnidge): Consider returning Dart_Null() when the library is | 2669 // TODO(turnidge): Consider returning Dart_Null() when the library is |
| 2551 // not found to distinguish that from a true error case. | 2670 // not found to distinguish that from a true error case. |
| 2552 | 2671 |
| 2553 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, | 2672 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, |
| 2554 Dart_Handle source); | 2673 Dart_Handle source); |
| 2555 | 2674 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 | 2724 |
| 2606 typedef void (*Dart_FileWriterFunction)(const char* buffer, int64_t num_bytes); | 2725 typedef void (*Dart_FileWriterFunction)(const char* buffer, int64_t num_bytes); |
| 2607 | 2726 |
| 2608 // Support for generating symbol maps for use by the Linux perf tool. | 2727 // Support for generating symbol maps for use by the Linux perf tool. |
| 2609 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function); | 2728 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function); |
| 2610 | 2729 |
| 2611 // Support for generating flow graph compiler debugging output into a file. | 2730 // Support for generating flow graph compiler debugging output into a file. |
| 2612 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function); | 2731 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function); |
| 2613 | 2732 |
| 2614 #endif // INCLUDE_DART_API_H_ | 2733 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |