| Initial commit: V -> Flutter FFI plugin | 1 | // C-ABI surface of the V library. Hand-maintained; ffigen parses this. |
| 2 | #ifndef VFLUTTER_H | |
| 3 | #define VFLUTTER_H | |
| 4 | ||
| 5 | #ifdef __cplusplus | |
| 6 | extern "C" { | |
| 7 | #endif | |
| 8 | ||
| 9 | #if defined(_WIN32) | |
| 10 | #define VF_API __declspec(dllexport) | |
| 11 | #else | |
| 12 | #define VF_API __attribute__((visibility("default"))) | |
| 13 | #endif | |
| 14 | ||
| 15 | // Idempotent. Safe to call from any isolate; required only on platforms | |
| 16 | // where the ELF/Mach-O constructor may not have run (iOS static archives). | |
| 17 | VF_API void vf_init(void); | |
| 18 | ||
| 19 | VF_API int vf_add(int a, int b); | |
| 20 | ||
| 21 | // Returns a NUL-terminated string allocated by V. Caller MUST release it | |
| 22 | // with vf_free. Never free it with Dart's calloc/malloc. | |
| 23 | VF_API char *vf_greet(const char *name); | |
| 24 | ||
| 25 | VF_API void vf_free(void *p); | |
| 26 | ||
| Add a Mandelbrot example app, and a V kernel worth demonstrating | 27 | // Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from |
| 28 | // the start of `buf`. The buffer is owned by the CALLER: V allocates nothing | |
| 29 | // here and there is nothing to vf_free. Bands are independent, so separate | |
| 30 | // calls may run concurrently on different threads/isolates. | |
| 31 | // | |
| 32 | // `buf` must hold at least (y1 - y0) * w * 4 bytes. | |
| 33 | VF_API void vf_mandelbrot(unsigned char *buf, int w, int h, double cx, | |
| 34 | double cy, double scale, int max_iter, int y0, | |
| 35 | int y1); | |
| 36 | ||
| Initial commit: V -> Flutter FFI plugin | 37 | #ifdef __cplusplus |
| 38 | } | |
| 39 | #endif | |
| 40 | #endif // VFLUTTER_H |