nandi/vflutter_ffipublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/nandi/vflutter_ffi.git
git clone ssh://git@rickub.com/nandi/vflutter_ffi.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

nimflutter.h · 46 lines · 1.6 KBC Blame HistoryRaw
Replace V with Nim 472eb49 nandithebull 13h ago1// C-ABI surface of the Nim library. Hand-maintained; ffigen parses this.
2#ifndef NIMFLUTTER_H
3#define NIMFLUTTER_H
4
5#include <stddef.h>
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11#if defined(_WIN32)
12 #define NF_API __declspec(dllexport)
13#else
14 #define NF_API __attribute__((visibility("default")))
15#endif
16
17// Runs NimMain. Idempotent. Shared builds run it from a library constructor,
18// but static archives (iOS) have no such hook, so call this first.
19NF_API void nf_init(void);
20
21NF_API int nf_add(int a, int b);
22
23// Returns a NUL-terminated string allocated by Nim on the SHARED heap.
24// Caller MUST release it with nf_free. Never free it with Dart's calloc.
25NF_API char *nf_greet(const char *name);
26
27NF_API void nf_free(void *p);
28
29// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
30// the start of `buf`. The buffer is owned by the CALLER: Nim allocates
31// nothing here and there is nothing to nf_free. Bands are independent, so
32// separate calls may run concurrently on different threads/isolates.
33//
34// `buf_len` is how many bytes `buf` holds; it must be at least
35// (y1 - y0) * w * 4. Every rejection is all-or-nothing — a buffer one byte
36// short writes nothing at all, rather than filling what fits, since partial
37// output is indistinguishable from a rendered frame. The size is computed in
38// 64-bit, because that product overflows int32 for plausible geometry.
39NF_API void nf_mandelbrot(unsigned char *buf, size_t buf_len, int w, int h,
40 double cx, double cy, double scale, int max_iter,
41 int y0, int y1);
42
43#ifdef __cplusplus
44}
45#endif
46#endif // NIMFLUTTER_H