The Battle for Wesnoth
1.19.7+dev
scripting
lua_formula_bridge.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2017 - 2024
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 <functional>
18
#include <memory>
19
#include <string>
20
21
struct
lua_State;
22
23
namespace
wfl
{
24
class
formula;
25
class
function_symbol_table;
26
class
formula_debugger;
27
class
formula_callable;
28
class
variant;
29
}
30
31
namespace
lua_formula_bridge
{
32
33
int
intf_eval_formula
(lua_State*);
34
int
intf_compile_formula
(lua_State*);
35
std::string
register_metatables
(lua_State*);
36
37
class
fwrapper
{
38
std::shared_ptr<wfl::formula>
formula_ptr
;
39
public
:
40
fwrapper
(
const
std::string& code,
wfl::function_symbol_table
* functions =
nullptr
);
41
std::string
str
()
const
;
42
wfl::variant
evaluate
(
const
wfl::formula_callable
& variables,
wfl::formula_debugger
* fdb =
nullptr
)
const
;
43
};
44
45
using
fpointer
= std::unique_ptr<
fwrapper
, std::function<void(
fwrapper
*)>>;
46
}
// end namespace lua_formula_bridge
47
lua_formula_bridge::fpointer
luaW_check_formula
(lua_State* L,
int
idx,
bool
allow_str);
lua_formula_bridge::fwrapper
Definition:
lua_formula_bridge.hpp:37
lua_formula_bridge::fwrapper::str
std::string str() const
Definition:
lua_formula_bridge.cpp:286
lua_formula_bridge::fwrapper::evaluate
wfl::variant evaluate(const wfl::formula_callable &variables, wfl::formula_debugger *fdb=nullptr) const
Definition:
lua_formula_bridge.cpp:294
lua_formula_bridge::fwrapper::formula_ptr
std::shared_ptr< wfl::formula > formula_ptr
Definition:
lua_formula_bridge.hpp:38
lua_formula_bridge::fwrapper::fwrapper
fwrapper(const std::string &code, wfl::function_symbol_table *functions=nullptr)
Definition:
lua_formula_bridge.cpp:281
wfl::formula_callable
Definition:
callable.hpp:30
wfl::formula_debugger
Definition:
debugger.hpp:74
wfl::function_symbol_table
Definition:
function.hpp:233
wfl::variant
Definition:
variant.hpp:29
luaW_check_formula
lua_formula_bridge::fpointer luaW_check_formula(lua_State *L, int idx, bool allow_str)
Get a formula from the stack.
Definition:
lua_formula_bridge.cpp:226
lua_formula_bridge
Definition:
lua_formula_bridge.hpp:31
lua_formula_bridge::fpointer
std::unique_ptr< fwrapper, std::function< void(fwrapper *)> > fpointer
Definition:
lua_formula_bridge.hpp:45
lua_formula_bridge::register_metatables
std::string register_metatables(lua_State *)
Definition:
lua_formula_bridge.cpp:317
lua_formula_bridge::intf_compile_formula
int intf_compile_formula(lua_State *)
Definition:
lua_formula_bridge.cpp:271
lua_formula_bridge::intf_eval_formula
int intf_eval_formula(lua_State *)
Evaluates a formula in the formula engine.
Definition:
lua_formula_bridge.cpp:249
wfl
Definition:
contexts.hpp:43
Generated by
1.9.1