Savarese Software Research Corporation
lua Namespace Reference

The lua namespace contains support functions for interfacing with the embedded Lua environment. More...

Namespaces

namespace  detail

Classes

class  LoadConfig
 Dynamically loads the code necessary to read a configuration file, reads the configuration file, converts it to a properties_ptr, and unloads the code. More...
struct  LuaCallError
class  PropertiesToTable

Typedefs

typedef properties_ptr fun_type (const std::string &)
typedef fun_typefun_ptr

Functions

template<typename R >
convert (lua_State *state, int index=-1)
template<>
bool convert< bool > (lua_State *state, int index)
template<>
int convert< int > (lua_State *state, int index)
template<>
unsigned int convert< unsigned int > (lua_State *state, int index)
template<>
string convert< string > (lua_State *state, int index)
template<>
const char * convert< const char * > (lua_State *state, int index)
template<>
lua_Number convert< lua_Number > (lua_State *state, int index)
void push_value (lua_State *state, const bool value)
void push_value (lua_State *state, const int value)
void push_value (lua_State *state, const lua_Number value)
void push_value (lua_State *state, const char *value)
void push_value (lua_State *state, const string &value)
void push_value (lua_State *state, void *value)
void push_value (lua_State *state, const void *value)
void push_values (lua_State *)
template<typename P >
void push_values (lua_State *state, const P &p)
template<typename T , typename... P>
void push_values (lua_State *state, const T &t, const P &...p)
template<typename V >
void set_field (lua_State *state, int index, const V &value, const char *const field)
template<typename V >
void set_field (lua_State *state, int index, const V &value, const string &field)
template<typename V >
void set_field (lua_State *state, int index, const V &value, int n)
void get_global (lua_State *state, const char *const field)
void get_global (lua_State *state, const string &field)
template<typename V >
void set_global (lua_State *state, const V &value, const char *const field)
template<typename V >
void set_global (lua_State *state, const V &value, const string &field)
template<typename R >
const R get_field (const R &default_value, lua_State *state, int index, const char *const field)
template<typename R >
const R get_field (const R &default_value, lua_State *state, int index, const string &field)
template<typename R >
const R get_field (const R &default_value, lua_State *state, int index, int n)
template<typename R , typename... P>
const R get_field (const R &default_value, lua_State *state, int index, const char *const field, P...p)
template<typename R >
const R get_field (lua_State *state, int index, const char *const field)
template<typename R >
const R get_field (lua_State *state, int index, const string &field)
template<typename R >
const R get_field (lua_State *state, int index, int n)
template<typename R , typename... P>
const R get_field (lua_State *state, int index, const char *const field, P...p)
template<typename R >
const R get_value (const R &default_value, lua_State *state, const char *const var)
template<typename R >
const R get_value (const R &default_value, lua_State *state, const string &var)
template<typename R , typename... P>
const R get_value (const R &default_value, lua_State *state, const char *const var, P...p)
template<typename R >
const R get_value (lua_State *state, const char *const var)
template<typename R >
const R get_value (lua_State *state, const string &var)
template<typename R , typename... P>
const R get_value (lua_State *state, const char *const var, P...p)
template<typename V >
void create_value (lua_State *state, const V &value, const char *const var)
template<typename V >
void create_value (lua_State *state, const V &value, const string &var)
template<typename V , typename... P>
void create_value (lua_State *state, const V &value, const char *const var, P...p)
template<typename V , typename... P>
void set_field (lua_State *state, int index, const V &value, const char *const field, P...p)
template<typename V >
void set_value (lua_State *state, const V &value, const char *const var)
template<typename V >
void set_value (lua_State *state, const V &value, const string &var)
template<typename V , typename... P>
void set_value (lua_State *state, const V &value, const char *const var, P...p)
template<typename I >
void prepend_package_path (lua_State *state, const I &begin, const I &end)
template<typename... P>
void pcall_nopop (const int nargs, const int nresults, lua_State *state, P...p) SSRC_DECL_THROW(LuaCallError)
 Assumes function has already been pushed to top of stack.
template<typename... P>
void pcall_nopop (const int nresults, lua_State *state, P...p) SSRC_DECL_THROW(LuaCallError)
template<typename R , typename... P>
pcall_ret (lua_State *state, const P &...p) SSRC_DECL_THROW(LuaCallError)
 Currently, we support only one return value, but it should be possible to work things out to specify multiple return values and return them via a tuple.
template<typename... P>
void pcall (lua_State *state, const P &...p) SSRC_DECL_THROW(LuaCallError)
template<typename container_type >
void map_to_table (lua_State *state, const container_type &map)
void table_to_properties (lua_State *state, Properties &properties)
 Copies a Lua table into a Properties instance.
void swig_table_to_properties (void *state, Properties &properties)
 This function is a kluge to work around a SWIG library relocation error.
properties_ptr load_properties (lua_State *state, const std::string &filename) SSRC_DECL_THROW(LuaCallError)
properties_ptr load_string_properties (lua_State *state, const std::string &code_str) SSRC_DECL_THROW(LuaCallError)
void properties_to_table (const PropertiesToTable &to_table, const Properties &properties)
void properties_to_table (lua_State *state, const Properties &properties)
 Converts a Properties instance to a Lua table, pushing the resulting table onto the Lua stack.
properties_ptr load_properties (const std::string &filename)
properties_ptr load_string_properties (const std::string &code_str)

Detailed Description

The lua namespace contains support functions for interfacing with the embedded Lua environment.


Typedef Documentation

Definition at line 33 of file LoadConfig.h.

typedef properties_ptr lua::fun_type(const std::string &)

Definition at line 32 of file LoadConfig.h.


Function Documentation

template<typename R >
R lua::convert ( lua_State *  state,
int  index = -1 
) [inline]
template<>
bool lua::convert< bool > ( lua_State *  state,
int  index 
) [inline]

Definition at line 46 of file lua.h.

Referenced by table_to_properties().

template<>
const char* lua::convert< const char * > ( lua_State *  state,
int  index 
) [inline]

Definition at line 65 of file lua.h.

template<>
int lua::convert< int > ( lua_State *  state,
int  index 
) [inline]

Definition at line 50 of file lua.h.

template<>
lua_Number lua::convert< lua_Number > ( lua_State *  state,
int  index 
) [inline]

Definition at line 69 of file lua.h.

Referenced by table_to_properties().

template<>
string lua::convert< string > ( lua_State *  state,
int  index 
) [inline]

Definition at line 59 of file lua.h.

Referenced by table_to_properties().

template<>
unsigned int lua::convert< unsigned int > ( lua_State *  state,
int  index 
) [inline]

Definition at line 55 of file lua.h.

template<typename V >
void lua::create_value ( lua_State *  state,
const V &  value,
const char *const  var 
) [inline]

Definition at line 352 of file lua.h.

References set_global().

template<typename V >
void lua::create_value ( lua_State *  state,
const V &  value,
const string &  var 
) [inline]

Definition at line 359 of file lua.h.

References set_global().

template<typename V , typename... P>
void lua::create_value ( lua_State *  state,
const V &  value,
const char *const  var,
P...  p 
) [inline]

Definition at line 366 of file lua.h.

References lua::detail::_create_value().

template<typename R >
const R lua::get_field ( const R &  default_value,
lua_State *  state,
int  index,
const char *const  field 
) [inline]

Definition at line 222 of file lua.h.

Referenced by get_field().

template<typename R >
const R lua::get_field ( const R &  default_value,
lua_State *  state,
int  index,
const string &  field 
) [inline]

Definition at line 235 of file lua.h.

References lua::detail::_get_field().

template<typename R >
const R lua::get_field ( const R &  default_value,
lua_State *  state,
int  index,
int  n 
) [inline]

Definition at line 248 of file lua.h.

template<typename R , typename... P>
const R lua::get_field ( const R &  default_value,
lua_State *  state,
int  index,
const char *const  field,
P...  p 
) [inline]

Definition at line 261 of file lua.h.

template<typename R >
const R lua::get_field ( lua_State *  state,
int  index,
const char *const  field 
) [inline]

Definition at line 276 of file lua.h.

References get_field().

template<typename R >
const R lua::get_field ( lua_State *  state,
int  index,
const string &  field 
) [inline]

Definition at line 281 of file lua.h.

References get_field().

template<typename R >
const R lua::get_field ( lua_State *  state,
int  index,
int  n 
) [inline]

Definition at line 286 of file lua.h.

References get_field().

template<typename R , typename... P>
const R lua::get_field ( lua_State *  state,
int  index,
const char *const  field,
P...  p 
) [inline]

Definition at line 291 of file lua.h.

References get_field().

void lua::get_global ( lua_State *  state,
const char *const  field 
) [inline]

Definition at line 196 of file lua.h.

Referenced by get_value(), prepend_package_path(), and set_value().

void lua::get_global ( lua_State *  state,
const string &  field 
) [inline]

Definition at line 200 of file lua.h.

References push_value().

template<typename R >
const R lua::get_value ( const R &  default_value,
lua_State *  state,
const char *const  var 
) [inline]

Definition at line 300 of file lua.h.

References get_global().

Referenced by get_value().

template<typename R >
const R lua::get_value ( const R &  default_value,
lua_State *  state,
const string &  var 
) [inline]

Definition at line 312 of file lua.h.

References get_global().

template<typename R , typename... P>
const R lua::get_value ( const R &  default_value,
lua_State *  state,
const char *const  var,
P...  p 
) [inline]

Definition at line 324 of file lua.h.

References get_global().

template<typename R >
const R lua::get_value ( lua_State *  state,
const char *const  var 
) [inline]

Definition at line 337 of file lua.h.

References get_value().

template<typename R >
const R lua::get_value ( lua_State *  state,
const string &  var 
) [inline]

Definition at line 342 of file lua.h.

References get_value().

template<typename R , typename... P>
const R lua::get_value ( lua_State *  state,
const char *const  var,
P...  p 
) [inline]

Definition at line 347 of file lua.h.

References get_value().

properties_ptr lua::load_properties ( const std::string &  filename) [inline]

Definition at line 138 of file lua/Properties.h.

References load_properties().

properties_ptr lua::load_properties ( lua_State *  state,
const std::string &  filename 
)

Definition at line 211 of file Properties.cc.

Referenced by load_properties(), load_string_properties(), and WSPR_DEFINE_NAMESPACE().

properties_ptr lua::load_string_properties ( const std::string &  code_str) [inline]

Definition at line 146 of file lua/Properties.h.

References load_string_properties().

properties_ptr lua::load_string_properties ( lua_State *  state,
const std::string &  code_str 
)

Definition at line 218 of file Properties.cc.

References load_properties().

Referenced by load_string_properties().

template<typename container_type >
void lua::map_to_table ( lua_State *  state,
const container_type &  map 
)

Definition at line 30 of file map.h.

References push_value(), set_field(), and database::value().

template<typename... P>
void lua::pcall ( lua_State *  state,
const P &...  p 
) [inline]
template<typename... P>
void lua::pcall_nopop ( const int  nargs,
const int  nresults,
lua_State *  state,
P...  p 
) [inline]

Assumes function has already been pushed to top of stack.

The nargs parameter is to allow you to pre-push values onto the stack.

Definition at line 441 of file lua.h.

References push_values().

Referenced by relay::Relay::finish_post(), renderer::Renderer::load_environment(), pcall(), pcall_nopop(), pcall_ret(), fcgi_lua::ServletRunner::process_fcgi_request(), renderer::Renderer::render_and_cache(), and renderer::Renderer::send_error().

template<typename... P>
void lua::pcall_nopop ( const int  nresults,
lua_State *  state,
P...  p 
) [inline]

Definition at line 456 of file lua.h.

References pcall_nopop().

template<typename R , typename... P>
R lua::pcall_ret ( lua_State *  state,
const P &...  p 
) [inline]

Currently, we support only one return value, but it should be possible to work things out to specify multiple return values and return them via a tuple.

Definition at line 468 of file lua.h.

References pcall_nopop().

template<typename I >
void lua::prepend_package_path ( lua_State *  state,
const I &  begin,
const I &  end 
) [inline]
void lua::properties_to_table ( const PropertiesToTable &  to_table,
const Properties &  properties 
) [inline]

Definition at line 105 of file lua/Properties.h.

References lua::PropertiesToTable::state().

Referenced by relay::Relay::finish_post(), and properties_to_table().

void lua::properties_to_table ( lua_State *  state,
const Properties &  properties 
) [inline]

Converts a Properties instance to a Lua table, pushing the resulting table onto the Lua stack.

Parameters:
stateA pointer to the Lua state in which to return the table.
propertiesThe Properties instance to convert.

Definition at line 121 of file lua/Properties.h.

References properties_to_table().

void lua::push_value ( lua_State *  state,
const bool  value 
) [inline]
void lua::push_value ( lua_State *  state,
const int  value 
) [inline]

Definition at line 77 of file lua.h.

void lua::push_value ( lua_State *  state,
const lua_Number  value 
) [inline]

Definition at line 81 of file lua.h.

void lua::push_value ( lua_State *  state,
const char *  value 
) [inline]

Definition at line 85 of file lua.h.

void lua::push_value ( lua_State *  state,
const string &  value 
) [inline]

Definition at line 89 of file lua.h.

void lua::push_value ( lua_State *  state,
void *  value 
) [inline]

Definition at line 93 of file lua.h.

void lua::push_value ( lua_State *  state,
const void *  value 
) [inline]

Definition at line 97 of file lua.h.

void lua::push_values ( lua_State *  ) [inline]

Definition at line 102 of file lua.h.

Referenced by pcall_nopop(), and push_values().

template<typename P >
void lua::push_values ( lua_State *  state,
const P &  p 
) [inline]

Definition at line 105 of file lua.h.

References push_value().

template<typename T , typename... P>
void lua::push_values ( lua_State *  state,
const T &  t,
const P &...  p 
) [inline]

Definition at line 110 of file lua.h.

References push_value(), and push_values().

template<typename V >
void lua::set_field ( lua_State *  state,
int  index,
const V &  value,
const char *const  field 
) [inline]
template<typename V >
void lua::set_field ( lua_State *  state,
int  index,
const V &  value,
const string &  field 
) [inline]

Definition at line 124 of file lua.h.

References push_value().

template<typename V >
void lua::set_field ( lua_State *  state,
int  index,
const V &  value,
int  n 
) [inline]

Definition at line 133 of file lua.h.

References push_value().

template<typename V , typename... P>
void lua::set_field ( lua_State *  state,
int  index,
const V &  value,
const char *const  field,
P...  p 
) [inline]

Definition at line 375 of file lua.h.

References set_field().

template<typename V >
void lua::set_global ( lua_State *  state,
const V &  value,
const char *const  field 
) [inline]

Definition at line 206 of file lua.h.

References push_value().

Referenced by create_value(), and set_value().

template<typename V >
void lua::set_global ( lua_State *  state,
const V &  value,
const string &  field 
) [inline]

Definition at line 214 of file lua.h.

References push_value().

template<typename V >
void lua::set_value ( lua_State *  state,
const V &  value,
const char *const  var 
) [inline]
template<typename V >
void lua::set_value ( lua_State *  state,
const V &  value,
const string &  var 
) [inline]

Definition at line 397 of file lua.h.

References set_global().

template<typename V , typename... P>
void lua::set_value ( lua_State *  state,
const V &  value,
const char *const  var,
P...  p 
) [inline]

Definition at line 402 of file lua.h.

References lua::detail::_set_value(), and get_global().

void lua::swig_table_to_properties ( void *  state,
Properties &  properties 
)

This function is a kluge to work around a SWIG library relocation error.

For some reason, table_to_properties doesn't resolve when called within a SWIG wrapper function. Removing lua_State* from the function signature allows the function to be located, which then resolves table_to_properties within the same relocation unit instead of crossing module boundaries.

Definition at line 180 of file Properties.cc.

References table_to_properties().

void lua::table_to_properties ( lua_State *  state,
Properties &  properties 
)

Copies a Lua table into a Properties instance.

Tables must either be pure arrays of primitive values, pure arrays of tables, or a zero-length table with key value pairs where all the keys are strings.

Parameters:
stateA pointer to the Lua state containing the table to convert at the top of the stack.
propertiesThe Properties instance to convert.

Definition at line 110 of file Properties.cc.

References convert< bool >(), convert< lua_Number >(), and convert< string >().

Referenced by swig_table_to_properties().


Savarese Software Research Corporation
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.