diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-22 22:40:43 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-22 22:40:43 +0000 |
| commit | ed4bbfd8cf4a72fdf4a5d6cba94d537cab340356 (patch) | |
| tree | 80f520cb36f25a210537b477007b0ac5a24e4b8e /src/constants.h | |
| parent | 3d1840e8690bef6e58a208d9ca33857a59a2e852 (diff) | |
Removing some duplicates and dissecting codegen/parser.
Diffstat (limited to 'src/constants.h')
| -rw-r--r-- | src/constants.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/constants.h b/src/constants.h new file mode 100644 index 0000000..15bb19f --- /dev/null +++ b/src/constants.h @@ -0,0 +1,46 @@ + +#ifndef ZEN_CONSTANTS_H +#define ZEN_CONSTANTS_H + +// Buffer sizes +#define MAX_TYPE_NAME_LEN 256 +#define MAX_FUNC_NAME_LEN 512 +#define MAX_ERROR_MSG_LEN 1024 +#define MAX_MANGLED_NAME_LEN 512 +#define MAX_PATH_LEN 4096 + +// Type checking helpers +#define IS_INT_TYPE(t) ((t) && strcmp((t), "int") == 0) +#define IS_BOOL_TYPE(t) ((t) && strcmp((t), "bool") == 0) +#define IS_CHAR_TYPE(t) ((t) && strcmp((t), "char") == 0) +#define IS_VOID_TYPE(t) ((t) && strcmp((t), "void") == 0) +#define IS_FLOAT_TYPE(t) ((t) && strcmp((t), "float") == 0) +#define IS_DOUBLE_TYPE(t) ((t) && strcmp((t), "double") == 0) +#define IS_USIZE_TYPE(t) ((t) && (strcmp((t), "usize") == 0 || strcmp((t), "size_t") == 0)) +#define IS_STRING_TYPE(t) \ + ((t) && \ + (strcmp((t), "string") == 0 || strcmp((t), "char*") == 0 || strcmp((t), "const char*") == 0)) + +// Composite type checks +#define IS_BASIC_TYPE(t) \ + ((t) && (IS_INT_TYPE(t) || IS_BOOL_TYPE(t) || IS_CHAR_TYPE(t) || IS_VOID_TYPE(t) || \ + IS_FLOAT_TYPE(t) || IS_DOUBLE_TYPE(t) || IS_USIZE_TYPE(t) || \ + strcmp((t), "ssize_t") == 0 || strcmp((t), "__auto_type") == 0)) + +#define IS_NUMERIC_TYPE(t) \ + ((t) && (IS_INT_TYPE(t) || IS_FLOAT_TYPE(t) || IS_DOUBLE_TYPE(t) || IS_USIZE_TYPE(t))) + +// Pointer type check +#define IS_PTR_TYPE(t) ((t) && strchr((t), '*') != NULL) + +// Struct prefix check +#define IS_STRUCT_PREFIX(t) ((t) && strncmp((t), "struct ", 7) == 0) +#define STRIP_STRUCT_PREFIX(t) (IS_STRUCT_PREFIX(t) ? ((t) + 7) : (t)) + +// Generic type checks +#define IS_OPTION_TYPE(t) ((t) && strncmp((t), "Option_", 7) == 0) +#define IS_RESULT_TYPE(t) ((t) && strncmp((t), "Result_", 7) == 0) +#define IS_VEC_TYPE(t) ((t) && strncmp((t), "Vec_", 4) == 0) +#define IS_SLICE_TYPE(t) ((t) && strncmp((t), "Slice_", 6) == 0) + +#endif // ZEN_CONSTANTS_H |
