The Battle for Wesnoth  1.15.1+dev
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions | Variables
lua_terrainfilter.cpp File Reference
#include "scripting/lua_terrainfilter.hpp"
#include "scripting/lua_terrainmap.hpp"
#include "formatter.hpp"
#include "log.hpp"
#include "map/location.hpp"
#include "map/map.hpp"
#include "pathutils_impl.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/push_check.hpp"
#include "scripting/game_lua_kernel.hpp"
#include "formula/callable_objects.hpp"
#include "formula/formula.hpp"
#include "formula/string_utils.hpp"
#include <boost/dynamic_bitset.hpp>
#include <boost/range/iterator_range.hpp>
#include <unordered_map>
#include "lua/lauxlib.h"
#include "lua/lua.h"
Include dependency graph for lua_terrainfilter.cpp:

Go to the source code of this file.

Classes

struct  inalid_lua_argument
 
class  filter_impl
 

Namespaces

 utils
 
 lua_mapgen
 
 lua_terrainfilter
 

Macros

#define LOG_LMG   LOG_STREAM(info, log_scripting_lua_mapgen)
 
#define ERR_LMG   LOG_STREAM(err, log_scripting_lua_mapgen)
 
#define LOG_MATCHES(NAME)   LOG_LMG << #NAME << ":matches(" << l << ") line:" << __LINE__ << "\n";
 

Typedefs

using knows_sets_t = std::map< std::string, std::set< map_location > >
 
using offset_list_t = std::vector< std::pair< int, int > >
 
using dynamic_bitset = boost::dynamic_bitset<>
 
using location_set = std::set< map_location >
 

Enumerations

enum  filter_keys
 

Functions

template<typename T , typename... Args>
std::unique_ptr< T > utils::make_unique (Args &&... args)
 
static int luaW_push_locationset (lua_State *L, const std::set< map_location > &locs)
 
static std::set< map_locationluaW_to_locationset (lua_State *L, int index)
 
static int intf_mg_get_locations_part2 (lua_State *L, mapgen_gamemap &m, lua_mapgen::filter &f)
 
int intf_mg_get_locations (lua_State *L)
 
int intf_mg_get_tiles_radius (lua_State *L)
 
bool luaW_is_mgfilter (lua_State *L, int index)
 
lua_mapgen::filterluaW_to_mgfilter (lua_State *L, int index)
 
lua_mapgen::filterluaW_check_mgfilter (lua_State *L, int index)
 
void lua_mgfilter_setmetatable (lua_State *L)
 
template<typename... T>
static lua_mapgen::filterluaW_push_mgfilter (lua_State *L, T &&... params)
 
int intf_terainfilter_create (lua_State *L)
 Create a filter. More...
 
static int impl_terainfilter_get (lua_State *L)
 Gets some data on a filter (__index metamethod). More...
 
static int impl_terainfilter_set (lua_State *L)
 Sets some data on a filter (__newindex metamethod). More...
 
static int intf_clearcache (lua_State *L)
 Clears the cache of a filter. More...
 
static int impl_terainfilter_collect (lua_State *L)
 Destroys a map object before it is collected (__gc metamethod). More...
 
std::string lua_terrainfilter::register_metatables (lua_State *L)
 

Variables

static lg::log_domain log_scripting_lua_mapgen ("scripting/lua/mapgen")
 
static const char terrinfilterKey [] = "terrainfilter"
 

Macro Definition Documentation

◆ ERR_LMG

#define ERR_LMG   LOG_STREAM(err, log_scripting_lua_mapgen)

Definition at line 38 of file lua_terrainfilter.cpp.

Referenced by filter_impl::~filter_impl().

◆ LOG_LMG

#define LOG_LMG   LOG_STREAM(info, log_scripting_lua_mapgen)

◆ LOG_MATCHES

#define LOG_MATCHES (   NAME)    LOG_LMG << #NAME << ":matches(" << l << ") line:" << __LINE__ << "\n";

Definition at line 57 of file lua_terrainfilter.cpp.

Referenced by filter_impl::~filter_impl().

Typedef Documentation

◆ dynamic_bitset

using dynamic_bitset = boost::dynamic_bitset<>

Definition at line 53 of file lua_terrainfilter.cpp.

◆ knows_sets_t

using knows_sets_t = std::map<std::string, std::set<map_location> >

Definition at line 50 of file lua_terrainfilter.cpp.

◆ location_set

using location_set = std::set<map_location>

Definition at line 54 of file lua_terrainfilter.cpp.

◆ offset_list_t

using offset_list_t = std::vector<std::pair<int, int> >

Definition at line 51 of file lua_terrainfilter.cpp.

Enumeration Type Documentation

◆ filter_keys

Definition at line 633 of file lua_terrainfilter.cpp.

Function Documentation

◆ impl_terainfilter_collect()

static int impl_terainfilter_collect ( lua_State L)
static

Destroys a map object before it is collected (__gc metamethod).

Definition at line 893 of file lua_terrainfilter.cpp.

References f, luaW_check_mgfilter(), and lua_mapgen::filter::~filter().

Referenced by lua_terrainfilter::register_metatables().

◆ impl_terainfilter_get()

static int impl_terainfilter_get ( lua_State L)
static

Gets some data on a filter (__index metamethod).

  • Arg 1: full userdata containing the filter.
  • Arg 2: string containing the name of the property.
  • Ret 1: something containing the attribute.

Definition at line 857 of file lua_terrainfilter.cpp.

References f, luaW_check_mgfilter(), and UNUSED.

Referenced by lua_terrainfilter::register_metatables().

◆ impl_terainfilter_set()

static int impl_terainfilter_set ( lua_State L)
static

Sets some data on a filter (__newindex metamethod).

  • Arg 1: full userdata containing the filter.
  • Arg 2: string containing the name of the property.
  • Arg 3: something containing the attribute.

Definition at line 870 of file lua_terrainfilter.cpp.

References f, luaL_argerror(), luaL_checkstring, luaW_check_mgfilter(), and UNUSED.

Referenced by lua_terrainfilter::register_metatables().

◆ intf_clearcache()

static int intf_clearcache ( lua_State L)
static

Clears the cache of a filter.

Definition at line 884 of file lua_terrainfilter.cpp.

References f, luaW_check_mgfilter(), and UNUSED.

Referenced by lua_terrainfilter::register_metatables().

◆ intf_mg_get_locations()

int intf_mg_get_locations ( lua_State L)

◆ intf_mg_get_locations_part2()

static int intf_mg_get_locations_part2 ( lua_State L,
mapgen_gamemap m,
lua_mapgen::filter f 
)
static

◆ intf_mg_get_tiles_radius()

int intf_mg_get_tiles_radius ( lua_State L)

◆ intf_terainfilter_create()

int intf_terainfilter_create ( lua_State L)

◆ lua_mgfilter_setmetatable()

void lua_mgfilter_setmetatable ( lua_State L)

Definition at line 814 of file lua_terrainfilter.cpp.

References luaL_setmetatable(), and terrinfilterKey.

Referenced by luaW_push_mgfilter().

◆ luaW_check_mgfilter()

lua_mapgen::filter& luaW_check_mgfilter ( lua_State L,
int  index 
)

◆ luaW_is_mgfilter()

bool luaW_is_mgfilter ( lua_State L,
int  index 
)

◆ luaW_push_locationset()

static int luaW_push_locationset ( lua_State L,
const std::set< map_location > &  locs 
)
static

◆ luaW_push_mgfilter()

template<typename... T>
static lua_mapgen::filter* luaW_push_mgfilter ( lua_State L,
T &&...  params 
)
static

Definition at line 820 of file lua_terrainfilter.cpp.

References LOG_LMG, and lua_mgfilter_setmetatable().

Referenced by intf_terainfilter_create().

◆ luaW_to_locationset()

static std::set<map_location> luaW_to_locationset ( lua_State L,
int  index 
)
static

◆ luaW_to_mgfilter()

lua_mapgen::filter* luaW_to_mgfilter ( lua_State L,
int  index 
)

Definition at line 797 of file lua_terrainfilter.cpp.

References lua_touserdata(), and luaW_is_mgfilter().

Variable Documentation

◆ log_scripting_lua_mapgen

lg::log_domain log_scripting_lua_mapgen("scripting/lua/mapgen")
static

◆ terrinfilterKey

const char terrinfilterKey[] = "terrainfilter"
static