Crazy Eddies GUI System  0.7.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 
35 struct lua_State;
36 
37 // Start of CEGUI namespace section
38 namespace CEGUI
39 {
40 
41 // forward declaration
42 class LuaScriptModule;
43 
49 {
50 public:
51  LuaFunctor(lua_State* state, int func, int selfIndex);
52  LuaFunctor(lua_State* state, const String& func, int selfIndex);
53 
54  LuaFunctor(lua_State* state, const int func, const int selfIndex,
55  const String& error_handler);
56  LuaFunctor(lua_State* state, const String& func, const int selfIndex,
57  const String& error_handler);
58  LuaFunctor(lua_State* state, const int func, const int selfIndex,
59  const int error_handler);
60  LuaFunctor(lua_State* state, const String& func, const int selfIndex,
61  const int error_handler);
62 
63  LuaFunctor(const LuaFunctor& cp);
64  ~LuaFunctor();
65 
66  bool operator()(const EventArgs& args) const;
67 
75  const String& eventName,
76  const int funcIndex,
77  const int selfIndex,
78  const int error_handler,
79  lua_State* L);
80 
86  static void pushNamedFunction(lua_State* L, const String& name);
87 
88 private:
95  void invalidateLuaRefs();
96 
97  lua_State* L;
98  mutable int index;
99  int self;
100  mutable bool needs_lookup;
101  mutable String function_name;
102 
104  mutable String d_errFuncName;
106  mutable int d_errFuncIndex;
108  mutable bool d_ourErrFuncIndex;
109 
110  friend class LuaScriptModule;
111 };
112 
113 } // namespace CEGUI
114 
115 #endif // end of guard _CEGUILuaFunctor_h_