2013-11-10 17:11:44 +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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <lua.hpp>
|
2013-11-12 04:29:53 +00:00
|
|
|
#include "kernel/threadsafe_environment.h"
|
|
|
|
|
2013-11-10 17:11:44 +00:00
|
|
|
namespace lean {
|
|
|
|
class environment;
|
|
|
|
void open_environment(lua_State * L);
|
|
|
|
bool is_environment(lua_State * L, int idx);
|
2013-11-10 18:12:43 +00:00
|
|
|
int push_environment(lua_State * L, environment const & env);
|
2013-11-12 04:29:53 +00:00
|
|
|
|
2013-11-10 18:12:43 +00:00
|
|
|
/**
|
|
|
|
\brief Auxiliary class for setting the Lua registry of a Lua state
|
|
|
|
with an environment object.
|
|
|
|
*/
|
|
|
|
class set_environment {
|
|
|
|
lua_State * m_state;
|
|
|
|
public:
|
|
|
|
set_environment(lua_State * L, environment & env);
|
|
|
|
~set_environment();
|
|
|
|
};
|
2013-11-12 04:29:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Helper class for getting a read-only reference
|
|
|
|
for an environment object on the Lua stack.
|
|
|
|
*/
|
|
|
|
class ro_environment : public read_only_environment {
|
|
|
|
public:
|
|
|
|
ro_environment(lua_State * L, int idx);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Helper class for getting a read-write reference
|
|
|
|
for an environment object on the Lua stack.
|
|
|
|
*/
|
|
|
|
class rw_environment : public read_write_environment {
|
|
|
|
public:
|
|
|
|
rw_environment(lua_State * L, int idx);
|
|
|
|
};
|
2013-11-10 17:11:44 +00:00
|
|
|
}
|