| OLD | NEW |
| 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 | 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 * passed as the 'reply_port' parameter. | 375 * passed as the 'reply_port' parameter. |
| 376 * | 376 * |
| 377 * The memory pointed to by 'message' has been allocated by malloc. It | 377 * The memory pointed to by 'message' has been allocated by malloc. It |
| 378 * is the responsibility of the callback to ensure that free(message) | 378 * is the responsibility of the callback to ensure that free(message) |
| 379 * is called once the message has been processed. | 379 * is called once the message has been processed. |
| 380 * | 380 * |
| 381 * The callback should return false if it runs into a problem | 381 * The callback should return false if it runs into a problem |
| 382 * processing this message. | 382 * processing this message. |
| 383 */ | 383 */ |
| 384 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate, | 384 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate, |
| 385 Dart_Port dest_port, | 385 Dart_Port dest_port_id, |
| 386 Dart_Port reply_port, | 386 Dart_Port reply_port_id, |
| 387 Dart_Message message); | 387 Dart_Message message); |
| 388 // TODO(turnidge): Add a Dart_ReleaseMessage to hide allocation details. | 388 // TODO(turnidge): Add a Dart_ReleaseMessage to hide allocation details. |
| 389 | 389 |
| 390 const Dart_Port kCloseAllPorts = 0; | 390 const Dart_Port kCloseAllPorts = 0; |
| 391 | 391 |
| 392 /** | 392 /** |
| 393 * A close port callback. | 393 * A close port callback. |
| 394 * | 394 * |
| 395 * This callback allows the embedder to receive notification when a | 395 * This callback allows the embedder to receive notification when a |
| 396 * port is closed. The constant 'kCloseAllPorts' is passed as the | 396 * port is closed. The constant 'kCloseAllPorts' is passed as the |
| 397 * 'port' parameter when all active ports are being closed at once. | 397 * 'port' parameter when all active ports are being closed at once. |
| 398 */ | 398 */ |
| 399 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate, | 399 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate, |
| 400 Dart_Port port); | 400 Dart_Port port_id); |
| 401 | 401 |
| 402 /** | 402 /** |
| 403 * Allows embedders to provide an alternative mechanism for sending | 403 * Allows embedders to provide an alternative mechanism for sending |
| 404 * inter-isolate messages. This setting only applies to the current | 404 * inter-isolate messages. This setting only applies to the current |
| 405 * isolate. | 405 * isolate. |
| 406 * | 406 * |
| 407 * Most embedders will only call this function once, before isolate | 407 * Most embedders will only call this function once, before isolate |
| 408 * execution begins. If this function is called after isolate | 408 * execution begins. If this function is called after isolate |
| 409 * execution begins, the embedder is responsible for threading issues. | 409 * execution begins, the embedder is responsible for threading issues. |
| 410 */ | 410 */ |
| 411 DART_EXPORT void Dart_SetMessageCallbacks( | 411 DART_EXPORT void Dart_SetMessageCallbacks( |
| 412 Dart_PostMessageCallback post_message_callback, | 412 Dart_PostMessageCallback post_message_callback, |
| 413 Dart_ClosePortCallback close_port_callback); | 413 Dart_ClosePortCallback close_port_callback); |
| 414 // TODO(turnidge): Consider moving this to isolate creation so that it | 414 // TODO(turnidge): Consider moving this to isolate creation so that it |
| 415 // is impossible to mess up. | 415 // is impossible to mess up. |
| 416 | 416 |
| 417 /** | 417 /** |
| 418 * Handles a message on the current isolate. | 418 * Handles a message on the current isolate. |
| 419 * | 419 * |
| 420 * May generate an unhandled exception error. | 420 * May generate an unhandled exception error. |
| 421 * | 421 * |
| 422 * Note that this function does not free the memory associated with | 422 * Note that this function does not free the memory associated with |
| 423 * 'dart_message'. | 423 * 'dart_message'. |
| 424 * | 424 * |
| 425 * \return A valid handle if no error occurs during the operation. | 425 * \return A valid handle if no error occurs during the operation. |
| 426 */ | 426 */ |
| 427 DART_EXPORT Dart_Handle Dart_HandleMessage(Dart_Port dest_port, | 427 DART_EXPORT Dart_Handle Dart_HandleMessage(Dart_Port dest_port_id, |
| 428 Dart_Port reply_port, | 428 Dart_Port reply_port_id, |
| 429 Dart_Message dart_message); | 429 Dart_Message dart_message); |
| 430 // TODO(turnidge): Revisit memory management of 'dart_message'. | 430 // TODO(turnidge): Revisit memory management of 'dart_message'. |
| 431 | 431 |
| 432 /** | 432 /** |
| 433 * Processes any incoming messages for the current isolate. | 433 * Processes any incoming messages for the current isolate. |
| 434 * | 434 * |
| 435 * This function may only be used when the embedder has not provided | 435 * This function may only be used when the embedder has not provided |
| 436 * an alternate message delivery mechanism with | 436 * an alternate message delivery mechanism with |
| 437 * Dart_SetMessageCallbacks. It is provided for convenience. | 437 * Dart_SetMessageCallbacks. It is provided for convenience. |
| 438 * | 438 * |
| 439 * This function waits for incoming messages for the current | 439 * This function waits for incoming messages for the current |
| 440 * isolate. As new messages arrive, they are handled using | 440 * isolate. As new messages arrive, they are handled using |
| 441 * Dart_HandleMessage. The routine exits when all ports to the | 441 * Dart_HandleMessage. The routine exits when all ports to the |
| 442 * current isolate are closed. | 442 * current isolate are closed. |
| 443 */ | 443 */ |
| 444 DART_EXPORT Dart_Handle Dart_RunLoop(); | 444 DART_EXPORT Dart_Handle Dart_RunLoop(); |
| 445 // TODO(turnidge): Should this be removed from the public api? | 445 // TODO(turnidge): Should this be removed from the public api? |
| 446 | 446 |
| 447 /** | 447 /** |
| 448 * Gets the main port id for the current isolate. |
| 449 */ |
| 450 DART_EXPORT Dart_Port Dart_GetMainPortId(); |
| 451 |
| 452 /** |
| 453 * Does the current isolate have live ReceivePorts? |
| 454 * |
| 455 * A ReceivePort is live when it has not been closed. |
| 456 */ |
| 457 DART_EXPORT bool Dart_HasLivePorts(); |
| 458 |
| 459 /** |
| 448 * Posts a message for some isolate. The message is built from a raw | 460 * Posts a message for some isolate. The message is built from a raw |
| 449 * array. | 461 * array. |
| 450 * | 462 * |
| 451 * \param port The destination port. | 463 * \param port The destination port. |
| 452 * \param length The length of the data array. | 464 * \param length The length of the data array. |
| 453 * \param data A data array to be sent in the message. | 465 * \param data A data array to be sent in the message. |
| 454 * | 466 * |
| 455 * \return True if the message was posted. | 467 * \return True if the message was posted. |
| 456 */ | 468 */ |
| 457 DART_EXPORT bool Dart_PostIntArray(Dart_Port port, | 469 DART_EXPORT bool Dart_PostIntArray(Dart_Port port_id, |
| 458 intptr_t length, | 470 intptr_t length, |
| 459 intptr_t* data); | 471 intptr_t* data); |
| 460 // TODO(turnidge): Should this be intptr_t or some fixed length type? | 472 // TODO(turnidge): Should this be intptr_t or some fixed length type? |
| 461 // TODO(turnidge): Reverse length/data for consistency. | 473 // TODO(turnidge): Reverse length/data for consistency. |
| 462 | 474 |
| 463 /** | 475 /** |
| 464 * Posts a message for some isolate. The message is a serialized | 476 * Posts a message for some isolate. The message is a serialized |
| 465 * object. | 477 * object. |
| 466 * | 478 * |
| 467 * Requires there to be a current isolate. | 479 * Requires there to be a current isolate. |
| 468 * | 480 * |
| 469 * \param port The destination port. | 481 * \param port The destination port. |
| 470 * \param object An object from the current isolate. | 482 * \param object An object from the current isolate. |
| 471 * | 483 * |
| 472 * \return True if the message was posted. | 484 * \return True if the message was posted. |
| 473 */ | 485 */ |
| 474 DART_EXPORT bool Dart_Post(Dart_Port port, Dart_Handle object); | 486 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); |
| 487 |
| 488 /** |
| 489 * Returns a new SendPort with the provided port id. |
| 490 */ |
| 491 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); |
| 492 |
| 493 /** |
| 494 * Gets the ReceivePort for the provided port id, creating it if necessary. |
| 495 * |
| 496 * Note that there is at most one ReceivePort for a given port id. |
| 497 */ |
| 498 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id); |
| 475 | 499 |
| 476 // --- Scopes ---- | 500 // --- Scopes ---- |
| 477 | 501 |
| 478 /** | 502 /** |
| 479 * Enters a new scope. | 503 * Enters a new scope. |
| 480 * | 504 * |
| 481 * All new local handles will be created in this scope. Additionally, | 505 * All new local handles will be created in this scope. Additionally, |
| 482 * some functions may return "scope allocated" memory which is only | 506 * some functions may return "scope allocated" memory which is only |
| 483 * valid within this scope. | 507 * valid within this scope. |
| 484 * | 508 * |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 | 1228 |
| 1205 // --- Profiling support ---- | 1229 // --- Profiling support ---- |
| 1206 | 1230 |
| 1207 // External pprof support for gathering and dumping symbolic | 1231 // External pprof support for gathering and dumping symbolic |
| 1208 // information that can be used for better profile reports for | 1232 // information that can be used for better profile reports for |
| 1209 // dynamically generated code. | 1233 // dynamically generated code. |
| 1210 DART_EXPORT void Dart_InitPprofSupport(); | 1234 DART_EXPORT void Dart_InitPprofSupport(); |
| 1211 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); | 1235 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
| 1212 | 1236 |
| 1213 #endif // INCLUDE_DART_API_H_ | 1237 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |