Loading...
Searching...
No Matches
state.hpp
Go to the documentation of this file.
// Copyright 2011 Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of Google Inc. nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if !defined(LUTOK_STATE_HPP)
#define LUTOK_STATE_HPP
#include <memory>
#include <string>
namespace lutok {
class debug;
class state;
typedef int (*cxx_function)(state&);
extern const int registry_index;
class state {
struct impl;
std::shared_ptr< impl > _pimpl;
void* new_userdata_voidp(const size_t);
void* to_userdata_voidp(const int);
friend class state_c_gate;
explicit state(void*);
void* raw_state(void);
public:
state(void);
~state(void);
void close(void);
void get_global(const std::string&);
void get_global_table(void);
bool get_metafield(const int, const std::string&);
bool get_metatable(const int);
void get_table(const int);
int get_top(void);
void insert(const int);
bool is_boolean(const int);
bool is_function(const int);
bool is_nil(const int);
bool is_number(const int);
bool is_string(const int);
bool is_table(const int);
bool is_userdata(const int);
void load_file(const std::string&);
void load_string(const std::string&);
void new_table(void);
template< typename Type > Type* new_userdata(void);
bool next(const int);
void open_all(void);
void open_base(void);
void open_string(void);
void open_table(void);
void pcall(const int, const int, const int);
void pop(const int);
void push_boolean(const bool);
void push_cxx_closure(cxx_function, const int);
void push_cxx_function(cxx_function);
void push_integer(const int);
void push_nil(void);
void push_string(const std::string&);
void push_value(const int);
void raw_get(const int);
void raw_set(const int);
void set_global(const std::string&);
void set_metatable(const int);
void set_table(const int);
bool to_boolean(const int);
long to_integer(const int);
template< typename Type > Type* to_userdata(const int);
std::string to_string(const int);
int upvalue_index(const int);
};
} // namespace lutok
#endif // !defined(LUTOK_STATE_HPP)
lutok::cxx_function
int(* cxx_function)(state &)
The type of a C++ function that can be bound into Lua.
Definition state.hpp:50
lutok::registry_index
const int registry_index
Stack index constant pointing to the registry table.
Definition state.cpp:215
lutok::debug
A model for the Lua debug state.
Definition debug.hpp:54
lutok::state::impl
Internal implementation for lutok::state.
Definition state.cpp:219
lutok::state
A RAII model for the Lua state.
Definition state.hpp:71
lutok::state::get_global
void get_global(const std::string &)
Wrapper around lua_getglobal.
Definition state.cpp:302
lutok::state::get_metafield
bool get_metafield(const int, const std::string &)
Wrapper around luaL_getmetafield.
Definition state.cpp:341
lutok::state::to_userdata
Type * to_userdata(const int)
Wrapper around lua_touserdata.
Definition state.ipp:59
lutok::state::push_cxx_closure
void push_cxx_closure(cxx_function, const int)
Wrapper around lua_pushcclosure.
Definition state.cpp:680
lutok::state::push_boolean
void push_boolean(const bool)
Wrapper around lua_pushboolean.
Definition state.cpp:666
lutok::state::upvalue_index
int upvalue_index(const int)
Wrapper around lua_upvalueindex.
Definition state.cpp:888
lutok::state::close
void close(void)
Terminates this Lua session.
Definition state.cpp:284
lutok::state::is_nil
bool is_nil(const int)
Wrapper around lua_isnil.
Definition state.cpp:430
lutok::state::get_global_table
void get_global_table(void)
Pushes a reference to the global table onto the stack.
Definition state.cpp:318
lutok::state::~state
~state(void)
Destructor for the Lua state.
Definition state.cpp:268
lutok::state::raw_state
void * raw_state(void)
Gets the internal lua_State object.
Definition state.cpp:901
lutok::state::pcall
void pcall(const int, const int, const int)
Wrapper around lua_pcall.
Definition state.cpp:643
lutok::state::to_boolean
bool to_boolean(const int)
Wrapper around lua_toboolean.
Definition state.cpp:825
lutok::state::to_userdata_voidp
void * to_userdata_voidp(const int)
Wrapper around lua_touserdata.
Definition state.cpp:856
lutok::state::is_table
bool is_table(const int)
Wrapper around lua_istable.
Definition state.cpp:466
lutok::state::_pimpl
std::shared_ptr< impl > _pimpl
Pointer to the shared internal implementation.
Definition state.hpp:75
lutok::state::push_value
void push_value(const int)
Wrapper around lua_pushvalue.
Definition state.cpp:739
lutok::state::load_file
void load_file(const std::string &)
Wrapper around luaL_loadfile.
Definition state.cpp:493
lutok::state::is_boolean
bool is_boolean(const int)
Wrapper around lua_isboolean.
Definition state.cpp:406
lutok::state::new_table
void new_table(void)
Wrapper around lua_newtable.
Definition state.cpp:521
lutok::state::state
state(void *)
Initializes the Lua state from an existing raw state.
Definition state.cpp:257
lutok::state::push_integer
void push_integer(const int)
Wrapper around lua_pushinteger.
Definition state.cpp:709
lutok::state::new_userdata_voidp
void * new_userdata_voidp(const size_t)
Wrapper around lua_newuserdata.
Definition state.cpp:538
lutok::state::load_string
void load_string(const std::string &)
Wrapper around luaL_loadstring.
Definition state.cpp:510
lutok::state::insert
void insert(const int)
Wrapper around lua_insert.
Definition state.cpp:394
lutok::state::push_nil
void push_nil(void)
Wrapper around lua_pushnil.
Definition state.cpp:717
lutok::state::open_string
void open_string(void)
Wrapper around luaopen_string.
Definition state.cpp:603
lutok::state::get_table
void get_table(const int)
Wrapper around lua_gettable.
Definition state.cpp:368
lutok::state::open_table
void open_table(void)
Wrapper around luaopen_table.
Definition state.cpp:622
lutok::state::push_string
void push_string(const std::string &)
Wrapper around lua_pushstring.
Definition state.cpp:729
lutok::state::open_all
void open_all(void)
Wrapper around luaL_openlibs.
Definition state.cpp:577
lutok::state::set_metatable
void set_metatable(const int)
Wrapper around lua_setmetatable.
Definition state.cpp:792
lutok::state::to_string
std::string to_string(const int)
Wrapper around lua_tostring.
Definition state.cpp:871
lutok::state::raw_set
void raw_set(const int)
Wrapper around lua_rawset.
Definition state.cpp:762
lutok::state::new_userdata
Type * new_userdata(void)
Wrapper around lua_newuserdata.
Definition state.ipp:46
lutok::state::is_function
bool is_function(const int)
Wrapper around lua_isfunction.
Definition state.cpp:418
lutok::state::get_metatable
bool get_metatable(const int)
Wrapper around lua_getmetatable.
Definition state.cpp:353
lutok::state::next
bool next(const int)
Wrapper around lua_next.
Definition state.cpp:552
lutok::state::open_base
void open_base(void)
Wrapper around luaopen_base.
Definition state.cpp:589
lutok::state::pop
void pop(const int)
Wrapper around lua_pop.
Definition state.cpp:654
lutok::state::set_table
void set_table(const int)
Wrapper around lua_settable.
Definition state.cpp:807
lutok::state::is_number
bool is_number(const int)
Wrapper around lua_isnumber.
Definition state.cpp:442
lutok::state::raw_get
void raw_get(const int)
Wrapper around lua_rawget.
Definition state.cpp:749
lutok::state::to_integer
long to_integer(const int)
Wrapper around lua_tointeger.
Definition state.cpp:838
lutok::state::is_userdata
bool is_userdata(const int)
Wrapper around lua_isuserdata.
Definition state.cpp:478
lutok::state::push_cxx_function
void push_cxx_function(cxx_function)
Wrapper around lua_pushcfunction.
Definition state.cpp:696
lutok::state::set_global
void set_global(const std::string &)
Wrapper around lua_setglobal.
Definition state.cpp:777
lutok::state::state
state(void)
Initializes the Lua state.
Definition state.cpp:242
lutok::state::is_string
bool is_string(const int)
Wrapper around lua_isstring.
Definition state.cpp:454
lutok::state::get_top
int get_top(void)
Wrapper around lua_gettop.
Definition state.cpp:384