Some reformatting
This commit is contained in:
parent
952aad1e02
commit
8eefe21aae
1 changed files with 114 additions and 109 deletions
53
shaders.cc
53
shaders.cc
|
@ -3,9 +3,10 @@
|
|||
|
||||
|
||||
namespace {
|
||||
const std::regex PreprocDirective_( "^\\s*//!\\s*([a-z]+(\\s+([^\\s]+))*)\\s*$" );
|
||||
|
||||
const std::map< std::string , E_ShaderInput > InputTypes_( ([] {
|
||||
const std::regex PreprocDirective_( "^\\s*//!\\s*([a-z]+(\\s+([^\\s]+))*)\\s*$" );
|
||||
|
||||
const std::map< std::string , E_ShaderInput > InputTypes_( ([] {
|
||||
std::map< std::string , E_ShaderInput > t;
|
||||
t.emplace( "chunk" , E_ShaderInput::CHUNK );
|
||||
t.emplace( "library" , E_ShaderInput::LIBRARY );
|
||||
|
@ -13,11 +14,13 @@ namespace {
|
|||
t.emplace( "vertex" , E_ShaderInput::VERTEX );
|
||||
t.emplace( "fragment" , E_ShaderInput::FRAGMENT );
|
||||
return t;
|
||||
})());
|
||||
})());
|
||||
|
||||
/*============================================================================*/
|
||||
|
||||
struct T_InputReader_
|
||||
{
|
||||
// Input reader state and functions, used when loading a source file
|
||||
struct T_InputReader_
|
||||
{
|
||||
using T_Tokens_ = std::vector< std::string >;
|
||||
|
||||
FILE* const file;
|
||||
|
@ -42,18 +45,20 @@ namespace {
|
|||
void handleDirective(
|
||||
__rd__ T_Tokens_ const& tokens );
|
||||
void error( __rd__ std::string const& err );
|
||||
};
|
||||
};
|
||||
|
||||
T_InputReader_::~T_InputReader_( )
|
||||
{
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
T_InputReader_::~T_InputReader_( )
|
||||
{
|
||||
if ( buffer ) {
|
||||
free( buffer );
|
||||
}
|
||||
fclose( file );
|
||||
}
|
||||
}
|
||||
|
||||
void T_InputReader_::read( )
|
||||
{
|
||||
void T_InputReader_::read( )
|
||||
{
|
||||
size_t bsz( 0 );
|
||||
while ( ( readCount = getline( &buffer , &bsz , file ) ) != -1 ) {
|
||||
line ++;
|
||||
|
@ -72,16 +77,16 @@ namespace {
|
|||
}
|
||||
}
|
||||
addAccumulated( );
|
||||
}
|
||||
}
|
||||
|
||||
void T_InputReader_::nl( )
|
||||
{
|
||||
void T_InputReader_::nl( )
|
||||
{
|
||||
accumLines ++;
|
||||
accumulator += '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void T_InputReader_::addAccumulated( )
|
||||
{
|
||||
void T_InputReader_::addAccumulated( )
|
||||
{
|
||||
if ( accumLines ) {
|
||||
auto& ck( input.chunks );
|
||||
ck.emplace_back( E_ShaderInputChunk::CODE ,
|
||||
|
@ -89,11 +94,11 @@ namespace {
|
|||
accumulator = {};
|
||||
accumLines = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void T_InputReader_::handleDirective(
|
||||
void T_InputReader_::handleDirective(
|
||||
__rd__ T_Tokens_ const& tokens )
|
||||
{
|
||||
{
|
||||
auto const& directive( tokens[ 0 ] );
|
||||
|
||||
if ( directive == "include" ) {
|
||||
|
@ -123,14 +128,14 @@ namespace {
|
|||
nl( );
|
||||
error( "unknown directive" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void T_InputReader_::error(
|
||||
void T_InputReader_::error(
|
||||
__rd__ std::string const& err )
|
||||
{
|
||||
{
|
||||
input.errors.push_back( T_ShaderInputError{
|
||||
line , err } );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
|
|
Loading…
Reference in a new issue