Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: runtime/include/dart_api.h

Issue 10916252: Implement more of the mirrors library, primarily stuff to do with types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/mirrors/mirrors.dart ('k') | runtime/lib/mirrors.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 _Dart_ReportErrorHandle(__FILE__, __LINE__, \ 332 _Dart_ReportErrorHandle(__FILE__, __LINE__, \
333 #handle, Dart_GetError(handle)); \ 333 #handle, Dart_GetError(handle)); \
334 } 334 }
335 335
336 336
337 /** 337 /**
338 * Converts an object to a string. 338 * Converts an object to a string.
339 * 339 *
340 * May generate an unhandled exception error. 340 * May generate an unhandled exception error.
341 * 341 *
342 * \return A handle to the converted string if no error occurs during 342 * \return The converted string if no error occurs during
343 * the conversion. If an error does occur, an error handle is 343 * the conversion. If an error does occur, an error handle is
344 * returned. 344 * returned.
345 */ 345 */
346 DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object); 346 DART_EXPORT Dart_Handle Dart_ToString(Dart_Handle object);
347 347
348 /** 348 /**
349 * Checks to see if two handles refer to identically equal objects. 349 * Checks to see if two handles refer to identically equal objects.
350 * 350 *
351 * This is equivalent to using the triple-equals (===) operator. 351 * This is equivalent to using the triple-equals (===) operator.
352 * 352 *
(...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
2043 // --- Function and Variable Declarations --- 2078 // --- Function and Variable Declarations ---
2044 2079
2045 /** 2080 /**
2046 * Returns a list of the names of all functions or methods declared in 2081 * Returns a list of the names of all functions or methods declared in
2047 * a library or class. 2082 * a library or class.
2048 * 2083 *
2049 * \param target A library or class. 2084 * \param target A library or class.
2050 * 2085 *
2051 * \return If no error occurs, a list of strings is returned. 2086 * \return If no error occurs, a list of strings is returned.
2052 * Otherwise an erorr handle is returned. 2087 * Otherwise an error handle is returned.
2053 */ 2088 */
2054 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target); 2089 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target);
2055 2090
2056 /** 2091 /**
2057 * Looks up a function or method declaration by name from a library or 2092 * Looks up a function or method declaration by name from a library or
2058 * class. 2093 * class.
2059 * 2094 *
2060 * \param target The library or class containing the function. 2095 * \param target The library or class containing the function.
2061 * \param function_name The name of the function. 2096 * \param function_name The name of the function.
2062 * 2097 *
2063 * \return If an error is encountered, returns an error handle. 2098 * \return If an error is encountered, returns an error handle.
2064 * Otherwise returns a function handle if the function is found of 2099 * Otherwise returns a function handle if the function is found of
2065 * Dart_Null() if the function is not found. 2100 * Dart_Null() if the function is not found.
2066 */ 2101 */
2067 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, 2102 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target,
2068 Dart_Handle function_name); 2103 Dart_Handle function_name);
2069 2104
2070 /** 2105 /**
2071 * Is this a function or method declaration handle? 2106 * Is this a function or method declaration handle?
2072 */ 2107 */
2073 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle); 2108 DART_EXPORT bool Dart_IsFunction(Dart_Handle handle);
2074 2109
2075 /** 2110 /**
2076 * Returns the name for the provided function or method. 2111 * Returns the name for the provided function or method.
2077 * 2112 *
2078 * \return A valid string handle if no error occurs during the 2113 * \return A valid string handle if no error occurs during the
2079 * operation. 2114 * operation.
2080 */ 2115 */
2081 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); 2116 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function);
2082 2117
2083 /** 2118 /**
2084 * Returns a handle to the owner of a function. The owner of an instance method 2119 * 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 2120 *
2086 * is its defining library. The owner of the function of a non-implicit closure 2121 * 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 2122 * class. The owner of a top-level function is its defining
2123 * library. The owner of the function of a non-implicit closure is the
2124 * function of the method or closure that defines the non-implicit
2088 * closure. 2125 * closure.
2089 * 2126 *
2090 * \return A valid handle on the owner of the function, or an error handle if 2127 * \return A valid handle to the owner of the function, or an error
2091 * the argument is not a valid handle to a function. 2128 * handle if the argument is not a valid handle to a function.
2092 */ 2129 */
2093 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); 2130 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function);
2094 2131
2095 /** 2132 /**
2096 * Determines whether a function handle refers to an abstract method. 2133 * Determines whether a function handle refers to an abstract method.
2097 * 2134 *
2098 * \param function A handle to a function or method declaration. 2135 * \param function A handle to a function or method declaration.
2099 * \param is_static Returns whether the handle refers to an abstract method. 2136 * \param is_static Returns whether the handle refers to an abstract method.
2100 * 2137 *
2101 * \return A valid handle if no error occurs during the operation. 2138 * \return A valid handle if no error occurs during the operation.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 * 2183 *
2147 * \param function A handle to a function or method declaration. 2184 * \param function A handle to a function or method declaration.
2148 * \param is_static Returns whether the function or method is a setter. 2185 * \param is_static Returns whether the function or method is a setter.
2149 * 2186 *
2150 * \return A valid handle if no error occurs during the operation. 2187 * \return A valid handle if no error occurs during the operation.
2151 */ 2188 */
2152 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, 2189 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function,
2153 bool* is_setter); 2190 bool* is_setter);
2154 2191
2155 /** 2192 /**
2193 * Returns the return type of a function.
2194 *
2195 * \return A valid handle to a type or an error handle if the argument
2196 * is not valid.
2197 */
2198 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function);
2199
2200 /**
2156 * Determines the number of required and optional parameters. 2201 * Determines the number of required and optional parameters.
2157 * 2202 *
2158 * \param function A handle to a function or method declaration. 2203 * \param function A handle to a function or method declaration.
2159 * \param fixed_param_count Returns the number of required parameters. 2204 * \param fixed_param_count Returns the number of required parameters.
2160 * \param opt_param_count Returns the number of optional parameters. 2205 * \param opt_param_count Returns the number of optional parameters.
2161 * 2206 *
2162 * \return A valid handle if no error occurs during the operation. 2207 * \return A valid handle if no error occurs during the operation.
2163 */ 2208 */
2164 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( 2209 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts(
2165 Dart_Handle function, 2210 Dart_Handle function,
2166 int64_t* fixed_param_count, 2211 int64_t* fixed_param_count,
2167 int64_t* opt_param_count); 2212 int64_t* opt_param_count);
2168 2213
2169 /** 2214 /**
2215 * Returns a handle to the type of a function parameter.
2216 *
2217 * \return A valid handle to a type or an error handle if the argument
2218 * is not valid.
2219 */
2220 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function,
2221 int parameter_index);
2222
2223 /**
2170 * Returns a list of the names of all variables declared in a library 2224 * Returns a list of the names of all variables declared in a library
2171 * or class. 2225 * or class.
2172 * 2226 *
2173 * \param target A library or class. 2227 * \param target A library or class.
2174 * 2228 *
2175 * \return If no error occurs, a list of strings is returned. 2229 * \return If no error occurs, a list of strings is returned.
2176 * Otherwise an erorr handle is returned. 2230 * Otherwise an error handle is returned.
2177 */ 2231 */
2178 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target); 2232 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target);
2179 2233
2180 /** 2234 /**
2181 * Looks up a variable declaration by name from a library or class. 2235 * Looks up a variable declaration by name from a library or class.
2182 * 2236 *
2183 * \param library The library or class containing the variable. 2237 * \param target The library or class containing the variable.
2184 * \param variable_name The name of the variable. 2238 * \param variable_name The name of the variable.
2185 * 2239 *
2186 * \return If an error is encountered, returns an error handle. 2240 * \return If an error is encountered, returns an error handle.
2187 * Otherwise returns a variable handle if the variable is found or 2241 * Otherwise returns a variable handle if the variable is found or
2188 * Dart_Null() if the variable is not found. 2242 * Dart_Null() if the variable is not found.
2189 */ 2243 */
2190 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target, 2244 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target,
2191 Dart_Handle variable_name); 2245 Dart_Handle variable_name);
2192 2246
2193 /** 2247 /**
(...skipping 24 matching lines...) Expand all
2218 * Determines whether a variable is declared final. 2272 * Determines whether a variable is declared final.
2219 * 2273 *
2220 * \param variable A handle to a variable declaration. 2274 * \param variable A handle to a variable declaration.
2221 * \param is_final Returns whether the variable is declared final. 2275 * \param is_final Returns whether the variable is declared final.
2222 * 2276 *
2223 * \return A valid handle if no error occurs during the operation. 2277 * \return A valid handle if no error occurs during the operation.
2224 */ 2278 */
2225 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable, 2279 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable,
2226 bool* is_final); 2280 bool* is_final);
2227 2281
2282 /**
2283 * Returns the type of a variable.
2284 *
2285 * \return A valid handle to a type of or an error handle if the
2286 * argument is not valid.
2287 */
2288 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle function);
2289
2290 /**
2291 * Returns a list of the names of all type variables declared in a class.
2292 *
2293 * The type variables list preserves the original declaration order.
2294 *
2295 * \param clazz A class.
2296 *
2297 * \return If no error occurs, a list of strings is returned.
2298 * Otherwise an error handle is returned.
2299 */
2300 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle clazz);
2301
2302 /**
2303 * Looks up a type variable declaration by name from a class.
2304 *
2305 * \param clazz The class containing the type variable.
2306 * \param variable_name The name of the type variable.
2307 *
2308 * \return If an error is encountered, returns an error handle.
2309 * Otherwise returns a type variable handle if the type variable is
2310 * found or Dart_Null() if the type variable is not found.
2311 */
2312 DART_EXPORT Dart_Handle Dart_LookupTypeVariable(Dart_Handle clazz,
2313 Dart_Handle type_variable_name);
2314
2315 /**
2316 * Is this a type variable handle?
2317 */
2318 DART_EXPORT bool Dart_IsTypeVariable(Dart_Handle handle);
2319
2320 /**
2321 * Returns the name for the provided type variable.
2322 */
2323 DART_EXPORT Dart_Handle Dart_TypeVariableName(Dart_Handle type_variable);
2324
2325 /**
2326 * Returns the owner of a function.
2327 *
2328 * The owner of a type variable is its defining class.
2329 *
2330 * \return A valid handle to the owner of the type variable, or an error
2331 * handle if the argument is not a valid handle to a type variable.
2332 */
2333 DART_EXPORT Dart_Handle Dart_TypeVariableOwner(Dart_Handle type_variable);
2334
2335 /**
2336 * Returns the upper bound of a type variable.
2337 *
2338 * The upper bound of a type variable is ...
2339 *
2340 * \return A valid handle to a type, or an error handle if the
2341 * argument is not a valid handle.
2342 */
2343 DART_EXPORT Dart_Handle Dart_TypeVariableUpperBound(Dart_Handle type_variable);
2344 // TODO(turnidge): Finish documentation.
2345
2228 // --- Constructors, Methods, and Fields --- 2346 // --- Constructors, Methods, and Fields ---
2229 2347
2230 /** 2348 /**
2231 * Invokes a constructor, creating a new object. 2349 * Invokes a constructor, creating a new object.
2232 * 2350 *
2233 * This function allows hidden constructors (constructors with leading 2351 * This function allows hidden constructors (constructors with leading
2234 * underscores) to be called. 2352 * underscores) to be called.
2235 * 2353 *
2236 * \param clazz A class or an interface. 2354 * \param clazz A class or an interface.
2237 * \param constructor_name The name of the constructor to invoke. Use 2355 * \param constructor_name The name of the constructor to invoke. Use
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 /** 2653 /**
2536 * Returns the url from which a library was loaded. 2654 * Returns the url from which a library was loaded.
2537 */ 2655 */
2538 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); 2656 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library);
2539 2657
2540 /** 2658 /**
2541 * Returns a list of the names of all classes and interfaces declared 2659 * Returns a list of the names of all classes and interfaces declared
2542 * in a library. 2660 * in a library.
2543 * 2661 *
2544 * \return If no error occurs, a list of strings is returned. 2662 * \return If no error occurs, a list of strings is returned.
2545 * Otherwise an erorr handle is returned. 2663 * Otherwise an error handle is returned.
2546 */ 2664 */
2547 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library); 2665 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library);
2548 2666
2549 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url); 2667 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url);
2550 // TODO(turnidge): Consider returning Dart_Null() when the library is 2668 // TODO(turnidge): Consider returning Dart_Null() when the library is
2551 // not found to distinguish that from a true error case. 2669 // not found to distinguish that from a true error case.
2552 2670
2553 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, 2671 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
2554 Dart_Handle source); 2672 Dart_Handle source);
2555 2673
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2605 2723
2606 typedef void (*Dart_FileWriterFunction)(const char* buffer, int64_t num_bytes); 2724 typedef void (*Dart_FileWriterFunction)(const char* buffer, int64_t num_bytes);
2607 2725
2608 // Support for generating symbol maps for use by the Linux perf tool. 2726 // Support for generating symbol maps for use by the Linux perf tool.
2609 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function); 2727 DART_EXPORT void Dart_InitPerfEventsSupport(Dart_FileWriterFunction function);
2610 2728
2611 // Support for generating flow graph compiler debugging output into a file. 2729 // Support for generating flow graph compiler debugging output into a file.
2612 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function); 2730 DART_EXPORT void Dart_InitFlowGraphPrinting(Dart_FileWriterFunction function);
2613 2731
2614 #endif // INCLUDE_DART_API_H_ 2732 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « lib/mirrors/mirrors.dart ('k') | runtime/lib/mirrors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698