Adaptations to changes in corelib
This commit is contained in:
parent
14288e3c87
commit
c093ba2213
7 changed files with 53 additions and 195 deletions
2
ebcl
2
ebcl
|
@ -1 +1 @@
|
|||
Subproject commit 3adfdadd119f2783877865a8365a29d4b567911f
|
||||
Subproject commit 0bc11d32d746f1075a41137adff51819007d5275
|
32
main.cc
32
main.cc
|
@ -54,7 +54,7 @@ void T_Main::mainLoop( )
|
|||
{
|
||||
auto& p( Globals::Profiler( ) );
|
||||
while ( !done ) {
|
||||
if ( demo.present( ) ) {
|
||||
if ( demo ) {
|
||||
auto const& dspSize( ImGui::GetIO( ).DisplaySize );
|
||||
if ( prevSize.x != dspSize.x || prevSize.y != dspSize.y ) {
|
||||
stopResize = ResizeDelay;
|
||||
|
@ -67,7 +67,7 @@ void T_Main::mainLoop( )
|
|||
demo.clear( );
|
||||
}
|
||||
}
|
||||
if ( !demo.present( ) ) {
|
||||
if ( !demo ) {
|
||||
initDemo( );
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ T_Main::~T_Main( )
|
|||
|
||||
void T_Main::initDemo( )
|
||||
{
|
||||
assert( !demo.present( ) );
|
||||
assert( !demo );
|
||||
auto const& dspSize( ImGui::GetIO( ).DisplaySize );
|
||||
if ( dspSize.x < 0 || dspSize.y < 0 ) {
|
||||
return;
|
||||
|
@ -108,7 +108,7 @@ void T_Main::initDemo( )
|
|||
|
||||
printf( "init w/ dspsize %dx%d\n" , int( dspSize.x ) , int( dspSize.y ) );
|
||||
demo.setNew( dspSize.x , dspSize.y );
|
||||
if ( ((T_Demo&)demo).initialise( ) ) {
|
||||
if ( demo->initialise( ) ) {
|
||||
Globals::Profiler( ).clear( );
|
||||
} else {
|
||||
demo.clear( );
|
||||
|
@ -155,8 +155,8 @@ void T_Main::handleCapture( )
|
|||
ImGui::SetMouseCursor( ImGuiMouseCursor_Arrow );
|
||||
} else if ( capture ) {
|
||||
ImGui::SetMouseCursor( ImGuiMouseCursor_Move );
|
||||
if ( demo.present( ) ) {
|
||||
demo.target( )->handleDND( mouseMove , ctrl , shift , lmb );
|
||||
if ( demo ) {
|
||||
demo->handleDND( mouseMove , ctrl , shift , lmb );
|
||||
}
|
||||
} else if ( appCanGrab && mb ) {
|
||||
capture = true;
|
||||
|
@ -166,8 +166,8 @@ void T_Main::handleCapture( )
|
|||
ImGui::SetMouseCursor( ImGuiMouseCursor_Move );
|
||||
}
|
||||
|
||||
if ( ( appCanGrab || capture ) && io.MouseWheel && demo.present( ) ) {
|
||||
demo.target( )->handleWheel( io.MouseWheel , ctrl , shift );
|
||||
if ( ( appCanGrab || capture ) && io.MouseWheel && demo ) {
|
||||
demo->handleWheel( io.MouseWheel , ctrl , shift );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,25 +183,25 @@ void T_Main::makeUI( )
|
|||
ImGui::Checkbox( "Profiler" , &Globals::Profiler( ).uiEnabled( ) );
|
||||
ImGui::Checkbox( "Shaders" , &Globals::Shaders( ).uiEnabled( ) );
|
||||
|
||||
if ( demo.present( ) ) {
|
||||
if ( demo ) {
|
||||
ImGui::Separator( );
|
||||
auto& sync( Globals::Sync( ) );
|
||||
const float duration( sync.duration( ) );
|
||||
float time( sync.time( ) );
|
||||
if ( ImGui::SliderFloat( "" , &time , 0 , duration , "%.1fs" ) ) {
|
||||
sync.setTime( time );
|
||||
demo.target( )->playing = demo.target( )->playing && ! sync.finished( );
|
||||
demo->playing = demo->playing && ! sync.finished( );
|
||||
}
|
||||
ImGui::SameLine( );
|
||||
if ( ImGui::Button( demo.target( )->playing ? "Stop" : "Play" ) ) {
|
||||
demo.target( )->playing = !demo.target( )->playing;
|
||||
if ( ImGui::Button( demo->playing ? "Stop" : "Play" ) ) {
|
||||
demo->playing = !demo->playing;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End( );
|
||||
|
||||
if ( demo.present( ) && demoCtrl_ ) {
|
||||
demo.target( )->makeUI( );
|
||||
if ( demo && demoCtrl_ ) {
|
||||
demo->makeUI( );
|
||||
}
|
||||
|
||||
Globals::Profiler( ).makeUI( );
|
||||
|
@ -211,9 +211,9 @@ void T_Main::makeUI( )
|
|||
|
||||
void T_Main::render( )
|
||||
{
|
||||
if ( demo.present( ) ) {
|
||||
if ( demo ) {
|
||||
Globals::Profiler( ).start( "Render" );
|
||||
demo.target( )->render( );
|
||||
demo->render( );
|
||||
glFinish( ); Globals::Profiler( ).end( "Render" );
|
||||
|
||||
Globals::Profiler( ).start( "Debug" );
|
||||
|
|
13
opast.cc
13
opast.cc
|
@ -491,7 +491,7 @@ void T_ParserImpl_::parseFunction(
|
|||
fn->location( ) = fw.location( );
|
||||
|
||||
const auto af( root->addFunction( fn ) );
|
||||
if ( af.dupLocation.present( ) ) {
|
||||
if ( af.dupLocation ) {
|
||||
T_StringBuilder esb( "duplicate " );
|
||||
switch ( fn->type( ) ) {
|
||||
case A_Node::DECL_FN:
|
||||
|
@ -505,7 +505,7 @@ void T_ParserImpl_::parseFunction(
|
|||
break;
|
||||
default: std::abort( );
|
||||
}
|
||||
esb << "; previous declaration: " << *af.dupLocation.target( );
|
||||
esb << "; previous declaration: " << *af.dupLocation;
|
||||
errors.addNew( std::move( esb ) , fw.location( ) );
|
||||
}
|
||||
|
||||
|
@ -527,10 +527,10 @@ void T_ParserImpl_::parseFunctionArguments(
|
|||
}
|
||||
|
||||
const auto rv( function.addArgument( token ) );
|
||||
if ( rv.present( ) ) {
|
||||
if ( rv ) {
|
||||
T_StringBuilder esb;
|
||||
esb << "duplicate argument '" << token.stringValue( )
|
||||
<< "'; previous declaration: " << *rv.target( );
|
||||
<< "'; previous declaration: " << *rv;
|
||||
errors.addNew( std::move( esb ) , token.location( ) );
|
||||
}
|
||||
}
|
||||
|
@ -708,10 +708,9 @@ M_INSTR_( Pipeline )
|
|||
continue;
|
||||
}
|
||||
const auto dup( pipeline.addProgram( tok ) );
|
||||
if ( dup.present( ) ) {
|
||||
if ( dup ) {
|
||||
T_StringBuilder esb;
|
||||
esb << "duplicate program identifier; previous use: "
|
||||
<< *dup.target( );
|
||||
esb << "duplicate program identifier; previous use: " << *dup;
|
||||
errors.addNew( std::move( esb ) , tok.location( ) );
|
||||
}
|
||||
}
|
||||
|
|
183
parsercheck.cc
183
parsercheck.cc
|
@ -2,6 +2,7 @@
|
|||
#include "opast.hh"
|
||||
#include <ebcl/Files.hh>
|
||||
#include <ebcl/SRDText.hh>
|
||||
#include <ebcl/Algorithms.hh>
|
||||
|
||||
using namespace ebcl;
|
||||
using namespace opast;
|
||||
|
@ -36,148 +37,6 @@ void WriteSRDError(
|
|||
/*============================================================================*/
|
||||
// FIXME TESTING, MOVE THIS LATER
|
||||
|
||||
template<
|
||||
typename Enum ,
|
||||
typename Storage = uint32_t
|
||||
> class T_Flags
|
||||
{
|
||||
private:
|
||||
Storage flags_;
|
||||
|
||||
public:
|
||||
constexpr T_Flags( ) noexcept
|
||||
: flags_( 0 ) {}
|
||||
|
||||
constexpr T_Flags( T_Flags const& other ) noexcept
|
||||
: flags_( other.flags_ ) { }
|
||||
|
||||
constexpr T_Flags( const Enum flag ) noexcept
|
||||
: flags_( 1 << int( flag ) ) {}
|
||||
|
||||
constexpr T_Flags( std::initializer_list< Enum > flags ) noexcept
|
||||
: flags_( 0 )
|
||||
{
|
||||
for ( auto f : flags ) {
|
||||
flags_ |= ( 1 << int( f ) );
|
||||
}
|
||||
}
|
||||
|
||||
explicit constexpr T_Flags( const Storage flags ) noexcept
|
||||
: flags_( flags ) { }
|
||||
|
||||
constexpr T_Flags operator |=( T_Flags other ) noexcept
|
||||
{ flags_ |= other.flags_; return *this; }
|
||||
constexpr T_Flags operator &=( T_Flags other ) noexcept
|
||||
{ flags_ &= other.flags_; return *this; }
|
||||
constexpr T_Flags operator ^=( T_Flags other ) noexcept
|
||||
{ flags_ ^= other.flags_; return *this; }
|
||||
|
||||
constexpr T_Flags operator ~( ) const noexcept
|
||||
{ return T_Flags( ~flags_ ); }
|
||||
constexpr T_Flags operator &( T_Flags other ) const noexcept
|
||||
{ return T_Flags( flags_ & other.flags_ ); }
|
||||
constexpr T_Flags operator |( T_Flags other ) const noexcept
|
||||
{ return T_Flags( flags_ & other.flags_ ); }
|
||||
constexpr T_Flags operator ^( T_Flags other ) const noexcept
|
||||
{ return T_Flags( flags_ ^ other.flags_ ); }
|
||||
|
||||
constexpr operator bool( ) const noexcept
|
||||
{ return flags_ != 0; }
|
||||
constexpr bool operator!( ) const noexcept
|
||||
{ return flags_ == 0; }
|
||||
explicit constexpr operator Storage( ) const noexcept
|
||||
{ return flags_; }
|
||||
|
||||
constexpr bool operator ==( const T_Flags other ) const noexcept
|
||||
{ return flags_ == other.flags_; }
|
||||
constexpr bool operator !=( const T_Flags other ) const noexcept
|
||||
{ return flags_ != other.flags_; }
|
||||
|
||||
constexpr bool isSet( const T_Flags value ) const noexcept
|
||||
{ return ( *this & value ) == value; }
|
||||
constexpr bool isClear( const T_Flags value ) const noexcept
|
||||
{ return !( *this & value ); }
|
||||
};
|
||||
|
||||
|
||||
template< typename NodeType >
|
||||
class T_Visitor
|
||||
{
|
||||
public:
|
||||
using T_Node = NodeType;
|
||||
|
||||
// Node browser. Returns the Nth child of the specified node, or null
|
||||
// if there are no children left.
|
||||
using F_NodeBrowser = std::function< T_Node*( T_Node& , uint32_t ) >;
|
||||
|
||||
// Node action. Second parameter indicates whether the action is
|
||||
// being called before (false) or after (true) visiting the children.
|
||||
using F_NodeAction = std::function< bool( T_Node& , bool ) >;
|
||||
|
||||
private:
|
||||
enum E_State_ {
|
||||
BEFORE , CHILDREN , AFTER
|
||||
};
|
||||
struct T_NodeRef_ {
|
||||
T_Node* node;
|
||||
uint32_t child;
|
||||
E_State_ state{ BEFORE };
|
||||
|
||||
explicit T_NodeRef_( T_Node* node )
|
||||
: node( node ) , child( 0 ) {}
|
||||
explicit T_NodeRef_( T_Node* node , uint32_t child )
|
||||
: node( node ) , child( child ) {}
|
||||
};
|
||||
|
||||
F_NodeBrowser nodeBrowser_;
|
||||
T_Array< T_NodeRef_ > stack_;
|
||||
|
||||
public:
|
||||
T_Visitor( ) = delete;
|
||||
T_Visitor( T_Visitor const& ) = default;
|
||||
T_Visitor( T_Visitor&& ) noexcept = default;
|
||||
|
||||
explicit T_Visitor( F_NodeBrowser browser ) noexcept;
|
||||
|
||||
void visit( T_Node& root , F_NodeAction action );
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
inline T_Visitor< T >::T_Visitor(
|
||||
F_NodeBrowser browser ) noexcept
|
||||
: nodeBrowser_( std::move( browser ) )
|
||||
{ }
|
||||
|
||||
template< typename T >
|
||||
inline void T_Visitor< T >::visit(
|
||||
T_Node& root ,
|
||||
F_NodeAction action )
|
||||
{
|
||||
stack_.addNew( &root , 0 );
|
||||
|
||||
while ( !stack_.empty( ) ) {
|
||||
auto& n( stack_.last( ) );
|
||||
switch ( n.state ) {
|
||||
case BEFORE:
|
||||
n.state = action( *n.node , false ) ? CHILDREN : AFTER;
|
||||
break;
|
||||
case CHILDREN: {
|
||||
T_Node* child( nodeBrowser_( *n.node , n.child ++ ) );
|
||||
if ( child ) {
|
||||
stack_.addNew( child , 0 );
|
||||
} else {
|
||||
n.state = AFTER;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AFTER:
|
||||
action( *n.node , true );
|
||||
stack_.removeLast( );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
A_Node* OpASTBrowser(
|
||||
A_Node& node ,
|
||||
const uint32_t child )
|
||||
|
@ -372,13 +231,13 @@ bool checkCalls( T_RootNode& root )
|
|||
return false;
|
||||
}
|
||||
|
||||
T_Visitor< uint32_t > callGraphVisitor(
|
||||
[&]( uint32_t& v , uint32_t child ) -> uint32_t* {
|
||||
T_Visitor< uint32_t , uint32_t > callGraphVisitor(
|
||||
[&]( uint32_t v , uint32_t child ) -> T_Optional< uint32_t > {
|
||||
const uint32_t nc( calls.sizeOf( v ) );
|
||||
if ( child < nc ) {
|
||||
return &calls.get( v , child );
|
||||
return calls.get( v , child );
|
||||
}
|
||||
return nullptr;
|
||||
return {};
|
||||
} );
|
||||
enum class E_CallInfo_ {
|
||||
INIT_CHECKED , FRAME_CHECKED ,
|
||||
|
@ -387,22 +246,22 @@ bool checkCalls( T_RootNode& root )
|
|||
using T_CallInfo_ = T_Flags< E_CallInfo_ , uint8_t >;
|
||||
T_CallInfo_ callInfo[ calls.size( ) ];
|
||||
|
||||
uint32_t initId( root.functionIndex( "*init*" ) );
|
||||
callGraphVisitor.visit( initId , [&]( uint32_t& id , const bool exit ) -> bool {
|
||||
if ( exit || callInfo[ id ] & E_CallInfo_::INIT_CALLED ) {
|
||||
return false;
|
||||
}
|
||||
callInfo[ id ] |= E_CallInfo_::INIT_CALLED;
|
||||
return true;
|
||||
} );
|
||||
uint32_t frameId( root.functionIndex( "*frame*" ) );
|
||||
callGraphVisitor.visit( frameId , [&]( uint32_t& id , const bool exit ) -> bool {
|
||||
if ( exit || callInfo[ id ] & E_CallInfo_::FRAME_CALLED ) {
|
||||
return false;
|
||||
}
|
||||
callInfo[ id ] |= E_CallInfo_::FRAME_CALLED;
|
||||
return true;
|
||||
} );
|
||||
callGraphVisitor.visit( root.functionIndex( "*init*" ) ,
|
||||
[&]( uint32_t id , const bool exit ) -> bool {
|
||||
if ( exit || callInfo[ id ] & E_CallInfo_::INIT_CALLED ) {
|
||||
return false;
|
||||
}
|
||||
callInfo[ id ] |= E_CallInfo_::INIT_CALLED;
|
||||
return true;
|
||||
} );
|
||||
callGraphVisitor.visit( root.functionIndex( "*frame*" ) ,
|
||||
[&]( uint32_t id , const bool exit ) -> bool {
|
||||
if ( exit || callInfo[ id ] & E_CallInfo_::FRAME_CALLED ) {
|
||||
return false;
|
||||
}
|
||||
callInfo[ id ] |= E_CallInfo_::FRAME_CALLED;
|
||||
return true;
|
||||
} );
|
||||
|
||||
T_StringBuilder sb;
|
||||
for ( auto callerId = 0u ; callerId < calls.size( ) ; callerId ++ ) {
|
||||
|
|
|
@ -19,7 +19,7 @@ T_RendertargetSetup& T_RendertargetSetup::add(
|
|||
T_RendertargetSetup& T_RendertargetSetup::depth(
|
||||
__rw__ T_Texture& texture )
|
||||
{
|
||||
assert( !depthAttachment_.present( ) );
|
||||
assert( !depthAttachment_ );
|
||||
checkAttachment( texture , 0 );
|
||||
depthAttachment_.setNew( texture , 0 );
|
||||
return *this;
|
||||
|
@ -65,8 +65,8 @@ T_Rendertarget T_RendertargetSetup::create( )
|
|||
colorAttachments_[ i ].texture->id( ) ,
|
||||
colorAttachments_[ i ].level );
|
||||
}
|
||||
if ( depthAttachment_.present( ) ) {
|
||||
T_Attachment_ const& de( depthAttachment_ );
|
||||
if ( depthAttachment_ ) {
|
||||
T_Attachment_ const& de( *depthAttachment_ );
|
||||
glFramebufferTexture( GL_FRAMEBUFFER ,
|
||||
GL_DEPTH_ATTACHMENT ,
|
||||
de.texture->id( ) ,
|
||||
|
|
|
@ -949,8 +949,8 @@ void T_ShaderManager::programUpdated(
|
|||
void T_ShaderManager::resetProgram(
|
||||
T_Program_& program )
|
||||
{
|
||||
if ( program.watch.present( ) ) {
|
||||
program.watch.clear( );
|
||||
if ( program.watch ) {
|
||||
program.watch->clear( );
|
||||
}
|
||||
if ( program.id != 0 ) {
|
||||
glDeleteProgram( program.id );
|
||||
|
|
8
sync.cc
8
sync.cc
|
@ -99,8 +99,8 @@ bool CPSegmentVD_( T_SRDParserData const& data )
|
|||
{
|
||||
auto const& input( *data.input );
|
||||
const auto ev( data.config.enumValue( "segment-type" , input[ 1 ].stringValue( ) ) );
|
||||
assert( ev.present( ) );
|
||||
CPHandleSegment_( (T_SyncSegment::E_SegmentType) *ev.target( ) ,
|
||||
assert( ev );
|
||||
CPHandleSegment_( (T_SyncSegment::E_SegmentType) *ev ,
|
||||
input[ 2 ].list( ) , input[ 3 ].list( ) ,
|
||||
data.errors , data.targetData->value< T_SyncCurve >( ) );
|
||||
return true;
|
||||
|
@ -110,8 +110,8 @@ bool CPSegmentDV_( T_SRDParserData const& data )
|
|||
{
|
||||
auto const& input( *data.input );
|
||||
const auto ev( data.config.enumValue( "segment-type" , input[ 1 ].stringValue( ) ) );
|
||||
assert( ev.present( ) );
|
||||
CPHandleSegment_( (T_SyncSegment::E_SegmentType) *ev.target( ) ,
|
||||
assert( ev );
|
||||
CPHandleSegment_( (T_SyncSegment::E_SegmentType) *ev ,
|
||||
input[ 3 ].list( ) , input[ 2 ].list( ) ,
|
||||
data.errors , data.targetData->value< T_SyncCurve >( ) );
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue