1
|
|
2
|
#ifndef _ARROW_CPP
|
3
|
#define _ARROW_CPP
|
4
|
|
5
|
#include <stdint.h>
|
6
|
#include <stdlib.h>
|
7
|
|
8
|
struct _arrow_mem {
|
9
|
struct _arrow_reg {
|
10
|
bool _first;
|
11
|
} _reg;
|
12
|
};
|
13
|
|
14
|
extern struct _arrow_mem *_arrow_alloc ();
|
15
|
|
16
|
#define _arrow_DECLARE(attr, inst)\
|
17
|
attr struct _arrow_mem inst;
|
18
|
|
19
|
#define _arrow_LINK(inst) do {\
|
20
|
;\
|
21
|
} while (0)
|
22
|
|
23
|
#define _arrow_ALLOC(attr, inst)\
|
24
|
_arrow_DECLARE(attr, inst);\
|
25
|
_arrow_LINK(inst)
|
26
|
|
27
|
#define _arrow_init(self) {}
|
28
|
|
29
|
#define _arrow_clear(self) {}
|
30
|
|
31
|
#define _arrow_step(x,y,output,self) ((self)->_reg._first?((self)->_reg._first=0,(*output = x)):(*output = y))
|
32
|
|
33
|
#define _arrow_reset(self) {(self)->_reg._first = 1;}
|
34
|
|
35
|
/* Step macro for specialized arrows of the form: (true -> false) */
|
36
|
|
37
|
#define _once_step(output,self) { *output = (self)->_reg._first; if ((self)->_reg._first) { (self)->_reg._first=0; }; }
|
38
|
|
39
|
#endif
|