UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
primitive.h File Reference
Include dependency graph for primitive.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 ugdk
 
 ugdk::script
 
 ugdk::script::lua
 

Macros

#define CHECK_LUA_TYPE(name, type)   (defined name) && (name == type)
 
#define LUA_OPNAME(name)   lua_##name
 Generates a Lua operation name. More...
 
#define DEFINE_LUA_PRIMITIVE_OP(name)
 Defines a Lua primitive operation. More...
 
#define DEFINE_LUA_PRIMITIVE_OPCASE(name, partial, type, ret, arg, exp)
 

Lua primitive <b>push</b>.

#define DEFINE_LUA_PARTIAL_PUSH(partial, type, call)   DEFINE_LUA_PRIMITIVE_OPCASE(push, partial, type, void, type val, call)
 
#define DEFINE_LUA_FULL_PUSH(type, call)   DEFINE_LUA_PARTIAL_PUSH(, type, call)
 
#define DEFINE_LUA_SIMPLE_PUSH(type, name)   DEFINE_LUA_FULL_PUSH(type, lua_push##name(L, val))
 
 ugdk::script::lua::DEFINE_LUA_PRIMITIVE_OP (push)
 
 ugdk::script::lua::DEFINE_LUA_PARTIAL_PUSH (class T, T *, lua_pushlightuserdata(L, AsUData< T >(val)))
 
 ugdk::script::lua::DEFINE_LUA_FULL_PUSH (lua_CFunction, lua_pushcclosure(L, val, 0))
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_PUSH (const char *, string)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_PUSH (bool, boolean)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_PUSH (int, integer)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_PUSH (double, number)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_PUSH (UData, lightuserdata)
 

Lua primitive <b>to</b>.

#define DEFINE_LUA_TO(type, call)   DEFINE_LUA_PRIMITIVE_OPCASE(to, , type, type, int index, return (call))
 
#define DEFINE_LUA_SIMPLE_TO(type, name)   DEFINE_LUA_TO(type, static_cast<type>(lua_to##name(L, index)))
 
 ugdk::script::lua::DEFINE_LUA_PRIMITIVE_OP (to)
 
 ugdk::script::lua::DEFINE_LUA_TO (const char *, lua_tolstring(L, index, nullptr))
 
 ugdk::script::lua::DEFINE_LUA_TO (bool,!!(lua_toboolean(L, index)))
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_TO (int, integer)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_TO (double, number)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_TO (UData, userdata)
 

Lua primitive <b>is</b>.

#define DEFINE_LUA_IS(type, check)   DEFINE_LUA_PRIMITIVE_OPCASE(is, , type, bool, int index, return !!(check))
 
#define DEFINE_LUA_SIMPLE_IS(type, name)   DEFINE_LUA_IS(type, lua_is##name(L, index))
 
 ugdk::script::lua::DEFINE_LUA_PRIMITIVE_OP (is)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_IS (const char *, string)
 
 ugdk::script::lua::DEFINE_LUA_IS (bool,!lua_isnone(L, index))
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_IS (int, number)
 
 ugdk::script::lua::DEFINE_LUA_SIMPLE_IS (double, number)
 

Macro Definition Documentation

#define CHECK_LUA_TYPE (   name,
  type 
)    (defined name) && (name == type)
#define DEFINE_LUA_FULL_PUSH (   type,
  call 
)    DEFINE_LUA_PARTIAL_PUSH(, type, call)
#define DEFINE_LUA_IS (   type,
  check 
)    DEFINE_LUA_PRIMITIVE_OPCASE(is, , type, bool, int index, return !!(check))
#define DEFINE_LUA_PARTIAL_PUSH (   partial,
  type,
  call 
)    DEFINE_LUA_PRIMITIVE_OPCASE(push, partial, type, void, type val, call)
#define DEFINE_LUA_PRIMITIVE_OP (   name)
Value:
template <class T> \
class LUA_OPNAME(name) { \
private: \
LUA_OPNAME(name)() {} \
void primitive(); \
}
#define LUA_OPNAME(name)
Generates a Lua operation name.
Definition: primitive.h:14

Defines a Lua primitive operation.

Note that just defining does not make much. One has to define operation cases for it to have any meaning.

Parameters
name- used to generate the operation name.
See also
DEFINE_LUA_PRIMITIVE_OPCASE
#define DEFINE_LUA_PRIMITIVE_OPCASE (   name,
  partial,
  type,
  ret,
  arg,
  exp 
)
Value:
template <partial> \
class LUA_OPNAME(name)<type> { \
public: \
static ret primitive(lua_State* L, arg) { \
exp; \
} \
private: \
LUA_OPNAME(name)() {} \
}
#define LUA_OPNAME(name)
Generates a Lua operation name.
Definition: primitive.h:14
struct lua_State lua_State
Definition: defs.h:8
#define DEFINE_LUA_SIMPLE_IS (   type,
  name 
)    DEFINE_LUA_IS(type, lua_is##name(L, index))
#define DEFINE_LUA_SIMPLE_PUSH (   type,
  name 
)    DEFINE_LUA_FULL_PUSH(type, lua_push##name(L, val))
#define DEFINE_LUA_SIMPLE_TO (   type,
  name 
)    DEFINE_LUA_TO(type, static_cast<type>(lua_to##name(L, index)))
#define DEFINE_LUA_TO (   type,
  call 
)    DEFINE_LUA_PRIMITIVE_OPCASE(to, , type, type, int index, return (call))
#define LUA_OPNAME (   name)    lua_##name

Generates a Lua operation name.