Crazy Eddies GUI System  0.6.2
CEGUILuaFunctor.h
1 /***********************************************************************
2  filename: CEGUILuaFunctor.h
3  created: Thu Jan 26 2006
4  author: Tomas Lindquist Olsen <tomas@famolsen.dk>
5 
6  purpose: Defines interface for LuaFunctor class
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUILuaFunctor_h_
31 #define _CEGUILuaFunctor_h_
32 
33 #include "CEGUIEventSet.h"
34 #include "CEGUIScriptWindowHelper.h"
35 
36 struct lua_State;
37 
38 // Start of CEGUI namespace section
39 namespace CEGUI
40 {
41 
42 // forward declaration
43 class LuaScriptModule;
44 
50 {
51 public:
52  LuaFunctor(lua_State* state, int func, int selfIndex);
53  LuaFunctor(lua_State* state, const String& func, int selfIndex);
54 
55  LuaFunctor(lua_State* state, const int func, const int selfIndex,
56  const String& error_handler);
57  LuaFunctor(lua_State* state, const String& func, const int selfIndex,
58  const String& error_handler);
59  LuaFunctor(lua_State* state, const int func, const int selfIndex,
60  const int error_handler);
61  LuaFunctor(lua_State* state, const String& func, const int selfIndex,
62  const int error_handler);
63 
64  LuaFunctor(const LuaFunctor& cp);
65  ~LuaFunctor();
66 
67  bool operator()(const EventArgs& args) const;
68 
76  const String& eventName,
77  const int funcIndex,
78  const int selfIndex,
79  const int error_handler,
80  lua_State* L);
81 
87  static void pushNamedFunction(lua_State* L, const String& name);
88 
89 private:
90  lua_State* L;
91  mutable int index;
92  int self;
93  mutable bool needs_lookup;
94  mutable String function_name;
95 
97  mutable String d_errFuncName;
99  mutable int d_errFuncIndex;
101  mutable bool d_ourErrFuncIndex;
102 
103  friend class LuaScriptModule;
104 };
105 
106 } // namespace CEGUI
107 
108 #endif // end of guard _CEGUILuaFunctor_h_