-
Notifications
You must be signed in to change notification settings - Fork 0
/
gera.h
47 lines (34 loc) · 1.46 KB
/
gera.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
#ifndef GERA_H
#define GERA_H
#include "geratypes.h"
#define GERA_CLOSURE_FPTR(closure, ret, ...) \
(ret (*)(GeraAllocation*, __VA_ARGS__)) ((closure).body)
#define GERA_CLOSURE_FPTR_NOARGS(closure, ret) \
(ret (*)(GeraAllocation*)) ((closure).body)
#define GERA_CLOSURE_CALL(closure, closure_fptr, ...) \
(closure_fptr)((closure).allocation, ...)
#define GERA_CLOSURE_CALL_NOARGS(closure, closure_fptr) \
(closure_fptr)((closure).allocation)
#define GERA_STRING_NULL_TERM(s_name, d_name) \
char d_name[s_name.length_bytes + 1]; \
for(size_t c = 0; c < s_name.length_bytes; c += 1) { \
d_name[c] = s_name.data[c]; \
} \
d_name[s_name.length_bytes] = '\0';
#define GERA_INT_MIN (-9223372036854775807 - 1)
GeraAllocation* gera___alloc(size_t size, GeraFreeHandler free_h);
void gera___ref_copied(GeraAllocation* a);
void gera___ref_deleted(GeraAllocation* a);
void gera___begin_read(GeraAllocation* a);
void gera___end_read(GeraAllocation* a);
void gera___begin_write(GeraAllocation* a);
void gera___end_write(GeraAllocation* a);
void gera___panic(const char* reason);
GeraString gera___alloc_string(const char* data);
GeraString gera___wrap_static_string(const char* data);
GeraString gera___substring(GeraString src, gint start, gint end);
GeraString gera___concat(GeraString a, GeraString b);
gint gera___hash(const unsigned char* data, size_t data_len);
size_t gera___codepoint_size(char first_byte);
extern GeraArray GERA_ARGS;
#endif