nandi/vflutter_ffipublic Fork 0
4506a586d7400b00d732dcb97167be75ab41cab1
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.

Replace V with Nim 472eb49 · on 4506a586d7400b00d732dcb97167be75ab41cab1 · nandithebull · 6h ago
nimflutter.h · 46 lines · 1.6 KBC Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// C-ABI surface of the Nim library. Hand-maintained; ffigen parses this.
#ifndef NIMFLUTTER_H
#define NIMFLUTTER_H

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

#if defined(_WIN32)
  #define NF_API __declspec(dllexport)
#else
  #define NF_API __attribute__((visibility("default")))
#endif

// Runs NimMain. Idempotent. Shared builds run it from a library constructor,
// but static archives (iOS) have no such hook, so call this first.
NF_API void nf_init(void);

NF_API int nf_add(int a, int b);

// Returns a NUL-terminated string allocated by Nim on the SHARED heap.
// Caller MUST release it with nf_free. Never free it with Dart's calloc.
NF_API char *nf_greet(const char *name);

NF_API void nf_free(void *p);

// Fills rows [y0, y1) of a w x h Mandelbrot image as RGBA8888, packed from
// the start of `buf`. The buffer is owned by the CALLER: Nim allocates
// nothing here and there is nothing to nf_free. Bands are independent, so
// separate calls may run concurrently on different threads/isolates.
//
// `buf_len` is how many bytes `buf` holds; it must be at least
// (y1 - y0) * w * 4. Every rejection is all-or-nothing — a buffer one byte
// short writes nothing at all, rather than filling what fits, since partial
// output is indistinguishable from a rendered frame. The size is computed in
// 64-bit, because that product overflows int32 for plausible geometry.
NF_API void nf_mandelbrot(unsigned char *buf, size_t buf_len, int w, int h,
                          double cx, double cy, double scale, int max_iter,
                          int y0, int y1);

#ifdef __cplusplus
}
#endif
#endif // NIMFLUTTER_H