mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Formatting corrections
This commit is contained in:
parent
9f79e8c573
commit
ebf4908c27
|
@ -1,38 +1,38 @@
|
||||||
#ifndef SOL_FUNCTION_HPP
|
#ifndef SOL_FUNCTION_HPP
|
||||||
#define SOL_FUNCTION_HPP
|
#define SOL_FUNCTION_HPP
|
||||||
|
|
||||||
#include <sol.hpp>
|
#include "reference.hpp"
|
||||||
#include <sol/tuple.hpp>
|
#include "tuple.hpp"
|
||||||
#include <sol/reference.hpp>
|
#include "stack.hpp"
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
class function : virtual public reference {
|
class function : virtual public reference {
|
||||||
private:
|
private:
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void push_args( Args&&... args ) {
|
void push_args(Args&&... args) {
|
||||||
auto L = state( );
|
auto L = state();
|
||||||
using swallow = char [];
|
using swallow = char [];
|
||||||
void( swallow{ ( stack::push( L, std::forward<Args>( args ) ), '\0' )... } );
|
void( swallow{ (stack::push(L, std::forward<Args>(args)), '\0')... } );
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
function( ) : reference( ) {}
|
function() : reference() {}
|
||||||
function( lua_State* L, int index = -1 ) : reference( L, index ) {
|
function(lua_State* L, int index = -1) : reference(L, index) {
|
||||||
type_assert( L, index, type::function );
|
type_assert(L, index, type::function);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
template<typename T, typename... Args>
|
||||||
T invoke( Args&&... args ) {
|
T invoke(Args&&... args) {
|
||||||
push( );
|
push();
|
||||||
push_args( std::forward<Args>( args )... );
|
push_args(std::forward<Args>(args)...);
|
||||||
lua_pcall( state( ), sizeof...( Args ), 1, 0 );
|
lua_pcall(state(), sizeof...(Args), 1, 0);
|
||||||
return stack::pop<T>( state( ) );
|
return stack::pop<T>(state());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
void invoke( Args&&... args ) {
|
void invoke(Args&&... args) {
|
||||||
push( );
|
push();
|
||||||
push_args( std::forward<Args>( args )... );
|
push_args(std::forward<Args>(args)...);
|
||||||
lua_pcall( state( ), sizeof...( Args ), 0, 0 );
|
lua_pcall(state(), sizeof...(Args), 0, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // sol
|
} // sol
|
||||||
|
|
Loading…
Reference in New Issue
Block a user