xoreos  0.0.5
function.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef AURORA_LUA_FUNCTION_H
26 #define AURORA_LUA_FUNCTION_H
27 
28 #include "src/aurora/lua/types.h"
29 
30 namespace Aurora {
31 
32 namespace Lua {
33 
35 class FunctionRef {
36 public:
37  FunctionRef();
38  FunctionRef(const Stack &stack, int index);
39  FunctionRef(lua_State &state, int index);
40  FunctionRef(const FunctionRef &fn);
41  ~FunctionRef();
42 
43  const FunctionRef &operator=(const FunctionRef &fn);
44 
45  Variables call(const Variables &params) const;
46 
47  Variables call() const;
48  Variables call(const Variable &v) const;
49  Variables call(const Variable &v1, const Variable &v2) const;
50  Variables call(const Variable &v1, const Variable &v2, const Variable &v3) const;
51  Variables call(const Variable &v1, const Variable &v2, const Variable &v3, const Variable &v4) const;
52 
53  lua_State &getLuaState() const;
54  int getRef() const;
55 
56 private:
57  lua_State *_luaState;
58  int _ref;
59 
60  void pushSelf() const;
61 };
62 
63 } // End of namespace Lua
64 
65 } // End of namespace Aurora
66 
67 #endif // AURORA_LUA_FUNCTION_H
Variables call() const
Definition: function.cpp:102
lua_State & getLuaState() const
Definition: function.cpp:136
A Lua stack wrapper.
Definition: stack.h:41
std::vector< Variable > Variables
Definition: types.h:50
Lua types.
A reference to a Lua function.
Definition: function.h:35
lua_State * _luaState
Definition: function.h:57
const FunctionRef & operator=(const FunctionRef &fn)
Definition: function.cpp:65