2023-08-28 20:46:50 -07:00
|
|
|
#ifdef GEN_INTELLISENSE_DIRECTIVES
|
2023-08-21 17:30:13 -07:00
|
|
|
#pragma once
|
2023-08-21 20:02:20 -07:00
|
|
|
#include "header_start.hpp"
|
2023-08-28 20:46:50 -07:00
|
|
|
#endif
|
2023-08-21 17:30:13 -07:00
|
|
|
|
2024-12-08 13:37:04 -08:00
|
|
|
/*
|
|
|
|
________ __ __ ________
|
|
|
|
| \ | \ | \ | \
|
|
|
|
| ▓▓▓▓▓▓▓▓_______ __ __ ______ ____ _______ | ▓▓\ | ▓▓ \▓▓▓▓▓▓▓▓__ __ ______ ______ _______
|
|
|
|
| ▓▓__ | \| \ | \ \ \ / \ | ▓▓▓\| ▓▓ | ▓▓ | \ | \/ \ / \ / \
|
|
|
|
| ▓▓ \ | ▓▓▓▓▓▓▓\ ▓▓ | ▓▓ ▓▓▓▓▓▓\▓▓▓▓\ ▓▓▓▓▓▓▓ | ▓▓▓▓\ ▓▓ | ▓▓ | ▓▓ | ▓▓ ▓▓▓▓▓▓\ ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓
|
|
|
|
| ▓▓▓▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ | ▓▓ | ▓▓\▓▓ \ | ▓▓\▓▓ ▓▓ | ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ ▓▓ ▓▓\▓▓ \
|
|
|
|
| ▓▓_____| ▓▓ | ▓▓ ▓▓__/ ▓▓ ▓▓ | ▓▓ | ▓▓_\▓▓▓▓▓▓\ | ▓▓ \▓▓▓▓ | ▓▓ | ▓▓__/ ▓▓ ▓▓__/ ▓▓ ▓▓▓▓▓▓▓▓_\▓▓▓▓▓▓\
|
|
|
|
| ▓▓ \ ▓▓ | ▓▓\▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓ ▓▓ | ▓▓ \▓▓▓ | ▓▓ \▓▓ ▓▓ ▓▓ ▓▓\▓▓ \ ▓▓
|
|
|
|
\▓▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓ \▓▓\▓▓▓▓▓▓▓ \▓▓ \▓▓ \▓▓ _\▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓ \▓▓▓▓▓▓▓\▓▓▓▓▓▓▓
|
|
|
|
| \__| ▓▓ ▓▓
|
|
|
|
\▓▓ ▓▓ ▓▓
|
|
|
|
\▓▓▓▓▓▓ \▓▓
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2024-10-27 15:58:37 -07:00
|
|
|
using LogFailType = ssize(*)(char const*, ...);
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
// By default this library will either crash or exit if an error is detected while generating codes.
|
2023-08-09 15:47:59 -07:00
|
|
|
// Even if set to not use GEN_FATAL, GEN_FATAL will still be used for memory failures as the library is unusable when they occur.
|
2023-07-24 14:45:27 -07:00
|
|
|
#ifdef GEN_DONT_USE_FATAL
|
2023-08-08 06:48:50 -07:00
|
|
|
#define log_failure log_fmt
|
2023-07-24 14:45:27 -07:00
|
|
|
#else
|
2023-08-09 15:47:59 -07:00
|
|
|
#define log_failure GEN_FATAL
|
2023-07-24 14:45:27 -07:00
|
|
|
#endif
|
|
|
|
|
2024-12-07 14:17:02 -08:00
|
|
|
enum AccessSpec : u32
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-01 02:30:37 -08:00
|
|
|
AccessSpec_Default,
|
|
|
|
AccessSpec_Private,
|
|
|
|
AccessSpec_Protected,
|
|
|
|
AccessSpec_Public,
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2024-12-01 02:30:37 -08:00
|
|
|
AccessSpec_Num_AccessSpec,
|
|
|
|
AccessSpec_Invalid,
|
|
|
|
|
|
|
|
AccessSpec_SizeDef = GEN_U32_MAX,
|
2023-07-24 14:45:27 -07:00
|
|
|
};
|
2024-12-01 15:50:37 -08:00
|
|
|
static_assert( size_of(AccessSpec) == size_of(u32), "AccessSpec not u32 size" );
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
inline
|
2024-12-12 09:55:15 -08:00
|
|
|
Str access_spec_to_str( AccessSpec type )
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
|
|
|
local_persist
|
2024-12-12 09:55:15 -08:00
|
|
|
Str lookup[ (u32)AccessSpec_Num_AccessSpec ] = {
|
2024-12-08 20:10:10 -08:00
|
|
|
{ sizeof("") - 1, "" },
|
|
|
|
{ sizeof("prviate") - 1, "private" },
|
|
|
|
{ sizeof("protected") - 1, "private" },
|
|
|
|
{ sizeof("public") - 1, "public" },
|
2023-07-24 14:45:27 -07:00
|
|
|
};
|
|
|
|
|
2024-12-12 09:55:15 -08:00
|
|
|
Str invalid = { sizeof("Invalid") - 1, "Invalid" };
|
2024-12-01 02:30:37 -08:00
|
|
|
if ( type > AccessSpec_Public )
|
2024-12-08 20:10:10 -08:00
|
|
|
return invalid;
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
return lookup[ (u32)type ];
|
|
|
|
}
|
|
|
|
|
2024-12-07 14:17:02 -08:00
|
|
|
enum CodeFlag : u32
|
2023-09-25 09:12:11 -07:00
|
|
|
{
|
2024-12-01 02:30:37 -08:00
|
|
|
CodeFlag_None = 0,
|
|
|
|
CodeFlag_FunctionType = bit(0),
|
|
|
|
CodeFlag_ParamPack = bit(1),
|
|
|
|
CodeFlag_Module_Export = bit(2),
|
|
|
|
CodeFlag_Module_Import = bit(3),
|
|
|
|
|
|
|
|
CodeFlag_SizeDef = GEN_U32_MAX,
|
2023-09-25 09:12:11 -07:00
|
|
|
};
|
2024-12-01 15:50:37 -08:00
|
|
|
static_assert( size_of(CodeFlag) == size_of(u32), "CodeFlag not u32 size" );
|
2023-09-25 09:12:11 -07:00
|
|
|
|
2023-07-29 22:21:04 -07:00
|
|
|
// Used to indicate if enum definitoin is an enum class or regular enum.
|
2024-12-07 14:17:02 -08:00
|
|
|
enum EnumDecl : u8
|
2023-07-29 22:21:04 -07:00
|
|
|
{
|
2024-12-01 02:30:37 -08:00
|
|
|
EnumDecl_Regular,
|
|
|
|
EnumDecl_Class,
|
2023-07-29 22:21:04 -07:00
|
|
|
|
2024-12-01 02:30:37 -08:00
|
|
|
EnumT_SizeDef = GEN_U8_MAX,
|
|
|
|
};
|
|
|
|
typedef u8 EnumT;
|
2023-07-29 22:21:04 -07:00
|
|
|
|
2024-12-07 14:17:02 -08:00
|
|
|
enum ModuleFlag : u32
|
2023-07-24 14:45:27 -07:00
|
|
|
{
|
2024-12-01 02:30:37 -08:00
|
|
|
ModuleFlag_None = 0,
|
|
|
|
ModuleFlag_Export = bit(0),
|
|
|
|
ModuleFlag_Import = bit(1),
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
Num_ModuleFlags,
|
2024-12-01 02:30:37 -08:00
|
|
|
ModuleFlag_Invalid,
|
|
|
|
|
|
|
|
ModuleFlag_SizeDef = GEN_U32_MAX,
|
2023-07-24 14:45:27 -07:00
|
|
|
};
|
2024-12-01 15:50:37 -08:00
|
|
|
static_assert( size_of(ModuleFlag) == size_of(u32), "ModuleFlag not u32 size" );
|
2023-07-24 14:45:27 -07:00
|
|
|
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2024-12-12 09:55:15 -08:00
|
|
|
Str module_flag_to_str( ModuleFlag flag )
|
2023-09-11 20:22:53 -07:00
|
|
|
{
|
|
|
|
local_persist
|
2024-12-12 09:55:15 -08:00
|
|
|
Str lookup[ (u32)Num_ModuleFlags ] = {
|
2023-09-11 20:22:53 -07:00
|
|
|
{ sizeof("__none__"), "__none__" },
|
|
|
|
{ sizeof("export"), "export" },
|
|
|
|
{ sizeof("import"), "import" },
|
|
|
|
};
|
|
|
|
|
2024-12-07 14:17:02 -08:00
|
|
|
local_persist
|
2024-12-12 09:55:15 -08:00
|
|
|
Str invalid_flag = { sizeof("invalid"), "invalid" };
|
2024-12-01 02:30:37 -08:00
|
|
|
if ( flag > ModuleFlag_Import )
|
2024-12-07 14:17:02 -08:00
|
|
|
return invalid_flag;
|
2023-09-11 20:22:53 -07:00
|
|
|
|
|
|
|
return lookup[ (u32)flag ];
|
|
|
|
}
|
|
|
|
|
2024-12-07 14:17:02 -08:00
|
|
|
enum EPreprocessCond : u32
|
2023-07-29 22:21:04 -07:00
|
|
|
{
|
2024-12-01 02:30:37 -08:00
|
|
|
PreprocessCond_If,
|
|
|
|
PreprocessCond_IfDef,
|
|
|
|
PreprocessCond_IfNotDef,
|
|
|
|
PreprocessCond_ElIf,
|
2023-07-29 22:21:04 -07:00
|
|
|
|
2024-12-01 02:30:37 -08:00
|
|
|
EPreprocessCond_SizeDef = GEN_U32_MAX,
|
|
|
|
};
|
2024-12-01 15:50:37 -08:00
|
|
|
static_assert( size_of(EPreprocessCond) == size_of(u32), "EPreprocessCond not u32 size" );
|
2024-12-08 17:00:16 -08:00
|
|
|
|
|
|
|
enum ETypenameTag : u16
|
|
|
|
{
|
|
|
|
Tag_None,
|
|
|
|
Tag_Class,
|
|
|
|
Tag_Enum,
|
|
|
|
Tag_Struct,
|
|
|
|
Tag_Union,
|
|
|
|
|
|
|
|
Tag_UnderlyingType = GEN_U16_MAX,
|
|
|
|
};
|
|
|
|
static_assert( size_of(ETypenameTag) == size_of(u16), "ETypenameTag is not u16 size");
|