Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/executor/executor_lua_state.h @ 9747

Last change on this file since 9747 was 9747, checked in by bensch, 18 years ago

orxonox/new_class_id: Indexing works again for all the Scripts.

File size: 2.3 KB
Line 
1/*!
2 * @file executor_generic.h
3 * Definition of a Generic Executor
4 */
5
6/*
7   orxonox - the future of 3D-vertical-scrollers
8
9   Copyright (C) 2004 orx
10
11   This program is free software; you can redistribute it and/or modify
12   it under the terms of the GNU General Public License as published by
13   the Free Software Foundation; either version 2, or (at your option)
14   any later version.
15
16### File Specific:
17   main-programmer: Benjamin Grauer
18   co-programmer: ...
19*/
20
21
22
23#ifndef __EXECUTOR_LUA_STATE_H_
24#define __EXECUTOR_LUA_STATE_H_
25
26
27#include "executor_generic.h"
28
29#include "luaincl.h"
30
31#ifdef FUNCTOR_CALL_TYPE
32 #undef FUNCTOR_CALL_TYPE
33#endif
34#define FUNCTOR_CALL_TYPE lua_State*
35
36
37template<typename type> type fromLua(lua_State* state, int index);
38template<> bool fromLua<bool>(lua_State* state, int index);
39template<> int fromLua<int>(lua_State* state, int index);
40template<> unsigned int fromLua<unsigned int>(lua_State* state, int index);
41template<> float fromLua<float>(lua_State* state, int index);
42template<> char fromLua<char>(lua_State* state, int index);
43template<> const std::string& fromLua<const std::string&>(lua_State* state, int index);
44
45template<typename type> void toLua(lua_State* state, type value);
46template<> void toLua<bool>(lua_State* state, bool value);
47template<> void toLua<int>(lua_State* state, int value);
48template<> void toLua<unsigned int>(lua_State* state, unsigned int value);
49template<> void toLua<float>(lua_State* state, float value);
50template<> void toLua<char>(lua_State* state, char value);
51template<> void toLua<const std::string&>(lua_State* state, const std::string& value);
52
53//! A Class, that evaluates a lua_State and converts indices into different Types.
54template<> class ExecutorEvaluater <lua_State*>
55{
56public:
57  /** @brief Executes the Evaluater
58   * @param CallValue the Value that should be converted
59   * @param defaults the default Values.
60   */
61  template <typename ToType, int index>
62  static ToType getValue(lua_State*& CallValue, const MultiType* const defaults)
63  {
64    return (fromLua<ToType>(CallValue, index+1));
65  }
66  template <typename FromType>
67  static void storeRet(lua_State*& state, FromType value)
68  {
69    toLua<FromType>(state, value);
70  }
71  static lua_State*& defaultValue() { static lua_State* nullState; return nullState; };
72};
73
74#endif /* __EXECUTOR_LUA_STATE_H_ */
Note: See TracBrowser for help on using the repository browser.