forked from pioneerspacesim/pioneer
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LuaRef.h
35 lines (26 loc) · 840 Bytes
/
LuaRef.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright © 2008-2013 Pioneer Developers. See AUTHORS.txt for details
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
#ifndef _LUAREF_H
#define _LUAREF_H
#include "lua/lua.hpp"
#include <vector>
class LuaRef {
public:
LuaRef(): m_lua(0), m_id(LUA_NOREF), m_copycount(new int(0)) {}
LuaRef(lua_State * l, int index);
LuaRef(const LuaRef & ref);
~LuaRef();
const LuaRef & operator=(const LuaRef & ref);
bool operator==(const LuaRef & ref) const;
void PushCopyToStack() const;
lua_State * GetLua() const { return m_lua; }
private:
lua_State * m_lua;
int m_id;
int * m_copycount;
// Does everything we need: get the table, or create it if it doesn't exist.
// Yay lua aux lib !
void PushGlobalToStack() const {luaL_getsubtable(m_lua, LUA_REGISTRYINDEX, "LuaRef");}
void CheckCopyCount();
};
#endif