Merge pull request #1811 from GregoryLundberg/GL_CMake_clang

Fix Lua for CMake with clang

Fixes #1669
This commit is contained in:
Celtic Minstrel 2017-07-25 19:57:37 -04:00 committed by GitHub
commit f1fe86ab5f
48 changed files with 78 additions and 91 deletions

View file

@ -283,10 +283,10 @@ if(UNIX AND NOT CMAKE_COMPILER_IS_GNUCXX)
# version of cmake will be able to this for us.
#
# Also silence some Clang specific warnings due to extra parenthesis in if statements when comparing instead
set_source_files_properties(
${libwesnoth-lua_STAT_SRC}
PROPERTIES COMPILE_FLAGS
"-x c++ -Wno-parentheses-equality"
set_property(SOURCE
SOURCE ${libwesnoth-lua_STAT_SRC}
APPEND_STRING PROPERTY COMPILE_FLAGS
" -x c++ -Wno-parentheses-equality -Wno-conditional-uninitialized"
)
endif(UNIX AND NOT CMAKE_COMPILER_IS_GNUCXX)
@ -469,6 +469,7 @@ if(ENABLE_CAMPAIGN_SERVER)
target_link_libraries(campaignd
wesnoth-core
${server-external-libs}
${CRYPTO_LIBRARY}
${Boost_RANDOM_LIBRARY}
${LIBRT}
)

View file

@ -141,6 +141,8 @@ const std::set<std::string> get_recruits(int side, const map_location &recruit_l
*/
std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_loc);
typedef std::tuple<bool /*event modified*/, int /*previous village owner side*/, bool /*capture bonus time*/> place_recruit_result;
/**
* Place a unit into the game.
* The unit will be placed on @a recruit_location, which should be retrieved
@ -148,7 +150,6 @@ std::vector<unit_const_ptr > get_recalls(int side, const map_location &recall_lo
* @param facing the desired facing for the unit, map_location::NDIRECTIONS to determine facing automatically.
* @returns true if an event (or fog clearing) has mutated the game state.
*/
typedef std::tuple<bool /*event modified*/, int /*previous village owner side*/, bool /*capture bonus time*/> place_recruit_result;
place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_location, const map_location& recruited_from,
int cost, bool is_recall, map_location::DIRECTION facing = map_location::NDIRECTIONS, bool show = false, bool fire_event = true, bool full_movement = false, bool wml_triggered = false);

View file

@ -97,7 +97,7 @@ namespace actions {
{
}
virtual const char* get_type() const { return "dummy"; }
virtual ~undo_dummy_action () {};
virtual ~undo_dummy_action () {}
/// Undoes this action.
virtual bool undo(int)
{

View file

@ -38,7 +38,7 @@ struct dismiss_action : undo_action
{
}
virtual const char* get_type() const { return "dismiss"; }
virtual ~dismiss_action() {};
virtual ~dismiss_action() {}
/// Writes this into the provided config.
virtual void write(config & cfg) const;

View file

@ -141,9 +141,9 @@ struct recruit_job : public component {
}
return cfg;
}
std::string get_id() const {return id;};
std::string get_name() const {return "recruit_job";};
std::string get_engine() const {return "cpp";};
std::string get_id() const {return id;}
std::string get_name() const {return "recruit_job";}
std::string get_engine() const {return "cpp";}
};
struct recruit_limit : public component {
@ -164,9 +164,9 @@ struct recruit_limit : public component {
}
return cfg;
}
std::string get_id() const {return id;};
std::string get_name() const {return "recruit_limit";};
std::string get_engine() const {return "cpp";};
std::string get_id() const {return id;}
std::string get_name() const {return "recruit_limit";}
std::string get_engine() const {return "cpp";}
};
class recruitment_aspect : public standard_aspect<config> {

View file

@ -188,7 +188,7 @@ public:
std::string str(const std::string& fallback = "") const;
t_string t_str() const;
/**
@param T a type created with MAKE_ENUM macro
@tparam T a type created with MAKE_ENUM macro
NOTE: since T::VALUE constants is not of type T but of the underlying enum type you must specify the template parameter explicitly
TODO: Fix this in c++11 using constexpr types.
*/

View file

@ -270,9 +270,9 @@ private:
/**
* The color to render links in.
*
* Links are formatted using pango <span> as follows:
* Links are formatted using pango &lt;span> as follows:
*
* "<span underline=\'single\' color=\'" + link_color_ + "\'>"
* &lt;span underline="single" color=" + link_color_ + ">
*/
color_t link_color_;

View file

@ -30,8 +30,8 @@ namespace font {
/**
* Retuns a Pango formatting string using the provided color_t object.
*
* The string returned will be in format: '<span foreground=#color>'
* Callers will need to manually append the closing</span>' tag.
* The string returned will be in format: &lt;span foreground=#color>
* Callers will need to manually append the closing &lt;/span>' tag.
*
* @param color The color_t object from which to retrieve the color.
*/

View file

@ -172,7 +172,7 @@ public:
* Implements the increment functionality of @ref variant_iterator
* for a value of this type.
*
* @param iter The opaque reference that was passed to the variant_iterator by @ref make_iterator.
* The parameter is an opaque reference that was passed to the variant_iterator by @ref make_iterator.
*/
virtual void iterator_inc(boost::any&) const {}
@ -180,7 +180,7 @@ public:
* Implements the decrement functionality of @ref variant_iterator
* for a value of this type.
*
* @param iter The opaque reference that was passed to the variant_iterator by @ref make_iterator.
* The parameter is an opaque reference that was passed to the variant_iterator by @ref make_iterator.
*/
virtual void iterator_dec(boost::any&) const {}
@ -190,8 +190,8 @@ public:
*
* Note that this is only called if the two iterators are already known to be of the same type.
*
* @param first The opaque reference that was passed to the variant_iterator by @ref make_iterator.
* @param second The opaque reference that was passed to the variant_iterator by @ref make_iterator.
* The first parameter is an opaque reference that was passed to the variant_iterator by @ref make_iterator.
* The second parameter is an opaque reference that was passed to the variant_iterator by @ref make_iterator.
*/
virtual bool iterator_equals(const boost::any& /*first*/, const boost::any& /*second*/) const
{

View file

@ -89,7 +89,7 @@ public:
* The undo stack will be cleared if the event mutated the gamestate.
*
* @param[in] event_hex The location of the event (where the menu was opened).
* @param[in] last_select The location of the most recent "select" event.
* @param[in] data The game data for the most recent "select" event.
*/
void fire_event(const map_location& event_hex, const game_data& data) const;

View file

@ -63,7 +63,7 @@ public:
/**
* Gets the menu item with the specified ID.
*
* @param Item id.
* @param id Item id.
* @returns Pointer to the relavent item, or nullptr if not found.
*/
item_ptr get_item(const std::string& id) const;

View file

@ -44,8 +44,6 @@ typedef std::pair<ng::controller, std::string> controller_option;
class connect_engine
{
public:
/// @param players the player which are already connected to the current game.
/// This is always empty unless we advance form a previous scenario.
connect_engine(saved_game& state,
const bool first_scenario, mp_campaign_info* campaign_info);

View file

@ -139,7 +139,7 @@ public:
/**
* Tells whether a certain mod is activated.
*
* @param string the string id of the mod
* @param id the string id of the mod
*
* @return true if activated, false is not
*/

View file

@ -260,7 +260,7 @@ public:
* @param target The widget that should receive the event.
* Normally this is the window holding the
* widget.
* @param message The extra information needed for a window
* @param msg The extra information needed for a window
* (or another widget in the chain) to handle
* the message.
*/

View file

@ -288,7 +288,7 @@ namespace implementation
* @param event The event to test.
* @param dispatcher The final widget to test, this is also the
* dispatcher the sends the event.
* @param widget The widget should parent(s) to check.
* @param w The widget should parent(s) to check.
*
* @returns The list of widgets with a handler.
* The order will be (assuming all have a

View file

@ -36,8 +36,6 @@ public:
* the dialog returns @ref window::OK or 3
* undefined otherwise.
* @param allow_remove Sets @ref allow_remove_.
* @param disp The display object used for showing the
* in-game help when requested.
*/
addon_connect(std::string& host_name,
const bool allow_remove);

View file

@ -34,7 +34,7 @@ class campaign_difficulty : public modal_dialog
{
public:
/**
* @param config of the campaign difficulty is being chosen for
* @param campaign The campaign the difficulty is being chosen for
*/
campaign_difficulty(const config& campaign);

View file

@ -379,8 +379,6 @@ private:
*
* At this point the registered fields are not yet registered.
*
* @param video The video which contains the surface to draw
* upon.
* @param window The window just created.
*/
virtual void post_build(window& window);

View file

@ -104,8 +104,6 @@ private:
/**
* Actions to be taken directly after the window is build.
*
* @param video The video which contains the surface to draw
* upon.
* @param window The window just created.
*/
virtual void post_build(window& window);
@ -113,8 +111,6 @@ private:
/**
* Actions to be taken before showing the window.
*
* @param video The video which contains the surface to draw
* upon.
* @param window The window to be shown.
*/
virtual void pre_show(window& window);

View file

@ -72,7 +72,7 @@ private:
void set_state_changed()
{
state_changed_ = true;
};
}
ng::connect_engine& connect_engine_;

View file

@ -31,9 +31,9 @@ public:
, description_(description)
, image_(image)
{}
std::string label() const {return label_;};
std::string description() const {return description_;};
std::string image() const {return image_;};
std::string label() const {return label_;}
std::string description() const {return description_;}
std::string image() const {return image_;}
private:
std::string label_, description_, image_;
};

View file

@ -66,7 +66,7 @@ public:
virtual bool get_active() const override;
/** See @ref styled_widget::get_state. */
virtual unsigned get_state() const override { return 0; };
virtual unsigned get_state() const override { return 0; }
void send_to_server(const ::config& cfg) override;

View file

@ -127,7 +127,7 @@ public:
* touch the other settings of the child.
*
* @param id The id of the widget to free.
* @param widget The widget to put in the grid.
* @param w The widget to put in the grid.
* @param recurse Do we want to decent into the child grids.
* @param new_parent The new parent for the swapped out widget.
*
@ -231,7 +231,7 @@ public:
*
* @param widget The widget whose cell to modify.
* @param set_flag The alignment flag to set.
* @param mask Whether to affect horizontal or vertical alignment.
* @param mode_mask Whether to affect horizontal or vertical alignment.
* Use either HORIZONTAL_MASK or VERTICAL_MASK
*/
void set_child_alignment(widget* widget, unsigned set_flag, unsigned mode_mask);

View file

@ -111,7 +111,7 @@ public:
/**
* Set the options selected in the menu.
*
* @param mask A mask specifying which options to select and deselect
* @param states A mask specifying which options to select and deselect
*/
void select_options(boost::dynamic_bitset<> states);

View file

@ -318,7 +318,7 @@ protected:
* The position where the additional content was
* inserted/removed, defaults to -1 whcih means
* 'at end'
* @param height_modification_po
* @param height_modification_pos
* The position where the additional content was
* inserted/removed, defaults to -1 whcih means
* 'at end'

View file

@ -80,7 +80,7 @@ using widget_parser_t = std::function<styled_widget_definition_ptr(const config&
* regarding the static initialization problem.
*
* @param id The id of the widget to register.
* @param functor The function to parse the definition config.
* @param f The function to parse the definition config.
* @param key The tagname from which to read the widget's definition in the game config.
* If nullptr the default [<id>_definition] is used.
*/
@ -89,7 +89,7 @@ void register_widget(const std::string& id, widget_parser_t f, const char* key =
/**
* Loads the definitions of a widget.
*
* @param gui_definition The gui definition the widget definition
* @param gui The gui definition the widget definition
* belongs to.
* @param definition_type The type of the widget whose definitions are
* to be loaded.

View file

@ -102,7 +102,7 @@ public:
* Gets the grid for a specified layer.
* This can be used to search for widgets in a hidden layer.
*
* @param The layer to retrieve
* @param i The layer to retrieve
* @returns The grid for the specified layer.
*/
grid* get_layer_grid(unsigned int i);

View file

@ -298,7 +298,7 @@ private:
point calculate_best_size(const int indentation_level,
const unsigned indentation_step_size) const;
/** @param assume_visible: if false (default) it will return 0 if the parent node is folded*/
/** @param assume_visible if false (default) it will return 0 if the parent node is folded*/
point get_current_size(bool assume_visible = false) const;
point get_folded_size() const;
point get_unfolded_size() const;

View file

@ -473,7 +473,7 @@ public:
*
* A window will only close if this function returns true.
*
* @param window The current window.
* @param func A function taking a window reference and returing a boolean result.
*/
void set_exit_hook(std::function<bool(window&)> func)
{

View file

@ -245,7 +245,7 @@ public:
/**
* Set the keycode associated with this class.
* @param keycode_ The SDL_Keycode that this hotkey should be associated with
* @param keycode The SDL_Keycode that this hotkey should be associated with
*/
void set_keycode(SDL_Keycode keycode)
{

View file

@ -578,7 +578,7 @@ surface cs_modification::operator()(const surface& src) const
surface blend_modification::operator()(const surface& src) const
{
return blend_surface(src, a_, color_t(r_, g_, b_));
return blend_surface(src, static_cast<double>(a_), color_t(r_, g_, b_));
}
surface bl_modification::operator()(const surface& src) const

View file

@ -147,7 +147,7 @@ struct lexical_caster
{
DEBUG_THROW("generic");
To result;
To result = To();
std::stringstream sstr;
if(!(sstr << value && sstr >> result)) {
@ -352,7 +352,7 @@ struct lexical_caster<
try {
long double res = std::stold(value);
if(std::numeric_limits<To>::lowest() <= res && std::numeric_limits<To>::max() >= res) {
if((static_cast<long double>(std::numeric_limits<To>::lowest()) <= res) && (static_cast<long double>(std::numeric_limits<To>::max()) >= res)) {
return static_cast<To>(res);
}
} catch(std::invalid_argument&) {

View file

@ -332,8 +332,8 @@ protected:
std::unique_ptr<game_display> gui_;
const std::unique_ptr<unit_experience_accelerator> xp_mod_;
const std::unique_ptr<const statistics::scenario_context> statistics_context_;
actions::undo_list& undo_stack() { return *gamestate().undo_stack_; };
const actions::undo_list& undo_stack() const { return *gamestate().undo_stack_; };
actions::undo_list& undo_stack() { return *gamestate().undo_stack_; }
const actions::undo_list& undo_stack() const { return *gamestate().undo_stack_; }
std::unique_ptr<replay> replay_;
bool skip_replay_;
@ -361,7 +361,7 @@ private:
protected:
mutable bool ignore_replay_errors_;
bool player_type_changed_;
virtual void sync_end_turn() {};
virtual void sync_end_turn() {}
virtual void check_time_over();
virtual void update_viewing_player() = 0;
void play_turn();

View file

@ -32,7 +32,7 @@ public:
virtual bool should_stop() { return true; }
virtual ~replay_stop_condition(){}
};
static void nop() {};
static void nop() {}
replay_controller(play_controller& controller, bool control_view, const std::shared_ptr<config>& reset_state, const std::function<void()>& on_end_replay = nop);
~replay_controller();
@ -49,7 +49,7 @@ public:
bool can_execute_command(const hotkey::hotkey_command& cmd, int index) const;
bool is_controlling_view() const { return vision_.is_initialized(); }
bool allow_reset_replay() const { return reset_state_.get() != nullptr; }
const std::shared_ptr<config>& get_reset_state() const { return reset_state_; };
const std::shared_ptr<config>& get_reset_state() const { return reset_state_; }
void return_to_play_side(bool r = true) { return_to_play_side_ = r; }
void replay_show_everything();
void replay_show_each();

View file

@ -2570,7 +2570,7 @@ int game_lua_kernel::intf_play_sound(lua_State *L)
static int intf_sound_volume(lua_State* L)
{
int vol = preferences::sound_volume();
lua_pushnumber(L, sound::get_sound_volume() * 100.0f / vol);
lua_pushnumber(L, sound::get_sound_volume() * 100.0 / vol);
if(lua_isnumber(L, 1)) {
float rel = lua_tonumber(L, 1);
if(rel < 0.0f || rel > 100.0f) {

View file

@ -114,7 +114,7 @@ static int impl_music_get(lua_State* L) {
}
// This calculation reverses the one used in [volume] to get back the relative volume level.
// (Which is the same calculation that's duplicated in impl_music_set.)
return_float_attrib("volume", sound::get_music_volume() * 100.0f / preferences::music_volume());
return_float_attrib("volume", sound::get_music_volume() * 100.0 / preferences::music_volume());
return luaW_getmetafield(L, 1, m);
}
@ -151,7 +151,7 @@ static int impl_music_set(lua_State* L) {
return 0;
}
const char* m = luaL_checkstring(L, 2);
modify_float_attrib_check_range("volume", sound::set_music_volume(value * preferences::music_volume() / 100.0f), 0.0, 100.0);
modify_float_attrib_check_range("volume", sound::set_music_volume(value * preferences::music_volume() / 100.0), 0.0, 100.0);
modify_int_attrib_check_range("current_i", sound::play_track(value - 1), 1, static_cast<int>(sound::get_num_tracks()));
return 0;
}

View file

@ -87,9 +87,9 @@ namespace utf8 {
*
* The output is guaranteed to be valid UTF-8.
*
* @param[in] str String encoded in UTF-8.
* @param[out] str String encoded UTF-8 that contains at most @p size
* codepoints.
* @param[in,out] str [in] String encoded in UTF-8.
* [out] String encoded UTF-8 that contains at most @p size
* codepoints.
* @param size The size to truncate to.
*/
void truncate_as_ucs4(utf8::string& str, const size_t size);

View file

@ -282,7 +282,7 @@ private:
void transfer_ai_sides(const socket_ptr player);
void send_leave_game(socket_ptr user) const;
/**
@param sides: a comma sperated list of side numbers to which the package should be sent,
@param sides a comma sperated list of side numbers to which the package should be sent,
*/
void send_data_sides(simple_wml::document& data, const simple_wml::string_span& sides,
const socket_ptr exclude=socket_ptr(), std::string packet_type = "") const;

View file

@ -133,7 +133,7 @@ public:
class server_choice
{
public:
virtual ~server_choice(){};
virtual ~server_choice(){}
/// We are in a game with no mp server and need to do this choice locally
virtual config local_choice() const = 0;
/// the request which is sended to the mp server.

View file

@ -105,8 +105,8 @@ public:
void ask_local_choice();
void fix_oos();
const std::string& wait_message() const { return wait_message_; }
/// @param name: the tagname for this user choice in the replay
/// @param sides: an array of team numbers (beginning with 1). the specified sides may not have an empty controller.
/// @param name the tagname for this user choice in the replay
/// @param sides an array of team numbers (beginning with 1). the specified sides may not have an empty controller.
static std::map<int, config> get_user_choice_internal(const std::string &name, const mp_sync::user_choice &uch, const std::set<int>& sides);
/// Inherited from events::pump_monitor
void process(events::pump_info&);

View file

@ -47,7 +47,6 @@ public:
/// @param loc The location to test
/// @param ref_unit A reference unit for the $teleport_unit auto-stored variable
/// @param unit_loc The reference unit's apparent location for this filter
/// @returns true if and only if the given location matches this filter
bool match(const map_location& loc, const unit& ref_unit) const {
return match_impl(loc, &ref_unit);
@ -66,7 +65,6 @@ public:
/// @param[out] locs set to store the results in
/// @param[in] with_border whether to include the borders
/// @param[in] ref_unit A reference unit for the $teleport_unit auto-stored variable
/// @param[in] unit_loc The reference unit's apparent location for this filter
void get_locations(std::set<map_location>& locs, const unit& ref_unit, bool with_border=false) const {
return get_locs_impl(locs, &ref_unit, with_border);
}

View file

@ -61,6 +61,8 @@ namespace t_translation {
*/
static terrain_code get_mask_(const terrain_code& terrain);
static ter_layer string_to_layer_(const char* begin, const char* end);
/**
* Converts a string to a layer.
*
@ -69,7 +71,6 @@ namespace t_translation {
*
* @return The converted layer.
*/
static ter_layer string_to_layer_(const char* begin, const char* end);
static ter_layer string_to_layer_(const std::string& str)
{
return string_to_layer_(str.c_str(), str.c_str() + str.size());

View file

@ -247,7 +247,7 @@ namespace t_translation {
* [S ]T
* S = starting location a positive non-zero number
* T = terrain code (see read_terrain_code)
* @param starting_positions This parameter will be filled with the starting
* @param positions This parameter will be filled with the starting
* locations found. Starting locations can only occur once
* if multiple definitions occur of the same position only
* the last is stored. The returned value is a map:
@ -263,7 +263,7 @@ namespace t_translation {
* Write a gamemap in to a vector string.
*
* @param map A terrain vector, as returned from read_game_map
* @param starting_positions A starting positions map, as returned from read_game_map
* @param positions A starting positions map, as returned from read_game_map
*
* @returns A terrain string which can be read with read_game_map.
* For readability the map is padded to groups of 12 chars,

View file

@ -1274,8 +1274,8 @@ public:
/**
* Count modifications of a particular type.
* @param The type of modification to count.
* Valid values are "advancement", "trait", "object"
* @param type The type of modification to count.
* Valid values are "advancement", "trait", "object"
* @param id The ID of the modification to count
* @return The total number of modifications of that type and ID.
*/
@ -1283,8 +1283,8 @@ public:
/**
* Add a new modification to the unit.
* @param The type of modification to add.
* Valid values are "advancement", "trait", "object"
* @param type The type of modification to add.
* Valid values are "advancement", "trait", "object"
* @param modification The details of the modification
* @param no_add If true, apply the modification but don't save it for unit rebuild time.
* Defaults to false.

View file

@ -108,9 +108,7 @@ inline std::size_t bit_width() {
*
* sizeof(x) * std::numeric_limits<unsigned char>::digits
*
* @tparam T The type of `x`.
*
* @param x The return value is the size, in bits, of this object.
* @tparam T The return value is the size, in bits, of the type of this object.
*
* @returns the size, in bits, of an instance of type `T`.
*/

View file

@ -50,8 +50,7 @@ private:
* Determines a name generator from WML data. Tries first to load a context-free generator,
* then falls back to Markov.
* @param config the WML data to be parsed for name generators
* @param the prefix to look for
* @returns a name generator or nullptr if not found
* @param prefix the prefix to look for
*/
void add_name_generator_from_config(const config& config, const std::string id, const std::string prefix);
};

View file

@ -62,16 +62,14 @@ public:
void set_fullscreen(bool ison);
void set_resolution(const std::pair<int,int>& res);
/**
* Set the resolution.
*
* @param width The new width.
* @param height The new height.
*
* @returns The status true if width and height are the
* size of the framebuffer, false otherwise.
*/
void set_resolution(const std::pair<int,int>& res);
void set_resolution(const unsigned width, const unsigned height);
std::pair<int,int> current_resolution();

View file

@ -256,10 +256,11 @@ struct future_map
struct future_map_if
{
/** @param cond: If true, applies the planned unit map for the duration of the struct's life and reverts to real unit map on destruction.
const std::unique_ptr<future_map> future_map_;
/** @param cond If true, applies the planned unit map for the duration of the struct's life and reverts to real unit map on destruction.
No effect if cond == false.
*/
const std::unique_ptr<future_map> future_map_;
future_map_if(bool cond)
: future_map_(cond ? new future_map() : nullptr)
{}