Graphite Version 3
An experimental 3D geometry processing program
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lua_interpreter.h
Go to the documentation of this file.
1/*
2 * GXML/Graphite: Geometry and Graphics Programming Library + Utilities
3 * Copyright (C) 2000 Bruno Levy
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 * If you modify this software, you should include a notice giving the
20 * name of the person performing the modification, the date of modification,
21 * and the reason for such modification.
22 *
23 * Contact: Bruno Levy
24 *
25 * levy@loria.fr
26 *
27 * ISA Project
28 * LORIA, INRIA Lorraine,
29 * Campus Scientifique, BP 239
30 * 54506 VANDOEUVRE LES NANCY CEDEX
31 * FRANCE
32 *
33 * Note that the GNU General Public License does not permit incorporating
34 * the Software into proprietary programs.
35 */
36
37#ifndef H_OGF_GOM_LUA_INTERPRETER_H
38#define H_OGF_GOM_LUA_INTERPRETER_H
39
42#include <OGF/gom/types/callable.h>
43
44struct lua_State;
45
51namespace OGF {
52
53 /*****************************************************************/
54
59 gom_class GOM_API LuaInterpreter : public Interpreter {
60 public:
65
69 ~LuaInterpreter() override;
70
74 void reset() override;
75
79 bool execute(
80 const std::string& command, bool save_in_history, bool log
81 ) override;
82
86 bool execute_file(const std::string& file_name) override;
87
91 Any resolve(const std::string& id, bool quiet=true) const override;
92
96 void bind(const std::string& id, const Any& value) override;
97
102 const std::string& expression, bool quiet=true
103 ) const override;
104
109 lua_State* lua_state() {
110 return lua_state_;
111 }
112
119 static void display_error_message(const std::string& msg);
120
126 void list_names(std::vector<std::string>& names) const override;
127
128 protected:
129
137 virtual void adjust_lua_state();
138
143 const std::string& context, std::vector<std::string>& keys
144 ) override;
145
150 const std::string& args
151 ) const override;
152
153
154 private:
155 lua_State* lua_state_;
156 };
157
158}
159
160#endif
A class that stores a variable of arbitrary type.
Definition any.h:62
Abstract base class for the GOM interpreter.
The main class that interfaces the Python interpreter with Graphite.
void get_keys(const std::string &context, std::vector< std::string > &keys) override
Gets all possible keys in a certain context.
~LuaInterpreter() override
LuaInterpreter destructor.
bool execute(const std::string &command, bool save_in_history, bool log) override
Executes a single line of code in the interpreted language.
std::string name_value_pair_call(const std::string &args) const override
Transforms a list of name-value pairs arguments.
lua_State * lua_state()
Gets the LUA state.
void reset() override
Clears all variables, restarts from initial state.
LuaInterpreter()
LuaInterpreter constructor.
void bind(const std::string &id, const Any &value) override
Binds a value to a variable.
Any resolve(const std::string &id, bool quiet=true) const override
Finds a variable by id.
virtual void adjust_lua_state()
Adjusts LUA state to recover from errors.
bool execute_file(const std::string &file_name) override
Executes commands from a given file.
Any eval(const std::string &expression, bool quiet=true) const override
Evaluates a string with an expression.
void list_names(std::vector< std::string > &names) const override
Lists the variable names in this Scope.
static void display_error_message(const std::string &msg)
Displays a Lua error message.
The abstract base class for the GOM interpreter.
Global Graphite namespace.
Definition common.h:76
Definitions common to all include files in the gom library.