Skip to content

Commit

Permalink
WFL/Formula: cleaned up formatting and greatly reduced code duplication
Browse files Browse the repository at this point in the history
I added a helper macro to define the various function classes.
  • Loading branch information
Vultraz committed Nov 14, 2017
1 parent 6713070 commit e50a639
Show file tree
Hide file tree
Showing 2 changed files with 1,198 additions and 1,326 deletions.

4 comments on commit e50a639

@matthiaskrgr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this broke stuff...

FAILED: src/CMakeFiles/wesnoth-game.dir/formula/function.cpp.o 
/home/matthias/LLVM/LLVM_dev/stage_2/build/bin/clang++  -DBOOST_TEST_DYN_LINK -DFIFODIR=\"/var/run/wesnothd\" -DHAS_RELATIVE_LOCALEDIR=1 -DHAVE_CONFIG_H -DHAVE_FRIBIDI -DHAVE_LIBDBUS -DHAVE_LIBPNG -DLOCALEDIR=\"translations\" -DLUA_USE_POSIX -DWESNOTH_PATH=\"/usr/local/share/wesnoth\" -D_X11 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/pango-1.0 -isystem /usr/include/harfbuzz -isystem /usr/include/cairo -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/pixman-1 -isystem /usr/include/libdrm -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -isystem /usr/include/SDL2 -I../src -Isrc -isystem /usr/include/fribidi -std=c++11 -W -Wall -fsanitize=address,undefined -g3 -I/usr/include/boost -Og -fno-omit-frame-pointer -march=native -fsanitize-address-use-after-scope  -fno-optimize-sibling-calls -O0 -DDEBUG -ggdb3     -I/usr/include/SDL2 -D_REENTRANT -MD -MT src/CMakeFiles/wesnoth-game.dir/formula/function.cpp.o -MF src/CMakeFiles/wesnoth-game.dir/formula/function.cpp.o.d -o src/CMakeFiles/wesnoth-game.dir/formula/function.cpp.o -c ../src/formula/function.cpp
../src/formula/function.cpp:83:1: error: pasting formed ',0', an invalid preprocessing token
DEFINE_WFL_FUNCTION(debug, 0, 1)
^
../src/formula/function.hpp:32:39: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                           ^
../src/formula/function.cpp:83:1: error: pasting formed ',1', an invalid preprocessing token
../src/formula/function.hpp:32:51: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                                       ^
../src/formula/function.cpp:105:1: error: pasting formed ',1', an invalid preprocessing token
DEFINE_WFL_FUNCTION(dir, 1, 1)
^
../src/formula/function.hpp:32:39: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                           ^
../src/formula/function.cpp:105:1: error: pasting formed ',1', an invalid preprocessing token
../src/formula/function.hpp:32:51: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                                       ^
../src/formula/function.cpp:121:1: error: pasting formed ',2', an invalid preprocessing token
DEFINE_WFL_FUNCTION(if, 2, -1)
^
../src/formula/function.hpp:32:39: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                           ^
../src/formula/function.cpp:121:1: error: pasting formed ',-', an invalid preprocessing token
../src/formula/function.hpp:32:51: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                                       ^
../src/formula/function.cpp:136:1: error: pasting formed ',3', an invalid preprocessing token
DEFINE_WFL_FUNCTION(switch, 3, -1)
^
../src/formula/function.hpp:32:39: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                           ^
../src/formula/function.cpp:136:1: error: pasting formed ',-', an invalid preprocessing token
../src/formula/function.hpp:32:51: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                                       ^
../src/formula/function.cpp:155:1: error: pasting formed ',1', an invalid preprocessing token
DEFINE_WFL_FUNCTION(abs, 1, 1)
^
../src/formula/function.hpp:32:39: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                           ^
../src/formula/function.cpp:155:1: error: pasting formed ',1', an invalid preprocessing token
../src/formula/function.hpp:32:51: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                                       ^
../src/formula/function.cpp:167:1: error: pasting formed ',1', an invalid preprocessing token
DEFINE_WFL_FUNCTION(min, 1, -1)
^
../src/formula/function.hpp:32:39: note: expanded from macro 'DEFINE_WFL_FUNCTION'
                        : function_expression(#name, args, ##min_args, ##max_args)                                                 \
                                                           ^
[...]

@Vultraz
Copy link
Member Author

@Vultraz Vultraz commented on e50a639 Nov 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work if you change that line to : function_expression(#name, args, min_args, max_args) ?

@matthiaskrgr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get some compiler warnings but it seems to have fixed the build

[  8%/31/4/355,67.058] Building CXX object src/CMakeFiles/wesnoth-game.dir/formula/function.cpp.o
../src/formula/function.cpp:590:1: warning: unused parameter 'variables' [-Wunused-parameter]
DEFINE_WFL_FUNCTION(pi, 0, 0)
^
../src/formula/function.hpp:40:59: note: expanded from macro 'DEFINE_WFL_FUNCTION'
        variant name##_function::execute(const formula_callable& variables, formula_debugger* fdb) const
                                                                 ^
../src/formula/function.cpp:590:1: warning: unused parameter 'fdb' [-Wunused-parameter]
../src/formula/function.hpp:40:88: note: expanded from macro 'DEFINE_WFL_FUNCTION'
        variant name##_function::execute(const formula_callable& variables, formula_debugger* fdb) const
                                                                                              ^
2 warnings generated.

@AI0867
Copy link
Member

@AI0867 AI0867 commented on e50a639 Nov 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got these issues too. I've fixed them in 133eb2a and ee10e33.

Please sign in to comment.