The Battle for Wesnoth  1.19.0-dev
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
wfl Namespace Reference

Namespaces

 actions
 
 builtins
 
 gamestate
 
 tokenizer
 

Classes

struct  unit_formula_compare
 
class  attack_map_callable
 
class  attack_callable
 
class  move_callable
 
class  move_partial_callable
 
class  recall_callable
 
class  recruit_callable
 
class  set_unit_var_callable
 
class  fallback_callable
 
class  move_map_callable
 
class  position_callable
 
class  outcome_callable
 
class  base_candidate_action
 
class  candidate_action_with_filters
 
class  move_candidate_action
 
class  attack_candidate_action
 
class  ai_function_symbol_table
 
class  formula_callable
 
class  action_callable
 
class  formula_callable_with_backup
 
class  formula_variant_callable_with_backup
 
class  map_formula_callable
 
struct  callable_die_subscriber
 
struct  formula_input
 
struct  fai_variant_visitor
 
class  gamestate_callable
 An object representing the state of the game, providing access to the map and basic information. More...
 
class  event_callable
 An object representing the state of the current event; equivalent to Lua's wesnoth.current.event_context. More...
 
class  terrain_callable
 
class  gamemap_callable
 
class  location_callable
 
class  attack_type_callable
 
class  unit_callable
 
class  unit_type_callable
 
class  config_callable
 
class  team_callable
 
class  set_var_callable
 
class  safe_call_callable
 
class  safe_call_result
 
class  end_breakpoint
 
class  step_in_breakpoint
 
class  step_out_breakpoint
 
class  next_breakpoint
 
class  debug_info
 
class  base_breakpoint
 
class  formula_debugger
 
class  null_expression
 
class  function_list_expression
 Classes that encapsulate and handle the various formula functions. More...
 
class  list_expression
 
class  map_expression
 
class  unary_operator_expression
 
class  string_callable
 
class  list_callable
 
class  map_callable
 
class  dot_callable
 
class  dot_expression
 
class  square_bracket_expression
 
class  operator_expression
 
class  where_variables
 
class  where_expression
 
class  identifier_expression
 
class  integer_expression
 
class  decimal_expression
 
class  string_expression
 
class  formula
 
struct  formula_error
 
struct  formula_variant_defines
 
struct  call_stack_manager
 Provides debugging information for error messages. More...
 
class  formula_expression
 
class  function_expression
 
class  key_value_pair
 
class  formula_function_expression
 
class  formula_function
 
class  user_formula_function
 
class  builtin_formula_function
 
class  function_symbol_table
 
class  action_function_symbol_table
 
class  wrapper_formula
 
class  gamestate_function_symbol_table
 
class  variant
 
class  variant_iterator
 Iterator class for the variant. More...
 
struct  type_error
 
class  variant_value_base
 Base class for all variant types. More...
 
class  variant_numeric
 Base class for numeric variant values. More...
 
class  variant_int
 
class  variant_decimal
 
class  variant_callable
 
class  variant_string
 
class  variant_container
 Generalized implementation handling container variants. More...
 
class  variant_list
 
class  variant_map
 

Typedefs

typedef std::pair< unit_map::unit_iterator, int > unit_formula_pair
 
typedef std::multiset< unit_formula_pair, unit_formula_compareunit_formula_set
 
typedef std::map< std::string, const_formula_ptrcandidate_action_filters
 
typedef std::shared_ptr< base_candidate_actioncandidate_action_ptr
 
using map_formula_callable_ptr = std::shared_ptr< map_formula_callable >
 
using const_map_formula_callable_ptr = std::shared_ptr< const map_formula_callable >
 
using formula_input_vector = std::vector< formula_input >
 
using formula_callable_ptr = std::shared_ptr< formula_callable >
 
using const_formula_callable_ptr = std::shared_ptr< const formula_callable >
 
using formula_seen_stack = std::vector< const_formula_callable_ptr >
 
typedef std::shared_ptr< base_breakpointbreakpoint_ptr
 
using expr_table = std::map< std::string, expression_ptr >
 
using expr_table_evaluated = std::map< std::string, variant >
 
using expr_table_ptr = std::shared_ptr< expr_table >
 
using expression_ptr = std::shared_ptr< formula_expression >
 
typedef std::shared_ptr< formulaformula_ptr
 
typedef std::shared_ptr< const formulaconst_formula_ptr
 
using formula_variant = string_enums::enum_base< formula_variant_defines >
 
typedef std::shared_ptr< function_expressionfunction_expression_ptr
 
typedef std::shared_ptr< formula_functionformula_function_ptr
 
typedef std::map< std::string, formula_function_ptrfunctions_map
 
using variant_vector = std::vector< variant >
 
using variant_map_raw = std::map< variant, variant >
 
using value_base_ptr = std::shared_ptr< variant_value_base >
 

Enumerations

enum class  formula_access { read_only , write_only , read_write }
 

Functions

static void msg (const char *act, debug_info &i, const char *to="", const char *result="")
 
formula_debuggeradd_debug_info (formula_debugger *fdb, int arg_number, const std::string &f_name)
 
variant evaluate_arg_callback (formula_debugger &fdb, const formula_expression &expression, const formula_callable &variables)
 
variant evaluate_formula_callback (formula_debugger &fdb, const formula &f, const formula_callable &variables)
 
variant evaluate_formula_callback (formula_debugger &fdb, const formula &f)
 
static std::string tokens_to_string (const tk::token *i1, const tk::token *i2)
 
expression_ptr parse_expression (const tk::token *i1, const tk::token *i2, function_symbol_table *symbols)
 
static int operator_precedence (const tk::token &t)
 Functions to handle the actual parsing of WFL. More...
 
static void parse_function_args (const tk::token *&i1, const tk::token *i2, std::vector< std::string > *res)
 
static void parse_args (const tk::token *i1, const tk::token *i2, std::vector< expression_ptr > *res, function_symbol_table *symbols)
 
static void parse_set_args (const tk::token *i1, const tk::token *i2, std::vector< expression_ptr > *res, function_symbol_table *symbols)
 
static void parse_where_clauses (const tk::token *i1, const tk::token *i2, expr_table_ptr res, function_symbol_table *symbols)
 
static value_base_ptr null_value (new variant_value_base)
 
static std::string variant_type_to_string (formula_variant::type type)
 
static std::string was_expecting (const std::string &message, const variant &v)
 
template<typename T >
static std::shared_ptr< T > value_cast (value_base_ptr ptr)
 Casts a variant_value_base shared pointer to a new derived type. More...
 
template<typename T >
static T & value_ref_cast (variant_value_base &ptr)
 Casts a variant_value_base reference to a new derived type. More...
 

Variables

static thread_local std::deque< std::string > call_stack
 For printing error messages when WFL parsing or evaluation fails, this contains the names of the WFL functions being evaluated. More...
 

Typedef Documentation

◆ breakpoint_ptr

typedef std::shared_ptr<base_breakpoint> wfl::breakpoint_ptr

Definition at line 38 of file debugger_fwd.hpp.

◆ candidate_action_filters

typedef std::map< std::string, const_formula_ptr > wfl::candidate_action_filters

Definition at line 35 of file candidates.hpp.

◆ candidate_action_ptr

Definition at line 36 of file candidates.hpp.

◆ const_formula_callable_ptr

using wfl::const_formula_callable_ptr = typedef std::shared_ptr<const formula_callable>

Definition at line 44 of file callable_fwd.hpp.

◆ const_formula_ptr

typedef std::shared_ptr<const formula> wfl::const_formula_ptr

Definition at line 24 of file formula_fwd.hpp.

◆ const_map_formula_callable_ptr

using wfl::const_map_formula_callable_ptr = typedef std::shared_ptr<const map_formula_callable>

Definition at line 313 of file callable.hpp.

◆ expr_table

using wfl::expr_table = typedef std::map<std::string, expression_ptr>

Definition at line 60 of file formula.cpp.

◆ expr_table_evaluated

using wfl::expr_table_evaluated = typedef std::map<std::string, variant>

Definition at line 61 of file formula.cpp.

◆ expr_table_ptr

using wfl::expr_table_ptr = typedef std::shared_ptr<expr_table>

Definition at line 62 of file formula.cpp.

◆ expression_ptr

typedef std::shared_ptr< formula_expression > wfl::expression_ptr

Definition at line 29 of file formula.hpp.

◆ formula_callable_ptr

using wfl::formula_callable_ptr = typedef std::shared_ptr<formula_callable>

Definition at line 43 of file callable_fwd.hpp.

◆ formula_function_ptr

typedef std::shared_ptr<formula_function> wfl::formula_function_ptr

Definition at line 229 of file function.hpp.

◆ formula_input_vector

using wfl::formula_input_vector = typedef std::vector<formula_input>

Definition at line 42 of file callable_fwd.hpp.

◆ formula_ptr

typedef std::shared_ptr<formula> wfl::formula_ptr

Definition at line 23 of file formula_fwd.hpp.

◆ formula_seen_stack

Definition at line 45 of file callable_fwd.hpp.

◆ formula_variant

Definition at line 34 of file formula_variant.hpp.

◆ function_expression_ptr

Definition at line 172 of file function.hpp.

◆ functions_map

typedef std::map<std::string, formula_function_ptr> wfl::functions_map

Definition at line 230 of file function.hpp.

◆ map_formula_callable_ptr

using wfl::map_formula_callable_ptr = typedef std::shared_ptr<map_formula_callable>

Definition at line 312 of file callable.hpp.

◆ unit_formula_pair

Definition at line 46 of file ai.hpp.

◆ unit_formula_set

Definition at line 56 of file ai.hpp.

◆ value_base_ptr

using wfl::value_base_ptr = typedef std::shared_ptr<variant_value_base>

Definition at line 36 of file variant_value.hpp.

◆ variant_map_raw

using wfl::variant_map_raw = typedef std::map<variant, variant>

Definition at line 35 of file variant_value.hpp.

◆ variant_vector

using wfl::variant_vector = typedef std::vector<variant>

Definition at line 34 of file variant_value.hpp.

Enumeration Type Documentation

◆ formula_access

enum wfl::formula_access
strong
Enumerator
read_only 
write_only 
read_write 

Definition at line 32 of file callable_fwd.hpp.

Function Documentation

◆ add_debug_info()

formula_debugger * wfl::add_debug_info ( formula_debugger fdb,
int  arg_number,
const std::string &  f_name 
)

◆ evaluate_arg_callback()

variant wfl::evaluate_arg_callback ( formula_debugger fdb,
const formula_expression expression,
const formula_callable variables 
)

◆ evaluate_formula_callback() [1/2]

variant wfl::evaluate_formula_callback ( formula_debugger fdb,
const formula f 
)

Definition at line 49 of file debugger_fwd.cpp.

References wfl::formula_debugger::evaluate_formula_callback(), and f.

◆ evaluate_formula_callback() [2/2]

variant wfl::evaluate_formula_callback ( formula_debugger fdb,
const formula f,
const formula_callable variables 
)

Definition at line 43 of file debugger_fwd.cpp.

References wfl::formula_debugger::evaluate_formula_callback(), and f.

Referenced by wfl::formula::evaluate().

◆ msg()

static void wfl::msg ( const char *  act,
debug_info i,
const char *  to = "",
const char *  result = "" 
)
static

Definition at line 109 of file debugger.cpp.

References DBG_FDB, and i.

Referenced by display_chat_manager::add_chat_message(), gui2::dialogs::lua_interpreter::lua_model::add_dialog_message(), game_events::event_handlers::add_event_handler(), lua_kernel_base::add_log_to_console(), wesnothd::server::adminmsg_handler(), server_base::async_send_error(), server_base::async_send_warning(), gui2::builder_grid::builder_grid(), events::menu_handler::can_recruit(), spirit_po::catalog< hashmap_type, pf_compiler >::catalog(), ng::depcheck::manager::change_era(), events::chat_handler::change_logging(), ng::depcheck::manager::change_scenario(), chat_message(), addons_client::connect(), help::convert_to_wml(), mapgen_lua_kernel::create_map(), lua_map_generator::create_map(), mapgen_lua_kernel::create_scenario(), lua_map_generator::create_scenario(), deprecated_message(), ai::readonly_context_proxy::diagnostic(), ai::readonly_context_impl::diagnostic(), gui2::dialogs::mp_create_game::dialog_exit_hook(), ai::formula_ai::display_message(), set_scontext_synced::do_final_checkup(), do_gameloop(), events::menu_handler::do_search(), simple_wml::error::error(), wfl::formula_debugger::evaluate_arg_callback(), wfl::formula_debugger::evaluate_formula_callback(), ng::depcheck::manager::failure_dialog(), game_events::wml_event_pump::fill_wml_messages_map(), gui2::window::finish_build(), gui2::event::dispatcher::fire(), spirit_po::catalog< hashmap_type, pf_compiler >::form_index(), help::generate_contents(), spirit_po::catalog< hashmap_type, pf_compiler >::get(), get_addon_pbl_info(), editor::terrain_palette::get_help_string(), config::get_old_attribute(), gui2::dialogs::get_title_suffix(), help::help_browser::handle_event(), wesnothd::server::handle_message(), help::help_text_area::handle_ref_cfg(), campaignd::server::handle_upload(), wesnothd::server::handle_whisper(), impl_warn(), spirit_po::catalog< hashmap_type, pf_compiler >::insert_message(), intf_deprecated_message(), intf_find_path(), lua_map_location::intf_get_direction(), game_lua_kernel::intf_log(), intf_log(), playsingle_controller::hotkey_handler::load_autosave(), editor::context_manager::load_map(), application_lua_kernel::load_script_from_string(), lua_kernel_base::load_string(), lua_kernel_base::log_error(), game_lua_kernel::log_error(), ai::readonly_context_proxy::log_message(), ai::readonly_context_impl::log_message(), ai_testing::log_turn(), game_lua_kernel::lua_chat(), lua_map_generator::lua_map_generator(), luaW_type_error(), gui2::parse_linked_group_definitions(), help::parse_text(), wesnothd::game::perform_controller_tweaks(), wesnothd::server::pm_handler(), wesnothd::server::process_command(), replay::process_error(), wesnothd::game::process_message(), play_controller::process_oos(), wesnothd::game::process_turn(), wesnothd::game::process_whiteboard(), lua_kernel_base::protected_call(), gui2::dialogs::addon_manager::publish_addon(), events::menu_handler::recall(), actions::undo_list::redo(), editor::map_context::save_map(), events::menu_handler::save_map(), editor::map_context::save_scenario(), editor::map_context::save_schedule(), events::menu_handler::search(), campaignd::server::send_error(), campaignd::server::send_message(), wesnothd::server::send_password_request(), wesnothd::game::send_server_message(), wesnothd::server::send_server_message(), display::set_diagnostic(), help::help_text_area::set_items(), gui2::show_error_message(), gui2::show_message(), lua_gui2::show_popup_dialog(), preferences::show_wesnothd_server_search(), help::show_with_toplevel(), game_events::wml_event_pump::show_wml_messages(), wesnothd::game::start_game(), help::help_text_area::str_to_align(), lua_kernel_base::throw_exception(), wesnothd::game::transfer_side_control(), lua_map_generator::user_config(), vgettext_impl(), vngettext_impl(), and editor::wrap_exc().

◆ null_value()

static value_base_ptr wfl::null_value ( new  variant_value_base)
static

◆ operator_precedence()

static int wfl::operator_precedence ( const tk::token t)
static

Functions to handle the actual parsing of WFL.

Definition at line 1074 of file formula.cpp.

References n, and t.

Referenced by parse_expression().

◆ parse_args()

static void wfl::parse_args ( const tk::token i1,
const tk::token i2,
std::vector< expression_ptr > *  res,
function_symbol_table symbols 
)
static

Definition at line 1140 of file formula.cpp.

References parse_expression(), and wfl::tokenizer::token::type.

Referenced by parse_expression().

◆ parse_expression()

expression_ptr wfl::parse_expression ( const tk::token i1,
const tk::token i2,
function_symbol_table symbols 
)

◆ parse_function_args()

static void wfl::parse_function_args ( const tk::token *&  i1,
const tk::token i2,
std::vector< std::string > *  res 
)
static

◆ parse_set_args()

static void wfl::parse_set_args ( const tk::token i1,
const tk::token i2,
std::vector< expression_ptr > *  res,
function_symbol_table symbols 
)
static

◆ parse_where_clauses()

static void wfl::parse_where_clauses ( const tk::token i1,
const tk::token i2,
expr_table_ptr  res,
function_symbol_table symbols 
)
static

◆ tokens_to_string()

static std::string wfl::tokens_to_string ( const tk::token i1,
const tk::token i2 
)
static

◆ value_cast()

template<typename T >
static std::shared_ptr<T> wfl::value_cast ( value_base_ptr  ptr)
static

Casts a variant_value_base shared pointer to a new derived type.

Definition at line 45 of file variant_value.hpp.

◆ value_ref_cast()

template<typename T >
static T& wfl::value_ref_cast ( variant_value_base ptr)
static

Casts a variant_value_base reference to a new derived type.

Definition at line 57 of file variant_value.hpp.

◆ variant_type_to_string()

static std::string wfl::variant_type_to_string ( formula_variant::type  type)
static

◆ was_expecting()

static std::string wfl::was_expecting ( const std::string &  message,
const variant v 
)
static

Variable Documentation

◆ call_stack

thread_local std::deque<std::string> wfl::call_stack
static

For printing error messages when WFL parsing or evaluation fails, this contains the names of the WFL functions being evaluated.

Two C++ threads might be evaluating WFL at the same; declaring this thread_local is a quick bugfix which should probably be replaced by having a context-object for each WFL evaluation.

Definition at line 48 of file function.cpp.

Referenced by wfl::call_stack_manager::call_stack_manager(), wfl::call_stack_manager::get(), wfl::end_breakpoint::is_break_now(), wfl::step_in_breakpoint::is_break_now(), wfl::step_out_breakpoint::is_break_now(), wfl::next_breakpoint::is_break_now(), and wfl::call_stack_manager::~call_stack_manager().