Skip to content

Commit

Permalink
Add lambda callback option with no objection
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-attack committed Sep 18, 2024
1 parent f51dc56 commit 54c406a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions gwen/include/Gwen/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ namespace Gwen
template <typename T> void Add( Event::Handler* ob, void ( T::*f )( Gwen::Event::Info ), void* data ) { AddInternal( ob, static_cast<Handler::FunctionWithInformation>( f ), data ); }
template <typename T> void Add( Event::Handler* ob, void ( T::*f )() ) { AddInternal( ob, static_cast<Handler::FunctionBlank>( f ) ); }
void Add( Event::Handler* pObject, const std::function<void()> fn );
void Add( const std::function<void()> fn );

template <typename T> void GlobalAdd( Event::Handler* ob, T f ) { AddInternal( ob, static_cast<Handler::GlobalFunction>( f ) ); }
void GlobalAdd( Event::Handler* ob, void ( *f )( Gwen::Event::Info ) ) { AddInternal( ob, static_cast<Handler::GlobalFunctionWithInformation>( f ) ); }
Expand Down
8 changes: 8 additions & 0 deletions gwen/src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ void Caller::Add( Event::Handler* pObject, const std::function<void()> fn )
pObject->RegisterCaller( this );
}

void Caller::Add( const std::function<void()> fn )
{
handler h;
h.fnFunctional = fn;
h.pObject = 0;
m_Handlers.push_back( h );
}

void Caller::AddInternal( Event::Handler* pObject, Event::Handler::Function pFunction )
{
handler h;
Expand Down

0 comments on commit 54c406a

Please sign in to comment.