gencpp/base/components/gen/especifier.hpp

109 lines
2.9 KiB
C++
Raw Normal View History

#ifdef GEN_INTELLISENSE_DIRECTIVES
#pragma once
#include "components/types.hpp"
#endif
// This file was generated automatially by gencpp's bootstrap.cpp (See: https://github.com/Ed94/gencpp)
2023-08-21 22:51:59 -07:00
enum Specifier : u32
{
2024-12-07 14:17:02 -08:00
Spec_Invalid,
Spec_Consteval,
Spec_Constexpr,
Spec_Constinit,
Spec_Explicit,
Spec_External_Linkage,
Spec_ForceInline,
Spec_Global,
Spec_Inline,
Spec_Internal_Linkage,
Spec_Local_Persist,
Spec_Mutable,
Spec_NeverInline,
Spec_Ptr,
Spec_Ref,
Spec_Register,
Spec_RValue,
Spec_Static,
Spec_Thread_Local,
Spec_Virtual,
Spec_Const,
Spec_Final,
Spec_NoExceptions,
Spec_Override,
Spec_Pure,
Spec_Volatile,
Spec_NumSpecifiers,
Spec_UnderlyingType = 0xffffffffu
};
2024-12-07 14:17:02 -08:00
inline Str spec_to_str( Specifier type )
2024-12-07 14:17:02 -08:00
{
local_persist Str lookup[26] = {
2024-12-07 14:17:02 -08:00
{ 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( "virtual" ), "virtual" },
{ sizeof( "const" ), "const" },
{ sizeof( "final" ), "final" },
{ sizeof( "noexcept" ), "noexcept" },
{ sizeof( "override" ), "override" },
{ sizeof( "= 0" ), "= 0" },
{ sizeof( "volatile" ), "volatile" },
};
return lookup[type];
}
inline bool spec_is_trailing( Specifier specifier )
{
2024-12-07 14:17:02 -08:00
return specifier > Spec_Virtual;
}
2024-12-07 14:17:02 -08:00
inline Specifier str_to_specifier( Str str )
{
2024-12-07 14:17:02 -08:00
local_persist u32 keymap[Spec_NumSpecifiers];
do_once_start for ( u32 index = 0; index < Spec_NumSpecifiers; index++ )
{
Str enum_str = spec_to_str( (Specifier)index );
2024-12-07 14:17:02 -08:00
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 < Spec_NumSpecifiers; index++ )
{
if ( keymap[index] == hash )
return (Specifier)index;
}
return Spec_Invalid;
}
2024-12-07 14:17:02 -08:00
forceinline Str to_str( Specifier spec )
{
2024-12-07 14:17:02 -08:00
return spec_to_str( spec );
}
forceinline Specifier to_type( Str str )
2024-12-07 14:17:02 -08:00
{
return str_to_specifier( str );
2024-12-07 14:17:02 -08:00
}
forceinline bool is_trailing( Specifier specifier )
{
return spec_is_trailing( specifier );
}