OpenMiner  0.0.1a
Voxel game engine
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
sol::basic_reference< main_only > Class Template Reference

#include <sol.hpp>

Inheritance diagram for sol::basic_reference< main_only >:
sol::basic_object_base< reference > sol::basic_object< reference >

Public Member Functions

 basic_reference () noexcept=default
 
 basic_reference (lua_nil_t) noexcept
 
 basic_reference (const stack_reference &r) noexcept
 
 basic_reference (stack_reference &&r) noexcept
 
template<bool r_main_only>
 basic_reference (lua_State *L, const basic_reference< r_main_only > &r) noexcept
 
template<bool r_main_only>
 basic_reference (lua_State *L, basic_reference< r_main_only > &&r) noexcept
 
 basic_reference (lua_State *L, const stack_reference &r) noexcept
 
 basic_reference (lua_State *L, int index=-1) noexcept
 
 basic_reference (lua_State *L, ref_index index) noexcept
 
 basic_reference (lua_State *L, lua_nil_t) noexcept
 
 ~basic_reference () noexcept
 
 basic_reference (const basic_reference &o) noexcept
 
 basic_reference (basic_reference &&o) noexcept
 
 basic_reference (const basic_reference<!main_only > &o) noexcept
 
 basic_reference (basic_reference<!main_only > &&o) noexcept
 
basic_referenceoperator= (basic_reference &&r) noexcept
 
basic_referenceoperator= (const basic_reference &r) noexcept
 
basic_referenceoperator= (basic_reference<!main_only > &&r) noexcept
 
basic_referenceoperator= (const basic_reference<!main_only > &r) noexcept
 
basic_referenceoperator= (const lua_nil_t &) noexcept
 
template<typename Super >
basic_referenceoperator= (proxy_base< Super > &&r)
 
template<typename Super >
basic_referenceoperator= (const proxy_base< Super > &r)
 
int push () const noexcept
 
int push (lua_State *Ls) const noexcept
 
void pop () const noexcept
 
void pop (lua_State *Ls, int n=1) const noexcept
 
int registry_index () const noexcept
 
bool valid () const noexcept
 
const void * pointer () const noexcept
 
 operator bool () const noexcept
 
type get_type () const noexcept
 
lua_State * lua_state () const noexcept
 
template<typename Super >
basic_reference< b > & operator= (proxy_base< Super > &&r)
 
template<typename Super >
basic_reference< b > & operator= (const proxy_base< Super > &r)
 

Protected Member Functions

 basic_reference (lua_State *L, detail::global_tag) noexcept
 
int stack_index () const noexcept
 
void deref () const noexcept
 

Private Member Functions

int copy () const noexcept
 
template<bool r_main_only>
void copy_assign (const basic_reference< r_main_only > &r)
 
template<bool r_main_only>
void move_assign (basic_reference< r_main_only > &&r)
 

Private Attributes

lua_State * luastate = nullptr
 
int ref = LUA_NOREF
 

Friends

template<bool o_main_only>
class basic_reference
 

Constructor & Destructor Documentation

§ basic_reference() [1/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( lua_State *  L,
detail::global_tag   
)
inlineprotectednoexcept
6781  : luastate(detail::pick_main_thread<main_only>(L, L)) {
6782  lua_pushglobaltable(lua_state());
6783  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6784  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ basic_reference() [2/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( )
defaultnoexcept

§ basic_reference() [3/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( lua_nil_t  )
inlinenoexcept
6797  : basic_reference() {
6798  }
basic_reference() noexcept=default

§ basic_reference() [4/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( const stack_reference r)
inlinenoexcept
6800  : basic_reference(r.lua_state(), r.stack_index()) {
6801  }
basic_reference() noexcept=default

§ basic_reference() [5/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( stack_reference &&  r)
inlinenoexcept
6803  : basic_reference(r.lua_state(), r.stack_index()) {
6804  }
basic_reference() noexcept=default

§ basic_reference() [6/15]

template<bool main_only = false>
template<bool r_main_only>
sol::basic_reference< main_only >::basic_reference ( lua_State *  L,
const basic_reference< r_main_only > &  r 
)
inlinenoexcept
6807  : luastate(detail::pick_main_thread<main_only>(L, L)) {
6808  if (r.ref == LUA_REFNIL) {
6809  ref = LUA_REFNIL;
6810  return;
6811  }
6812  if (r.ref == LUA_NOREF || lua_state() == nullptr) {
6813  ref = LUA_NOREF;
6814  return;
6815  }
6816  if (detail::xmovable(lua_state(), r.lua_state())) {
6817  r.push(lua_state());
6818  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6819  return;
6820  }
6821  ref = r.copy();
6822  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718
bool xmovable(lua_State *leftL, lua_State *rightL)
Definition: sol.hpp:6435
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ basic_reference() [7/15]

template<bool main_only = false>
template<bool r_main_only>
sol::basic_reference< main_only >::basic_reference ( lua_State *  L,
basic_reference< r_main_only > &&  r 
)
inlinenoexcept
6826  : luastate(detail::pick_main_thread<main_only>(L, L)) {
6827  if (r.ref == LUA_REFNIL) {
6828  ref = LUA_REFNIL;
6829  return;
6830  }
6831  if (r.ref == LUA_NOREF || lua_state() == nullptr) {
6832  ref = LUA_NOREF;
6833  return;
6834  }
6835  if (detail::xmovable(lua_state(), r.lua_state())) {
6836  r.push(lua_state());
6837  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6838  return;
6839  }
6840  ref = r.ref;
6841  r.ref = LUA_NOREF;
6842  r.luastate = nullptr;
6843  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718
bool xmovable(lua_State *leftL, lua_State *rightL)
Definition: sol.hpp:6435
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ basic_reference() [8/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( lua_State *  L,
const stack_reference r 
)
inlinenoexcept
6846  : luastate(detail::pick_main_thread<main_only>(L, L)) {
6847  if (lua_state() == nullptr || r.lua_state() == nullptr || r.get_type() == type::none) {
6848  ref = LUA_NOREF;
6849  return;
6850  }
6851  if (r.get_type() == type::lua_nil) {
6852  ref = LUA_REFNIL;
6853  return;
6854  }
6855  if (lua_state() != r.lua_state() && !detail::xmovable(lua_state(), r.lua_state())) {
6856  return;
6857  }
6858  r.push(lua_state());
6859  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6860  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718
bool xmovable(lua_State *leftL, lua_State *rightL)
Definition: sol.hpp:6435
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ basic_reference() [9/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( lua_State *  L,
int  index = -1 
)
inlinenoexcept
6862  : luastate(detail::pick_main_thread<main_only>(L, L)) {
6863  // use L to stick with that state's execution stack
6864  lua_pushvalue(L, index);
6865  ref = luaL_ref(L, LUA_REGISTRYINDEX);
6866  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718

§ basic_reference() [10/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( lua_State *  L,
ref_index  index 
)
inlinenoexcept
6868  : luastate(detail::pick_main_thread<main_only>(L, L)) {
6869  lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, index.index);
6870  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6871  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ basic_reference() [11/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( lua_State *  L,
lua_nil_t   
)
inlinenoexcept
6873  : luastate(detail::pick_main_thread<main_only>(L, L)) {
6874  }
lua_State * luastate
Definition: sol.hpp:6718

§ ~basic_reference()

template<bool main_only = false>
sol::basic_reference< main_only >::~basic_reference ( )
inlinenoexcept
6876  {
6877  if (lua_state() == nullptr || ref == LUA_NOREF)
6878  return;
6879  deref();
6880  }
int ref
Definition: sol.hpp:6719
void deref() const noexcept
Definition: sol.hpp:6790
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ basic_reference() [12/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( const basic_reference< main_only > &  o)
inlinenoexcept
6883  : luastate(o.lua_state()), ref(o.copy()) {
6884  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718

§ basic_reference() [13/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( basic_reference< main_only > &&  o)
inlinenoexcept
6887  : luastate(o.lua_state()), ref(o.ref) {
6888  o.luastate = nullptr;
6889  o.ref = LUA_NOREF;
6890  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718

§ basic_reference() [14/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( const basic_reference<!main_only > &  o)
inlinenoexcept
6893  : luastate(detail::pick_main_thread < main_only && !main_only > (o.lua_state(), o.lua_state())), ref(o.copy()) {
6894  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718

§ basic_reference() [15/15]

template<bool main_only = false>
sol::basic_reference< main_only >::basic_reference ( basic_reference<!main_only > &&  o)
inlinenoexcept
6897  : luastate(detail::pick_main_thread < main_only && !main_only > (o.lua_state(), o.lua_state())), ref(o.ref) {
6898  o.luastate = nullptr;
6899  o.ref = LUA_NOREF;
6900  }
int ref
Definition: sol.hpp:6719
lua_State * luastate
Definition: sol.hpp:6718

Member Function Documentation

§ copy()

template<bool main_only = false>
int sol::basic_reference< main_only >::copy ( ) const
inlineprivatenoexcept
6721  {
6722  if (ref == LUA_NOREF)
6723  return LUA_NOREF;
6724  push();
6725  return luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6726  }
int ref
Definition: sol.hpp:6719
int push() const noexcept
Definition: sol.hpp:6937
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ copy_assign()

template<bool main_only = false>
template<bool r_main_only>
void sol::basic_reference< main_only >::copy_assign ( const basic_reference< r_main_only > &  r)
inlineprivate
6729  {
6730  if (valid()) {
6731  deref();
6732  }
6733  if (r.ref == LUA_REFNIL) {
6734  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
6735  ref = LUA_REFNIL;
6736  return;
6737  }
6738  if (r.ref == LUA_NOREF) {
6739  luastate = r.luastate;
6740  ref = LUA_NOREF;
6741  return;
6742  }
6743  if (detail::xmovable(lua_state(), r.lua_state())) {
6744  r.push(lua_state());
6745  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6746  return;
6747  }
6748  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
6749  ref = r.copy();
6750  }
int ref
Definition: sol.hpp:6719
bool valid() const noexcept
Definition: sol.hpp:6965
void deref() const noexcept
Definition: sol.hpp:6790
lua_State * luastate
Definition: sol.hpp:6718
bool xmovable(lua_State *leftL, lua_State *rightL)
Definition: sol.hpp:6435
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ deref()

template<bool main_only = false>
void sol::basic_reference< main_only >::deref ( ) const
inlineprotectednoexcept
6790  {
6791  luaL_unref(lua_state(), LUA_REGISTRYINDEX, ref);
6792  }
int ref
Definition: sol.hpp:6719
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ get_type()

template<bool main_only = false>
type sol::basic_reference< main_only >::get_type ( ) const
inlinenoexcept
6980  {
6981  auto pp = stack::push_pop(*this);
6982  int result = lua_type(lua_state(), -1);
6983  return static_cast<type>(result);
6984  }
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986
push_popper< top_level, T > push_pop(T &&x)
Definition: sol.hpp:6661

§ lua_state()

template<bool main_only = false>
lua_State* sol::basic_reference< main_only >::lua_state ( ) const
inlinenoexcept
6986  {
6987  return luastate;
6988  }
lua_State * luastate
Definition: sol.hpp:6718

§ move_assign()

template<bool main_only = false>
template<bool r_main_only>
void sol::basic_reference< main_only >::move_assign ( basic_reference< r_main_only > &&  r)
inlineprivate
6753  {
6754  if (valid()) {
6755  deref();
6756  }
6757  if (r.ref == LUA_REFNIL) {
6758  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
6759  ref = LUA_REFNIL;
6760  return;
6761  }
6762  if (r.ref == LUA_NOREF) {
6763  luastate = r.luastate;
6764  ref = LUA_NOREF;
6765  return;
6766  }
6767  if (detail::xmovable(lua_state(), r.lua_state())) {
6768  r.push(lua_state());
6769  ref = luaL_ref(lua_state(), LUA_REGISTRYINDEX);
6770  return;
6771  }
6772 
6773  luastate = detail::pick_main_thread < main_only && !r_main_only > (r.lua_state(), r.lua_state());
6774  ref = r.ref;
6775  r.ref = LUA_NOREF;
6776  r.luastate = nullptr;
6777  }
int ref
Definition: sol.hpp:6719
bool valid() const noexcept
Definition: sol.hpp:6965
void deref() const noexcept
Definition: sol.hpp:6790
lua_State * luastate
Definition: sol.hpp:6718
bool xmovable(lua_State *leftL, lua_State *rightL)
Definition: sol.hpp:6435
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ operator bool()

template<bool main_only = false>
sol::basic_reference< main_only >::operator bool ( ) const
inlineexplicitnoexcept
6976  {
6977  return valid();
6978  }
bool valid() const noexcept
Definition: sol.hpp:6965

§ operator=() [1/9]

template<bool main_only = false>
basic_reference& sol::basic_reference< main_only >::operator= ( basic_reference< main_only > &&  r)
inlinenoexcept
6902  {
6903  move_assign(std::move(r));
6904  return *this;
6905  }
void move_assign(basic_reference< r_main_only > &&r)
Definition: sol.hpp:6753

§ operator=() [2/9]

template<bool main_only = false>
basic_reference& sol::basic_reference< main_only >::operator= ( const basic_reference< main_only > &  r)
inlinenoexcept
6907  {
6908  copy_assign(r);
6909  return *this;
6910  }
void copy_assign(const basic_reference< r_main_only > &r)
Definition: sol.hpp:6729

§ operator=() [3/9]

template<bool main_only = false>
basic_reference& sol::basic_reference< main_only >::operator= ( basic_reference<!main_only > &&  r)
inlinenoexcept
6912  {
6913  move_assign(std::move(r));
6914  return *this;
6915  }
void move_assign(basic_reference< r_main_only > &&r)
Definition: sol.hpp:6753

§ operator=() [4/9]

template<bool main_only = false>
basic_reference& sol::basic_reference< main_only >::operator= ( const basic_reference<!main_only > &  r)
inlinenoexcept
6917  {
6918  copy_assign(r);
6919  return *this;
6920  }
void copy_assign(const basic_reference< r_main_only > &r)
Definition: sol.hpp:6729

§ operator=() [5/9]

template<bool main_only = false>
basic_reference& sol::basic_reference< main_only >::operator= ( const lua_nil_t )
inlinenoexcept
6922  {
6923  if (valid()) {
6924  deref();
6925  }
6926  luastate = nullptr;
6927  ref = LUA_NOREF;
6928  return *this;
6929  }
int ref
Definition: sol.hpp:6719
bool valid() const noexcept
Definition: sol.hpp:6965
void deref() const noexcept
Definition: sol.hpp:6790
lua_State * luastate
Definition: sol.hpp:6718

§ operator=() [6/9]

template<bool main_only = false>
template<typename Super >
basic_reference& sol::basic_reference< main_only >::operator= ( proxy_base< Super > &&  r)

§ operator=() [7/9]

template<bool main_only = false>
template<typename Super >
basic_reference& sol::basic_reference< main_only >::operator= ( const proxy_base< Super > &  r)

§ operator=() [8/9]

template<bool main_only = false>
template<typename Super >
basic_reference<b>& sol::basic_reference< main_only >::operator= ( proxy_base< Super > &&  r)
15706  {
15707  basic_reference<b> v = r;
15708  this->operator=(std::move(v));
15709  return *this;
15710  }
basic_reference & operator=(basic_reference &&r) noexcept
Definition: sol.hpp:6902

§ operator=() [9/9]

template<bool main_only = false>
template<typename Super >
basic_reference<b>& sol::basic_reference< main_only >::operator= ( const proxy_base< Super > &  r)
15714  {
15715  basic_reference<b> v = r;
15716  this->operator=(std::move(v));
15717  return *this;
15718  }
basic_reference & operator=(basic_reference &&r) noexcept
Definition: sol.hpp:6902

§ pointer()

template<bool main_only = false>
const void* sol::basic_reference< main_only >::pointer ( ) const
inlinenoexcept
6969  {
6970  int si = push();
6971  const void* vp = lua_topointer(lua_state(), -si);
6972  lua_pop(this->lua_state(), si);
6973  return vp;
6974  }
int push() const noexcept
Definition: sol.hpp:6937
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ pop() [1/2]

template<bool main_only = false>
void sol::basic_reference< main_only >::pop ( ) const
inlinenoexcept
6953  {
6954  pop(lua_state());
6955  }
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986
void pop() const noexcept
Definition: sol.hpp:6953

§ pop() [2/2]

template<bool main_only = false>
void sol::basic_reference< main_only >::pop ( lua_State *  Ls,
int  n = 1 
) const
inlinenoexcept
6957  {
6958  lua_pop(Ls, n);
6959  }

§ push() [1/2]

template<bool main_only = false>
int sol::basic_reference< main_only >::push ( ) const
inlinenoexcept
6937  {
6938  return push(lua_state());
6939  }
int push() const noexcept
Definition: sol.hpp:6937
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ push() [2/2]

template<bool main_only = false>
int sol::basic_reference< main_only >::push ( lua_State *  Ls) const
inlinenoexcept
6941  {
6942  if (lua_state() == nullptr) {
6943  lua_pushnil(Ls);
6944  return 1;
6945  }
6946  lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, ref);
6947  if (Ls != lua_state()) {
6948  lua_xmove(lua_state(), Ls, 1);
6949  }
6950  return 1;
6951  }
int ref
Definition: sol.hpp:6719
lua_State * lua_state() const noexcept
Definition: sol.hpp:6986

§ registry_index()

template<bool main_only = false>
int sol::basic_reference< main_only >::registry_index ( ) const
inlinenoexcept
6961  {
6962  return ref;
6963  }
int ref
Definition: sol.hpp:6719

§ stack_index()

template<bool main_only = false>
int sol::basic_reference< main_only >::stack_index ( ) const
inlineprotectednoexcept
6786  {
6787  return -1;
6788  }

§ valid()

template<bool main_only = false>
bool sol::basic_reference< main_only >::valid ( ) const
inlinenoexcept
6965  {
6966  return !(ref == LUA_NOREF || ref == LUA_REFNIL);
6967  }
int ref
Definition: sol.hpp:6719

Friends And Related Function Documentation

§ basic_reference

template<bool main_only = false>
template<bool o_main_only>
friend class basic_reference
friend

Member Data Documentation

§ luastate

template<bool main_only = false>
lua_State* sol::basic_reference< main_only >::luastate = nullptr
private

§ ref

template<bool main_only = false>
int sol::basic_reference< main_only >::ref = LUA_NOREF
private

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