Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 17, 2006, 2:43:41 PM (18 years ago)
Author:
bensch
Message:

changed some functions to be inlined, (only runtime-specifics (important for LUA)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/executor/executor_lua_state.h

    r9748 r9752  
    3535#define FUNCTOR_CALL_TYPE lua_State*
    3636
     37/**
     38 * @brief Converts a lua_State into any type.
     39 * @param state the State to get the value from.
     40 * @param index the position inside of the lua_State to get the value from.
     41 * @returns The value if found.
     42 */
    3743template<typename type> type fromLua(lua_State* state, int index);
    38 template<> bool fromLua<bool>(lua_State* state, int index);
    39 template<> int fromLua<int>(lua_State* state, int index);
    40 template<> unsigned int fromLua<unsigned int>(lua_State* state, int index);
    41 template<> float fromLua<float>(lua_State* state, int index);
    42 template<> char fromLua<char>(lua_State* state, int index);
    43 template<> const std::string& fromLua<const std::string&>(lua_State* state, int index);
     44/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
     45template<> inline bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); };
     46/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
     47template<> inline int fromLua<int>(lua_State* state, int index) { return (int)lua_tonumber(state, index); };
     48/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
     49template<> inline unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); };
     50/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
     51template<> inline float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); };
     52/** @see template<typename type> inline type fromLua(lua_State* state, int index) */
     53template<> inline char fromLua<char>(lua_State* state, int index) { return (char)lua_tonumber(state, index); };
    4454
     55
     56/**
     57 * @brief writes a value into a lua_State.
     58 * @param state the state to write into.
     59 * @param value the Value of type to write into the State.
     60 */
    4561template<typename type> void toLua(lua_State* state, type value);
    46 template<> void toLua<bool>(lua_State* state, bool value);
    47 template<> void toLua<int>(lua_State* state, int value);
    48 template<> void toLua<unsigned int>(lua_State* state, unsigned int value);
    49 template<> void toLua<float>(lua_State* state, float value);
    50 template<> void toLua<char>(lua_State* state, char value);
    51 template<> void toLua<const std::string&>(lua_State* state, const std::string& value);
     62/** @see template<typename type> void toLua(lua_State* state, type value) */
     63template<> inline void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); };
     64/** @see template<typename type> void toLua(lua_State* state, type value) */
     65template<> inline void toLua<int>(lua_State* state, int value)  { lua_pushnumber(state, (lua_Number) value); };
     66/** @see template<typename type> void toLua(lua_State* state, type value) */
     67template<> inline void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };
     68/** @see template<typename type> void toLua(lua_State* state, type value) */
     69template<> inline void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); };
     70/** @see template<typename type> void toLua(lua_State* state, type value) */
     71template<> inline void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); };
     72/** @see template<typename type> void toLua(lua_State* state, type value) */
     73template<> inline void toLua<const std::string&>(lua_State* state, const std::string& value) { lua_pushstring (state, value.c_str()); }
     74
     75
    5276
    5377//! A Class, that evaluates a lua_State and converts indices into different Types.
Note: See TracChangeset for help on using the changeset viewer.