2013-11-14 22:41:54 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
2013-11-27 03:15:49 +00:00
|
|
|
#include "util/lua.h"
|
|
|
|
#pragma once
|
2013-11-14 22:41:54 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
/**
|
|
|
|
\brief Reference to Lua object.
|
|
|
|
*/
|
2013-11-27 03:15:49 +00:00
|
|
|
class luaref {
|
2013-11-14 22:41:54 +00:00
|
|
|
lua_State * m_state;
|
|
|
|
int m_ref;
|
|
|
|
public:
|
2013-11-30 08:34:38 +00:00
|
|
|
luaref():m_state(nullptr), m_ref(0) {}
|
2013-11-14 22:41:54 +00:00
|
|
|
/**
|
|
|
|
\brief Create a reference to the Lua object at position \c i on \c L stack.
|
|
|
|
*/
|
2013-11-27 03:15:49 +00:00
|
|
|
luaref(lua_State * L, int i);
|
|
|
|
luaref(luaref const & r);
|
|
|
|
luaref(luaref && r);
|
|
|
|
~luaref();
|
2013-11-28 21:09:30 +00:00
|
|
|
void release();
|
2013-11-27 03:15:49 +00:00
|
|
|
luaref & operator=(luaref const & r);
|
2013-11-14 22:41:54 +00:00
|
|
|
void push() const;
|
|
|
|
lua_State * get_state() const { return m_state; }
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2013-11-27 03:15:49 +00:00
|
|
|
\brief '<' functor for luaref.
|
2013-11-14 22:41:54 +00:00
|
|
|
*/
|
2013-11-27 03:15:49 +00:00
|
|
|
struct luaref_lt_proc {
|
|
|
|
int operator()(luaref const & r1, luaref const & r2) const;
|
2013-11-14 22:41:54 +00:00
|
|
|
};
|
|
|
|
}
|