master
test.c
1#include <stdio.h>
2#include <stdlib.h>
3
4#include "expl.h"
5
6static expl_value
7birds_who_hit_my_window(int argc, const expl_value* argv, void* data)
8{
9 int* count = (int*)data;
10 expl_value result = { 0 };
11
12 if (argc == 1 && argv[0].type == EXPL_VALUE_NUMBER)
13 *count += (int)argv[0].as.number;
14
15 result.type = EXPL_VALUE_NUMBER;
16 result.as.number = *count;
17
18 return result;
19}
20
21#define FIND_THE_BIRDS \
22"(fn foo (x) (birds_who_hit_my_window x))\n" \
23"(foo 134)\n"
24
25int
26main(void)
27{
28 int birds_who_hit_my_window_c = 0;
29 expl* ctx = expl_init();
30
31 if (!ctx)
32 return EXIT_FAILURE;
33
34 expl_register(ctx, "birds_who_hit_my_window", birds_who_hit_my_window, &birds_who_hit_my_window_c);
35 expl_run(ctx, FIND_THE_BIRDS);
36 printf("Stupid birds: %d\n", birds_who_hit_my_window_c);
37
38 expl_close(ctx);
39 return EXIT_SUCCESS;
40}