aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/class.h
blob: 8cb05da611b373f6edef5f440ff55db0071c5034 (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
/*
 * The kpl class a 64bit value with a table of functions
 */

#pragma once

/*
 * How to traverse the object and mark kpl_object_gc
 */
typedef void kpl_interface_gc_mark_object_fn(void *object);

/*
 * A free for objects allocated outside the kpl allocator, wrapped in a kpl_object_native
 */
typedef void kpl_interface_native_free_fn(kpl_object_native *object_native);

/*
 * `log operator
 */
typedef void kpl_interface_log_fn(kpl_thread *thread, void *object);

/*
 * `copy operator
 */
typedef kpl_value64 kpl_interface_copy_fn(kpl_thread *thread_from, kpl_thread *thread_to, kpl_value64 object);

typedef struct {
    // TODO
    kpl_interface_gc_mark_object_fn *gc_mark_object_fn;
    kpl_interface_native_free_fn *native_free_fn;
    kpl_interface_log_fn *log_fn;
    kpl_interface_copy_fn *copy_fn;
} kpl_interface;

typedef struct {
    kpl_value64 value;
    const kpl_interface *interface;
} kpl_class;