aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/storage.h
blob: 87586247729674304ca4f99293bf6548e1361a9d (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
/*
 * KPL Object storage
 */

#pragma once

/*
 * Inner tree storage
 * Keys will always be kpl_identifier
 */
typedef struct _kpl_storgae_object {
    KPL_TREE_HEADER(_kpl_storgae_object);
    kpl_type_base *type;
    union {
        kpl_class class;
        kpl_function function;
    };
    kpl_identifier identifier;
} kpl_stoage_object;

// c_string_ptr used for tree search comparisons
#define KPL_STORAGE_HEADER(STRUCT_NAME) \
    KPL_TREE_HEADER(STRUCT_NAME); \
    bool import_ready; \
    kpl_tree object_tree; \
    const char *c_string_ptr;

/*
 * Uses const c string keys
 * The namespace is c_string_ptr
 */
typedef struct _kpl_storage_namespace {
    KPL_TREE_HEADER(_kpl_storage_namespace);
} kpl_stoage_namespace;

/*
 * Alias used for string comparison functions
 */
typedef kpl_stoage_namespace kpl_stoage_search;

/*
 * Modules make a copy of absolute file path
 * The c_string_ptr is pointed to this file path copy string
 * This tree can only be accessed through a mutex
 */
typedef struct _kpl_storage_module {
    KPL_TREE_HEADER(_kpl_storage_module);
    char c_string_array[]; // null term, c_string_ptr points to this
} kpl_storage_module;