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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 * | 639 * |
640 * This function should be used to dispose of native resources that | 640 * This function should be used to dispose of native resources that |
641 * are allocated to an isolate in order to avoid leaks. | 641 * are allocated to an isolate in order to avoid leaks. |
642 * | 642 * |
643 * \param callback_data The same callback data which was passed to the | 643 * \param callback_data The same callback data which was passed to the |
644 * isolate when it was created. | 644 * isolate when it was created. |
645 * | 645 * |
646 */ | 646 */ |
647 typedef void (*Dart_IsolateShutdownCallback)(void* callback_data); | 647 typedef void (*Dart_IsolateShutdownCallback)(void* callback_data); |
648 | 648 |
649 typedef void* (*Dart_FileOpenCallback)(const char* name); | 649 /** |
| 650 * Callbacks provided by the embedder for file operations. If the |
| 651 * embedder does not allow file operations these callbacks can be |
| 652 * NULL. |
| 653 * |
| 654 * Dart_FileOpenCallback - opens a file for reading or writing. |
| 655 * \param name The name of the file to open. |
| 656 * \param write A boolean variable which indicates if the file is to |
| 657 * opened for writing. If there is an existing file it needs to truncated. |
| 658 * |
| 659 * Dart_FileReadCallback - Read contents of file. |
| 660 * \param data Buffer allocated in the callback into which the contents |
| 661 * of the file are read into. It is the responsibility of the caller to |
| 662 * free this buffer. |
| 663 * \param file_length A variable into which the length of the file is returned. |
| 664 * In the case of an error this value would be -1. |
| 665 * \param stream Handle to the opened file. |
| 666 * |
| 667 * Dart_FileWriteCallback - Write data into file. |
| 668 * \param data Buffer which needs to be written into the file. |
| 669 * \param length Length of the buffer. |
| 670 * \param stream Handle to the opened file. |
| 671 * |
| 672 * Dart_FileCloseCallback - Closes the opened file. |
| 673 * \param stream Handle to the opened file. |
| 674 * |
| 675 */ |
| 676 typedef void* (*Dart_FileOpenCallback)(const char* name, bool write); |
| 677 |
| 678 typedef void (*Dart_FileReadCallback)(const uint8_t** data, |
| 679 intptr_t* file_length, |
| 680 void* stream); |
650 | 681 |
651 typedef void (*Dart_FileWriteCallback)(const void* data, | 682 typedef void (*Dart_FileWriteCallback)(const void* data, |
652 intptr_t length, | 683 intptr_t length, |
653 void* stream); | 684 void* stream); |
654 | 685 |
655 typedef void (*Dart_FileCloseCallback)(void* stream); | 686 typedef void (*Dart_FileCloseCallback)(void* stream); |
656 | 687 |
657 | 688 |
658 /** | 689 /** |
659 * Initializes the VM. | 690 * Initializes the VM. |
660 * | 691 * |
661 * \param create A function to be called during isolate creation. | 692 * \param create A function to be called during isolate creation. |
662 * See Dart_IsolateCreateCallback. | 693 * See Dart_IsolateCreateCallback. |
663 * \param interrupt A function to be called when an isolate is interrupted. | 694 * \param interrupt A function to be called when an isolate is interrupted. |
664 * See Dart_IsolateInterruptCallback. | 695 * See Dart_IsolateInterruptCallback. |
665 * \param unhandled_exception A function to be called if an isolate has an | 696 * \param unhandled_exception A function to be called if an isolate has an |
666 * unhandled exception. Set Dart_IsolateUnhandledExceptionCallback. | 697 * unhandled exception. Set Dart_IsolateUnhandledExceptionCallback. |
667 * \param shutdown A function to be called when an isolate is shutdown. | 698 * \param shutdown A function to be called when an isolate is shutdown. |
668 * See Dart_IsolateShutdownCallback. | 699 * See Dart_IsolateShutdownCallback. |
669 * | 700 * |
670 * \return True if initialization is successful. | 701 * \return True if initialization is successful. |
671 */ | 702 */ |
672 DART_EXPORT bool Dart_Initialize( | 703 DART_EXPORT bool Dart_Initialize( |
673 Dart_IsolateCreateCallback create, | 704 Dart_IsolateCreateCallback create, |
674 Dart_IsolateInterruptCallback interrupt, | 705 Dart_IsolateInterruptCallback interrupt, |
675 Dart_IsolateUnhandledExceptionCallback unhandled_exception, | 706 Dart_IsolateUnhandledExceptionCallback unhandled_exception, |
676 Dart_IsolateShutdownCallback shutdown, | 707 Dart_IsolateShutdownCallback shutdown, |
677 Dart_FileOpenCallback file_open, | 708 Dart_FileOpenCallback file_open, |
| 709 Dart_FileReadCallback file_read, |
678 Dart_FileWriteCallback file_write, | 710 Dart_FileWriteCallback file_write, |
679 Dart_FileCloseCallback file_close); | 711 Dart_FileCloseCallback file_close); |
680 | 712 |
681 /** | 713 /** |
682 * Sets command line flags. Should be called before Dart_Initialize. | 714 * Sets command line flags. Should be called before Dart_Initialize. |
683 * | 715 * |
684 * \param argc The length of the arguments array. | 716 * \param argc The length of the arguments array. |
685 * \param argv An array of arguments. | 717 * \param argv An array of arguments. |
686 * | 718 * |
687 * \return True if VM flags set successfully. | 719 * \return True if VM flags set successfully. |
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 * | 2635 * |
2604 * \param object An object. | 2636 * \param object An object. |
2605 * \param peer A value to store in the peer field. | 2637 * \param peer A value to store in the peer field. |
2606 * | 2638 * |
2607 * \return Returns an error if 'object' is a subtype of Null, num, or | 2639 * \return Returns an error if 'object' is a subtype of Null, num, or |
2608 * bool. | 2640 * bool. |
2609 */ | 2641 */ |
2610 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); | 2642 DART_EXPORT Dart_Handle Dart_SetPeer(Dart_Handle object, void* peer); |
2611 | 2643 |
2612 #endif // INCLUDE_DART_API_H_ | 2644 #endif // INCLUDE_DART_API_H_ |
OLD | NEW |