gencpp/project/components/gen/especifier.hpp
Ed_ a42e241afb Got rid of the temp compoonent files, they are now generated via bootstrapping.
This isn't the last step though everything in the main project directory that isn't md files needs to be generated only.
Can't do that till testing is robust enough...
2023-08-21 23:28:39 -04:00

94 lines
2.4 KiB
C++

// This file was generated automatially by gen.bootstrap.cpp (See: https://github.com/Ed94/gencpp)
#pragma once
namespace ESpecifier
{
enum Type : u32
{
Invalid,
Consteval,
Constexpr,
Constinit,
Explicit,
External_Linkage,
ForceInline,
Global,
Inline,
Internal_Linkage,
Local_Persist,
Mutable,
NeverInline,
Ptr,
Ref,
Register,
RValue,
Static,
Thread_Local,
Volatile,
Virtual,
Const,
Final,
Override,
Pure,
NumSpecifiers
};
bool is_trailing( Type specifier )
{
return specifier > Virtual;
}
StrC to_str( Type type )
{
local_persist StrC lookup[] {
{sizeof( "INVALID" ), "INVALID" },
{ sizeof( "consteval" ), "consteval" },
{ sizeof( "constexpr" ), "constexpr" },
{ sizeof( "constinit" ), "constinit" },
{ sizeof( "explicit" ), "explicit" },
{ sizeof( "extern" ), "extern" },
{ sizeof( "forceinline" ), "forceinline" },
{ sizeof( "global" ), "global" },
{ sizeof( "inline" ), "inline" },
{ sizeof( "internal" ), "internal" },
{ sizeof( "local_persist" ), "local_persist"},
{ sizeof( "mutable" ), "mutable" },
{ sizeof( "neverinline" ), "neverinline" },
{ sizeof( "*" ), "*" },
{ sizeof( "&" ), "&" },
{ sizeof( "register" ), "register" },
{ sizeof( "&&" ), "&&" },
{ sizeof( "static" ), "static" },
{ sizeof( "thread_local" ), "thread_local" },
{ sizeof( "volatile" ), "volatile" },
{ sizeof( "virtual" ), "virtual" },
{ sizeof( "const" ), "const" },
{ sizeof( "final" ), "final" },
{ sizeof( "override" ), "override" },
{ sizeof( "= 0" ), "= 0" },
};
return lookup[ type ];
}
Type to_type( StrC str )
{
local_persist u32 keymap[ NumSpecifiers ];
do_once_start for ( u32 index = 0; index < NumSpecifiers; index++ )
{
StrC enum_str = to_str( ( Type )index );
keymap[ index ] = crc32( enum_str.Ptr, enum_str.Len - 1 );
}
do_once_end u32 hash = crc32( str.Ptr, str.Len );
for ( u32 index = 0; index < NumSpecifiers; index++ )
{
if ( keymap[ index ] == hash )
return ( Type )index;
}
return Invalid;
}
} // namespace ESpecifier
using SpecifierT = ESpecifier::Type;