forked from kevinlawler/kona
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kona.h
91 lines (71 loc) · 1.42 KB
/
kona.h
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _KONA_H_
#define _KONA_H_
/*
* Interface between C & K
* atom functions/accessors:
* list functions/accessors:
* misc functions: ci, cd
*/
#ifdef __cplusplus
extern "C" {
#endif
/* abbreviations */
#define O printf
#define R return
#define Z static
/* types */
typedef void* V;
typedef long long I;
typedef double F;
typedef char C;
typedef C* S;
typedef const C* cS;
typedef unsigned char UC;
typedef unsigned long UI;
/* the main struct */
typedef struct k0{I c,t,n;struct k0*k[1];}*K;
#define ke(x) (((K)x)->k)
/* list accessors */
#define KI(x) ((I*)((x)->k))
#define KF(x) ((F*)((x)->k))
#define KC(x) ((UC*)((x)->k))
#define KS(x) ((S*)((x)->k))
#define KK(x) ((K*)((x)->k))
#define KV(x) ((V*)ke(x))
extern K kap(K*,V);
/* atom accessors */
#define Ki(x) (*KI(x))
#define Kf(x) (*KF(x))
#define Kc(x) (*KC(x))
#define Ks(x) (*KS(x))
/* atom generators */
extern K gi(I);
extern K gf(F);
extern K gc(C);
extern K gs(S);
extern K gn();
/* list generators */
extern K gtn(I,I);
extern K gsk(S,K);
extern K gp(S);
extern K gpn(S,I);
extern K gnk(I,...);
extern K kerr(S);
/* Call k from c */
extern K ksk(S,K);
extern I sfn(S,K(*)(),I);
/* ref counting */
extern K ci(K);
extern I cd(K);
/* date conversion */
extern I jd(I);
extern I dj(I);
/* callbacks */
extern I sdf(I,I(*)());
extern I scd(I);
extern S sp(S);
#define DO(n,x) {I i,_n=(n);for(i=0;i<_n;++i){x;}}
#ifdef __cplusplus
}
#endif
#endif/*_KONA_H_*/