| OLD | NEW |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #ifndef INCLUDE_FLETCH_API_H_ | 5 #ifndef INCLUDE_DARTINO_API_H_ |
| 6 #define INCLUDE_FLETCH_API_H_ | 6 #define INCLUDE_DARTINO_API_H_ |
| 7 | 7 |
| 8 #include <stdbool.h> | 8 #include <stdbool.h> |
| 9 | 9 |
| 10 #ifdef _MSC_VER | 10 #ifdef _MSC_VER |
| 11 // TODO(herhut): Do we need a __declspec here for Windows? | 11 // TODO(herhut): Do we need a __declspec here for Windows? |
| 12 #define FLETCH_VISIBILITY_DEFAULT | 12 #define DARTINO_VISIBILITY_DEFAULT |
| 13 #else | 13 #else |
| 14 #define FLETCH_VISIBILITY_DEFAULT __attribute__((visibility("default"))) | 14 #define DARTINO_VISIBILITY_DEFAULT __attribute__((visibility("default"))) |
| 15 #endif | 15 #endif |
| 16 | 16 |
| 17 #ifdef __cplusplus | 17 #ifdef __cplusplus |
| 18 #define FLETCH_EXPORT extern "C" FLETCH_VISIBILITY_DEFAULT | 18 #define DARTINO_EXPORT extern "C" DARTINO_VISIBILITY_DEFAULT |
| 19 #else | 19 #else |
| 20 #define FLETCH_EXPORT FLETCH_VISIBILITY_DEFAULT | 20 #define DARTINO_EXPORT DARTINO_VISIBILITY_DEFAULT |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 typedef void* FletchProgram; | 23 typedef void* DartinoProgram; |
| 24 typedef void* FletchPrintInterceptor; | 24 typedef void* DartinoPrintInterceptor; |
| 25 typedef void (*PrintInterceptionFunction)( | 25 typedef void (*PrintInterceptionFunction)( |
| 26 const char* message, int out, void* data); | 26 const char* message, int out, void* data); |
| 27 typedef void (*ProgramExitCallback)(FletchProgram*, int exitcode, void* data); | 27 typedef void (*ProgramExitCallback)(DartinoProgram*, int exitcode, void* data); |
| 28 | 28 |
| 29 // Setup must be called before using any of the other API methods. | 29 // Setup must be called before using any of the other API methods. |
| 30 FLETCH_EXPORT void FletchSetup(void); | 30 DARTINO_EXPORT void DartinoSetup(void); |
| 31 | 31 |
| 32 // TearDown should be called when an application is done using the | 32 // TearDown should be called when an application is done using the |
| 33 // fletch API in order to free up resources. | 33 // dartino API in order to free up resources. |
| 34 FLETCH_EXPORT void FletchTearDown(void); | 34 DARTINO_EXPORT void DartinoTearDown(void); |
| 35 | 35 |
| 36 // Wait for a debugger connection. The debugger will build the program | 36 // Wait for a debugger connection. The debugger will build the program |
| 37 // to run in the VM and start it. | 37 // to run in the VM and start it. |
| 38 FLETCH_EXPORT void FletchWaitForDebuggerConnection(int port); | 38 DARTINO_EXPORT void DartinoWaitForDebuggerConnection(int port); |
| 39 | 39 |
| 40 // Load a program from a snapshot. | 40 // Load a program from a snapshot. |
| 41 FLETCH_EXPORT FletchProgram FletchLoadSnapshot(unsigned char* snapshot, | 41 DARTINO_EXPORT DartinoProgram DartinoLoadSnapshot(unsigned char* snapshot, |
| 42 int length); | 42 int length); |
| 43 | 43 |
| 44 // Load the snapshot from the file and load the program from the snapshot. | 44 // Load the snapshot from the file and load the program from the snapshot. |
| 45 FLETCH_EXPORT FletchProgram FletchLoadSnapshotFromFile(const char* path); | 45 DARTINO_EXPORT DartinoProgram DartinoLoadSnapshotFromFile(const char* path); |
| 46 | 46 |
| 47 // Delete a program. | 47 // Delete a program. |
| 48 FLETCH_EXPORT void FletchDeleteProgram(FletchProgram program); | 48 DARTINO_EXPORT void DartinoDeleteProgram(DartinoProgram program); |
| 49 | 49 |
| 50 // Load a program from the given location. Location should point to a | 50 // Load a program from the given location. Location should point to a |
| 51 // reloacted program heap with appended info block, usually build using | 51 // reloacted program heap with appended info block, usually build using |
| 52 // the flashtool utility or by relocating a loaded program. | 52 // the flashtool utility or by relocating a loaded program. |
| 53 FLETCH_EXPORT FletchProgram FletchLoadProgramFromFlash(void* location, | 53 DARTINO_EXPORT DartinoProgram DartinoLoadProgramFromFlash(void* location, |
| 54 size_t size); | 54 size_t size); |
| 55 | 55 |
| 56 // Starts the main method of the program. The given callback will be called once | 56 // Starts the main method of the program. The given callback will be called once |
| 57 // all processes of the program have terminated. | 57 // all processes of the program have terminated. |
| 58 // | 58 // |
| 59 // The [callback] might be called on FletchVM internal threads and is not | 59 // The [callback] might be called on DartinoVM internal threads and is not |
| 60 // allowed to use the Fletch API. | 60 // allowed to use the Dartino API. |
| 61 // TODO(kustermann/herhut): We should | 61 // TODO(kustermann/herhut): We should |
| 62 // * make clear what the callback can do and what not (e.g. | 62 // * make clear what the callback can do and what not (e.g. |
| 63 // FletchDeleteProgram) | 63 // DartinoDeleteProgram) |
| 64 // * use thread-local storage - at least in debug mode - which ensures this. | 64 // * use thread-local storage - at least in debug mode - which ensures this. |
| 65 FLETCH_EXPORT void FletchStartMain(FletchProgram program, | 65 DARTINO_EXPORT void DartinoStartMain(DartinoProgram program, |
| 66 ProgramExitCallback callback, | 66 ProgramExitCallback callback, |
| 67 void* callback_data); | 67 void* callback_data); |
| 68 | 68 |
| 69 // Run the main method of the program and wait until it is done executing. | 69 // Run the main method of the program and wait until it is done executing. |
| 70 FLETCH_EXPORT int FletchRunMain(FletchProgram program); | 70 DARTINO_EXPORT int DartinoRunMain(DartinoProgram program); |
| 71 | 71 |
| 72 // Run the main method of multiple programs and wait until all of them are done | 72 // Run the main method of multiple programs and wait until all of them are done |
| 73 // executing. | 73 // executing. |
| 74 FLETCH_EXPORT void FletchRunMultipleMain(int count, | 74 DARTINO_EXPORT void DartinoRunMultipleMain(int count, |
| 75 FletchProgram* programs, | 75 DartinoProgram* programs, |
| 76 int* exitcodes); | 76 int* exitcodes); |
| 77 | 77 |
| 78 // Load the snapshot from the file, load the program from the | 78 // Load the snapshot from the file, load the program from the |
| 79 // snapshot, run the main process of that program and wait until it is done | 79 // snapshot, run the main process of that program and wait until it is done |
| 80 // executing. | 80 // executing. |
| 81 FLETCH_EXPORT void FletchRunSnapshotFromFile(const char* path); | 81 DARTINO_EXPORT void DartinoRunSnapshotFromFile(const char* path); |
| 82 | 82 |
| 83 // Add a default shared library for the dart:ffi foreign lookups. | 83 // Add a default shared library for the dart:ffi foreign lookups. |
| 84 // More than one default shared library can be added. The libraries | 84 // More than one default shared library can be added. The libraries |
| 85 // are used for foreign lookups where no library has been specified. | 85 // are used for foreign lookups where no library has been specified. |
| 86 // The libraries are searched in the order in which they are added. | 86 // The libraries are searched in the order in which they are added. |
| 87 // The library string must be null-terminated and Fletch does not | 87 // The library string must be null-terminated and Dartino does not |
| 88 // take over ownership of the passed in string. | 88 // take over ownership of the passed in string. |
| 89 FLETCH_EXPORT bool FletchAddDefaultSharedLibrary(const char* library); | 89 DARTINO_EXPORT bool DartinoAddDefaultSharedLibrary(const char* library); |
| 90 | 90 |
| 91 // Register a print interception function. When a print occurs the passed | 91 // Register a print interception function. When a print occurs the passed |
| 92 // function will be called with the message, an output id 2 for stdout or output | 92 // function will be called with the message, an output id 2 for stdout or output |
| 93 // id 3 for stderr, as well as the data associated with this registration. | 93 // id 3 for stderr, as well as the data associated with this registration. |
| 94 // The result of registration is an interceptor instance that can be used to | 94 // The result of registration is an interceptor instance that can be used to |
| 95 // subsequently unregister the interceptor. | 95 // subsequently unregister the interceptor. |
| 96 FLETCH_EXPORT FletchPrintInterceptor FletchRegisterPrintInterceptor( | 96 DARTINO_EXPORT DartinoPrintInterceptor DartinoRegisterPrintInterceptor( |
| 97 PrintInterceptionFunction function, | 97 PrintInterceptionFunction function, |
| 98 void* data); | 98 void* data); |
| 99 | 99 |
| 100 // Unregister a print interceptor. This must be called with an interceptor | 100 // Unregister a print interceptor. This must be called with an interceptor |
| 101 // instance that was created using the registration function. The interceptor | 101 // instance that was created using the registration function. The interceptor |
| 102 // instance is reclaimed and no longer valid after having called this function. | 102 // instance is reclaimed and no longer valid after having called this function. |
| 103 FLETCH_EXPORT void FletchUnregisterPrintInterceptor( | 103 DARTINO_EXPORT void DartinoUnregisterPrintInterceptor( |
| 104 FletchPrintInterceptor interceptor); | 104 DartinoPrintInterceptor interceptor); |
| 105 | 105 |
| 106 #endif // INCLUDE_FLETCH_API_H_ | 106 #endif // INCLUDE_DARTINO_API_H_ |
| OLD | NEW |