Chromium Code Reviews| 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. These typedef classes allow the | |
|
cshapiro
2012/09/12 18:52:07
typedef classes or typedef class handles?
turnidge
2012/09/12 21:39:30
Done.
| |
| 2048 * embedder to find their referent by using | |
| 2049 * Dart_ClassGetTypedefReferent. | |
|
cshapiro
2012/09/12 18:52:07
Wordy.
"Dart_ClassGetTypedefReferent returns the
turnidge
2012/09/12 21:39:30
Made less wordy.
| |
| 2050 * | |
| 2051 * TODO(turnidge): Finish documentation. | |
| 2052 */ | |
| 2053 DART_EXPORT bool Dart_ClassIsTypedef(Dart_Handle handle); | |
|
cshapiro
2012/09/12 18:52:07
Rename "handle" to "klass", "cls", or "clazz" ?
| |
| 2054 | |
| 2055 /** | |
| 2056 * Returns a handle to the type to which a typedef refers. | |
| 2057 * | |
| 2058 * This function should only be called when Dart_ClassIsTypedef returns | |
| 2059 * true. | |
|
cshapiro
2012/09/12 18:52:07
Why? I would expect this function to return an er
turnidge
2012/09/12 21:39:30
Just so. I'm telling them how to avoid getting an
| |
| 2060 * | |
| 2061 * TODO(turnidge): Finish documentation. | |
| 2062 */ | |
| 2063 DART_EXPORT Dart_Handle Dart_ClassGetTypedefReferent(Dart_Handle clazz); | |
| 2064 | |
| 2065 /** | |
| 2066 * Does this class represent the type of a function? | |
| 2067 */ | |
| 2068 DART_EXPORT bool Dart_ClassIsFunctionType(Dart_Handle handle); | |
|
cshapiro
2012/09/12 18:52:07
Rename "handle" to "klass", "cls", or "clazz" ?
turnidge
2012/09/12 21:39:30
Done.
| |
| 2069 | |
| 2070 /** | |
| 2071 * Returns a signature function for a function type. | |
|
cshapiro
2012/09/12 18:52:07
signature function or function signature?
turnidge
2012/09/12 21:39:30
Um, rewrote comment entirely:
/**
* Returns a f
| |
| 2072 */ | |
| 2073 DART_EXPORT Dart_Handle Dart_ClassGetFunctionTypeSignature(Dart_Handle clazz); | |
| 2074 | |
| 2075 | |
| 2043 // --- Function and Variable Declarations --- | 2076 // --- Function and Variable Declarations --- |
| 2044 | 2077 |
| 2045 /** | 2078 /** |
| 2046 * Returns a list of the names of all functions or methods declared in | 2079 * Returns a list of the names of all functions or methods declared in |
| 2047 * a library or class. | 2080 * a library or class. |
| 2048 * | 2081 * |
| 2049 * \param target A library or class. | 2082 * \param target A library or class. |
| 2050 * | 2083 * |
| 2051 * \return If no error occurs, a list of strings is returned. | 2084 * \return If no error occurs, a list of strings is returned. |
| 2052 * Otherwise an erorr handle is returned. | 2085 * Otherwise an error handle is returned. |
| 2053 */ | 2086 */ |
| 2054 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target); | 2087 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target); |
| 2055 | 2088 |
| 2056 /** | 2089 /** |
| 2057 * Looks up a function or method declaration by name from a library or | 2090 * Looks up a function or method declaration by name from a library or |
| 2058 * class. | 2091 * class. |
| 2059 * | 2092 * |
| 2060 * \param target The library or class containing the function. | 2093 * \param target The library or class containing the function. |
| 2061 * \param function_name The name of the function. | 2094 * \param function_name The name of the function. |
| 2062 * | 2095 * |
| 2063 * \return If an error is encountered, returns an error handle. | 2096 * \return If an error is encountered, returns an error handle. |
| 2064 * Otherwise returns a function handle if the function is found of | 2097 * Otherwise returns a function handle if the function is found of |
| 2065 * Dart_Null() if the function is not found. | 2098 * Dart_Null() if the function is not found. |
| 2066 */ | 2099 */ |
| 2067 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, | 2100 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, |
| 2068 Dart_Handle function_name); | 2101 Dart_Handle function_name); |
| 2069 | 2102 |
| 2070 /** | 2103 /** |
| 2071 * Is this a function or method declaration handle? | 2104 * Is this a function or method declaration handle? |
| 2072 */ | 2105 */ |
| 2073 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); | 2106 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); |
| 2074 | 2107 |
| 2075 /** | 2108 /** |
| 2076 * Returns the name for the provided function or method. | 2109 * Returns the name for the provided function or method. |
| 2077 * | 2110 * |
| 2078 * \return A valid string handle if no error occurs during the | 2111 * \return A valid string handle if no error occurs during the |
| 2079 * operation. | 2112 * operation. |
| 2080 */ | 2113 */ |
| 2081 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); | 2114 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); |
| 2082 | 2115 |
| 2083 /** | 2116 /** |
| 2084 * Returns a handle to the owner of a function. The owner of an instance method | 2117 * 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 | 2118 * |
| 2086 * is its defining library. The owner of the function of a non-implicit closure | 2119 * 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 | 2120 * class. The owner of a top-level function is its defining |
| 2121 * library. The owner of the function of a non-implicit closure is the | |
| 2122 * function of the method or closure that defines the non-implicit | |
| 2088 * closure. | 2123 * closure. |
| 2089 * | 2124 * |
| 2090 * \return A valid handle on the owner of the function, or an error handle if | 2125 * \return A valid handle to the owner of the function, or an error |
| 2091 * the argument is not a valid handle to a function. | 2126 * handle if the argument is not a valid handle to a function. |
| 2092 */ | 2127 */ |
| 2093 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); | 2128 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); |
| 2094 | 2129 |
| 2095 /** | 2130 /** |
| 2096 * Determines whether a function handle refers to an abstract method. | 2131 * Determines whether a function handle refers to an abstract method. |
| 2097 * | 2132 * |
| 2098 * \param function A handle to a function or method declaration. | 2133 * \param function A handle to a function or method declaration. |
| 2099 * \param is_static Returns whether the handle refers to an abstract method. | 2134 * \param is_static Returns whether the handle refers to an abstract method. |
| 2100 * | 2135 * |
| 2101 * \return A valid handle if no error occurs during the operation. | 2136 * \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 * | 2181 * |
| 2147 * \param function A handle to a function or method declaration. | 2182 * \param function A handle to a function or method declaration. |
| 2148 * \param is_static Returns whether the function or method is a setter. | 2183 * \param is_static Returns whether the function or method is a setter. |
| 2149 * | 2184 * |
| 2150 * \return A valid handle if no error occurs during the operation. | 2185 * \return A valid handle if no error occurs during the operation. |
| 2151 */ | 2186 */ |
| 2152 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, | 2187 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, |
| 2153 bool* is_setter); | 2188 bool* is_setter); |
| 2154 | 2189 |
| 2155 /** | 2190 /** |
| 2191 * Returns a handle to the return type of a function. | |
|
cshapiro
2012/09/12 18:52:07
I am confused about the pervasive use of handle in
turnidge
2012/09/12 21:39:30
Right. I am torn about this. I could start dropp
cshapiro
2012/09/13 04:29:58
I think the handle is superfluous, after all what
turnidge
2012/09/13 17:02:57
Fixed this use. Will fix the more pervasive probl
| |
| 2192 * | |
| 2193 * \return A valid handle to a type or an error handle if the argument | |
| 2194 * is not valid. | |
| 2195 */ | |
| 2196 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function); | |
| 2197 | |
| 2198 /** | |
| 2156 * Determines the number of required and optional parameters. | 2199 * Determines the number of required and optional parameters. |
| 2157 * | 2200 * |
| 2158 * \param function A handle to a function or method declaration. | 2201 * \param function A handle to a function or method declaration. |
| 2159 * \param fixed_param_count Returns the number of required parameters. | 2202 * \param fixed_param_count Returns the number of required parameters. |
| 2160 * \param opt_param_count Returns the number of optional parameters. | 2203 * \param opt_param_count Returns the number of optional parameters. |
| 2161 * | 2204 * |
| 2162 * \return A valid handle if no error occurs during the operation. | 2205 * \return A valid handle if no error occurs during the operation. |
| 2163 */ | 2206 */ |
| 2164 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( | 2207 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( |
| 2165 Dart_Handle function, | 2208 Dart_Handle function, |
| 2166 int64_t* fixed_param_count, | 2209 int64_t* fixed_param_count, |
| 2167 int64_t* opt_param_count); | 2210 int64_t* opt_param_count); |
| 2168 | 2211 |
| 2169 /** | 2212 /** |
| 2213 * Returns a handle to the type of a function parameter. | |
| 2214 * | |
| 2215 * \return A valid handle to a type or an error handle if the argument | |
| 2216 * is not valid. | |
| 2217 */ | |
| 2218 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function, | |
| 2219 int parameter_index); | |
| 2220 | |
| 2221 /** | |
| 2170 * Returns a list of the names of all variables declared in a library | 2222 * Returns a list of the names of all variables declared in a library |
| 2171 * or class. | 2223 * or class. |
| 2172 * | 2224 * |
| 2173 * \param target A library or class. | 2225 * \param target A library or class. |
| 2174 * | 2226 * |
| 2175 * \return If no error occurs, a list of strings is returned. | 2227 * \return If no error occurs, a list of strings is returned. |
| 2176 * Otherwise an erorr handle is returned. | 2228 * Otherwise an error handle is returned. |
| 2177 */ | 2229 */ |
| 2178 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target); | 2230 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target); |
| 2179 | 2231 |
| 2180 /** | 2232 /** |
| 2181 * Looks up a variable declaration by name from a library or class. | 2233 * Looks up a variable declaration by name from a library or class. |
| 2182 * | 2234 * |
| 2183 * \param library The library or class containing the variable. | 2235 * \param target The library or class containing the variable. |
| 2184 * \param variable_name The name of the variable. | 2236 * \param variable_name The name of the variable. |
| 2185 * | 2237 * |
| 2186 * \return If an error is encountered, returns an error handle. | 2238 * \return If an error is encountered, returns an error handle. |
| 2187 * Otherwise returns a variable handle if the variable is found or | 2239 * Otherwise returns a variable handle if the variable is found or |
| 2188 * Dart_Null() if the variable is not found. | 2240 * Dart_Null() if the variable is not found. |
| 2189 */ | 2241 */ |
| 2190 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target, | 2242 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target, |
| 2191 Dart_Handle variable_name); | 2243 Dart_Handle variable_name); |
| 2192 | 2244 |
| 2193 /** | 2245 /** |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 2218 * Determines whether a variable is declared final. | 2270 * Determines whether a variable is declared final. |
| 2219 * | 2271 * |
| 2220 * \param variable A handle to a variable declaration. | 2272 * \param variable A handle to a variable declaration. |
| 2221 * \param is_final Returns whether the variable is declared final. | 2273 * \param is_final Returns whether the variable is declared final. |
| 2222 * | 2274 * |
| 2223 * \return A valid handle if no error occurs during the operation. | 2275 * \return A valid handle if no error occurs during the operation. |
| 2224 */ | 2276 */ |
| 2225 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable, | 2277 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable, |
| 2226 bool* is_final); | 2278 bool* is_final); |
| 2227 | 2279 |
| 2280 /** | |
| 2281 * Returns a handle to the type of a variable. | |
| 2282 * | |
| 2283 * \return A valid handle to a type of or an error handle if the | |
| 2284 * argument is not valid. | |
| 2285 */ | |
| 2286 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle function); | |
| 2287 | |
| 2288 /** | |
| 2289 * Returns a list of the names of all type variables declared in a class. | |
| 2290 * | |
| 2291 * The type variables list preserves the original declaration order. | |
| 2292 * | |
| 2293 * \param clazz A class. | |
| 2294 * | |
| 2295 * \return If no error occurs, a list of strings is returned. | |
| 2296 * Otherwise an error handle is returned. | |
| 2297 */ | |
| 2298 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle clazz); | |
| 2299 | |
| 2300 /** | |
| 2301 * Looks up a type variable declaration by name from a class. | |
| 2302 * | |
| 2303 * \param clazz The class containing the type variable. | |
| 2304 * \param variable_name The name of the type variable. | |
| 2305 * | |
| 2306 * \return If an error is encountered, returns an error handle. | |
| 2307 * Otherwise returns a type variable handle if the type variable is | |
| 2308 * found or Dart_Null() if the type variable is not found. | |
| 2309 */ | |
| 2310 DART_EXPORT Dart_Handle Dart_LookupTypeVariable(Dart_Handle clazz, | |
| 2311 Dart_Handle type_variable_name); | |
| 2312 | |
| 2313 /** | |
| 2314 * Is this a type variable handle? | |
| 2315 */ | |
| 2316 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle); | |
| 2317 | |
| 2318 /** | |
| 2319 * Returns the name for the provided type variable. | |
| 2320 */ | |
| 2321 DART_EXPORT Dart_Handle Dart_TypeVariableName(Dart_Handle type_variable); | |
| 2322 | |
| 2323 /** | |
| 2324 * Returns a handle to the owner of a function. | |
| 2325 * | |
| 2326 * The owner of a type variable is its defining class. | |
| 2327 * | |
| 2328 * \return A valid handle to the owner of the type variable, or an error | |
| 2329 * handle if the argument is not a valid handle to a type variable. | |
| 2330 */ | |
| 2331 DART_EXPORT Dart_Handle Dart_TypeVariableOwner(Dart_Handle type_variable); | |
| 2332 | |
| 2333 /** | |
| 2334 * Returns a handle to the upper bound of a type variable. | |
| 2335 * | |
| 2336 * The upper bound of a type variable is ... | |
| 2337 * | |
| 2338 * \return A valid handle to a type, or an error handle if the | |
| 2339 * argument is not a valid handle. | |
| 2340 */ | |
| 2341 DART_EXPORT Dart_Handle Dart_TypeVariableUpperBound(Dart_Handle type_variable); | |
| 2342 // TODO(turnidge): Finish documentation. | |
| 2343 | |
| 2228 // --- Constructors, Methods, and Fields --- | 2344 // --- Constructors, Methods, and Fields --- |
| 2229 | 2345 |
| 2230 /** | 2346 /** |
| 2231 * Invokes a constructor, creating a new object. | 2347 * Invokes a constructor, creating a new object. |
| 2232 * | 2348 * |
| 2233 * This function allows hidden constructors (constructors with leading | 2349 * This function allows hidden constructors (constructors with leading |
| 2234 * underscores) to be called. | 2350 * underscores) to be called. |
| 2235 * | 2351 * |
| 2236 * \param clazz A class or an interface. | 2352 * \param clazz A class or an interface. |
| 2237 * \param constructor_name The name of the constructor to invoke. Use | 2353 * \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 /** | 2651 /** |
| 2536 * Returns the url from which a library was loaded. | 2652 * Returns the url from which a library was loaded. |
| 2537 */ | 2653 */ |
| 2538 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); | 2654 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); |
| 2539 | 2655 |
| 2540 /** | 2656 /** |
| 2541 * Returns a list of the names of all classes and interfaces declared | 2657 * Returns a list of the names of all classes and interfaces declared |
| 2542 * in a library. | 2658 * in a library. |
| 2543 * | 2659 * |
| 2544 * \return If no error occurs, a list of strings is returned. | 2660 * \return If no error occurs, a list of strings is returned. |
| 2545 * Otherwise an erorr handle is returned. | 2661 * Otherwise an error handle is returned. |
| 2546 */ | 2662 */ |
| 2547 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library); | 2663 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library); |
| 2548 | 2664 |
| 2549 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); | 2665 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); |
| 2550 // TODO(turnidge): Consider returning Dart_Null() when the library is | 2666 // TODO(turnidge): Consider returning Dart_Null() when the library is |
| 2551 // not found to distinguish that from a true error case. | 2667 // not found to distinguish that from a true error case. |
| 2552 | 2668 |
| 2553 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, | 2669 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, |
| 2554 Dart_Handle source); | 2670 Dart_Handle source); |
| 2555 | 2671 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2605 | 2721 |
| 2606 typedef void (*Dart_FileWriterFunction)(const char* buffer, int64_t num_bytes); | 2722 typedef void (*Dart_FileWriterFunction)(const char* buffer, int64_t num_bytes); |
| 2607 | 2723 |
| 2608 // Support for generating symbol maps for use by the Linux perf tool. | 2724 // Support for generating symbol maps for use by the Linux perf tool. |
| 2609 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function); | 2725 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function); |
| 2610 | 2726 |
| 2611 // Support for generating flow graph compiler debugging output into a file. | 2727 // Support for generating flow graph compiler debugging output into a file. |
| 2612 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function); | 2728 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function); |
| 2613 | 2729 |
| 2614 #endif // INCLUDE_DART_API_H_ | 2730 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |