| OLD | NEW |
| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate); | 422 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate); |
| 423 | 423 |
| 424 // --- Messages and Ports --- | 424 // --- Messages and Ports --- |
| 425 | 425 |
| 426 /** | 426 /** |
| 427 * A port is used to send or receive inter-isolate messages | 427 * A port is used to send or receive inter-isolate messages |
| 428 */ | 428 */ |
| 429 typedef int64_t Dart_Port; | 429 typedef int64_t Dart_Port; |
| 430 | 430 |
| 431 /** | 431 /** |
| 432 * kIllegalPort is a port number guaranteed never to be associated |
| 433 * with a valid port. |
| 434 */ |
| 435 const Dart_Port kIllegalPort = 0; |
| 436 |
| 437 /** |
| 432 * A message notification callback. | 438 * A message notification callback. |
| 433 * | 439 * |
| 434 * This callback allows the embedder to provide an alternate wakeup | 440 * This callback allows the embedder to provide an alternate wakeup |
| 435 * mechanism for the delivery of inter-isolate messages. It is the | 441 * mechanism for the delivery of inter-isolate messages. It is the |
| 436 * responsibility of the embedder to call Dart_HandleMessage to | 442 * responsibility of the embedder to call Dart_HandleMessage to |
| 437 * process the message. | 443 * process the message. |
| 438 */ | 444 */ |
| 439 typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate dest_isolate); | 445 typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate dest_isolate); |
| 440 | 446 |
| 441 /** | 447 /** |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 * Requires there to be a current isolate. | 521 * Requires there to be a current isolate. |
| 516 * | 522 * |
| 517 * \param port The destination port. | 523 * \param port The destination port. |
| 518 * \param object An object from the current isolate. | 524 * \param object An object from the current isolate. |
| 519 * | 525 * |
| 520 * \return True if the message was posted. | 526 * \return True if the message was posted. |
| 521 */ | 527 */ |
| 522 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); | 528 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); |
| 523 | 529 |
| 524 /** | 530 /** |
| 531 * A native message handler. |
| 532 * |
| 533 * This handler is associated with a native port by calling |
| 534 * Dart_NewNativePort. |
| 535 */ |
| 536 typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id, |
| 537 Dart_Port reply_port_id, |
| 538 uint8_t* data); |
| 539 // TODO(turnidge): Make this function take more appropriate arguments. |
| 540 |
| 541 /** |
| 542 * Creates a new native port. When messages are received on this |
| 543 * native port, then they will be dispatched to the provided native |
| 544 * message handler. |
| 545 * |
| 546 * \param name The name of this port in debugging messages. |
| 547 * \param handler The C handler to run when messages arrive on the port. |
| 548 * \param handle_concurrently Is it okay to process requests on this |
| 549 * native port concurrently? |
| 550 * |
| 551 * \return If successful, returns the port id for the native port. In |
| 552 * case of error, returns kIllegalPort. |
| 553 */ |
| 554 DART_EXPORT Dart_Port Dart_NewNativePort(const char* name, |
| 555 Dart_NativeMessageHandler handler, |
| 556 bool handle_concurrently); |
| 557 // TODO(turnidge): Currently handle_concurrently is ignored. |
| 558 |
| 559 /** |
| 560 * Closes the native port with the given id. |
| 561 * |
| 562 * The port must have been allocated by a call to Dart_NewNativePort. |
| 563 * |
| 564 * \param native_port_id The id of the native port to close. |
| 565 * |
| 566 * \return Returns true if the port was closed successfully. |
| 567 */ |
| 568 DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id); |
| 569 |
| 570 /** |
| 525 * Returns a new SendPort with the provided port id. | 571 * Returns a new SendPort with the provided port id. |
| 526 */ | 572 */ |
| 527 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); | 573 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); |
| 528 | 574 |
| 529 /** | 575 /** |
| 530 * Gets the ReceivePort for the provided port id, creating it if necessary. | 576 * Gets the ReceivePort for the provided port id, creating it if necessary. |
| 531 * | 577 * |
| 532 * Note that there is at most one ReceivePort for a given port id. | 578 * Note that there is at most one ReceivePort for a given port id. |
| 533 */ | 579 */ |
| 534 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id); | 580 DART_EXPORT Dart_Handle Dart_GetReceivePort(Dart_Port port_id); |
| (...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 }; | 1437 }; |
| 1392 | 1438 |
| 1393 /** | 1439 /** |
| 1394 * A Dart_CMessage is used for encoding and decoding messages from native code. | 1440 * A Dart_CMessage is used for encoding and decoding messages from native code. |
| 1395 */ | 1441 */ |
| 1396 struct Dart_CMessage { | 1442 struct Dart_CMessage { |
| 1397 Dart_CObject** message; | 1443 Dart_CObject** message; |
| 1398 }; | 1444 }; |
| 1399 | 1445 |
| 1400 #endif // INCLUDE_DART_API_H_ | 1446 #endif // INCLUDE_DART_API_H_ |
| OLD | NEW |