The Battle for Wesnoth  1.17.0-dev
lua_formula_bridge.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2021
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
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  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #pragma once
16 
17 #include <memory>
18 #include <string>
19 
20 struct lua_State;
21 
22 namespace wfl {
23  class formula;
24  class function_symbol_table;
25  class formula_debugger;
26  class formula_callable;
27  class variant;
28 }
29 
30 namespace lua_formula_bridge {
31 
34  std::string register_metatables(lua_State*);
35 
36  class fwrapper {
37  std::shared_ptr<wfl::formula> formula_ptr;
38  public:
39  fwrapper(const std::string& code, wfl::function_symbol_table* functions = nullptr);
40  std::string str() const;
41  wfl::variant evaluate(const wfl::formula_callable& variables, wfl::formula_debugger* fdb = nullptr) const;
42  };
43 
44 } // 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:44
std::shared_ptr< wfl::formula > formula_ptr