Zen-C
Loading...
Searching...
No Matches
constants.h
Go to the documentation of this file.
1
2#ifndef ZEN_CONSTANTS_H
3#define ZEN_CONSTANTS_H
4
5// Buffer sizes
6#define MAX_TYPE_NAME_LEN 256
7#define MAX_FUNC_NAME_LEN 512
8#define MAX_ERROR_MSG_LEN 1024
9#define MAX_MANGLED_NAME_LEN 512
10#define MAX_PATH_LEN 4096
11
12// Type checking helpers
13#define IS_INT_TYPE(t) ((t) && strcmp((t), "int") == 0)
14#define IS_BOOL_TYPE(t) ((t) && strcmp((t), "bool") == 0)
15#define IS_CHAR_TYPE(t) ((t) && strcmp((t), "char") == 0)
16#define IS_VOID_TYPE(t) ((t) && strcmp((t), "void") == 0)
17#define IS_FLOAT_TYPE(t) ((t) && strcmp((t), "float") == 0)
18#define IS_DOUBLE_TYPE(t) ((t) && strcmp((t), "double") == 0)
19#define IS_USIZE_TYPE(t) \
20 ((t) && (strcmp((t), "usize") == 0 || \
21 strcmp((t), "size_t") == 0))
25#define IS_STRING_TYPE(t) \
26 ((t) && \
27 (strcmp((t), "string") == 0 || strcmp((t), "char*") == 0 || strcmp((t), "const char*") == 0))
28
29// Composite type checks
33#define IS_BASIC_TYPE(t) \
34 ((t) && (IS_INT_TYPE(t) || IS_BOOL_TYPE(t) || IS_CHAR_TYPE(t) || IS_VOID_TYPE(t) || \
35 IS_FLOAT_TYPE(t) || IS_DOUBLE_TYPE(t) || IS_USIZE_TYPE(t) || \
36 strcmp((t), "ssize_t") == 0 || strcmp((t), "__auto_type") == 0))
37
41#define IS_NUMERIC_TYPE(t) \
42 ((t) && (IS_INT_TYPE(t) || IS_FLOAT_TYPE(t) || IS_DOUBLE_TYPE(t) || IS_USIZE_TYPE(t)))
44// Pointer type check
45#define IS_PTR_TYPE(t) ((t) && strchr((t), '*') != NULL)
46
47// Struct prefix check
48#define IS_STRUCT_PREFIX(t) \
49 ((t) && strncmp((t), "struct ", 7) == 0)
50#define STRIP_STRUCT_PREFIX(t) \
51 (IS_STRUCT_PREFIX(t) ? ((t) + 7) : (t))
53// Generic type checks
54#define IS_OPTION_TYPE(t) ((t) && strncmp((t), "Option_", 7) == 0)
55#define IS_RESULT_TYPE(t) ((t) && strncmp((t), "Result_", 7) == 0)
56#define IS_VEC_TYPE(t) ((t) && strncmp((t), "Vec_", 4) == 0)
57#define IS_SLICE_TYPE(t) ((t) && strncmp((t), "Slice_", 6) == 0)
59#endif // ZEN_CONSTANTS_H