aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/type.h
diff options
context:
space:
mode:
authornodist <kevin.comas.git@gmail.com>2026-11-13 16:28:13 -0500
committernodist <kevin.comas.git@gmail.com>2026-11-13 16:28:13 -0500
commitc3d23d3091c23978b12c140e6cfd964eff1d3986 (patch)
tree3342a73aea427fa19d2b0936a98e37fbe479c85d /include/kpl/type.h
parent75c8828d804f45cf8f44af73bfe87e0f3eaf9a9e (diff)
rewriteHEADmain
Diffstat (limited to 'include/kpl/type.h')
-rw-r--r--include/kpl/type.h179
1 files changed, 0 insertions, 179 deletions
diff --git a/include/kpl/type.h b/include/kpl/type.h
deleted file mode 100644
index 91c3bd4..0000000
--- a/include/kpl/type.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * KPL Types
- * A Type is a declaration of code and data
- * Types can be shared across threads
- */
-
-#pragma once
-
-typedef enum : uint8_t {
- KPL_TYPE_NAME_INVALID,
- // VALUES
- KPL_TYPE_NAME_BOOLEAN,
- KPL_TYPE_NAME_INTEGER,
- KPL_TYPE_NAME_U8,
- KPL_TYPE_NAME_U16,
- KPL_TYPE_NAME_U32,
- KPL_TYPE_NAME_U64,
- KPL_TYPE_NAME_I8,
- KPL_TYPE_NAME_I16,
- KPL_TYPE_NAME_I32,
- KPL_TYPE_NAME_I64,
- KPL_TYPE_NAME_FLOAT,
- KPL_TYPE_NAME_F32,
- KPL_TYPE_NAME_F64,
- KPL_TYPE_NAME_CHAR,
- // CONTAINERS
- KPL_TYPE_NAME_STRING,
- KPL_TYPE_NAME_ARRAY,
- KPL_TYPE_NAME_TUPLE,
- KPL_TYPE_NAME_TABLE,
- KPL_TYPE_NAME_MAP,
- KPL_TYPE_NAME_SET,
- KPL_TYPE_NAME_UNION,
- KPL_TYPE_NAME_ANY,
- KPL_TYPE_NAME_NATIVE,
- KPL_TYPE_NAME_ERROR,
- // COROUTINES
- KPL_TYPE_NAME_LAMBDA,
- KPL_TYPE_NAME_GENERATOR,
- KPL_TYPE_NAME_REGEXP,
- // STORAGE
- KPL_TYPE_NAME_MODULE,
- KPL_TYPE_NAME_NAMESPACE,
- // DEFINITIONS
- KPL_TYPE_NAME_ALIAS,
- KPL_TYPE_NAME_UNIQUE,
- // ENUM COUNT
- KPL_TYPE_NAME_ENUM_COUNT
-} kpl_type_name;
-
-const char *kpl_type_name_c_string(kpl_type_name type_name);
-
-/*
- * The c struct for this type
- */
-typedef enum : uint8_t {
- KPL_TYPE_KIND_INVALID,
- KPL_TYPE_KIND_BASE, // has no additional type information
- KPL_TYPE_KIND_NATIVE, // keeps interface pointer
- KPL_TYPE_KIND_ARRAY, // type wraps an unknown number of types
- KPL_TYPE_KIND_TREE, // tree of type/type or identifier/type
- KPL_TYPE_KIND_RESULT, // union of array and tree for tags
- KPL_TYPE_KIND_COROUTINE // coroutine type, tree + array
-} kpl_type_kind;
-
-kpl_type_kind kpl_type_name_get_kind(kpl_type_name type_name);
-
-typedef enum : uint16_t {
- KPL_TYPE_FLAG_EMPTY = 0,
- KPL_TYPE_FLAG_NULLABLE = 1 << 0,
- KPL_TYPE_FLAG_TREE_TYPE = 1 << 1,
- KPL_TYPE_FLAG_TREE_IDENTIFIER = 1 << 2
-} kpl_type_flags;
-
-// type_kind is for struct polymorphism
-// types are in the gc cannot use object_flags for meta
-#define KPL_TYPE_HEADER(STRUCT_NAME) \
- KPL_OBJECT_HEADER(STRUCT_NAME); \
- kpl_type_name type_name; \
- kpl_type_kind type_kind; \
- uint16_t type_flags
-
-/*
- * Type has no additional information
- */
-typedef struct _kpl_type_base {
- KPL_TYPE_HEADER(_kpl_type_base);
-} kpl_type_base;
-
-/*
- * Keeps interface pointer for its type comparison
- */
-typedef struct _kpl_type_native {
- KPL_TYPE_HEADER(_kpl_type_native);
- kpl_interface *interface;
-} kpl_type_native;
-
-/*
- * Type wraps an unknown number of types
- * Array does not grow or shrink
- * Minimum array size is 1
- */
-typedef struct _kpl_type_array {
- KPL_TYPE_HEADER(_kpl_type_array);
- uint16_t array_size;
- kpl_type_base *array[];
-} kpl_type_array;
-
-/*
- * Tree based on matching types
- */
-typedef struct _kpl_type_tree_item_type {
- KPL_TREE_HEADER(_kpl_type_tree_item_type);
- uint16_t tag; // unique id
- kpl_type_base *type;
-} kpl_type_tree_item_type;
-
-/*
- * Tree based on matching identifiers
- */
-typedef struct _kpl_type_tree_item_identifier {
- KPL_TREE_HEADER(_kpl_type_tree_item_identifier);
- uint16_t tag; // unique id for the item
- kpl_type_base *type;
- kpl_identifier identifier;
-} kpl_type_tree_item_identifier;
-
-/*
- * Tree of types
- * Tag counter provides a unique tag to each new inserted item
- */
-typedef struct _kpl_type_tree {
- KPL_TYPE_HEADER(_kpl_type_tree);
- uint16_t tag_counter;
- kpl_tree tag_tree;
-} kpl_type_tree;
-
-/*
- * Reserved ids for result types
- * For result_types tag_counter has to be initialized to 3
- * New tags cannot use these ids
- */
-typedef enum : uint8_t {
- KPL_TYPE_RESULT_ID_DEFAULT = 0, // .default can be any type
- KPL_TYPE_RESULT_ID_ERROR = 1, // .error must be error type
- KPL_TYPE_RESULT_ID_DONE = 2 // .done must be void
-} kpL_type_result_ids;
-
-/*
- * Most of the time we can use default_error and map all .default and .error tags to this array
- * .done does not need a type it is always void
- * If more tags are added move .default, .error (.done if applicable) to the tree and add additional tags to tree
- */
-typedef union {
- kpl_type_base *default_error[2]; // used if tag counter == 3
- kpl_tree tree; // tag counter > 3
-} kpl_type_result_union;
-
-/*
- * KPL result type
- */
-typedef struct _kpl_type_result {
- KPL_TYPE_HEADER(_kpl_type_result);
- uint16_t tag_counter;
- kpl_type_result_union result;
-} kpl_type_result;
-
-/*
- * Coroutine Type
- * Arguments size is known at creation and does not grow
- * Arguments size can be zero
- * Can be cased to kpl_type_result when working with results
- */
-typedef struct _kpl_type_coroutine {
- KPL_TYPE_HEADER(_kpl_type_coroutine);
- uint16_t tag_counter, arguments_size; // unique id generator
- kpl_type_result_union result;
- kpl_type_base *arguments[];
-} kpl_type_coroutine;