| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 * for details. All rights reserved. Use of this source code is governed by a | 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. | 4 * BSD-style license that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #ifndef INCLUDE_DART_API_H_ | 7 #ifndef INCLUDE_DART_API_H_ |
| 8 #define INCLUDE_DART_API_H_ | 8 #define INCLUDE_DART_API_H_ |
| 9 | 9 |
| 10 /** \mainpage Dart Embedding API Reference | 10 /** \mainpage Dart Embedding API Reference |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 * The type Dart_Handle represents a handle (both local and persistent). | 202 * The type Dart_Handle represents a handle (both local and persistent). |
| 203 * The type Dart_PersistentHandle is a Dart_Handle and it is used to | 203 * The type Dart_PersistentHandle is a Dart_Handle and it is used to |
| 204 * document that a persistent handle is expected as a parameter to a call | 204 * document that a persistent handle is expected as a parameter to a call |
| 205 * or the return value from a call is a persistent handle. | 205 * or the return value from a call is a persistent handle. |
| 206 */ | 206 */ |
| 207 typedef struct _Dart_Handle* Dart_Handle; | 207 typedef struct _Dart_Handle* Dart_Handle; |
| 208 typedef Dart_Handle Dart_PersistentHandle; | 208 typedef Dart_Handle Dart_PersistentHandle; |
| 209 typedef struct _Dart_WeakPersistentHandle* Dart_WeakPersistentHandle; | 209 typedef struct _Dart_WeakPersistentHandle* Dart_WeakPersistentHandle; |
| 210 | 210 |
| 211 typedef void (*Dart_WeakPersistentHandleFinalizer)( | 211 typedef void (*Dart_WeakPersistentHandleFinalizer)( |
| 212 Dart_Isolate isolate, | 212 void* isolate_callback_data, |
| 213 Dart_WeakPersistentHandle handle, | 213 Dart_WeakPersistentHandle handle, |
| 214 void* peer); | 214 void* peer); |
| 215 typedef void (*Dart_PeerFinalizer)(void* peer); | 215 typedef void (*Dart_PeerFinalizer)(void* peer); |
| 216 | 216 |
| 217 /** | 217 /** |
| 218 * Is this an error handle? | 218 * Is this an error handle? |
| 219 * | 219 * |
| 220 * Requires there to be a current isolate. | 220 * Requires there to be a current isolate. |
| 221 */ | 221 */ |
| 222 DART_EXPORT bool Dart_IsError(Dart_Handle handle); | 222 DART_EXPORT bool Dart_IsError(Dart_Handle handle); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 /** | 428 /** |
| 429 * Deallocates a persistent handle. | 429 * Deallocates a persistent handle. |
| 430 * | 430 * |
| 431 * Requires there to be a current isolate. | 431 * Requires there to be a current isolate. |
| 432 */ | 432 */ |
| 433 DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object); | 433 DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object); |
| 434 | 434 |
| 435 /** | 435 /** |
| 436 * Allocates a weak persistent handle for an object. | 436 * Allocates a weak persistent handle for an object. |
| 437 * | 437 * |
| 438 * This handle has the lifetime of the current isolate unless it is | 438 * This handle has the lifetime of the current isolate unless the object |
| 439 * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle. | 439 * pointed to by the handle is garbage collected, in this case the VM |
| 440 * automatically deletes the handle after invoking the callback associated |
| 441 * with the handle. The handle can also be explicitly deallocated by |
| 442 * calling Dart_DeleteWeakPersistentHandle. |
| 440 * | 443 * |
| 441 * If the object becomes unreachable the callback is invoked with the weak | 444 * If the object becomes unreachable the callback is invoked with the weak |
| 442 * persistent handle and the peer as arguments. This gives the native code the | 445 * persistent handle and the peer as arguments. This gives the native code the |
| 443 * ability to cleanup data associated with the object and to delete the weak | 446 * ability to cleanup data associated with the object and clear out any cached |
| 444 * persistent handle. It is illegal to call into the VM from the callback, | 447 * references to the handle. All references to this handle after the callback |
| 445 * except to delete the weak persistent handle. If the handle is deleted before | 448 * will be invalid. It is illegal to call into the VM from the callback. |
| 446 * the object becomes unreachable, the callback is never invoked. | 449 * If the handle is deleted before the object becomes unreachable, |
| 450 * the callback is never invoked. |
| 447 * | 451 * |
| 448 * Requires there to be a current isolate. | 452 * Requires there to be a current isolate. |
| 449 * | 453 * |
| 450 * \param object An object. | 454 * \param object An object. |
| 451 * \param peer A pointer to a native object or NULL. This value is | 455 * \param peer A pointer to a native object or NULL. This value is |
| 452 * provided to callback when it is invoked. | 456 * provided to callback when it is invoked. |
| 453 * \param external_allocation_size The number of externally allocated | 457 * \param external_allocation_size The number of externally allocated |
| 454 * bytes for peer. Used to inform the garbage collector. | 458 * bytes for peer. Used to inform the garbage collector. |
| 455 * \param callback A function pointer that will be invoked sometime | 459 * \param callback A function pointer that will be invoked sometime |
| 456 * after the object is garbage collected, unless the handle has been deleted. | 460 * after the object is garbage collected, unless the handle has been deleted. |
| 461 * A valid callback needs to be specified it cannot be NULL. |
| 457 * | 462 * |
| 458 * \return Success if the weak persistent handle was | 463 * \return Success if the weak persistent handle was |
| 459 * created. Otherwise, returns an error. | 464 * created. Otherwise, returns an error. |
| 460 */ | 465 */ |
| 461 DART_EXPORT Dart_WeakPersistentHandle Dart_NewWeakPersistentHandle( | 466 DART_EXPORT Dart_WeakPersistentHandle Dart_NewWeakPersistentHandle( |
| 462 Dart_Handle object, | 467 Dart_Handle object, |
| 463 void* peer, | 468 void* peer, |
| 464 intptr_t external_allocation_size, | 469 intptr_t external_allocation_size, |
| 465 Dart_WeakPersistentHandleFinalizer callback); | 470 Dart_WeakPersistentHandleFinalizer callback); |
| 466 | 471 |
| 467 DART_EXPORT void Dart_DeleteWeakPersistentHandle( | 472 DART_EXPORT void Dart_DeleteWeakPersistentHandle( |
| 468 Dart_Isolate isolate, | 473 Dart_Isolate isolate, |
| 469 Dart_WeakPersistentHandle object); | 474 Dart_WeakPersistentHandle object); |
| 470 | 475 |
| 471 /** | 476 /** |
| 472 * Allocates a prologue weak persistent handle for an object. | 477 * Allocates a prologue weak persistent handle for an object. |
| 473 * | 478 * |
| 474 * Prologue weak persistent handles are similar to weak persistent | 479 * Prologue weak persistent handles are similar to weak persistent |
| 475 * handles but exhibit different behavior during garbage collections | 480 * handles but exhibit different behavior during garbage collections |
| 476 * that invoke the prologue and epilogue callbacks. While weak | 481 * that invoke the prologue and epilogue callbacks. While weak |
| 477 * persistent handles always weakly reference their referents, | 482 * persistent handles always weakly reference their referents, |
| 478 * prologue weak persistent handles weakly reference their referents | 483 * prologue weak persistent handles weakly reference their referents |
| 479 * only during a garbage collection that invokes the prologue and | 484 * only during a garbage collection that invokes the prologue and |
| 480 * epilogue callbacks. During all other garbage collections, prologue | 485 * epilogue callbacks. During all other garbage collections, prologue |
| 481 * weak persistent handles strongly reference their referents. | 486 * weak persistent handles strongly reference their referents. |
| 482 * | 487 * |
| 483 * This handle has the lifetime of the current isolate unless it is | 488 * This handle has the lifetime of the current isolate unless the object |
| 484 * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle. | 489 * pointed to by the handle is garbage collected, in this case the VM |
| 490 * automatically deletes the handle after invoking the callback associated |
| 491 * with the handle. The handle can also be explicitly deallocated by |
| 492 * calling Dart_DeleteWeakPersistentHandle. |
| 493 * |
| 494 * If the object becomes unreachable the callback is invoked with the weak |
| 495 * persistent handle and the peer as arguments. This gives the native code the |
| 496 * ability to cleanup data associated with the object and clear out any cached |
| 497 * references to the handle. All references to this handle after the callback |
| 498 * will be invalid. It is illegal to call into the VM from the callback. |
| 499 * If the handle is deleted before the object becomes unreachable, |
| 500 * the callback is never invoked. |
| 485 * | 501 * |
| 486 * Requires there to be a current isolate. | 502 * Requires there to be a current isolate. |
| 487 * | 503 * |
| 488 * \param object An object. | 504 * \param object An object. |
| 489 * \param peer A pointer to a native object or NULL. This value is | 505 * \param peer A pointer to a native object or NULL. This value is |
| 490 * provided to callback when it is invoked. | 506 * provided to callback when it is invoked. |
| 491 * \param external_allocation_size The number of externally allocated | 507 * \param external_allocation_size The number of externally allocated |
| 492 * bytes for peer. Used to inform the garbage collector. | 508 * bytes for peer. Used to inform the garbage collector. |
| 493 * \param callback A function pointer that will be invoked sometime | 509 * \param callback A function pointer that will be invoked sometime |
| 494 * after the object is garbage collected, unless the handle has been deleted. | 510 * after the object is garbage collected, unless the handle has been deleted. |
| 511 * A valid callback needs to be specified it cannot be NULL. |
| 495 * | 512 * |
| 496 * \return Success if the prologue weak persistent handle was created. | 513 * \return Success if the prologue weak persistent handle was created. |
| 497 * Otherwise, returns an error. | 514 * Otherwise, returns an error. |
| 498 */ | 515 */ |
| 499 DART_EXPORT Dart_WeakPersistentHandle Dart_NewPrologueWeakPersistentHandle( | 516 DART_EXPORT Dart_WeakPersistentHandle Dart_NewPrologueWeakPersistentHandle( |
| 500 Dart_Handle object, | 517 Dart_Handle object, |
| 501 void* peer, | 518 void* peer, |
| 502 intptr_t external_allocation_size, | 519 intptr_t external_allocation_size, |
| 503 Dart_WeakPersistentHandleFinalizer callback); | 520 Dart_WeakPersistentHandleFinalizer callback); |
| 504 | 521 |
| (...skipping 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2519 * NOTE: If multiple callbacks with the same name are registered, only the | 2536 * NOTE: If multiple callbacks with the same name are registered, only the |
| 2520 * last callback registered will be remembered. | 2537 * last callback registered will be remembered. |
| 2521 */ | 2538 */ |
| 2522 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 2539 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 2523 const char* name, | 2540 const char* name, |
| 2524 Dart_ServiceRequestCallback callback, | 2541 Dart_ServiceRequestCallback callback, |
| 2525 void* user_data); | 2542 void* user_data); |
| 2526 | 2543 |
| 2527 | 2544 |
| 2528 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 2545 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
| OLD | NEW |