OpenMiner  0.0.1a
Voxel game engine
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
sol::basic_coroutine< base_t > Class Template Reference

#include <sol.hpp>

Inheritance diagram for sol::basic_coroutine< base_t >:
base_t

Public Types

typedef reference handler_t
 

Public Member Functions

 basic_coroutine ()=default
 
template<typename T , meta::enable< meta::neg< std::is_same< meta::unqualified_t< T >, basic_coroutine >>, meta::neg< std::is_base_of< proxy_base_tag, meta::unqualified_t< T >>>, meta::neg< std::is_same< base_t, stack_reference >>, meta::neg< std::is_same< lua_nil_t, meta::unqualified_t< T >>>, is_lua_reference< meta::unqualified_t< T >>> = meta::enabler>
 basic_coroutine (T &&r) noexcept
 
 basic_coroutine (const basic_coroutine &)=default
 
basic_coroutineoperator= (const basic_coroutine &)=default
 
 basic_coroutine (basic_coroutine &&)=default
 
basic_coroutineoperator= (basic_coroutine &&)=default
 
 basic_coroutine (const basic_function< base_t > &b)
 
 basic_coroutine (basic_function< base_t > &&b)
 
 basic_coroutine (const basic_function< base_t > &b, handler_t eh)
 
 basic_coroutine (basic_function< base_t > &&b, handler_t eh)
 
 basic_coroutine (const stack_reference &r)
 
 basic_coroutine (stack_reference &&r)
 
 basic_coroutine (const stack_reference &r, handler_t eh)
 
 basic_coroutine (stack_reference &&r, handler_t eh)
 
template<typename Super >
 basic_coroutine (const proxy_base< Super > &p)
 
template<typename Super >
 basic_coroutine (proxy_base< Super > &&p)
 
template<typename Proxy , typename Handler , meta::enable< std::is_base_of< proxy_base_tag, meta::unqualified_t< Proxy >>, meta::neg< is_lua_index< meta::unqualified_t< Handler >>>> = meta::enabler>
 basic_coroutine (Proxy &&p, Handler &&eh)
 
template<typename T , meta::enable< is_lua_reference< meta::unqualified_t< T >>> = meta::enabler>
 basic_coroutine (lua_State *L, T &&r)
 
template<typename T , meta::enable< is_lua_reference< meta::unqualified_t< T >>> = meta::enabler>
 basic_coroutine (lua_State *L, T &&r, handler_t eh)
 
 basic_coroutine (lua_nil_t n)
 
 basic_coroutine (lua_State *L, int index=-1)
 
 basic_coroutine (lua_State *L, int index, handler_t eh)
 
 basic_coroutine (lua_State *L, absolute_index index)
 
 basic_coroutine (lua_State *L, absolute_index index, handler_t eh)
 
 basic_coroutine (lua_State *L, raw_index index)
 
 basic_coroutine (lua_State *L, raw_index index, handler_t eh)
 
 basic_coroutine (lua_State *L, ref_index index)
 
 basic_coroutine (lua_State *L, ref_index index, handler_t eh)
 
call_status status () const noexcept
 
bool error () const noexcept
 
bool runnable () const noexcept
 
 operator bool () const noexcept
 
template<typename... Args>
protected_function_result operator() (Args &&... args)
 
template<typename... Ret, typename... Args>
decltype(auto) operator() (types< Ret... >, Args &&... args)
 
template<typename... Ret, typename... Args>
decltype(auto) call (Args &&... args)
 

Public Attributes

handler_t error_handler
 

Private Member Functions

void luacall (std::ptrdiff_t argcount, std::ptrdiff_t)
 
template<std::size_t... I, typename... Ret>
auto invoke (types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n)
 
template<std::size_t I, typename Ret >
Ret invoke (types< Ret >, std::index_sequence< I >, std::ptrdiff_t n)
 
template<std::size_t I>
void invoke (types< void >, std::index_sequence< I >, std::ptrdiff_t n)
 
protected_function_result invoke (types<>, std::index_sequence<>, std::ptrdiff_t n)
 

Private Attributes

call_status stats = call_status::yielded
 

Member Typedef Documentation

§ handler_t

template<typename base_t >
typedef reference sol::basic_coroutine< base_t >::handler_t

Constructor & Destructor Documentation

§ basic_coroutine() [1/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( )
default

§ basic_coroutine() [2/26]

template<typename base_t >
template<typename T , meta::enable< meta::neg< std::is_same< meta::unqualified_t< T >, basic_coroutine >>, meta::neg< std::is_base_of< proxy_base_tag, meta::unqualified_t< T >>>, meta::neg< std::is_same< base_t, stack_reference >>, meta::neg< std::is_same< lua_nil_t, meta::unqualified_t< T >>>, is_lua_reference< meta::unqualified_t< T >>> = meta::enabler>
sol::basic_coroutine< base_t >::basic_coroutine ( T &&  r)
inlinenoexcept
21952  : base_t(std::forward<T>(r)), error_handler(detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
21953 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
21954  if (!is_function<meta::unqualified_t<T>>::value) {
21955  auto pp = stack::push_pop(*this);
21956  constructor_handler handler{};
21957  stack::check<basic_coroutine>(lua_state(), -1, handler);
21958  }
21959 #endif // Safety
21960  }
handler_t error_handler
Definition: sol.hpp:21898
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101
push_popper< top_level, T > push_pop(T &&x)
Definition: sol.hpp:6661

§ basic_coroutine() [3/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( const basic_coroutine< base_t > &  )
default

§ basic_coroutine() [4/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( basic_coroutine< base_t > &&  )
default

§ basic_coroutine() [5/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( const basic_function< base_t > &  b)
inline
21966  : basic_coroutine(b, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(b.lua_state())) {
21967  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [6/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( basic_function< base_t > &&  b)
inline
21969  : basic_coroutine(std::move(b), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(b.lua_state())) {
21970  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [7/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( const basic_function< base_t > &  b,
handler_t  eh 
)
inline
21972  : base_t(b), error_handler(std::move(eh)) {
21973  }
handler_t error_handler
Definition: sol.hpp:21898

§ basic_coroutine() [8/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( basic_function< base_t > &&  b,
handler_t  eh 
)
inline
21975  : base_t(std::move(b)), error_handler(std::move(eh)) {
21976  }
handler_t error_handler
Definition: sol.hpp:21898

§ basic_coroutine() [9/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( const stack_reference r)
inline
21978  : basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
21979  }
basic_coroutine()=default

§ basic_coroutine() [10/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( stack_reference &&  r)
inline
21981  : basic_coroutine(r.lua_state(), r.stack_index(), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(r.lua_state())) {
21982  }
basic_coroutine()=default

§ basic_coroutine() [11/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( const stack_reference r,
handler_t  eh 
)
inline
21984  : basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
21985  }
basic_coroutine()=default

§ basic_coroutine() [12/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( stack_reference &&  r,
handler_t  eh 
)
inline
21987  : basic_coroutine(r.lua_state(), r.stack_index(), std::move(eh)) {
21988  }
basic_coroutine()=default

§ basic_coroutine() [13/26]

template<typename base_t >
template<typename Super >
sol::basic_coroutine< base_t >::basic_coroutine ( const proxy_base< Super > &  p)
inline
21992  : basic_coroutine(p, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
21993  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [14/26]

template<typename base_t >
template<typename Super >
sol::basic_coroutine< base_t >::basic_coroutine ( proxy_base< Super > &&  p)
inline
21996  : basic_coroutine(std::move(p), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(p.lua_state())) {
21997  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [15/26]

template<typename base_t >
template<typename Proxy , typename Handler , meta::enable< std::is_base_of< proxy_base_tag, meta::unqualified_t< Proxy >>, meta::neg< is_lua_index< meta::unqualified_t< Handler >>>> = meta::enabler>
sol::basic_coroutine< base_t >::basic_coroutine ( Proxy &&  p,
Handler &&  eh 
)
inline
22000  : basic_coroutine(detail::force_cast<base_t>(p), std::forward<Handler>(eh)) {
22001  }
basic_coroutine()=default

§ basic_coroutine() [16/26]

template<typename base_t >
template<typename T , meta::enable< is_lua_reference< meta::unqualified_t< T >>> = meta::enabler>
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
T &&  r 
)
inline
22005  : basic_coroutine(L, std::forward<T>(r), detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
22006  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [17/26]

template<typename base_t >
template<typename T , meta::enable< is_lua_reference< meta::unqualified_t< T >>> = meta::enabler>
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
T &&  r,
handler_t  eh 
)
inline
22009  : base_t(L, std::forward<T>(r)), error_handler(std::move(eh)) {
22010 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
22011  auto pp = stack::push_pop(*this);
22012  constructor_handler handler{};
22013  stack::check<basic_coroutine>(lua_state(), -1, handler);
22014 #endif // Safety
22015  }
handler_t error_handler
Definition: sol.hpp:21898
push_popper< top_level, T > push_pop(T &&x)
Definition: sol.hpp:6661

§ basic_coroutine() [18/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_nil_t  n)
inline
22018  : base_t(n), error_handler(n) {
22019  }
handler_t error_handler
Definition: sol.hpp:21898

§ basic_coroutine() [19/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
int  index = -1 
)
inline
22022  : basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
22023  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [20/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
int  index,
handler_t  eh 
)
inline
22025  : base_t(L, index), error_handler(std::move(eh)) {
22026 #ifdef SOL_SAFE_REFERENCES
22027  constructor_handler handler{};
22028  stack::check<basic_coroutine>(L, index, handler);
22029 #endif // Safety
22030  }
handler_t error_handler
Definition: sol.hpp:21898

§ basic_coroutine() [21/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
absolute_index  index 
)
inline
22032  : basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
22033  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [22/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
absolute_index  index,
handler_t  eh 
)
inline
22035  : base_t(L, index), error_handler(std::move(eh)) {
22036 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
22037  constructor_handler handler{};
22038  stack::check<basic_coroutine>(L, index, handler);
22039 #endif // Safety
22040  }
handler_t error_handler
Definition: sol.hpp:21898

§ basic_coroutine() [23/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
raw_index  index 
)
inline
22042  : basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
22043  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [24/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
raw_index  index,
handler_t  eh 
)
inline
22045  : base_t(L, index), error_handler(std::move(eh)) {
22046 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
22047  constructor_handler handler{};
22048  stack::check<basic_coroutine>(L, index, handler);
22049 #endif // Safety
22050  }
handler_t error_handler
Definition: sol.hpp:21898

§ basic_coroutine() [25/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
ref_index  index 
)
inline
22052  : basic_coroutine(L, index, detail::get_default_handler<reference, is_main_threaded<base_t>::value>(L)) {
22053  }
basic_coroutine()=default
basic_reference< false > reference
Definition: sol.hpp:267
static Reference get_default_handler(lua_State *L)
Definition: sol.hpp:15101

§ basic_coroutine() [26/26]

template<typename base_t >
sol::basic_coroutine< base_t >::basic_coroutine ( lua_State *  L,
ref_index  index,
handler_t  eh 
)
inline
22055  : base_t(L, index), error_handler(std::move(eh)) {
22056 #if defined(SOL_SAFE_REFERENCES) && SOL_SAFE_REFERENCES
22057  auto pp = stack::push_pop(*this);
22058  constructor_handler handler{};
22059  stack::check<basic_coroutine>(lua_state(), -1, handler);
22060 #endif // Safety
22061  }
handler_t error_handler
Definition: sol.hpp:21898
push_popper< top_level, T > push_pop(T &&x)
Definition: sol.hpp:6661

Member Function Documentation

§ call()

template<typename base_t >
template<typename... Ret, typename... Args>
decltype(auto) sol::basic_coroutine< base_t >::call ( Args &&...  args)
inline
22092  {
22093  // some users screw up coroutine.create
22094  // and try to use it with sol::coroutine without ever calling the first resume in Lua
22095  // this makes the stack incompatible with other kinds of stacks: protect against this
22096  // make sure coroutines don't screw us over
22097  base_t::push();
22098  int pushcount = stack::multi_push_reference(lua_state(), std::forward<Args>(args)...);
22099  return invoke(types<Ret...>(), std::make_index_sequence<sizeof...(Ret)>(), pushcount);
22100  }
int multi_push_reference(lua_State *)
Definition: sol.hpp:7802
auto invoke(types< Ret... >, std::index_sequence< I... >, std::ptrdiff_t n)
Definition: sol.hpp:21913
int push(lua_State *L, Arg &&arg, Args &&... args)
Definition: sol.hpp:7776

§ error()

template<typename base_t >
bool sol::basic_coroutine< base_t >::error ( ) const
inlinenoexcept
22067  {
22068  call_status cs = status();
22069  return cs != call_status::ok && cs != call_status::yielded;
22070  }
call_status status() const noexcept
Definition: sol.hpp:22063
call_status
Definition: sol.hpp:5144

§ invoke() [1/4]

template<typename base_t >
template<std::size_t... I, typename... Ret>
auto sol::basic_coroutine< base_t >::invoke ( types< Ret... >  ,
std::index_sequence< I... >  ,
std::ptrdiff_t  n 
)
inlineprivate
21913  {
21914  luacall(n, sizeof...(Ret));
21915  return stack::pop<std::tuple<Ret...>>(lua_state());
21916  }
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t)
Definition: sol.hpp:21903
decltype(auto) pop(lua_State *L)
Definition: sol.hpp:8064

§ invoke() [2/4]

template<typename base_t >
template<std::size_t I, typename Ret >
Ret sol::basic_coroutine< base_t >::invoke ( types< Ret >  ,
std::index_sequence< I >  ,
std::ptrdiff_t  n 
)
inlineprivate
21919  {
21920  luacall(n, 1);
21921  return stack::pop<Ret>(lua_state());
21922  }
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t)
Definition: sol.hpp:21903

§ invoke() [3/4]

template<typename base_t >
template<std::size_t I>
void sol::basic_coroutine< base_t >::invoke ( types< void >  ,
std::index_sequence< I >  ,
std::ptrdiff_t  n 
)
inlineprivate
21925  {
21926  luacall(n, 0);
21927  }
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t)
Definition: sol.hpp:21903

§ invoke() [4/4]

template<typename base_t >
protected_function_result sol::basic_coroutine< base_t >::invoke ( types<>  ,
std::index_sequence<>  ,
std::ptrdiff_t  n 
)
inlineprivate
21929  {
21930  int firstreturn = 1;
21931  luacall(n, LUA_MULTRET);
21932  int poststacksize = lua_gettop(this->lua_state());
21933  int returncount = poststacksize - (firstreturn - 1);
21934  if (error()) {
21935  if (error_handler.valid()) {
21936  string_view err = stack::get<string_view>(this->lua_state(), poststacksize);
21937  error_handler.push();
21938  stack::push(this->lua_state(), err);
21939  lua_call(lua_state(), 1, 1);
21940  }
21941  return protected_function_result(this->lua_state(), lua_absindex(this->lua_state(), -1), 1, returncount, status());
21942  }
21943  return protected_function_result(this->lua_state(), firstreturn, returncount, returncount, status());
21944  }
handler_t error_handler
Definition: sol.hpp:21898
bool valid() const noexcept
Definition: sol.hpp:6965
void luacall(std::ptrdiff_t argcount, std::ptrdiff_t)
Definition: sol.hpp:21903
bool error() const noexcept
Definition: sol.hpp:22067
int push(lua_State *L, T &&t, Args &&... args)
Definition: sol.hpp:7770
call_status status() const noexcept
Definition: sol.hpp:22063
int push() const noexcept
Definition: sol.hpp:6937
basic_string_view< char > string_view
Definition: sol.hpp:1186

§ luacall()

template<typename base_t >
void sol::basic_coroutine< base_t >::luacall ( std::ptrdiff_t  argcount,
std::ptrdiff_t   
)
inlineprivate
21903  {
21904 #if SOL_LUA_VERSION >= 504
21905  int nres;
21906  stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount), &nres));
21907 #else
21908  stats = static_cast<call_status>(lua_resume(lua_state(), nullptr, static_cast<int>(argcount)));
21909 #endif
21910  }
call_status
Definition: sol.hpp:5144
call_status stats
Definition: sol.hpp:21901

§ operator bool()

template<typename base_t >
sol::basic_coroutine< base_t >::operator bool ( ) const
inlineexplicitnoexcept
22077  {
22078  return runnable();
22079  }
bool runnable() const noexcept
Definition: sol.hpp:22072

§ operator()() [1/2]

template<typename base_t >
template<typename... Args>
protected_function_result sol::basic_coroutine< base_t >::operator() ( Args &&...  args)
inline
22082  {
22083  return call<>(std::forward<Args>(args)...);
22084  }

§ operator()() [2/2]

template<typename base_t >
template<typename... Ret, typename... Args>
decltype(auto) sol::basic_coroutine< base_t >::operator() ( types< Ret... >  ,
Args &&...  args 
)
inline
22087  {
22088  return call<Ret...>(std::forward<Args>(args)...);
22089  }
decltype(auto) call(Args &&... args)
Definition: sol.hpp:22092

§ operator=() [1/2]

template<typename base_t >
basic_coroutine& sol::basic_coroutine< base_t >::operator= ( const basic_coroutine< base_t > &  )
default

§ operator=() [2/2]

template<typename base_t >
basic_coroutine& sol::basic_coroutine< base_t >::operator= ( basic_coroutine< base_t > &&  )
default

§ runnable()

template<typename base_t >
bool sol::basic_coroutine< base_t >::runnable ( ) const
inlinenoexcept
22072  {
22073  return base_t::valid()
22074  && (status() == call_status::yielded);
22075  }
call_status status() const noexcept
Definition: sol.hpp:22063

§ status()

template<typename base_t >
call_status sol::basic_coroutine< base_t >::status ( ) const
inlinenoexcept
22063  {
22064  return stats;
22065  }
call_status stats
Definition: sol.hpp:21901

Member Data Documentation

§ error_handler

template<typename base_t >
handler_t sol::basic_coroutine< base_t >::error_handler

§ stats

template<typename base_t >
call_status sol::basic_coroutine< base_t >::stats = call_status::yielded
private

The documentation for this class was generated from the following file: