The Battle for Wesnoth  1.15.1+dev
lua_formula_bridge.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017-2018 by the Battle for Wesnoth Project https://www.wesnoth.org/
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY.
10 
11  See the COPYING file for more details.
12 */
13 
14 #pragma once
15 
16 #include <memory>
17 #include <string>
18 
19 struct lua_State;
20 
21 namespace wfl {
22  class formula;
23  class function_symbol_table;
24  class formula_debugger;
25  class formula_callable;
26  class variant;
27 }
28 
29 namespace lua_formula_bridge {
30 
33  std::string register_metatables(lua_State*);
34 
35  class fwrapper {
36  std::shared_ptr<wfl::formula> formula_ptr;
37  public:
38  fwrapper(const std::string& code, wfl::function_symbol_table* functions = nullptr);
39  std::string str() const;
40  wfl::variant evaluate(const wfl::formula_callable& variables, wfl::formula_debugger* fdb = nullptr) const;
41  };
42 
43 } // end namespace lua_formula_bridge
int intf_eval_formula(lua_State *)
Evaluates a formula in the formula engine.
int intf_compile_formula(lua_State *)
std::string register_metatables(lua_State *)
Definition: contexts.hpp:42
std::shared_ptr< wfl::formula > formula_ptr