Changeset 9752 in orxonox.OLD for branches/new_class_id/src/lib/util/executor/executor_lua_state.h
- Timestamp:
- Sep 17, 2006, 2:43:41 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor_lua_state.h
r9748 r9752 35 35 #define FUNCTOR_CALL_TYPE lua_State* 36 36 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 */ 37 43 template<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) */ 45 template<> 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) */ 47 template<> 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) */ 49 template<> 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) */ 51 template<> 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) */ 53 template<> inline char fromLua<char>(lua_State* state, int index) { return (char)lua_tonumber(state, index); }; 44 54 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 */ 45 61 template<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) */ 63 template<> 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) */ 65 template<> 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) */ 67 template<> 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) */ 69 template<> 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) */ 71 template<> 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) */ 73 template<> inline void toLua<const std::string&>(lua_State* state, const std::string& value) { lua_pushstring (state, value.c_str()); } 74 75 52 76 53 77 //! A Class, that evaluates a lua_State and converts indices into different Types.
Note: See TracChangeset
for help on using the changeset viewer.