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

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

Issue 8343045: Reorganize dart_api.h and add a bunch of documentation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « no previous file | runtime/vm/dart_api_impl.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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
9 *
10 * Dart is a class-based programming language for creating structured
11 * web applications. This reference describes the Dart embedding api,
12 * which is used to embed the Dart Virtual Machine within an
13 * application.
14 *
15 * This reference is generated from the header include/dart_api.h.
16 */
17
8 #ifdef __cplusplus 18 #ifdef __cplusplus
9 #define DART_EXTERN_C extern "C" 19 #define DART_EXTERN_C extern "C"
10 #else 20 #else
11 #define DART_EXTERN_C 21 #define DART_EXTERN_C
12 #endif 22 #endif
13 23
14 #if defined(__CYGWIN__) 24 #if defined(__CYGWIN__)
15 #error Tool chain and platform not supported. 25 #error Tool chain and platform not supported.
16 #elif defined(_WIN32) 26 #elif defined(_WIN32)
17 typedef signed __int8 int8_t; 27 typedef signed __int8 int8_t;
(...skipping 17 matching lines...) Expand all
35 #else 45 #else
36 #define DART_EXPORT DART_EXTERN_C 46 #define DART_EXPORT DART_EXTERN_C
37 #endif 47 #endif
38 #else 48 #else
39 #error Tool chain not supported. 49 #error Tool chain not supported.
40 #endif 50 #endif
41 #endif 51 #endif
42 52
43 #include <assert.h> 53 #include <assert.h>
44 54
55 // --- Handles ---
56
57 /**
58 * An object reference managed by the Dart VM garbage collector.
59 *
60 * Because the garbage collector may move objects, it is unsafe to
61 * refer to objects directly. Instead, we refer to objects through
62 * handles, which are known to the garbage collector and updates
63 * automatically when the object is moved. Handles should be passed
64 * by value (except in cases like out-parameters) and should never be
65 * allocated on the heap.
66 *
67 * A handle may either be valid or invalid. Valid handles refer to a
68 * (possibly null) object in the Dart VM heap. Invalid handles are
siva 2011/10/31 21:52:13 Should we say: refer to an (possibly null or an ex
turnidge 2011/10/31 23:04:43 Changed the language a bit...
69 * returned by many Dart api functions when they encounter an error.
70 * Invalid handles have an associated error message.
71 *
72 * Local handles are allocated within the current scope (see
73 * Dart_EnterScope) and go away when the current scope exits. Unless
74 * otherwise indicated, all functions in the Dart embedding api return
75 * local handles.
76 *
77 * Persistent handles are allocated within the current isolate. They
78 * can be used to store objects across scopes. Persistent handles
79 * need to be explicitly deallocated when they are no longer needed.
80 */
81 typedef void* Dart_Handle;
82
83 /**
84 * Is this handle valid?
85 *
86 * Requires there to be a current isolate.
87 */
88 DART_EXPORT bool Dart_IsValid(const Dart_Handle& handle);
89
90 /**
91 * Gets the error message from an invalid handle.
92 *
93 * Requires there to be a current isolate.
94 *
95 * \return A C string containing an error message if the handle is
96 * invalid. An empty C string ("") if the handle is valid. This C
97 * String is scope allocated and is only valid until the next call
98 * to Dart_ExitScope.
99 */
100 DART_EXPORT const char* Dart_GetError(const Dart_Handle& handle);
101
102 /**
103 * Produces an invalid handle with the provided error message.
104 *
105 * Requires there to be a current isolate.
106 *
107 * \param error A C string containing an error message.
108 */
109 DART_EXPORT Dart_Handle Dart_Error(const char* error);
110 // TODO(turnidge): Accept printf-style args here.
siva 2011/10/31 21:52:13 Should this go to dart_api_impl.h file as I have a
turnidge 2011/10/31 23:04:43 People who implement LibraryTagHandlers currently
111
112 /**
113 * Allocates a persistent handle for an object.
114 *
115 * This handle has the lifetime of the current isolate unless it is
116 * explicitly deallocated by calling Dart_DeletePersistentHandle.
117 *
118 * Requires there to be a current isolate.
119 */
120 DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object);
121
122 /**
123 * Deallocates a persistent handle.
124 *
125 * Requires there to be a current isolate.
126 */
127 DART_EXPORT void Dart_DeletePersistentHandle(Dart_Handle object);
128
129 /**
130 * Takes a persistent handle and makes it weak.
131 *
132 * UNIMPLEMENTED.
133 *
134 * Requires there to be a current isolate.
135 */
136 DART_EXPORT Dart_Handle Dart_MakeWeakPersistentHandle(Dart_Handle object);
137 // TODO(turnidge): Needs a "near death" callback here.
138 // TODO(turnidge): Add IsWeak, Clear, etc.
siva 2011/10/31 21:52:13 What would Clear be used for? Dart_ClearWeakPerisi
turnidge 2011/10/31 23:04:43 Just copying the v8 weak handle apis here. I figu
139
140 /**
141 * Takes a weak persistent handle and makes it non-weak.
142 *
143 * UNIMPLEMENTED.
144 *
145 * Requires there to be a current isolate.
146 */
147 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object);
148
149 // --- Initialization and Globals ---
150
151 /**
152 * An isolate initialization callback function.
153 *
154 * This callback, provided by the embedder, is called during isolate
155 * creation. It is called for all isolates, regardless of whether they
156 * are created via Dart_CreateIsolate or directly from Dart code.
157 *
158 * \param data Embedder-specific data used during isolate initialization.
159 *
160 * \return If the embedder returns NULL, then the isolate being
161 * initialized will be shut down without executing any Dart code.
162 * Otherwise, the embedder should return a pointer to
163 * embedder-specific data created during the initialization of this
164 * isolate. This data will, in turn, be passed by the VM to all
165 * isolates spawned from the isolate currently being initialized.
166 */
167 typedef void* (*Dart_IsolateInitCallback)(void* embedder_data);
168 // TODO(iposva): Pass a specification of the app file being spawned.
169 // TODO(turnidge): We don't actually shut down the isolate on NULL yet.
170 // TODO(turnidge): Should we separate the two return values?
siva 2011/10/31 21:52:13 I think some of this may change as we restructure
171
172 /**
173 * Initializes the VM with the given commmand line flags.
174 *
175 * \param argc The length of the arguments array.
176 * \param argv An array of arguments.
177 * \param callback A function to be called during isolate creation.
178 * See Dart_IsolateInitCallback.
179 *
180 * \return True if initialization is successful.
181 */
182 DART_EXPORT bool Dart_Initialize(int argc, char** argv,
183 Dart_IsolateInitCallback callback);
184
185 /**
186 * Returns true if the named VM flag is set.
187 */
188 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
189
190 // --- Isolates ---
191
192 /**
193 * An isolate is the unit of concurrency in Dart. Each isolate has
194 * its own memory and thread of control. No state is shared between
195 * isolates. Instead, isolates communicate by message passing.
196 *
197 * There is a notion of a current isolate, which is the isolate which
198 * is able to execute on the current thread. The current isolate may
199 * be NULL, in which case no isolate is ready to execute. Most of the
200 * Dart apis require there to be a current isolate in order to
201 * function properly.
202 */
45 typedef void* Dart_Isolate; 203 typedef void* Dart_Isolate;
46 typedef void* Dart_Handle; 204
205 /**
206 * A buffer containing a snapshot of the Dart VM. A snapshot can be
207 * used to restore the VM quickly to a saved state and is useful for
208 * fast startup.
209 */
210 typedef void Dart_Snapshot;
211
212 /**
213 * Creates a new isolate. If snapshot data is provided, the isolate
214 * will be started using that snapshot data. The new isolate becomes
215 * the current isolate.
216 *
217 * Requires there to be no current isolate.
218 *
219 * \param snapshot A buffer containing a VM snapshot or NULL if no
220 * snapshot is provided.
221 * \param data Embedder-specific data. See Dart_IsolateInitCallback.
222 *
223 * \return The new isolate is returned. May be NULL if an error
224 * occurs duing isolate initialization.
225 */
226 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot,
227 void* data);
228 // TODO(turnidge): Document behavior when there is already a current
229 // isolate.
230
231 /**
232 * Shuts down the current isolate. After this call, the current
233 * isolate is NULL.
234 *
235 * Requires there to be a current isolate.
236 */
237 DART_EXPORT void Dart_ShutdownIsolate();
238 // TODO(turnidge): Document behavior when there is no current isolate.
239
240 /**
241 * Returns the current isolate. Will return NULL if there is no
242 * current isolate.
243 */
244 DART_EXPORT Dart_Isolate Dart_CurrentIsolate();
245
246 /**
247 * Enters an isolate. After calling this function,
248 * the current isolate will be set to the provided isolate.
249 *
250 * Requires there to be no current isolate.
251 */
252 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate);
253
254 /**
255 * Exits an isolate. After this call, Dart_CurrentIsolate will
256 * return NULL.
257 *
258 * Requires there to be a current isolate.
259 */
260 DART_EXPORT void Dart_ExitIsolate();
261
262 /**
263 * Creates a snapshot of the state of the current isolate.
264 */
265 DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** snaphot_buffer,
266 intptr_t* snapshot_size);
267
268 // --- Messages and Ports ---
269
270 /**
271 * Messages are used to communicate between isolates.
272 */
273 typedef void* Dart_Message;
274
275 /**
276 * A port is used to send or receive inter-isolate messages
277 */
278 typedef int64_t Dart_Port;
279
280 const Dart_Port kNoReplyPort = 0;
281
282 /**
283 * A message posting callback.
284 *
285 * This callback allows the embedder to provide an alternate delivery
286 * mechanism for inter-isolate messages. It is the responsibility of
287 * the embedder to call Dart_HandleMessage to process the message.
288 *
289 * If there is no reply port, then the constant 'kNoReplyPort' is
290 * passed as the 'reply_port' parameter.
291 *
292 * The memory pointed to by 'message' has been allocated by malloc. It
293 * is the responsibility of the callback to ensure that free(message)
294 * is called once the message has been processed.
295 *
296 * The callback should return false if it runs into a problem
297 * processing this message.
298 */
299 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate,
300 Dart_Port dest_port,
301 Dart_Port reply_port,
302 Dart_Message message);
303 // TODO(turnidge): Add a Dart_ReleaseMessage to hide allocation details?
siva 2011/10/31 21:52:13 Sounds like a good idea.
turnidge 2011/10/31 23:04:43 Ok. Will do in another CL.
304
305 const Dart_Port kCloseAllPorts = 0;
306
307 /**
308 * A close port callback.
309 *
310 * This callback allows the embedder to receive notification when a
311 * port is closed. The constant 'kCloseAllPorts' is passed as the
312 * 'port' parameter when all active ports are being closed at once.
313 */
314 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate,
315 Dart_Port port);
316
317 /**
318 * Allows embedders to provide an alternative mechanism for sending
319 * inter-isolate messages. This setting only applies to the current
320 * isolate.
321 *
322 * Most embedders will only call this function once, before isolate
323 * execution begins. If this function is called after isolate
324 * execution begins, the embedder is responsible for threading issues.
325 */
326 DART_EXPORT void Dart_SetMessageCallbacks(
327 Dart_PostMessageCallback post_message_callback,
328 Dart_ClosePortCallback close_port_callback);
329 // TODO(turnidge): Consider moving this to isolate creation so that it
330 // is impossible to mess up.
331
332 /**
333 * Handles a message on the current isolate.
334 *
335 * Note that this function does not free the memory associated with
336 * 'dart_message'.
337 */
338 DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port,
339 Dart_Port reply_port,
340 Dart_Message dart_message);
341 // TODO(turnidge): Revisit memory management of 'dart_message'.
342
343 /**
344 * Processes any incoming messages for the current isolate.
345 *
346 * This function may only be used when the embedder has not provided
347 * an alternate message delivery mechanism with
348 * Dart_SetMessageCallbacks. It is provided for convenience.
349 *
350 * This function waits for incoming messages for the current
351 * isolate. As new messages arrive, they are handled using
352 * Dart_HandleMessage. The routine exits when all ports to the
353 * current isolate are closed.
354 */
355 DART_EXPORT Dart_Handle Dart_RunLoop();
356 // TODO(turnidge): Should this be removed from the public api?
357
358 /**
359 * Posts a message for some isolate. The message is built from a raw
360 * array.
361 *
362 * \param port The destination port.
363 * \param length The length of the data array.
364 * \param data A data array to be sent in the message.
365 *
366 * \return True if the message was posted.
367 */
368 DART_EXPORT bool Dart_PostIntArray(Dart_Port port,
369 intptr_t length,
370 intptr_t* data);
371 // TODO(turnidge): Should this be intptr_t or some fixed length type?
siva 2011/10/31 21:52:13 What do you mean by a fixed length type?
turnidge 2011/10/31 23:04:43 I mean something like int64_t.
372 // TODO(turnidge): Reverse length/data for consistency.
373
374 /**
375 * Posts a message for some isolate. The message is a serialized
376 * object.
377 *
378 * Requires there to be a current isolate.
379 *
380 * \param port The destination port.
381 * \param object An object from the current isolate.
382 *
383 * \return True if the message was posted.
384 */
385 DART_EXPORT bool Dart_Post(Dart_Port port, Dart_Handle object);
386
387 // --- Scopes ----
388
389 /**
390 * Enters a new scope.
391 *
392 * All new local handles will be created in this scope. Additionally,
393 * some functions may return "scope allocated" memory which is only
394 * valid within this scope.
395 *
396 * Requires there to be a current isolate.
397 */
398 DART_EXPORT void Dart_EnterScope();
399
400 /**
401 * Exits a scope.
402 *
403 * The previous scope (if any) becomes the current scope.
404 *
405 * Requires there to be a current isolate.
406 */
407 DART_EXPORT void Dart_ExitScope();
408
409 // --- Objects ----
410
411 /**
412 * Is this object null?
413 */
414 DART_EXPORT bool Dart_IsNull(Dart_Handle object);
415
416 /**
417 * Converts an object to a string.
418 *
419 * If an exception occurs during the conversion, this is treated as an
420 * error.
421 *
422 * \return A handle to the converted string if no errors occur during
423 * the conversion. If an error does occur, an invalid handle is
424 * returned.
425 */
426 DART_EXPORT Dart_Handle Dart_ObjectToString(Dart_Handle object);
427 // TODO(turnidge): Consider shortening name to Dart_ToString.
428
429 /**
430 * Returns true if the two objects are equal.
431 *
432 * The result of the comparison is returned through the 'equal'
433 * parameter. The return value itself is used to indicate success or
434 * failure, not equality.
435 *
436 * \param obj1 An object to be compared.
437 * \param obj2 An object to be compared.
438 * \param equal Returns the result of the equality comparison.
439 *
440 * \return A valid handle if no error occurs during the comparison.
441 */
442 DART_EXPORT Dart_Handle Dart_Objects_Equal(Dart_Handle obj1,
443 Dart_Handle obj2,
444 bool* equal);
445 // TODO(turnidge): Consider renaming for consistency. Maybe just
446 // Dart_Equals.
447 // TODO(turnidge): Need to add identity equality function.
448
449 /**
450 * Is this object an instance of some type?
451 *
452 * The result of the test is returned through the 'instanceif' parameter.
453 * The return value itself is used to indicate success or failure.
454 *
455 * \param object An object.
456 * \param type A type.
457 * \param instanceof Return true if 'object' is an instance of type 'type'.
458 *
459 * \return A valid handle if no error occurs during the operation.
460 */
461 DART_EXPORT Dart_Handle Dart_IsInstanceOf(Dart_Handle object,
462 Dart_Handle type,
463 bool* instanceof);
464
465 // --- Numbers ----
466
467 /**
468 * Is this object a Number?
469 */
470 DART_EXPORT bool Dart_IsNumber(Dart_Handle object);
471
472 // --- Integers ----
473
474 /**
475 * Is this object an Integer?
476 */
477 DART_EXPORT bool Dart_IsInteger(Dart_Handle object);
478
479 /**
480 * Does this Integer fit into a 64-bit signed integer?
481 *
482 * \param integer An integer.
483 * \param fits Returns true if the integer fits into a 64-bit signed integer.
484 *
485 * \return A valid handle if no error occurs during the operation.
486 */
487 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
488 bool* fits);
489
490 /**
491 * Returns an Integer with the provided value.
492 *
493 * \param value The value of the integer.
494 *
495 * \return The Integer object if no errors occurs. Otherwise returns
496 * an invalid handle.
497 */
498 DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value);
499
500 /**
501 * Returns an Integer with the provided value..
502 *
503 * \param value The value of the integer represented as a C string
504 * containing a hexadecimal number.
505 *
506 * \return The Integer object if no errors occurs. Otherwise returns
507 * an invalid handle.
508 */
509 DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* value);
510
511 /**
512 * Gets the value of an Integer.
513 *
514 * The integer must fit into a 64-bit signed integer, otherwise an error occurs.
515 *
516 * \param integer An Integer.
517 * \param value Returns the value of the Integer.
518 *
519 * \return A valid handle if no error occurs during the operation.
520 */
521 DART_EXPORT Dart_Handle Dart_IntegerValue(Dart_Handle integer, int64_t* value);
522
523 /**
524 * Gets the value of an integer as a hexadecimal C string.
525 *
526 * \param integer An Integer.
527 * \param value Returns the value of the Integer as a hexadecimal C
528 * string. This C string is scope allocated and is only valid until
529 * the next call to Dart_ExitScope.
530 *
531 * \return A valid handle if no error occurs during the operation.
532 */
533 DART_EXPORT Dart_Handle Dart_IntegerValueHexCString(Dart_Handle integer,
534 const char** value);
535
536 // --- Booleans ----
537
538 /**
539 * Is this object a Boolean?
540 */
541 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object);
542
543 /**
544 * Returns a Boolean with the provided value.
545 *
546 * \param value true or false.
547 *
548 * \return The Boolean object if no errors occurs. Otherwise returns
549 * an invalid handle.
550 */
551 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value);
552
553 /**
554 * Gets the value of a Boolean
555 *
556 * \param bool_object A Boolean
557 * \param value Returns the value of the Boolean.
558 *
559 * \return A valid handle if no error occurs during the operation.
560 */
561 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object, bool* value);
562
563 // --- Doubles ---
564
565 /**
566 * Is this object a Double?
567 */
568 DART_EXPORT bool Dart_IsDouble(Dart_Handle object);
569
570 /**
571 * Returns a Double with the provided value.
572 *
573 * \param value A double.
574 *
575 * \return The Double object if no errors occurs. Otherwise returns
576 * an invalid handle.
577 */
578 DART_EXPORT Dart_Handle Dart_NewDouble(double value);
579
580 /**
581 * Gets the value of a Double
582 *
583 * \param bool_object A Double
584 * \param value Returns the value of the Double.
585 *
586 * \return A valid handle if no error occurs during the operation.
587 */
588 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result);
589
590 // --- Strings ---
591
592 /**
593 * Is this object a String?
594 */
595 DART_EXPORT bool Dart_IsString(Dart_Handle object);
596
597 /**
598 * Is this object a String whose codepoints all fit into 8 bits?
599 */
600 DART_EXPORT bool Dart_IsString8(Dart_Handle object);
601
602 /**
603 * Is this object a String whose codepoints all fit into 16 bits?
604 */
605 DART_EXPORT bool Dart_IsString16(Dart_Handle object);
606
607 /**
608 * Gets the length of a String.
609 *
610 * \param str A String.
611 * \param length Returns the length of the String.
612 *
613 * \return A valid handle if no error occurs during the operation.
614 */
615 DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* length);
616
617 /**
618 * Returns a String built from the provided C string
619 *
620 * \param value A C String
621 *
622 * \return The String object if no errors occurs. Otherwise returns
623 * an invalid handle.
624 */
625 DART_EXPORT Dart_Handle Dart_NewString(const char* str);
626
627 /**
628 * Returns a String built from an array of 8-bit codepoints.
629 *
630 * \param value An array of 8-bit codepoints.
631 * \param length The length of the codepoints array.
632 *
633 * \return The String object if no errors occurs. Otherwise returns
634 * an invalid handle.
635 */
636 DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints,
637 intptr_t length);
638
639 /**
640 * Returns a String built from an array of 16-bit codepoints.
641 *
642 * \param value An array of 16-bit codepoints.
643 * \param length The length of the codepoints array.
644 *
645 * \return The String object if no errors occurs. Otherwise returns
646 * an invalid handle.
647 */
648 DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints,
649 intptr_t length);
650
651 /**
652 * Returns a String built from an array of 32-bit codepoints.
653 *
654 * \param value An array of 32-bit codepoints.
655 * \param length The length of the codepoints array.
656 *
657 * \return The String object if no errors occurs. Otherwise returns
658 * an invalid handle.
659 */
660 DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints,
661 intptr_t length);
662
663 /**
664 * Gets the codepoints from a String.
665 *
666 * This function is only valid on strings for which Dart_IsString8 is
667 * true. Otherwise an error occurs.
668 *
669 * \param str A string.
670 * \param codepoints An array allocated by the caller, used to return
671 * the array of codepoints.
672 * \param length Used to pass in the length of the provided array.
673 * Used to return the length of the array which was actually used.
674 *
675 * \return A valid handle if no error occurs during the operation.
676 */
677 DART_EXPORT Dart_Handle Dart_StringGet8(Dart_Handle str,
678 uint8_t* codepoints,
679 intptr_t* length);
680 // TODO(turnidge): Rename to GetString8 to be consistent with the Is*
681 // and New* functions above?
682
683 /**
684 * Gets the codepoints from a String.
685 *
686 * This function is only valid on strings for which Dart_IsString8 or
687 * Dart_IsString16 is true. Otherwise an error occurs.
688 *
689 * \param str A string.
690 * \param codepoints An array allocated by the caller, used to return
691 * the array of codepoints.
692 * \param length Used to pass in the length of the provided array.
693 * Used to return the length of the array which was actually used.
694 *
695 * \return A valid handle if no error occurs during the operation.
696 */
697 DART_EXPORT Dart_Handle Dart_StringGet16(Dart_Handle str,
698 uint16_t* codepoints,
699 intptr_t* length);
700
701 /**
702 * Gets the codepoints from a String
703 *
704 * \param str A string.
705 * \param codepoints An array allocated by the caller, used to return
706 * the array of codepoints.
707 * \param length Used to pass in the length of the provided array.
708 * Used to return the length of the array which was actually used.
709 *
710 * \return A valid handle if no error occurs during the operation.
711 */
712 DART_EXPORT Dart_Handle Dart_StringGet32(Dart_Handle str,
713 uint32_t* codepoints,
714 intptr_t* length);
715
716 /**
717 * Gets the utf8 encoded representation of a String.
718 *
719 * \param str A string.
720 * \param utf8 Returns the String represented as a utf8 encoded C
721 * string. This C string is scope allocated and is only valid until
722 * the next call to Dart_ExitScope.
723 *
724 * \return A valid handle if no error occurs during the operation.
725 */
726 DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str,
727 const char** utf8);
728
729 // --- Arrays ---
siva 2011/10/31 21:52:13 There was a proposal to rename Array to List in th
turnidge 2011/10/31 23:04:43 Yep. Saving up my incompatible changes for anothe
730
731 /**
732 * Is this object an Array?
733 */
734 DART_EXPORT bool Dart_IsArray(Dart_Handle object);
735 // TODO(turnidge): Rename Array -> List.
736
737 /**
738 * Returns an Array of the desired length.
739 *
740 * \param length The length of the array.
741 *
742 * \return The Array object if no errors occurs. Otherwise returns
743 * an invalid handle.
744 */
745 DART_EXPORT Dart_Handle Dart_NewArray(intptr_t length);
746 // TODO(turnidge): Rename Array -> List.
747
748 /**
749 * Gets the length of an Array.
750 *
751 * \param array An Array.
752 * \param length Returns the length of the Array.
753 *
754 * \return A valid handle if no error occurs during the operation.
755 */
756 DART_EXPORT Dart_Handle Dart_GetLength(Dart_Handle array, intptr_t* length);
757 // TODO(turnidge): Rename Array -> List.
758
759 /**
760 * Gets the Object at some index of an Array.
761 *
762 * If the index is out of bounds, an error occurs.
763 *
764 * \param array An Array.
765 * \param index A valid index into the Array.
766 *
767 * \return The Object in the Array at the specified index if no errors
768 * occurs. Otherwise returns an invalid handle.
769 */
770 DART_EXPORT Dart_Handle Dart_ArrayGetAt(Dart_Handle array,
771 intptr_t index);
772 // TODO(turnidge): Rename Array -> List.
773
774 /**
775 * Sets the Object at some index of an Array.
776 *
777 * If the index is out of bounds, an error occurs.
778 *
779 * \param array An Array.
780 * \param index A valid index into the Array.
781 * \param value The Object to put in the Array.
782 *
783 * \return A valid handle if no error occurs during the operation.
784 */
785 DART_EXPORT Dart_Handle Dart_ArraySetAt(Dart_Handle array,
786 intptr_t index,
787 Dart_Handle value);
788 // TODO(turnidge): Rename Array -> List.
789
790 // TODO(turnidge): Figure out what this is for.
791 DART_EXPORT Dart_Handle Dart_ArrayGet(Dart_Handle array,
792 intptr_t offset,
793 uint8_t* native_array,
794 intptr_t length);
795
796 // TODO(turnidge): Figure out what this is for.
797 DART_EXPORT Dart_Handle Dart_ArraySet(Dart_Handle array,
798 intptr_t offset,
799 uint8_t* native_array,
800 intptr_t length);
801
802 // --- Closures ---
803
804 /**
805 * Is this object a Closure?
806 */
807 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
808
809 /**
810 * Invokes a Closure with the given arguments.
811 *
812 * \return If no error occurs during execution, then the result of
813 * invoking the closure is returned. Note that this may be an
814 * uncaught exception (see Dart_ExceptionOccurred) or the null
815 * Object. If an error occurred during execution, then an invalid
816 * handle is returned.
817 */
818 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
819 int number_of_arguments,
820 Dart_Handle* arguments);
821
822 // DEPRECATED: The API below is a temporary hack.
823 DART_EXPORT int64_t Dart_ClosureSmrck(Dart_Handle object);
824
825 // DEPRECATED: The API below is a temporary hack.
826 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value);
827
828 // --- Methods and Fields ---
829
830 /**
831 * Invokes a static method with the given arguments.
832 *
833 * \return If no error occurs during execution, then the result of
834 * invoking the closure is returned. Note that this may be an
835 * uncaught exception (see Dart_ExceptionOccurred) or the null
836 * Object. If an error occurred during execution, then an invalid
837 * handle is returned.
838 */
839 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library,
840 Dart_Handle class_name,
841 Dart_Handle function_name,
842 int number_of_arguments,
843 Dart_Handle* arguments);
844
845 /**
846 * Invokes an instance method with the given arguments.
847 *
848 * \return If no error occurs during execution, then the result of
849 * invoking the closure is returned. Note that this may be an
850 * uncaught exception (see Dart_ExceptionOccurred) or the null
851 * Object. If an error occurred during execution, then an invalid
852 * handle is returned.
853 */
854 DART_EXPORT Dart_Handle Dart_InvokeDynamic(Dart_Handle receiver,
855 Dart_Handle function_name,
856 int number_of_arguments,
857 Dart_Handle* arguments);
858
859 /**
860 * Gets the value of a static field.
861 *
862 * \return If no error occurs, then the value of the field is
863 * returned. Otherwise an invalid handle is returned.
864 */
865 DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls, Dart_Handle name);
866
867 /**
868 * Sets the value of a static field.
869 *
870 * \return A valid handle if no error occurs.
871 */
872 DART_EXPORT Dart_Handle Dart_SetStaticField(Dart_Handle cls,
873 Dart_Handle name,
874 Dart_Handle value);
875 /**
876 * Gets the value of an instance field.
877 *
878 * \return If no error occurs, then the value of the field is
879 * returned. Otherwise an invalid handle is returned.
880 */
881 DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj,
882 Dart_Handle name);
883 /**
884 * Sets the value of an instance field.
885 *
886 * \return A valid handle if no error occurs.
887 */
888 DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj,
889 Dart_Handle name,
890 Dart_Handle value);
891
892 /**
893 * Creates a native wrapper class.
894 *
895 * TODO(turnidge): Document.
896 */
897 DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
898 Dart_Handle class_name,
899 int field_count);
900
901 /**
902 * Gets the value of a native field.
903 *
904 * TODO(turnidge): Document.
905 */
906 DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj,
907 int index,
908 intptr_t* value);
909 /**
910 * Sets the value of a native field.
911 *
912 * TODO(turnidge): Document.
913 */
914 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj,
915 int index,
916 intptr_t value);
917
918 // --- Exceptions ----
919
920 /**
921 * Does this handle hold information about an unhandled exception?
922 */
923 DART_EXPORT bool Dart_ExceptionOccurred(Dart_Handle handle);
924 // TODO(turnidge): Consider exposing the name of this thing. Maybe
925 // IsUnhandledException, IsUncaughtException, or IsThrownException.
926 // It is like a regular exception, but plus a stack trace.
927 // TODO(turnidge): Consider subsuming exception results into invalid
928 // handles so that only one error check needs to be done after method
929 // invocation.
930
931 /**
932 * Gets the exception Object from an unhandled exception.
933 */
934 DART_EXPORT Dart_Handle Dart_GetException(Dart_Handle result);
935
936 /**
937 * Gets the stack trace Object from an unhandled exception.
938 */
939 DART_EXPORT Dart_Handle Dart_GetStacktrace(Dart_Handle unhandled_exception);
940
941 /**
942 * Throws an exception.
943 *
944 * Throws an exception, unwinding all dart frames on the stack. If
945 * successful, this function does not return. If there are no Dart
946 * frames on the stack, an error occurs.
947 *
948 * \return An invalid handle if the exception was not thrown.
949 * Otherwise the function does not return.
950 */
951 DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception);
952
953 /**
954 * Rethrows an exception.
955 *
956 * Rethrows an exception, unwinding all dart frames on the stack. If
957 * successful, this function does not return. If there are no Dart
958 * frames on the stack, an error occurs.
959 *
960 * \return An invalid handle if the exception was not thrown.
961 * Otherwise the function does not return.
962 */
963 DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
964 Dart_Handle stacktrace);
965 // TODO(turnidge): ReThrow -> Rethrow.
966
967 // --- Native functions ---
968
969 /**
970 * The arguments to a native function.
971 *
972 * This object is passed to a native function to represent its
973 * arguments and return value. It allows access to the arguments to a
974 * native function by index. It also allows the return value of a
975 * native function to be set.
976 */
47 typedef void* Dart_NativeArguments; 977 typedef void* Dart_NativeArguments;
48 978
979 /**
980 * Gets the native argument at some index.
981 */
982 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
983 int index);
984 // TODO(turnidge): Specify the behavior of an out-of-bounds access.
985
986 /**
987 * Gets the number of native arguments.
988 */
989 DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args);
990
991 /**
992 * Sets the return value for a native function.
993 */
994 DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
995 Dart_Handle retval);
996
997 /**
998 * A native function.
999 */
1000 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments);
1001
1002 /**
1003 * Native entry resolution callback.
1004 *
1005 * For libraries which have native functions, the embedder can provide
1006 * a native entry resolver. This callback is used to map a name/arity
1007 * to a Dart_NativeFunction. If no function is found, the callback
1008 * should return NULL.
1009 *
1010 * See Dart_SetNativeResolver.
1011 */
1012 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name,
1013 int num_of_arguments);
1014 // TODO(turnidge): Consider renaming to NativeFunctionResolver or
1015 // NativeResolver.
1016
1017 // --- Scripts and Libraries ---
1018 // TODO(turnidge): Finish documenting this section.
1019
49 typedef enum { 1020 typedef enum {
50 kLibraryTag = 0, 1021 kLibraryTag = 0,
51 kImportTag, 1022 kImportTag,
52 kSourceTag, 1023 kSourceTag,
53 kCanonicalizeUrl, 1024 kCanonicalizeUrl,
54 } Dart_LibraryTag; 1025 } Dart_LibraryTag;
55 1026
56 typedef void Dart_Snapshot;
57
58 typedef int64_t Dart_Port;
59 typedef void* Dart_Message;
60
61 // Allow the embedder to intercept isolate creation. Both at startup
62 // and when spawning new isolates from Dart code. The result returned
63 // from this callback is handed to all isolates spawned from the
64 // isolate currently being initialized.
65 //
66 // Return NULL if an error is encountered. The isolate being
67 // initialized will be shutdown. No Dart code will execute before it
68 // is shutdown.
69 //
70 // TODO(iposva): Pass a specification of the app file being spawned.
71 typedef void* (*Dart_IsolateInitCallback)(void* data);
72
73 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments);
74 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name,
75 int num_of_arguments);
76 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, 1027 typedef Dart_Handle (*Dart_LibraryTagHandler)(Dart_LibraryTag tag,
77 Dart_Handle library, 1028 Dart_Handle library,
78 Dart_Handle url); 1029 Dart_Handle url);
79 1030
80 // TODO(iposva): This is a placeholder for the eventual external Dart API. 1031 /**
81 1032 * Loads the root script for the current isolate.
82 // Return value handling after a Dart API call. 1033 *
83 DART_EXPORT bool Dart_IsValid(const Dart_Handle& result); 1034 * TODO(turnidge): Document.
84 1035 */
85 DART_EXPORT const char* Dart_GetError(const Dart_Handle& result); 1036 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url,
86 DART_EXPORT Dart_Handle Dart_Error(const char* value); 1037 Dart_Handle source,
87 1038 Dart_LibraryTagHandler handler);
88 1039
89 // Initialize the VM with commmand line flags. 1040 /**
90 DART_EXPORT bool Dart_Initialize(int argc, char** argv, 1041 * Forces all loaded classes and functions to be compiled eagerly in
91 Dart_IsolateInitCallback callback); 1042 * the current isolate..
92 1043 *
93 1044 * TODO(turnidge): Document.
94 // Isolate handling. 1045 */
95 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, 1046 DART_EXPORT Dart_Handle Dart_CompileAll();
96 void* data); 1047
97 DART_EXPORT void Dart_ShutdownIsolate(); 1048 /**
98 1049 * Is this object a Library?
99 DART_EXPORT Dart_Isolate Dart_CurrentIsolate(); 1050 */
100 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate); 1051 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object);
101 DART_EXPORT void Dart_ExitIsolate(); 1052
102 1053 /**
103 // A convenience routine which processes any incoming messages for the 1054 * Lookup a class by name from a Library.
104 // current isolate. The routine exits when all ports to the current 1055 *
105 // isolate are closed. 1056 * \return If no errors occur, the Library is returned. Otherwise an
106 // 1057 * invalid handle is returned.
107 // This routine may only be used when the embedder has not provided an 1058 */
108 // alternate message delivery mechanism with Dart_SetPostMessageCallback.
109 DART_EXPORT Dart_Handle Dart_RunLoop();
110
111 // Messages/ports
112
113 // A post message callback allows the embedder to provide an alternate
114 // delivery mechanism for inter-isolate messages. It is the
115 // responsibility of the embedder to call Dart_HandleMessage to
116 // process the message.
117 //
118 // If there is no reply port, then the constant 'kNoReplyPort' is
119 // passed as the 'reply_port' parameter.
120 //
121 // The memory pointed to by 'message' has been allocated by malloc. It
122 // is the responsibility of the callback to ensure that free(message)
123 // is called once the message has been processed.
124 //
125 // The callback should return false if it runs into a problem
126 // processing this message.
127 //
128 // Todo(turnidge): Add a Dart_ReleaseMessage to hide allocation details?
129 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate,
130 Dart_Port dest_port,
131 Dart_Port reply_port,
132 Dart_Message message);
133 const Dart_Port kNoReplyPort = 0;
134
135 // A close port callback allows the embedder to receive notification
136 // when a port is closed. The constant 'kCloseAllPorts' is passed as
137 // the 'port' parameter when all active ports are being closed at
138 // once.
139 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate,
140 Dart_Port port);
141 const Dart_Port kCloseAllPorts = 0;
142
143 // Allows embedders to provide an alternative mechanism for sending
144 // inter-isolate messages. This setting only applies to the current
145 // isolate.
146 //
147 // Most embedders will only call this function once, before isolate
148 // execution begins. If this function is called after isolate
149 // execution begins, the embedder is responsible for threading issues.
150 //
151 // TODO(turnidge): Consider moving this to isolate creation so that it
152 // is impossible to mess up.
153 DART_EXPORT void Dart_SetMessageCallbacks(
154 Dart_PostMessageCallback post_message_callback,
155 Dart_ClosePortCallback close_port_callback);
156
157 // Handle a message on the current isolate.
158 DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port,
159 Dart_Port reply_port,
160 Dart_Message dart_message);
161
162
163 // Object.
164 DART_EXPORT Dart_Handle Dart_ObjectToString(Dart_Handle object);
165 DART_EXPORT bool Dart_IsNull(Dart_Handle object);
166
167
168 // Returns true if the two objects are equal.
169 DART_EXPORT Dart_Handle Dart_Objects_Equal(Dart_Handle obj1,
170 Dart_Handle obj2,
171 bool* value);
172
173
174 // Classes.
175 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name); 1059 DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle name);
176 DART_EXPORT Dart_Handle Dart_IsInstanceOf(Dart_Handle object, 1060
177 Dart_Handle cls, 1061 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url);
178 bool* value); 1062
179
180
181 // Number.
182 DART_EXPORT bool Dart_IsNumber(Dart_Handle object);
183
184
185 // Integer.
186 DART_EXPORT bool Dart_IsInteger(Dart_Handle object);
187 DART_EXPORT Dart_Handle Dart_NewInteger(int64_t value);
188 DART_EXPORT Dart_Handle Dart_NewIntegerFromHexCString(const char* value);
189 DART_EXPORT Dart_Handle Dart_IntegerValue(Dart_Handle integer, int64_t* value);
190 DART_EXPORT Dart_Handle Dart_IntegerValueHexCString(Dart_Handle integer,
191 const char** value);
192 DART_EXPORT Dart_Handle Dart_IntegerFitsIntoInt64(Dart_Handle integer,
193 bool* value);
194
195
196 // Boolean.
197 DART_EXPORT bool Dart_IsBoolean(Dart_Handle object);
198 DART_EXPORT Dart_Handle Dart_NewBoolean(bool value);
199 DART_EXPORT Dart_Handle Dart_BooleanValue(Dart_Handle bool_object, bool* value);
200
201
202 // Double.
203 DART_EXPORT bool Dart_IsDouble(Dart_Handle object);
204 DART_EXPORT Dart_Handle Dart_NewDouble(double value);
205 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle integer, double* result);
206
207
208 // String.
209 DART_EXPORT bool Dart_IsString(Dart_Handle object);
210
211 DART_EXPORT Dart_Handle Dart_StringLength(Dart_Handle str, intptr_t* len);
212
213 DART_EXPORT Dart_Handle Dart_NewString(const char* str);
214 DART_EXPORT Dart_Handle Dart_NewString8(const uint8_t* codepoints,
215 intptr_t length);
216 DART_EXPORT Dart_Handle Dart_NewString16(const uint16_t* codepoints,
217 intptr_t length);
218 DART_EXPORT Dart_Handle Dart_NewString32(const uint32_t* codepoints,
219 intptr_t length);
220
221 // The functions below test whether the object is a String and its codepoints
222 // all fit into 8 or 16 bits respectively.
223 DART_EXPORT bool Dart_IsString8(Dart_Handle object);
224 DART_EXPORT bool Dart_IsString16(Dart_Handle object);
225
226 DART_EXPORT Dart_Handle Dart_StringGet8(Dart_Handle str,
227 uint8_t* codepoints,
228 intptr_t* length);
229 DART_EXPORT Dart_Handle Dart_StringGet16(Dart_Handle str,
230 uint16_t* codepoints,
231 intptr_t* length);
232 DART_EXPORT Dart_Handle Dart_StringGet32(Dart_Handle str,
233 uint32_t* codepoints,
234 intptr_t* length);
235
236 DART_EXPORT Dart_Handle Dart_StringToCString(Dart_Handle str,
237 const char** result);
238
239
240 // Array.
241 DART_EXPORT bool Dart_IsArray(Dart_Handle object);
242 DART_EXPORT Dart_Handle Dart_NewArray(intptr_t length);
243 DART_EXPORT Dart_Handle Dart_GetLength(Dart_Handle array, intptr_t* len);
244 DART_EXPORT Dart_Handle Dart_ArrayGetAt(Dart_Handle array,
245 intptr_t index);
246 DART_EXPORT Dart_Handle Dart_ArrayGet(Dart_Handle array,
247 intptr_t offset,
248 uint8_t* native_array,
249 intptr_t length);
250 DART_EXPORT Dart_Handle Dart_ArraySetAt(Dart_Handle array,
251 intptr_t index,
252 Dart_Handle value);
253 DART_EXPORT Dart_Handle Dart_ArraySet(Dart_Handle array,
254 intptr_t offset,
255 uint8_t* native_array,
256 intptr_t length);
257
258 // Closure.
259 DART_EXPORT bool Dart_IsClosure(Dart_Handle object);
260 // DEPRECATED: The API below is a temporary hack.
261 DART_EXPORT int64_t Dart_ClosureSmrck(Dart_Handle object);
262 DART_EXPORT void Dart_ClosureSetSmrck(Dart_Handle object, int64_t value);
263
264
265 // Invocation of methods.
266 DART_EXPORT Dart_Handle Dart_InvokeStatic(Dart_Handle library,
267 Dart_Handle class_name,
268 Dart_Handle function_name,
269 int number_of_arguments,
270 Dart_Handle* arguments);
271 DART_EXPORT Dart_Handle Dart_InvokeDynamic(Dart_Handle receiver,
272 Dart_Handle function_name,
273 int number_of_arguments,
274 Dart_Handle* arguments);
275 DART_EXPORT Dart_Handle Dart_InvokeClosure(Dart_Handle closure,
276 int number_of_arguments,
277 Dart_Handle* arguments);
278
279
280 // Interaction with native methods.
281 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
282 int index);
283 DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args);
284 DART_EXPORT void Dart_SetReturnValue(Dart_NativeArguments args,
285 Dart_Handle retval);
286
287 // Library.
288 DART_EXPORT bool Dart_IsLibrary(Dart_Handle object);
289 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library); 1063 DART_EXPORT Dart_Handle Dart_LibraryUrl(Dart_Handle library);
290 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library, 1064 DART_EXPORT Dart_Handle Dart_LibraryImportLibrary(Dart_Handle library,
291 Dart_Handle import); 1065 Dart_Handle import);
292 1066
293 DART_EXPORT Dart_Handle Dart_LookupLibrary(Dart_Handle url);
294
295 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, 1067 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
296 Dart_Handle source); 1068 Dart_Handle source);
297 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library, 1069 DART_EXPORT Dart_Handle Dart_LoadSource(Dart_Handle library,
298 Dart_Handle url, 1070 Dart_Handle url,
299 Dart_Handle source); 1071 Dart_Handle source);
1072
1073 /**
1074 * Sets the callback used to resolve native functions for a library.
1075 *
1076 * \param library A library.
1077 * \param resolver A native entry resolver.
1078 *
1079 * \return A valid handle if the native resolver was set successfully.
1080 */
300 DART_EXPORT Dart_Handle Dart_SetNativeResolver( 1081 DART_EXPORT Dart_Handle Dart_SetNativeResolver(
301 Dart_Handle library, 1082 Dart_Handle library,
302 Dart_NativeEntryResolver resolver); 1083 Dart_NativeEntryResolver resolver);
303 1084
304 1085 // --- Profiling support ----
305 // Script handling. 1086
306 DART_EXPORT Dart_Handle Dart_LoadScript(Dart_Handle url, 1087 // External pprof support for gathering and dumping symbolic
307 Dart_Handle source, 1088 // information that can be used for better profile reports for
308 Dart_LibraryTagHandler handler); 1089 // dynamically generated code.
309
310 // Compile all loaded classes and functions eagerly.
311 DART_EXPORT Dart_Handle Dart_CompileAll();
312
313 // Exception related.
314 DART_EXPORT bool Dart_ExceptionOccurred(Dart_Handle result);
315 DART_EXPORT Dart_Handle Dart_GetException(Dart_Handle result);
316 DART_EXPORT Dart_Handle Dart_GetStacktrace(Dart_Handle unhandled_exception);
317 DART_EXPORT Dart_Handle Dart_ThrowException(Dart_Handle exception);
318 DART_EXPORT Dart_Handle Dart_ReThrowException(Dart_Handle exception,
319 Dart_Handle stacktrace);
320
321 // Global Handles and Scope for local handles and zone based memory allocation.
322 DART_EXPORT void Dart_EnterScope();
323 DART_EXPORT void Dart_ExitScope();
324
325 DART_EXPORT Dart_Handle Dart_NewPersistentHandle(Dart_Handle object);
326 DART_EXPORT Dart_Handle Dart_MakeWeakPersistentHandle(Dart_Handle object);
327 DART_EXPORT Dart_Handle Dart_MakePersistentHandle(Dart_Handle object);
328 DART_EXPORT void Dart_DeletePersistentHandle(Dart_Handle object);
329
330 // Fields.
331 DART_EXPORT Dart_Handle Dart_GetStaticField(Dart_Handle cls, Dart_Handle name);
332 DART_EXPORT Dart_Handle Dart_SetStaticField(Dart_Handle cls,
333 Dart_Handle name,
334 Dart_Handle value);
335 DART_EXPORT Dart_Handle Dart_GetInstanceField(Dart_Handle obj,
336 Dart_Handle name);
337 DART_EXPORT Dart_Handle Dart_SetInstanceField(Dart_Handle obj,
338 Dart_Handle name,
339 Dart_Handle value);
340
341 // Native fields.
342 DART_EXPORT Dart_Handle Dart_CreateNativeWrapperClass(Dart_Handle library,
343 Dart_Handle class_name,
344 int field_count);
345 DART_EXPORT Dart_Handle Dart_GetNativeInstanceField(Dart_Handle obj,
346 int index,
347 intptr_t* value);
348 DART_EXPORT Dart_Handle Dart_SetNativeInstanceField(Dart_Handle obj,
349 int index,
350 intptr_t value);
351
352 // Snapshot creation.
353 DART_EXPORT Dart_Handle Dart_CreateSnapshot(uint8_t** snaphot_buffer,
354 intptr_t* snapshot_size);
355
356 // Message communication.
357 DART_EXPORT bool Dart_PostIntArray(Dart_Port port,
358 int field_count,
359 intptr_t* data);
360
361 DART_EXPORT bool Dart_Post(Dart_Port port, Dart_Handle value);
362
363 // External pprof support for gathering and dumping symbolic information
364 // that can be used for better profile reports for dynamically generated
365 // code.
366 DART_EXPORT void Dart_InitPprofSupport(); 1090 DART_EXPORT void Dart_InitPprofSupport();
367 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 1091 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
368 1092
369 // Check set vm flags.
370 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
371
372 #endif // INCLUDE_DART_API_H_ 1093 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698