OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
5 */ | |
6 | |
7 #ifndef INCLUDE_DART_MIRRORS_API_H_ | |
8 #define INCLUDE_DART_MIRRORS_API_H_ | |
9 | |
10 #include "include/dart_api.h" | |
11 | |
12 /* | |
13 * ================================= | |
14 * Classes and Interfaces Reflection | |
15 * ================================= | |
vsm
2013/06/13 22:34:55
You might consider moving Dart_GetSuperclass and s
siva
2013/06/13 22:53:17
Yes, that would be the plan. I will do that in a d
| |
16 */ | |
17 | |
18 /** | |
19 * Returns the class name for the provided class or interface. | |
20 */ | |
21 DART_EXPORT Dart_Handle Dart_ClassName(Dart_Handle clazz); | |
22 | |
23 /** | |
24 * Returns the library for the provided class or interface. | |
25 */ | |
26 DART_EXPORT Dart_Handle Dart_ClassGetLibrary(Dart_Handle clazz); | |
27 | |
28 /** | |
29 * Returns the number of interfaces directly implemented by some class | |
30 * or interface. | |
31 * | |
32 * TODO(turnidge): Finish documentation. | |
33 */ | |
34 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceCount(Dart_Handle clazz, | |
35 intptr_t* count); | |
36 | |
37 /** | |
38 * Returns the interface at some index in the list of interfaces some | |
39 * class or inteface. | |
40 * | |
41 * TODO(turnidge): Finish documentation. | |
42 */ | |
43 DART_EXPORT Dart_Handle Dart_ClassGetInterfaceAt(Dart_Handle clazz, | |
44 intptr_t index); | |
45 | |
46 /** | |
47 * Is this class defined by a typedef? | |
48 * | |
49 * Typedef definitions from the main program are represented as a | |
50 * special kind of class handle. See Dart_ClassGetTypedefReferent. | |
51 * | |
52 * TODO(turnidge): Finish documentation. | |
53 */ | |
54 DART_EXPORT bool Dart_ClassIsTypedef(Dart_Handle clazz); | |
55 | |
56 /** | |
57 * Returns a handle to the type to which a typedef refers. | |
58 * | |
59 * It is an error to call this function on a handle for which | |
60 * Dart_ClassIsTypedef is not true. | |
61 * | |
62 * TODO(turnidge): Finish documentation. | |
63 */ | |
64 DART_EXPORT Dart_Handle Dart_ClassGetTypedefReferent(Dart_Handle clazz); | |
65 | |
66 /** | |
67 * Does this class represent the type of a function? | |
68 */ | |
69 DART_EXPORT bool Dart_ClassIsFunctionType(Dart_Handle clazz); | |
70 | |
71 /** | |
72 * Returns a function handle representing the signature associated | |
73 * with a function type. | |
74 * | |
75 * The return value is a function handle (See Dart_IsFunction, etc.). | |
76 * | |
77 * TODO(turnidge): Finish documentation. | |
78 */ | |
79 DART_EXPORT Dart_Handle Dart_ClassGetFunctionTypeSignature(Dart_Handle clazz); | |
80 | |
81 | |
82 /* | |
83 * ================================= | |
84 * Function and Variables Reflection | |
85 * ================================= | |
86 */ | |
87 | |
88 /** | |
89 * Returns a list of the names of all functions or methods declared in | |
90 * a library or class. | |
91 * | |
92 * \param target A library or class. | |
93 * | |
94 * \return If no error occurs, a list of strings is returned. | |
95 * Otherwise an error handle is returned. | |
96 */ | |
97 DART_EXPORT Dart_Handle Dart_GetFunctionNames(Dart_Handle target); | |
98 | |
99 /** | |
100 * Looks up a function or method declaration by name from a library or | |
101 * class. | |
102 * | |
103 * \param target The library or class containing the function. | |
104 * \param function_name The name of the function. | |
105 * | |
106 * \return If an error is encountered, returns an error handle. | |
107 * Otherwise returns a function handle if the function is found of | |
108 * Dart_Null() if the function is not found. | |
109 */ | |
110 DART_EXPORT Dart_Handle Dart_LookupFunction(Dart_Handle target, | |
111 Dart_Handle function_name); | |
112 | |
113 /** | |
114 * Returns the name for the provided function or method. | |
115 * | |
116 * \return A valid string handle if no error occurs during the | |
117 * operation. | |
118 */ | |
119 DART_EXPORT Dart_Handle Dart_FunctionName(Dart_Handle function); | |
120 | |
121 /** | |
122 * Returns a handle to the owner of a function. | |
123 * | |
124 * The owner of an instance method or a static method is its defining | |
125 * class. The owner of a top-level function is its defining | |
126 * library. The owner of the function of a non-implicit closure is the | |
127 * function of the method or closure that defines the non-implicit | |
128 * closure. | |
129 * | |
130 * \return A valid handle to the owner of the function, or an error | |
131 * handle if the argument is not a valid handle to a function. | |
132 */ | |
133 DART_EXPORT Dart_Handle Dart_FunctionOwner(Dart_Handle function); | |
134 | |
135 /** | |
136 * Determines whether a function handle refers to an abstract method. | |
137 * | |
138 * \param function A handle to a function or method declaration. | |
139 * \param is_static Returns whether the handle refers to an abstract method. | |
140 * | |
141 * \return A valid handle if no error occurs during the operation. | |
142 */ | |
143 DART_EXPORT Dart_Handle Dart_FunctionIsAbstract(Dart_Handle function, | |
144 bool* is_abstract); | |
145 | |
146 /** | |
147 * Determines whether a function handle referes to a static function | |
148 * of method. | |
149 * | |
150 * For the purposes of the embedding API, a top-level function is | |
151 * implicitly declared static. | |
152 * | |
153 * \param function A handle to a function or method declaration. | |
154 * \param is_static Returns whether the function or method is declared static. | |
155 * | |
156 * \return A valid handle if no error occurs during the operation. | |
157 */ | |
158 DART_EXPORT Dart_Handle Dart_FunctionIsStatic(Dart_Handle function, | |
159 bool* is_static); | |
160 | |
161 /** | |
162 * Determines whether a function handle referes to a constructor. | |
163 * | |
164 * \param function A handle to a function or method declaration. | |
165 * \param is_static Returns whether the function or method is a constructor. | |
166 * | |
167 * \return A valid handle if no error occurs during the operation. | |
168 */ | |
169 DART_EXPORT Dart_Handle Dart_FunctionIsConstructor(Dart_Handle function, | |
170 bool* is_constructor); | |
171 /* TODO(turnidge): Document behavior for factory constructors too. */ | |
172 | |
173 /** | |
174 * Determines whether a function or method is a getter. | |
175 * | |
176 * \param function A handle to a function or method declaration. | |
177 * \param is_static Returns whether the function or method is a getter. | |
178 * | |
179 * \return A valid handle if no error occurs during the operation. | |
180 */ | |
181 DART_EXPORT Dart_Handle Dart_FunctionIsGetter(Dart_Handle function, | |
182 bool* is_getter); | |
183 | |
184 /** | |
185 * Determines whether a function or method is a setter. | |
186 * | |
187 * \param function A handle to a function or method declaration. | |
188 * \param is_static Returns whether the function or method is a setter. | |
189 * | |
190 * \return A valid handle if no error occurs during the operation. | |
191 */ | |
192 DART_EXPORT Dart_Handle Dart_FunctionIsSetter(Dart_Handle function, | |
193 bool* is_setter); | |
194 | |
195 /** | |
196 * Returns the return type of a function. | |
197 * | |
198 * \return A valid handle to a type or an error handle if the argument | |
199 * is not valid. | |
200 */ | |
201 DART_EXPORT Dart_Handle Dart_FunctionReturnType(Dart_Handle function); | |
202 | |
203 /** | |
204 * Determines the number of required and optional parameters. | |
205 * | |
206 * \param function A handle to a function or method declaration. | |
207 * \param fixed_param_count Returns the number of required parameters. | |
208 * \param opt_param_count Returns the number of optional parameters. | |
209 * | |
210 * \return A valid handle if no error occurs during the operation. | |
211 */ | |
212 DART_EXPORT Dart_Handle Dart_FunctionParameterCounts( | |
213 Dart_Handle function, | |
214 int64_t* fixed_param_count, | |
215 int64_t* opt_param_count); | |
216 | |
217 /** | |
218 * Returns a handle to the type of a function parameter. | |
219 * | |
220 * \return A valid handle to a type or an error handle if the argument | |
221 * is not valid. | |
222 */ | |
223 DART_EXPORT Dart_Handle Dart_FunctionParameterType(Dart_Handle function, | |
224 int parameter_index); | |
225 | |
226 /** | |
227 * Returns a list of the names of all variables declared in a library | |
228 * or class. | |
229 * | |
230 * \param target A library or class. | |
231 * | |
232 * \return If no error occurs, a list of strings is returned. | |
233 * Otherwise an error handle is returned. | |
234 */ | |
235 DART_EXPORT Dart_Handle Dart_GetVariableNames(Dart_Handle target); | |
236 | |
237 /** | |
238 * Looks up a variable declaration by name from a library or class. | |
239 * | |
240 * \param target The library or class containing the variable. | |
241 * \param variable_name The name of the variable. | |
242 * | |
243 * \return If an error is encountered, returns an error handle. | |
244 * Otherwise returns a variable handle if the variable is found or | |
245 * Dart_Null() if the variable is not found. | |
246 */ | |
247 DART_EXPORT Dart_Handle Dart_LookupVariable(Dart_Handle target, | |
248 Dart_Handle variable_name); | |
249 | |
250 /** | |
251 * Returns the name for the provided variable. | |
252 */ | |
253 DART_EXPORT Dart_Handle Dart_VariableName(Dart_Handle variable); | |
254 | |
255 /** | |
256 * Determines whether a variable is declared static. | |
257 * | |
258 * For the purposes of the embedding API, a top-level variable is | |
259 * implicitly declared static. | |
260 * | |
261 * \param variable A handle to a variable declaration. | |
262 * \param is_static Returns whether the variable is declared static. | |
263 * | |
264 * \return A valid handle if no error occurs during the operation. | |
265 */ | |
266 DART_EXPORT Dart_Handle Dart_VariableIsStatic(Dart_Handle variable, | |
267 bool* is_static); | |
268 | |
269 /** | |
270 * Determines whether a variable is declared final. | |
271 * | |
272 * \param variable A handle to a variable declaration. | |
273 * \param is_final Returns whether the variable is declared final. | |
274 * | |
275 * \return A valid handle if no error occurs during the operation. | |
276 */ | |
277 DART_EXPORT Dart_Handle Dart_VariableIsFinal(Dart_Handle variable, | |
278 bool* is_final); | |
279 | |
280 /** | |
281 * Returns the type of a variable. | |
282 * | |
283 * \return A valid handle to a type of or an error handle if the | |
284 * argument is not valid. | |
285 */ | |
286 DART_EXPORT Dart_Handle Dart_VariableType(Dart_Handle function); | |
287 | |
288 /** | |
289 * Returns a list of the names of all type variables declared in a class. | |
290 * | |
291 * The type variables list preserves the original declaration order. | |
292 * | |
293 * \param clazz A class. | |
294 * | |
295 * \return If no error occurs, a list of strings is returned. | |
296 * Otherwise an error handle is returned. | |
297 */ | |
298 DART_EXPORT Dart_Handle Dart_GetTypeVariableNames(Dart_Handle clazz); | |
299 | |
300 /** | |
301 * Looks up a type variable declaration by name from a class. | |
302 * | |
303 * \param clazz The class containing the type variable. | |
304 * \param variable_name The name of the type variable. | |
305 * | |
306 * \return If an error is encountered, returns an error handle. | |
307 * Otherwise returns a type variable handle if the type variable is | |
308 * found or Dart_Null() if the type variable is not found. | |
309 */ | |
310 DART_EXPORT Dart_Handle Dart_LookupTypeVariable(Dart_Handle clazz, | |
311 Dart_Handle type_variable_name); | |
312 | |
313 /** | |
314 * Returns the name for the provided type variable. | |
315 */ | |
316 DART_EXPORT Dart_Handle Dart_TypeVariableName(Dart_Handle type_variable); | |
317 | |
318 /** | |
319 * Returns the owner of a function. | |
320 * | |
321 * The owner of a type variable is its defining class. | |
322 * | |
323 * \return A valid handle to the owner of the type variable, or an error | |
324 * handle if the argument is not a valid handle to a type variable. | |
325 */ | |
326 DART_EXPORT Dart_Handle Dart_TypeVariableOwner(Dart_Handle type_variable); | |
327 | |
328 /** | |
329 * Returns the upper bound of a type variable. | |
330 * | |
331 * The upper bound of a type variable is ... | |
332 * | |
333 * \return A valid handle to a type, or an error handle if the | |
334 * argument is not a valid handle. | |
335 */ | |
336 DART_EXPORT Dart_Handle Dart_TypeVariableUpperBound(Dart_Handle type_variable); | |
337 /* TODO(turnidge): Finish documentation. */ | |
338 | |
339 | |
340 /* | |
341 * ==================== | |
342 * Libraries Reflection | |
343 * ==================== | |
344 */ | |
345 | |
346 /** | |
347 * Returns the name of a library as declared in the #library directive. | |
348 */ | |
349 DART_EXPORT Dart_Handle Dart_LibraryName(Dart_Handle library); | |
350 | |
351 /** | |
352 * Returns a list of the names of all classes and interfaces declared | |
353 * in a library. | |
354 * | |
355 * \return If no error occurs, a list of strings is returned. | |
356 * Otherwise an error handle is returned. | |
357 */ | |
358 DART_EXPORT Dart_Handle Dart_LibraryGetClassNames(Dart_Handle library); | |
359 | |
360 | |
361 /* | |
362 * =================== | |
363 * Closures Reflection | |
364 * =================== | |
365 */ | |
366 | |
367 /** | |
368 * Retrieves the function of a closure. | |
369 * | |
370 * \return A handle to the function of the closure, or an error handle if the | |
371 * argument is not a closure. | |
372 */ | |
373 DART_EXPORT Dart_Handle Dart_ClosureFunction(Dart_Handle closure); | |
374 | |
375 /* | |
376 * =================== | |
377 * Metadata Reflection | |
378 * =================== | |
379 */ | |
380 | |
381 /** | |
382 * Get metadata associated with an object. | |
383 * | |
384 * \param obj Object for which the metadata is retrieved. | |
385 * | |
386 * \return If no error occurs, returns an array of metadata values. | |
387 * Returns an empty array if there is no metadata for the object. | |
388 * Returns an error if the evaluation of the metadata expressions fails. | |
389 * | |
390 */ | |
391 DART_EXPORT Dart_Handle Dart_GetMetadata(Dart_Handle obj); | |
392 | |
393 #endif /* INCLUDE_DART_MIRRORS_API_H_ */ /* NOLINT */ | |
OLD | NEW |