[Commits] [wesnoth/wesnoth] 99874f: Refactor variant class

GitHub noreply at github.com
Sun Apr 2 06:56:09 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 99874f4253788624281e1bd1778c299995813448
      https://github.com/wesnoth/wesnoth/commit/99874f4253788624281e1bd1778c299995813448
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M projectfiles/CodeBlocks/wesnoth.cbp
    M source_lists/wesnoth
    M src/ai/composite/value_translator.hpp
    M src/ai/default/attack.cpp
    M src/ai/formula/ai.cpp
    M src/ai/formula/callable_objects.cpp
    M src/ai/formula/candidates.cpp
    M src/ai/formula/function_table.cpp
    M src/formula/callable.hpp
    M src/formula/callable_fwd.hpp
    M src/formula/callable_objects.cpp
    M src/formula/callable_objects.hpp
    M src/formula/formula.cpp
    M src/formula/function.cpp
    M src/formula/variant.cpp
    M src/formula/variant.hpp
    A src/formula/variant_private.cpp
    A src/formula/variant_private.hpp
    M src/gui/widgets/styled_widget.cpp
    M src/scripting/lua_formula_bridge.cpp
    M src/tests/test_formula_core.cpp
    M src/units/formula_manager.cpp

  Log Message:
  -----------
  Refactor variant class

This splits the handling of each applicable type into its own helper class to better encapsulate the functionality of each.
It also contains a lot of related cleanup and improvements to the class interface itself.


  Commit: 3f10883c456fa1f26ef1e1e2272e607c0ed07345
      https://github.com/wesnoth/wesnoth/commit/3f10883c456fa1f26ef1e1e2272e607c0ed07345
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/ai/composite/value_translator.hpp
    M src/ai/default/attack.cpp
    M src/ai/formula/ai.cpp
    M src/ai/formula/callable_objects.cpp
    M src/ai/formula/candidates.cpp
    M src/ai/formula/function_table.cpp
    M src/formula/callable.hpp
    M src/formula/callable_objects.cpp
    M src/formula/formula.cpp
    M src/formula/function.cpp
    M src/tests/test_formula_core.cpp

  Log Message:
  -----------
  Made use of emplace_back for variant creation


  Commit: 29f04bdfc2ad336d12364c912ba0998cba67f770
      https://github.com/wesnoth/wesnoth/commit/29f04bdfc2ad336d12364c912ba0998cba67f770
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/ai/formula/ai.cpp
    M src/ai/formula/function_table.cpp
    M src/formula/function.cpp
    M src/formula/variant.hpp

  Log Message:
  -----------
  Removed external variant conversion functions in favor of in-class ones.


  Commit: 00a987369d31ac27cda0d6318fc1305aac17c80e
      https://github.com/wesnoth/wesnoth/commit/00a987369d31ac27cda0d6318fc1305aac17c80e
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/variant.hpp
    M src/formula/variant_private.cpp
    M src/formula/variant_private.hpp

  Log Message:
  -----------
  Removed 'mutable' member of variant_callable

In the old code, both this and the const version were part of a union, which meant both got intialized with a value.
Now, the mutable variable was always nullptr. Since we cannot pass a non-const callable ptr to the variant ctor, we
need to use const_cast.


  Commit: ccadd7625eface6ecdd1b46cfa5ecbc3a127c49f
      https://github.com/wesnoth/wesnoth/commit/ccadd7625eface6ecdd1b46cfa5ecbc3a127c49f
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/variant.cpp

  Log Message:
  -----------
  Fixed nullptr access if variant is of type null


  Commit: 4d7fd5fa1c85c0a58f5ff4dd116d8b9c057038af
      https://github.com/wesnoth/wesnoth/commit/4d7fd5fa1c85c0a58f5ff4dd116d8b9c057038af
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/ai/formula/candidates.cpp

  Log Message:
  -----------
  Use variant::try_convert when possible


  Commit: d3b85060d01a2020fbc5de0e508d648f467cd41b
      https://github.com/wesnoth/wesnoth/commit/d3b85060d01a2020fbc5de0e508d648f467cd41b
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/variant_private.hpp

  Log Message:
  -----------
  Added/improved variant value documentation


  Commit: 5b5013547474a902813489f28f3390cbaf8098c6
      https://github.com/wesnoth/wesnoth/commit/5b5013547474a902813489f28f3390cbaf8098c6
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/tests/test_formula_core.cpp

  Log Message:
  -----------
  Attempt to fixup tests


  Commit: 725bd6291f33928d625535f644fe0b1e88774090
      https://github.com/wesnoth/wesnoth/commit/725bd6291f33928d625535f644fe0b1e88774090
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/callable_fwd.hpp
    M src/formula/debugger.cpp
    M src/formula/function.cpp
    M src/formula/variant.cpp
    M src/formula/variant.hpp
    M src/formula/variant_private.cpp
    M src/formula/variant_private.hpp
    M src/gui/dialogs/formula_debugger.cpp

  Log Message:
  -----------
  Refactored handling of the callable variant debug stack

The debug stack is only relevant to callable variants. So instead of continuously passing around a stack reference
to all value classes just so it can be passed back to variant::to_debug_string in the case of recursive calls,
we now keep a static stack member in variant_callable. A second bool flag (clear_stack) has been added to
variant::to_debug_string, to which all recursive value callers should pass false in order to preserve the stack.


  Commit: c5de7fd50e3ad3a6ca6ab771c8a050897a5d95ae
      https://github.com/wesnoth/wesnoth/commit/c5de7fd50e3ad3a6ca6ab771c8a050897a5d95ae
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/variant.cpp
    M src/formula/variant.hpp
    M src/formula/variant_private.hpp

  Log Message:
  -----------
  Address a bunch of critique from the feedback Minstrel


  Commit: dec492d6dc9d5f7d3750d42605a744fd32da25f5
      https://github.com/wesnoth/wesnoth/commit/dec492d6dc9d5f7d3750d42605a744fd32da25f5
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M projectfiles/CodeBlocks/wesnoth.cbp
    M source_lists/wesnoth
    M src/formula/variant.hpp
    R src/formula/variant_private.cpp
    R src/formula/variant_private.hpp
    A src/formula/variant_value.cpp
    A src/formula/variant_value.hpp

  Log Message:
  -----------
  Renamed variable_private.*pp to better reflect its role


  Commit: 7cab3f29a3d2bc1b35b9ea860a40a1745bbcfba3
      https://github.com/wesnoth/wesnoth/commit/7cab3f29a3d2bc1b35b9ea860a40a1745bbcfba3
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/variant.cpp

  Log Message:
  -----------
  Minor cleanup to variant error reporting


  Commit: 978c8d34199f3ea26b30033fdcb307965e3d1e60
      https://github.com/wesnoth/wesnoth/commit/978c8d34199f3ea26b30033fdcb307965e3d1e60
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/variant_value.cpp

  Log Message:
  -----------
  Attempt to fix tests again

Restores a space between list values.


  Commit: 9fe45ce42f70db3245253ef8ff1380f445f47ba7
      https://github.com/wesnoth/wesnoth/commit/9fe45ce42f70db3245253ef8ff1380f445f47ba7
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-04-02 (Sun, 02 Apr 2017)

  Changed paths:
    M src/formula/function.cpp
    M src/formula/variant.hpp
    M src/formula/variant_value.cpp
    M src/formula/variant_value.hpp
    M src/scripting/lua_formula_bridge.cpp

  Log Message:
  -----------
  Revert variant_callable handling to raw pointers temporarily

Since there are some issues with deploying shared_ptr fully and it has not yet been done, there's the possibility
of pointers being freed twice. The raw pointer implementation results in memory leaks, but at least it should
suffice until full smart pointer support can be added.


Compare: https://github.com/wesnoth/wesnoth/compare/d8c670654a3d...9fe45ce42f70


More information about the Commits mailing list