summaryrefslogtreecommitdiff
path: root/docs/application/interface.md
blob: 9a7fa2294bb91ce29f2304d9a9f5a2176f1dc943 (plain)
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
# Interface

---

General definitions used throughout the code

## Object Definitions

```c
typedef union {
    bool b;
    uint8_t u8;
    uint16_t u16;
    uint32_t u32;
    uint64_t u64;
    int8_t i8;
    int16_t i16;
    int32_t i32;
    int64_t i64;
    float f32;
    double f64;
    void *ptr;
} kpl_any;

typedef void kpl_interface_free(kpl_any a);

typedef struct {
    // TODO
} kpl_interface;

typedef struct {
    kpl_any *any;
    kpl_interface *interface;
} kpl_class;

typedef enum : uint8_t {
    KPL_STATUS_ERROR,
    KPL_STATUS_NULL,
    KPL_STATUS_VALUE
} kpl_result_status;

typedef struct {
    any value;
    kpl_result_status status;
} kpl_result;

kpl_result kpl_result_error(error *er);

kpl_result kpl_result_null(void);

kpl_result kpl_result_value(any value);

typdef struct {
    uint16_t slab_index, array_index;
} kpl_ptr;

#define KPL_PTR_NULL (kpl_ptr) { .slab_index = UINT16_MAX, .array_index = UINT16_MAX }
```

## `kpl_interface`

See [Operators](../language/operators.md)