Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Extension possible now

File size: 2.2 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#include "luaincl.h"
29#ifdef FUNCTOR_CALL_TYPE
30 #undef FUNCTOR_CALL_TYPE
31#endif
32#define FUNCTOR_CALL_TYPE lua_State*
33
34
35template<typename type> type fromLua(lua_State* state, int index);
36template<> bool fromLua<bool>(lua_State* state, int index);
37template<> int fromLua<int>(lua_State* state, int index);
38template<> unsigned int fromLua<unsigned int>(lua_State* state, int index);
39template<> float fromLua<float>(lua_State* state, int index);
40template<> char fromLua<char>(lua_State* state, int index);
41template<> const std::string& fromLua<const std::string&>(lua_State* state, int index);
42
43template<typename type> void toLua(lua_State* state, type value);
44template<> void toLua<bool>(lua_State* state, bool value);
45template<> void toLua<int>(lua_State* state, int value);
46template<> void toLua<unsigned int>(lua_State* state, unsigned int value);
47template<> void toLua<float>(lua_State* state, float value);
48template<> void toLua<char>(lua_State* state, char value);
49template<> void toLua<const std::string&>(lua_State* state, const std::string& value);
50
51/**
52 * @brief to remove writing errors, this function is Used.
53 * @param sub The SubString to use
54 * @param default The default Values.
55 */
56template<> class ExecutorEvaluater <lua_State*>
57{
58public:
59  /** @brief Executes the Evaluater
60   * @param CallValue the Value that should be converted
61   * @param defaults the default Values.
62   */
63  template <typename ToType, int index>
64  ToType operator()(lua_State*& CallValue, const MultiType* const defaults)
65  {
66    return (fromLua<ToType>(CallValue, index));
67  }
68  static lua_State*& defaultValue() { static lua_State* nullState; return nullState; };
69};
70
71#endif /* __EXECUTOR_LUA_STATE_H_ */
Note: See TracBrowser for help on using the repository browser.