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-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
|
|
|
|
|
|
|
|
enum class AccessSpec : u32
|
|
|
|
{
|
|
|
|
Default,
|
|
|
|
Private,
|
2024-04-17 14:40:32 -07:00
|
|
|
Protected,
|
|
|
|
Public,
|
2023-07-24 14:45:27 -07:00
|
|
|
|
|
|
|
Num_AccessSpec,
|
|
|
|
Invalid,
|
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
char const* to_str( AccessSpec type )
|
|
|
|
{
|
|
|
|
local_persist
|
|
|
|
char const* lookup[ (u32)AccessSpec::Num_AccessSpec ] = {
|
|
|
|
"",
|
|
|
|
"private",
|
2024-04-17 14:40:32 -07:00
|
|
|
"protected",
|
|
|
|
"public",
|
2023-07-24 14:45:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
if ( type > AccessSpec::Public )
|
|
|
|
return "Invalid";
|
|
|
|
|
|
|
|
return lookup[ (u32)type ];
|
|
|
|
}
|
|
|
|
|
2023-09-25 09:12:11 -07:00
|
|
|
|
|
|
|
enum CodeFlag : u32
|
|
|
|
{
|
2023-11-21 17:09:14 -08:00
|
|
|
None = 0,
|
2023-09-25 09:12:11 -07:00
|
|
|
FunctionType = bit(0),
|
|
|
|
ParamPack = bit(1),
|
|
|
|
Module_Export = bit(2),
|
|
|
|
Module_Import = bit(3),
|
|
|
|
};
|
|
|
|
|
2023-07-29 22:21:04 -07:00
|
|
|
// Used to indicate if enum definitoin is an enum class or regular enum.
|
|
|
|
enum class EnumT : u8
|
|
|
|
{
|
|
|
|
Regular,
|
|
|
|
Class
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr EnumT EnumClass = EnumT::Class;
|
|
|
|
constexpr EnumT EnumRegular = EnumT::Regular;
|
|
|
|
|
2023-07-24 14:45:27 -07:00
|
|
|
enum class ModuleFlag : u32
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Export = bit(0),
|
|
|
|
Import = bit(1),
|
|
|
|
|
|
|
|
Num_ModuleFlags,
|
|
|
|
Invalid,
|
|
|
|
};
|
|
|
|
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2023-09-11 20:22:53 -07:00
|
|
|
StrC to_str( ModuleFlag flag )
|
|
|
|
{
|
|
|
|
local_persist
|
|
|
|
StrC lookup[ (u32)ModuleFlag::Num_ModuleFlags ] = {
|
|
|
|
{ sizeof("__none__"), "__none__" },
|
|
|
|
{ sizeof("export"), "export" },
|
|
|
|
{ sizeof("import"), "import" },
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( flag > ModuleFlag::Import )
|
|
|
|
return { sizeof("invalid"), "invalid" };
|
|
|
|
|
|
|
|
return lookup[ (u32)flag ];
|
|
|
|
}
|
|
|
|
|
2024-10-24 22:04:17 -07:00
|
|
|
inline
|
2023-07-24 14:45:27 -07:00
|
|
|
ModuleFlag operator|( ModuleFlag A, ModuleFlag B)
|
|
|
|
{
|
|
|
|
return (ModuleFlag)( (u32)A | (u32)B );
|
|
|
|
}
|
|
|
|
|
2023-07-29 22:21:04 -07:00
|
|
|
enum class EPreprocessCond : u32
|
|
|
|
{
|
|
|
|
If,
|
|
|
|
IfDef,
|
|
|
|
IfNotDef,
|
|
|
|
ElIf
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr EPreprocessCond PreprocessCond_If = EPreprocessCond::If;
|
|
|
|
constexpr EPreprocessCond PreprocessCond_IfDef = EPreprocessCond::IfDef;
|
|
|
|
constexpr EPreprocessCond PreprocessCond_IfNotDef = EPreprocessCond::IfNotDef;
|
|
|
|
constexpr EPreprocessCond PreprocessCond_ElIf = EPreprocessCond::ElIf;
|