From 5e92d9455c2fb06cc1a49b8ce587c551abcbaaa2 Mon Sep 17 00:00:00 2001 From: Twan van Laarhoven Date: Sun, 26 Apr 2020 00:37:13 +0200 Subject: [PATCH] Code cleanup: remove messy spaces before line continuation (\) in macros --- src/data/field.hpp | 24 ++++----- src/gfx/combine_image.cpp | 48 ++++++++--------- src/gui/control/card_editor.hpp | 8 +-- src/gui/control/card_list.hpp | 12 ++--- src/gui/control/keyword_list.hpp | 6 +-- src/gui/set/cards_panel.cpp | 10 ++-- src/gui/set/console_panel.cpp | 6 +-- src/gui/set/keywords_panel.cpp | 16 +++--- src/gui/set/style_panel.cpp | 10 ++-- src/gui/value/editor.hpp | 28 +++++----- src/render/value/viewer.hpp | 26 +++++----- src/script/context.cpp | 32 ++++++------ src/script/functions/util.hpp | 86 +++++++++++++++---------------- src/util/action_stack.hpp | 14 ++--- src/util/dynamic_arg.hpp | 38 +++++++------- src/util/for_each.hpp | 88 ++++++++++++++++---------------- src/util/io/get_member.hpp | 24 ++++----- src/util/io/reader.hpp | 32 ++++++------ src/util/io/writer.hpp | 20 ++++---- 19 files changed, 263 insertions(+), 265 deletions(-) diff --git a/src/data/field.hpp b/src/data/field.hpp index 3d116006..9cd01305 100644 --- a/src/data/field.hpp +++ b/src/data/field.hpp @@ -258,10 +258,10 @@ inline String type_name(const Value&) { // ----------------------------------------------------------------------------- : Utilities -#define DECLARE_FIELD_TYPE(Type) \ - DECLARE_REFLECTION(); public: \ - virtual ValueP newValue(const FieldP& thisP) const; \ - virtual StyleP newStyle(const FieldP& thisP) const; \ +#define DECLARE_FIELD_TYPE(Type) \ + DECLARE_REFLECTION(); public: \ + virtual ValueP newValue(const FieldP& thisP) const; \ + virtual StyleP newStyle(const FieldP& thisP) const; \ virtual String typeName() const // implement newStyle and newValue @@ -291,17 +291,17 @@ inline String type_name(const Value&) { virtual ValueViewerP makeViewer(DataViewer& parent, const StyleP& thisP); \ virtual ValueViewerP makeEditor(DataEditor& parent, const StyleP& thisP) -#define DECLARE_VALUE_TYPE(Type,ValueType_) \ - DECLARE_REFLECTION(); public: \ - DECLARE_HAS_FIELD(Type) \ - virtual ValueP clone() const; \ - virtual String toString() const; \ +#define DECLARE_VALUE_TYPE(Type,ValueType_) \ + DECLARE_REFLECTION(); public: \ + DECLARE_HAS_FIELD(Type) \ + virtual ValueP clone() const; \ + virtual String toString() const; \ typedef ValueType_ ValueType // implement field() which returns a field with the right (derived) type -#define DECLARE_HAS_FIELD(Type) \ - inline Type ## Field& field() const { \ - return *static_cast(fieldP.get()); \ +#define DECLARE_HAS_FIELD(Type) \ + inline Type ## Field& field() const { \ + return *static_cast(fieldP.get()); \ } void mark_dependency_member(const IndexMap& value, const String& name, const Dependency& dep); diff --git a/src/gfx/combine_image.cpp b/src/gfx/combine_image.cpp index 1662a902..5c6f7657 100644 --- a/src/gfx/combine_image.cpp +++ b/src/gfx/combine_image.cpp @@ -50,40 +50,40 @@ template struct Combine { }; // Give a combining function for enum value 'combine' -#define COMBINE_FUN(combine,fun) \ +#define COMBINE_FUN(combine,fun) \ template <> int Combine::f(int a, int b) { return fun; } // Based on // http://www.pegtop.net/delphi/articles/blendmodes/ -COMBINE_FUN(COMBINE_NORMAL, b ) -COMBINE_FUN(COMBINE_ADD, top(a + b) ) -COMBINE_FUN(COMBINE_SUBTRACT, bot(a - b) ) -COMBINE_FUN(COMBINE_STAMP, col(a - 2 * b + 256) ) -COMBINE_FUN(COMBINE_DIFFERENCE, abs(a - b) ) -COMBINE_FUN(COMBINE_NEGATION, 255 - abs(255 - a - b) ) -COMBINE_FUN(COMBINE_MULTIPLY, (a * b) / 255 ) -COMBINE_FUN(COMBINE_DARKEN, min(a, b) ) -COMBINE_FUN(COMBINE_LIGHTEN, max(a, b) ) -COMBINE_FUN(COMBINE_COLOR_DODGE,b == 255 ? 255 : top(a * 255 / (255 - b)) ) -COMBINE_FUN(COMBINE_COLOR_BURN, b == 0 ? 0 : bot(255 - (255-a) * 255 / b) ) -COMBINE_FUN(COMBINE_SCREEN, 255 - (((255 - a) * (255 - b)) / 255) ) +COMBINE_FUN(COMBINE_NORMAL, b) +COMBINE_FUN(COMBINE_ADD, top(a + b)) +COMBINE_FUN(COMBINE_SUBTRACT, bot(a - b)) +COMBINE_FUN(COMBINE_STAMP, col(a - 2 * b + 256)) +COMBINE_FUN(COMBINE_DIFFERENCE, abs(a - b)) +COMBINE_FUN(COMBINE_NEGATION, 255 - abs(255 - a - b)) +COMBINE_FUN(COMBINE_MULTIPLY, (a * b) / 255) +COMBINE_FUN(COMBINE_DARKEN, min(a, b)) +COMBINE_FUN(COMBINE_LIGHTEN, max(a, b)) +COMBINE_FUN(COMBINE_COLOR_DODGE, b == 255 ? 255 : top(a * 255 / (255 - b))) +COMBINE_FUN(COMBINE_COLOR_BURN, b == 0 ? 0 : bot(255 - (255-a) * 255 / b)) +COMBINE_FUN(COMBINE_SCREEN, 255 - (((255 - a) * (255 - b)) / 255)) COMBINE_FUN(COMBINE_OVERLAY, a < 128 ? (a * b) >> 7 - : 255 - (((255 - a) * (255 - b)) >> 7) ) + : 255 - (((255 - a) * (255 - b)) >> 7)) COMBINE_FUN(COMBINE_HARD_LIGHT, b < 128 ? (a * b) >> 7 - : 255 - (((255 - a) * (255 - b)) >> 7) ) + : 255 - (((255 - a) * (255 - b)) >> 7)) COMBINE_FUN(COMBINE_SOFT_LIGHT, b) -COMBINE_FUN(COMBINE_REFLECT, b == 255 ? 255 : top(a * a / (255 - b)) ) -COMBINE_FUN(COMBINE_GLOW, a == 255 ? 255 : top(b * b / (255 - a)) ) -COMBINE_FUN(COMBINE_FREEZE, b == 0 ? 0 : bot(255 - (255 - a) * (255 - a) / b) ) -COMBINE_FUN(COMBINE_HEAT, a == 0 ? 0 : bot(255 - (255 - b) * (255 - b) / a) ) -COMBINE_FUN(COMBINE_AND, a & b ) -COMBINE_FUN(COMBINE_OR, a | b ) -COMBINE_FUN(COMBINE_XOR, a ^ b ) -COMBINE_FUN(COMBINE_SHADOW, (b * a * a) / (255 * 255) ) -COMBINE_FUN(COMBINE_SYMMETRIC_OVERLAY, (Combine::f(a,b) + Combine::f(b,a)) / 2 ) +COMBINE_FUN(COMBINE_REFLECT, b == 255 ? 255 : top(a * a / (255 - b))) +COMBINE_FUN(COMBINE_GLOW, a == 255 ? 255 : top(b * b / (255 - a))) +COMBINE_FUN(COMBINE_FREEZE, b == 0 ? 0 : bot(255 - (255 - a) * (255 - a) / b)) +COMBINE_FUN(COMBINE_HEAT, a == 0 ? 0 : bot(255 - (255 - b) * (255 - b) / a)) +COMBINE_FUN(COMBINE_AND, a & b) +COMBINE_FUN(COMBINE_OR, a | b) +COMBINE_FUN(COMBINE_XOR, a ^ b) +COMBINE_FUN(COMBINE_SHADOW, (b * a * a) / (255 * 255)) +COMBINE_FUN(COMBINE_SYMMETRIC_OVERLAY, (Combine::f(a,b) + Combine::f(b,a)) / 2 ) // ----------------------------------------------------------------------------- : Combining diff --git a/src/gui/control/card_editor.hpp b/src/gui/control/card_editor.hpp index 7441d6ab..f96eb706 100644 --- a/src/gui/control/card_editor.hpp +++ b/src/gui/control/card_editor.hpp @@ -142,11 +142,11 @@ typedef DataEditor CardEditor; // ----------------------------------------------------------------------------- : Utility -#define FOR_EACH_EDITOR \ - FOR_EACH(v, viewers) \ +#define FOR_EACH_EDITOR \ + FOR_EACH(v, viewers) \ if (ValueEditor* e = v->getEditor()) -#define FOR_EACH_EDITOR_REVERSE \ - FOR_EACH_REVERSE(v, viewers) \ +#define FOR_EACH_EDITOR_REVERSE \ + FOR_EACH_REVERSE(v, viewers) \ if (ValueEditor* e = v->getEditor()) // ----------------------------------------------------------------------------- : EOF diff --git a/src/gui/control/card_list.hpp b/src/gui/control/card_list.hpp index 49a29c2c..bf75fe55 100644 --- a/src/gui/control/card_list.hpp +++ b/src/gui/control/card_list.hpp @@ -24,15 +24,15 @@ DECLARE_LOCAL_EVENT_TYPE(EVENT_CARD_SELECT, ) DECLARE_LOCAL_EVENT_TYPE(EVENT_CARD_ACTIVATE, ) /// Handle EVENT_CARD_SELECT events -#define EVT_CARD_SELECT(id, handler) \ - DECLARE_EVENT_TABLE_ENTRY(EVENT_CARD_SELECT, id, -1, \ - (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) \ +#define EVT_CARD_SELECT(id, handler) \ + DECLARE_EVENT_TABLE_ENTRY(EVENT_CARD_SELECT, id, -1, \ + (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) \ (void (wxEvtHandler::*)(CardSelectEvent&)) (&handler), (wxObject*) NULL), /// Handle EVENT_CARD_ACTIVATE events -#define EVT_CARD_ACTIVATE(id, handler) \ - DECLARE_EVENT_TABLE_ENTRY(EVENT_CARD_ACTIVATE, id, -1, \ - (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) \ +#define EVT_CARD_ACTIVATE(id, handler) \ + DECLARE_EVENT_TABLE_ENTRY(EVENT_CARD_ACTIVATE, id, -1, \ + (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) \ (void (wxEvtHandler::*)(CardSelectEvent&)) (&handler), (wxObject*) NULL), /// The event of selecting a card diff --git a/src/gui/control/keyword_list.hpp b/src/gui/control/keyword_list.hpp index 11f4791b..91c570cb 100644 --- a/src/gui/control/keyword_list.hpp +++ b/src/gui/control/keyword_list.hpp @@ -21,9 +21,9 @@ typedef intrusive_ptr > KeywordListFilterP; DECLARE_LOCAL_EVENT_TYPE(EVENT_KEYWORD_SELECT, ) /// Handle KeywordSelectEvents -#define EVT_KEYWORD_SELECT(id, handler) \ - DECLARE_EVENT_TABLE_ENTRY(EVENT_KEYWORD_SELECT, id, -1, \ - (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) \ +#define EVT_KEYWORD_SELECT(id, handler) \ + DECLARE_EVENT_TABLE_ENTRY(EVENT_KEYWORD_SELECT, id, -1, \ + (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) \ (void (wxEvtHandler::*)(KeywordSelectEvent&)) (&handler), (wxObject*) NULL), /// The event of selecting a keyword diff --git a/src/gui/set/cards_panel.cpp b/src/gui/set/cards_panel.cpp index a4c448db..8c7820b7 100644 --- a/src/gui/set/cards_panel.cpp +++ b/src/gui/set/cards_panel.cpp @@ -390,11 +390,11 @@ bool CardsPanel::wantsToHandle(const Action&, bool undone) const { // ----------------------------------------------------------------------------- : Clipboard // determine what control to use for clipboard actions -#define CUT_COPY_PASTE(op,return) \ - int id = focused_control(this); \ - if (id == ID_EDITOR) { return editor->op(); } \ - else if (id == ID_CARD_LIST) { return card_list->op(); } \ - else if (id == ID_NOTES) { return notes->op(); } \ +#define CUT_COPY_PASTE(op,return) \ + int id = focused_control(this); \ + if (id == ID_EDITOR) { return editor->op(); } \ + else if (id == ID_CARD_LIST) { return card_list->op(); } \ + else if (id == ID_NOTES) { return notes->op(); } \ else { return false; } bool CardsPanel::canCut() const { CUT_COPY_PASTE(canCut, return) } diff --git a/src/gui/set/console_panel.cpp b/src/gui/set/console_panel.cpp index d56bc12c..3c195c8d 100644 --- a/src/gui/set/console_panel.cpp +++ b/src/gui/set/console_panel.cpp @@ -533,9 +533,9 @@ END_EVENT_TABLE () // ----------------------------------------------------------------------------- : Clipboard // determine what control to use for clipboard actions -#define CUT_COPY_PASTE(op,return) \ - int id = focused_control(this); \ - if (id == ID_MESSAGE_LIST) { return messages->op(); } \ +#define CUT_COPY_PASTE(op,return) \ + int id = focused_control(this); \ + if (id == ID_MESSAGE_LIST) { return messages->op(); } \ else { return false; } bool ConsolePanel::canCut() const { return false; } diff --git a/src/gui/set/keywords_panel.cpp b/src/gui/set/keywords_panel.cpp index 8e2ce14e..89b1bca2 100644 --- a/src/gui/set/keywords_panel.cpp +++ b/src/gui/set/keywords_panel.cpp @@ -260,15 +260,15 @@ String KeywordsPanel::runRefScript(int find_i) { // ----------------------------------------------------------------------------- : Clipboard // determine what control to use for clipboard actions -#define CUT_COPY_PASTE(op,return,check) \ - if (!isInitialized()) return false; \ - int id = focused_control(this); \ - if (id == ID_KEYWORD_LIST && keyword ->IsEnabled()) { return list ->op(); } \ +#define CUT_COPY_PASTE(op,return,check) \ + if (!isInitialized()) return false; \ + int id = focused_control(this); \ + if (id == ID_KEYWORD_LIST && keyword ->IsEnabled()) { return list ->op(); } \ else if (check) { return false; } \ - else if (id == ID_KEYWORD && keyword ->IsEnabled()) { return keyword ->op(); } \ - else if (id == ID_MATCH && match ->IsEnabled()) { return match ->op(); } \ - else if (id == ID_REMINDER && reminder->IsEnabled()) { return reminder->op(); } \ - else if (id == ID_RULES && rules ->IsEnabled()) { return rules ->op(); } \ + else if (id == ID_KEYWORD && keyword ->IsEnabled()) { return keyword ->op(); } \ + else if (id == ID_MATCH && match ->IsEnabled()) { return match ->op(); } \ + else if (id == ID_REMINDER && reminder->IsEnabled()) { return reminder->op(); } \ + else if (id == ID_RULES && rules ->IsEnabled()) { return rules ->op(); } \ else { return false; } bool KeywordsPanel::canCopy() const { CUT_COPY_PASTE(canCopy, return, false) } diff --git a/src/gui/set/style_panel.cpp b/src/gui/set/style_panel.cpp index 0764c383..0f77461a 100644 --- a/src/gui/set/style_panel.cpp +++ b/src/gui/set/style_panel.cpp @@ -146,11 +146,11 @@ void StylePanel::selectCard(const CardP& card) { // ----------------------------------------------------------------------------- : Clipboard // determine what control to use for clipboard actions -#define CUT_COPY_PASTE(op,return) \ - if (!isInitialized()) return false; \ - int id = focused_control(this); \ - if (id == ID_EDITOR) { return editor->op(); } \ - else { return false; } +#define CUT_COPY_PASTE(op,return) \ + if (!isInitialized()) return false; \ + int id = focused_control(this); \ + if (id == ID_EDITOR) { return editor->op(); } \ + else { return false; } bool StylePanel::canCopy() const { CUT_COPY_PASTE(canCopy, return) } bool StylePanel::canCut() const { CUT_COPY_PASTE(canCut, return) } diff --git a/src/gui/value/editor.hpp b/src/gui/value/editor.hpp index 2bc7dd85..500bad6e 100644 --- a/src/gui/value/editor.hpp +++ b/src/gui/value/editor.hpp @@ -135,22 +135,22 @@ class ValueEditor { // ----------------------------------------------------------------------------- : Utility -#define DECLARE_VALUE_EDITOR(Type) \ - Type##ValueEditor(DataEditor& parent, const Type##StyleP& style); \ - virtual ValueEditor* getEditor() { return this; } \ - private: \ - /** Retrieve the parent editor object */ \ - inline DataEditor& editor() const { \ - return static_cast(viewer); \ - } \ +#define DECLARE_VALUE_EDITOR(Type) \ + Type##ValueEditor(DataEditor& parent, const Type##StyleP& style); \ + virtual ValueEditor* getEditor() { return this; } \ + private: \ + /** Retrieve the parent editor object */ \ + inline DataEditor& editor() const { \ + return static_cast(viewer); \ + } \ public: -#define IMPLEMENT_VALUE_EDITOR(Type) \ - ValueViewerP Type##Style::makeEditor(DataEditor& parent, const StyleP& thisP) { \ - assert(thisP.get() == this); \ - return ValueViewerP(new Type##ValueEditor(parent, static_pointer_cast(thisP))); \ - } \ - Type##ValueEditor::Type##ValueEditor(DataEditor& parent, const Type##StyleP& style) \ +#define IMPLEMENT_VALUE_EDITOR(Type) \ + ValueViewerP Type##Style::makeEditor(DataEditor& parent, const StyleP& thisP) { \ + assert(thisP.get() == this); \ + return ValueViewerP(new Type##ValueEditor(parent, static_pointer_cast(thisP))); \ + } \ + Type##ValueEditor::Type##ValueEditor(DataEditor& parent, const Type##StyleP& style) \ : Type##ValueViewer(parent, style) // ----------------------------------------------------------------------------- : EOF diff --git a/src/render/value/viewer.hpp b/src/render/value/viewer.hpp index 2deab6ab..9ac4b9d0 100644 --- a/src/render/value/viewer.hpp +++ b/src/render/value/viewer.hpp @@ -102,21 +102,21 @@ class ValueViewer : public StyleListener { // ----------------------------------------------------------------------------- : Utility -#define DECLARE_VALUE_VIEWER(Type) \ - protected: \ - inline Type##Style& style() const { return static_cast< Type##Style&>(*ValueViewer::styleP); } \ - inline const Type##Value& value() const { return static_cast(*ValueViewer::valueP); } \ - inline const Type##Field& field() const { return style().field(); } \ - inline Type##StyleP styleP() const { return static_pointer_cast(ValueViewer::styleP); } \ - inline Type##ValueP valueP() const { return static_pointer_cast(ValueViewer::valueP); } \ - inline Type##FieldP fieldP() const { return static_pointer_cast(style().fieldP); } \ - public: \ +#define DECLARE_VALUE_VIEWER(Type) \ + protected: \ + inline Type##Style& style() const { return static_cast< Type##Style&>(*ValueViewer::styleP); } \ + inline const Type##Value& value() const { return static_cast(*ValueViewer::valueP); } \ + inline const Type##Field& field() const { return style().field(); } \ + inline Type##StyleP styleP() const { return static_pointer_cast(ValueViewer::styleP); } \ + inline Type##ValueP valueP() const { return static_pointer_cast(ValueViewer::valueP); } \ + inline Type##FieldP fieldP() const { return static_pointer_cast(style().fieldP); } \ + public: \ Type##ValueViewer(DataViewer& parent, const Type ## StyleP& style) -#define IMPLEMENT_VALUE_VIEWER(Type) \ - ValueViewerP Type##Style::makeViewer(DataViewer& parent, const StyleP& thisP) { \ - assert(thisP.get() == this); \ - return ValueViewerP(new Type##ValueViewer(parent, static_pointer_cast(thisP))); \ +#define IMPLEMENT_VALUE_VIEWER(Type) \ + ValueViewerP Type##Style::makeViewer(DataViewer& parent, const StyleP& thisP) { \ + assert(thisP.get() == this); \ + return ValueViewerP(new Type##ValueViewer(parent, static_pointer_cast(thisP))); \ } diff --git a/src/script/context.cpp b/src/script/context.cpp index 71a7d730..7abbd4b7 100644 --- a/src/script/context.cpp +++ b/src/script/context.cpp @@ -424,31 +424,31 @@ class ScriptCompose : public ScriptValue { // ----------------------------------------------------------------------------- : Simple instructions : binary // operator on ints -#define OPERATOR_I(OP) \ - a = to_script((int)*a OP (int)*b); \ +#define OPERATOR_I(OP) \ + a = to_script((int)*a OP (int)*b); \ break // operator on bools -#define OPERATOR_B(OP) \ - a = to_script((bool)*a OP (bool)*b); \ +#define OPERATOR_B(OP) \ + a = to_script((bool)*a OP (bool)*b); \ break // operator on doubles or ints -#define OPERATOR_DI(OP) \ - if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \ - a = to_script((double)*a OP (double)*b); \ - } else { \ - a = to_script((int)*a OP (int)*b); \ - } \ +#define OPERATOR_DI(OP) \ + if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \ + a = to_script((double)*a OP (double)*b); \ + } else { \ + a = to_script((int)*a OP (int)*b); \ + } \ break // operator on doubles or ints, defined as a function -#define OPERATOR_FUN_DI(OP) \ - if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \ - a = to_script(OP((double)*a, (double)*b)); \ - } else { \ - a = to_script(OP((int)*a, (int)*b)); \ - } \ +#define OPERATOR_FUN_DI(OP) \ + if (at == SCRIPT_DOUBLE || bt == SCRIPT_DOUBLE) { \ + a = to_script(OP((double)*a, (double)*b)); \ + } else { \ + a = to_script(OP((int)*a, (int)*b)); \ + } \ break diff --git a/src/script/functions/util.hpp b/src/script/functions/util.hpp index 16d5979e..2c670aff 100644 --- a/src/script/functions/util.hpp +++ b/src/script/functions/util.hpp @@ -38,30 +38,30 @@ #define SCRIPT_FUNCTION(name) SCRIPT_FUNCTION_AUX(name,;) /// Macro to declare a new script function with custom dependency handling -#define SCRIPT_FUNCTION_WITH_DEP(name) \ +#define SCRIPT_FUNCTION_WITH_DEP(name) \ SCRIPT_FUNCTION_AUX(name, virtual ScriptValueP dependencies(Context&, const Dependency&) const;) -#define SCRIPT_FUNCTION_DEPENDENCIES(name) \ +#define SCRIPT_FUNCTION_DEPENDENCIES(name) \ ScriptValueP ScriptBuiltIn_##name::dependencies(Context& ctx, const Dependency& dep) const /// Macro to declare a new script function with custom closure simplification -#define SCRIPT_FUNCTION_WITH_SIMPLIFY(name) \ +#define SCRIPT_FUNCTION_WITH_SIMPLIFY(name) \ SCRIPT_FUNCTION_AUX(name, virtual ScriptValueP simplifyClosure(ScriptClosure&) const;) -#define SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(name) \ +#define SCRIPT_FUNCTION_SIMPLIFY_CLOSURE(name) \ ScriptValueP ScriptBuiltIn_##name::simplifyClosure(ScriptClosure& closure) const // helper for SCRIPT_FUNCTION and SCRIPT_FUNCTION_DEP -#define SCRIPT_FUNCTION_AUX(name,dep) \ - class ScriptBuiltIn_##name : public ScriptValue { \ - dep \ - virtual ScriptType type() const \ - { return SCRIPT_FUNCTION; } \ - virtual String typeName() const \ - { return _("built-in function '") _(#name) _("'"); } \ - virtual ScriptValueP do_eval(Context&, bool) const; \ - }; \ - ScriptValueP script_##name(new ScriptBuiltIn_##name); \ +#define SCRIPT_FUNCTION_AUX(name,dep) \ + class ScriptBuiltIn_##name : public ScriptValue { \ + dep \ + virtual ScriptType type() const \ + { return SCRIPT_FUNCTION; } \ + virtual String typeName() const \ + { return _("built-in function '") _(#name) _("'"); } \ + virtual ScriptValueP do_eval(Context&, bool) const; \ + }; \ + ScriptValueP script_##name(new ScriptBuiltIn_##name); \ ScriptValueP ScriptBuiltIn_##name::do_eval(Context& ctx, bool) const /// Return a value from a SCRIPT_FUNCTION @@ -96,13 +96,13 @@ inline Type from_script(const ScriptValueP& v, Variable var) { * @endcode * Throws an error if the parameter is not found. */ -#define SCRIPT_PARAM(Type, name) \ +#define SCRIPT_PARAM(Type, name) \ SCRIPT_PARAM_N(Type, _(#name), name) -#define SCRIPT_PARAM_N(Type, str, name) \ +#define SCRIPT_PARAM_N(Type, str, name) \ Type name = from_script(ctx.getVariable(str), str) /// Faster variant of SCRIPT_PARAM when name is a CommonScriptVariable /** Doesn't require a runtime lookup of the name */ -#define SCRIPT_PARAM_C(Type, name) \ +#define SCRIPT_PARAM_C(Type, name) \ SCRIPT_PARAM_N(Type, SCRIPT_VAR_ ## name, name) /// Retrieve an optional parameter @@ -116,42 +116,42 @@ inline Type from_script(const ScriptValueP& v, Variable var) { * } * @endcode */ -#define SCRIPT_OPTIONAL_PARAM(Type, name) \ +#define SCRIPT_OPTIONAL_PARAM(Type, name) \ SCRIPT_OPTIONAL_PARAM_N(Type, _(#name), name) /// Retrieve a named optional parameter -#define SCRIPT_OPTIONAL_PARAM_N(Type, str, name) \ - SCRIPT_OPTIONAL_PARAM_N_(Type, str, name) \ +#define SCRIPT_OPTIONAL_PARAM_N(Type, str, name) \ + SCRIPT_OPTIONAL_PARAM_N_(Type, str, name) \ if (name##_) -#define SCRIPT_OPTIONAL_PARAM_C(Type, name) \ +#define SCRIPT_OPTIONAL_PARAM_C(Type, name) \ SCRIPT_OPTIONAL_PARAM_N(Type, SCRIPT_VAR_ ## name, name) /// Retrieve an optional parameter, can't be used as an if statement -#define SCRIPT_OPTIONAL_PARAM_(Type, name) \ +#define SCRIPT_OPTIONAL_PARAM_(Type, name) \ SCRIPT_OPTIONAL_PARAM_N_(Type, _(#name), name) /// Retrieve a named optional parameter, can't be used as an if statement -#define SCRIPT_OPTIONAL_PARAM_N_(Type, str, name) \ - ScriptValueP name##_ = ctx.getVariableOpt(str); \ - Type name = name##_ && name##_ != script_nil \ +#define SCRIPT_OPTIONAL_PARAM_N_(Type, str, name) \ + ScriptValueP name##_ = ctx.getVariableOpt(str); \ + Type name = name##_ && name##_ != script_nil \ ? from_script(name##_, str) : Type(); -#define SCRIPT_OPTIONAL_PARAM_C_(Type, name) \ +#define SCRIPT_OPTIONAL_PARAM_C_(Type, name) \ SCRIPT_OPTIONAL_PARAM_N_(Type, SCRIPT_VAR_ ## name, name) /// Retrieve an optional parameter with a default value -#define SCRIPT_PARAM_DEFAULT(Type, name, def) \ +#define SCRIPT_PARAM_DEFAULT(Type, name, def) \ SCRIPT_PARAM_DEFAULT_N(Type, _(#name), name, def) /// Retrieve a named optional parameter with a default value -#define SCRIPT_PARAM_DEFAULT_N(Type, str, name, def) \ - ScriptValueP name##_ = ctx.getVariableOpt(str); \ +#define SCRIPT_PARAM_DEFAULT_N(Type, str, name, def) \ + ScriptValueP name##_ = ctx.getVariableOpt(str); \ Type name = name##_ ? from_script(name##_, str) : def -#define SCRIPT_PARAM_DEFAULT_C(Type, name, def) \ +#define SCRIPT_PARAM_DEFAULT_C(Type, name, def) \ SCRIPT_PARAM_DEFAULT_N(Type, SCRIPT_VAR_ ## name, name, def) // ----------------------------------------------------------------------------- : Rules /// Utility for defining a script rule with a single parameter -#define SCRIPT_RULE_1(funname, type1, name1) \ +#define SCRIPT_RULE_1(funname, type1, name1) \ SCRIPT_RULE_1_N(funname, type1, _(#name1), name1) -#define SCRIPT_RULE_1_C(funname, type1, name1) \ +#define SCRIPT_RULE_1_C(funname, type1, name1) \ SCRIPT_RULE_1_N(funname, type1, SCRIPT_VAR_ ## name1, name1) /// Utility for defining a script rule with a single named parameter #define SCRIPT_RULE_1_N(funname, type1, str1, name1) \ @@ -176,21 +176,21 @@ inline Type from_script(const ScriptValueP& v, Variable var) { ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const /// Utility for defining a script rule with two parameters -#define SCRIPT_RULE_2(funname, type1, name1, type2, name2) \ +#define SCRIPT_RULE_2(funname, type1, name1, type2, name2) \ SCRIPT_RULE_2_N(funname, type1, _(#name1), name1, type2, _(#name2), name2) -#define SCRIPT_RULE_2_C(funname, type1, name1, type2, name2) \ +#define SCRIPT_RULE_2_C(funname, type1, name1, type2, name2) \ SCRIPT_RULE_2_N(funname, type1, SCRIPT_VAR_ ## name1, name1, type2, SCRIPT_VAR_ ## name2, name2) /// Utility for defining a script rule with two named parameters -#define SCRIPT_RULE_2_N(funname, type1, str1, name1, type2, str2, name2) \ +#define SCRIPT_RULE_2_N(funname, type1, str1, name1, type2, str2, name2) \ SCRIPT_RULE_2_N_AUX(funname, type1, str1, name1, type2, str2, name2, ;, ;) /// Utility for defining a script rule with two named parameters, with dependencies -#define SCRIPT_RULE_2_N_DEP(funname, type1, str1, name1, type2, str2, name2) \ - SCRIPT_RULE_2_N_AUX( funname, type1, str1, name1, type2, str2, name2, \ - virtual ScriptValueP dependencies(Context&, const Dependency&) const;, \ - SCRIPT_FUNCTION_DEPENDENCIES(funname) { \ - SCRIPT_PARAM_N(type1, str1, name1); \ - SCRIPT_PARAM_N(type2, str2, name2); \ - return ScriptRule_##funname(name1, name2).dependencies(ctx, dep); \ +#define SCRIPT_RULE_2_N_DEP(funname, type1, str1, name1, type2, str2, name2) \ + SCRIPT_RULE_2_N_AUX( funname, type1, str1, name1, type2, str2, name2, \ + virtual ScriptValueP dependencies(Context&, const Dependency&) const; \ + SCRIPT_FUNCTION_DEPENDENCIES(funname) { \ + SCRIPT_PARAM_N(type1, str1, name1); \ + SCRIPT_PARAM_N(type2, str2, name2); \ + return ScriptRule_##funname(name1, name2).dependencies(ctx, dep); \ }) #define SCRIPT_RULE_2_N_AUX(funname, type1, str1, name1, type2, str2, name2, dep, more) \ @@ -220,7 +220,7 @@ inline Type from_script(const ScriptValueP& v, Variable var) { more \ ScriptValueP ScriptRule_##funname::do_eval(Context& ctx, bool) const -#define SCRIPT_RULE_2_DEPENDENCIES(name) \ +#define SCRIPT_RULE_2_DEPENDENCIES(name) \ ScriptValueP ScriptRule_##name::dependencies(Context& ctx, const Dependency& dep) const diff --git a/src/util/action_stack.hpp b/src/util/action_stack.hpp index 9a5c1a27..842588a4 100644 --- a/src/util/action_stack.hpp +++ b/src/util/action_stack.hpp @@ -123,7 +123,7 @@ class ActionStack { /// Tests if variable has the type Type. /** Uses dynamic cast, so Type must have a virtual function. */ -#define TYPE_CASE_(variable, Type) \ +#define TYPE_CASE_(variable, Type) \ if (dynamic_cast(&variable)) /// Tests if variable has the type Type. @@ -131,12 +131,12 @@ class ActionStack { * * Uses dynamic cast, so Type must have a virtual function. */ -#define TYPE_CASE(variable, Type) \ - pair Type##variable \ - (dynamic_cast(&variable), true); \ - if (Type##variable.first) \ - for (const Type& variable = *Type##variable.first ; \ - Type##variable.second ; \ +#define TYPE_CASE(variable, Type) \ + pair Type##variable \ + (dynamic_cast(&variable), true); \ + if (Type##variable.first) \ + for (const Type& variable = *Type##variable.first ; \ + Type##variable.second ; \ Type##variable.second = false) diff --git a/src/util/dynamic_arg.hpp b/src/util/dynamic_arg.hpp index d3f95b5a..e5c00b9e 100644 --- a/src/util/dynamic_arg.hpp +++ b/src/util/dynamic_arg.hpp @@ -37,24 +37,24 @@ * To change the value use WITH_DYNAMIC_ARG(name, newValue) * To be used in a header file. Use IMPLEMENT_DYN_ARG in a source file */ - #define DECLARE_DYNAMIC_ARG(Type, name) \ - extern THREAD_LOCAL Type name##_private; \ - inline Type name() { return name##_private; } \ - class name##_changer { \ - public: \ - inline name##_changer(Type const& newValue) \ - : oldValue(name##_private) { \ - name##_private = newValue; \ - } \ - inline ~name##_changer() { \ - name##_private = oldValue; \ - } \ - private: \ - Type oldValue; \ + #define DECLARE_DYNAMIC_ARG(Type, name) \ + extern THREAD_LOCAL Type name##_private; \ + inline Type name() { return name##_private; } \ + class name##_changer { \ + public: \ + inline name##_changer(Type const& newValue) \ + : oldValue(name##_private) { \ + name##_private = newValue; \ + } \ + inline ~name##_changer() { \ + name##_private = oldValue; \ + } \ + private: \ + Type oldValue; \ } /// Implementation of a dynamic argument - #define IMPLEMENT_DYNAMIC_ARG(Type, name, initial) \ + #define IMPLEMENT_DYNAMIC_ARG(Type, name, initial) \ THREAD_LOCAL Type name##_private = initial; /// Locally change the value of a dynamic argument @@ -68,7 +68,7 @@ * // here name() == old value * @endcode */ - #define WITH_DYNAMIC_ARG(name, value) \ + #define WITH_DYNAMIC_ARG(name, value) \ name##_changer name##_dummmy(value) #else @@ -107,13 +107,13 @@ } }; - #define DECLARE_DYNAMIC_ARG(Type, name) \ + #define DECLARE_DYNAMIC_ARG(Type, name) \ extern ThreadLocalObject name; - #define IMPLEMENT_DYNAMIC_ARG(Type, name, initial) \ + #define IMPLEMENT_DYNAMIC_ARG(Type, name, initial) \ ThreadLocalObject name (initial); - #define WITH_DYNAMIC_ARG(name, value) \ + #define WITH_DYNAMIC_ARG(name, value) \ name.store(value); #endif diff --git a/src/util/for_each.hpp b/src/util/for_each.hpp index ac419135..ea1d7053 100644 --- a/src/util/for_each.hpp +++ b/src/util/for_each.hpp @@ -45,33 +45,33 @@ /// Iterate over a collection, using an iterator it of type Type /** Usage: FOR_EACH_IT_T(Type,it,collect) { body-of-loop } */ -#define FOR_EACH_IT_T(Type,Iterator,Collection) \ - for(Type Iterator = (Collection).begin() ; \ - Iterator != (Collection).end() ; \ - ++Iterator) +#define FOR_EACH_IT_T(Type,Iterator,Collection) \ + for(Type Iterator = (Collection).begin() ; \ + Iterator != (Collection).end() ; \ + ++Iterator) /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /** Usage: FOR_EACH_IT(it,collect) { body-of-loop } */ -#define FOR_EACH_IT(Iterator,Collection) \ - FOR_EACH_IT_T(TYPEOF_IT(Collection), Iterator, Collection) +#define FOR_EACH_IT(Iterator,Collection) \ + FOR_EACH_IT_T(TYPEOF_IT(Collection), Iterator, Collection) /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /** Uses a const_iterator * Usage: FOR_EACH_IT(it,collect) { body-of-loop } */ -#define FOR_EACH_CONST_IT(Iterator,Collection) \ - FOR_EACH_IT_T(TYPEOF_CIT(Collection), Iterator, Collection) +#define FOR_EACH_CONST_IT(Iterator,Collection) \ + FOR_EACH_IT_T(TYPEOF_CIT(Collection), Iterator, Collection) /// Iterate over a collection in whos type must be declared with DECLARE_TYPEOF /** Iterates using a reverse_iterator * Usage: FOR_EACH_REVERSE_IT(it,collect) { body-of-loop } */ -#define FOR_EACH_REVERSE_IT(Iterator,Collection) \ - for(TYPEOF_RIT(Collection) \ - Iterator = (Collection).rbegin() ; \ - Iterator != (Collection).rend() ; \ - ++Iterator) +#define FOR_EACH_REVERSE_IT(Iterator,Collection) \ + for(TYPEOF_RIT(Collection) \ + Iterator = (Collection).rbegin() ; \ + Iterator != (Collection).rend() ; \ + ++Iterator) // ----------------------------------------------------------------------------- : Looping macros @@ -82,13 +82,13 @@ * To do this we use a nested for loop that is only executed once, and which is optimized away. * To terminate this loop we need an extra bool, which we set to false after the first iteration. */ -#define FOR_EACH_T(TypeIt,TypeElem,Elem,Collection, begin, end) \ - for(std::pair Elem##_IT((Collection).begin(), true) ; \ - Elem##_IT.second && Elem##_IT.first != (Collection).end() ; \ - ++Elem##_IT.first, Elem##_IT.second = !Elem##_IT.second) \ - for(TypeElem Elem = *Elem##_IT.first ; \ - Elem##_IT.second ; \ - Elem##_IT.second = false) +#define FOR_EACH_T(TypeIt,TypeElem,Elem,Collection, begin, end) \ + for(std::pair Elem##_IT((Collection).begin(), true) ; \ + Elem##_IT.second && Elem##_IT.first != (Collection).end() ; \ + ++Elem##_IT.first, Elem##_IT.second = !Elem##_IT.second) \ + for(TypeElem Elem = *Elem##_IT.first ; \ + Elem##_IT.second ; \ + Elem##_IT.second = false) /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /** Usage: FOR_EACH(e,collect) { body-of-loop } @@ -102,8 +102,6 @@ /** Uses a const iterator * Usage: FOR_EACH_CONST(e,collect) { body-of-loop } */ -//#define FOR_EACH_CONST(Elem,Collection) \ -// FOR_EACH_T(TYPEOF_CIT(Collection), TYPEOF_CREF(Collection), Elem, Collection, begin, end) #define FOR_EACH_CONST(Elem,Collection) \ for (auto const& Elem : Collection) @@ -111,15 +109,15 @@ /** Iterates using a reverse_iterator * Usage: FOR_EACH_REVERSE(e,collect) { body-of-loop } */ -#define FOR_EACH_REVERSE(Elem,Collection) \ - FOR_EACH_T(TYPEOF_RIT(Collection), TYPEOF_REF(Collection), Elem, Collection, rbegin, rend) +#define FOR_EACH_REVERSE(Elem,Collection) \ + FOR_EACH_T(TYPEOF_RIT(Collection), TYPEOF_REF(Collection), Elem, Collection, rbegin, rend) /// Iterate over a collection whos type must be declared with DECLARE_TYPEOF /** Iterates using a const_reverse_iterator * Usage: FOR_EACH_CONST_REVERSE(e,collect) { body-of-loop } */ -#define FOR_EACH_CONST_REVERSE(Elem,Collection) \ - FOR_EACH_T(TYPEOF_CRIT(Collection), TYPEOF_CREF(Collection), Elem, Collection, rbegin, rend) +#define FOR_EACH_CONST_REVERSE(Elem,Collection) \ + FOR_EACH_T(TYPEOF_CRIT(Collection), TYPEOF_CREF(Collection), Elem, Collection, rbegin, rend) /// Iterate over two collection in parallel /** Usage: FOR_EACH_2_T(TypeIt1,TypeElem1,e1,collect1,TypeIt2,TypeElem2,e2,collect2) { body-of-loop } @@ -127,33 +125,33 @@ * Note: This has got to be one of the craziest pieces of code I have ever written :) * It is just an extension of the idea of FOR_EACH_T. */ -#define FOR_EACH_2_T(TypeIt1,TypeElem1,Elem1,Coll1,TypeIt2,TypeElem2,Elem2,Coll2) \ - for(std::pair, bool> \ - Elem1##_IT(make_pair((Coll1).begin(), (Coll2).begin()), true) ; \ - Elem1##_IT.first.first != (Coll1).end() && \ - Elem1##_IT.first.second != (Coll2).end() ; \ - ++Elem1##_IT.first.first, ++Elem1##_IT.first.second, \ - Elem1##_IT.second = true) \ - for(TypeElem1 Elem1 = *Elem1##_IT.first.first ; \ - Elem1##_IT.second ; \ - Elem1##_IT.second = false) \ - for(TypeElem2 Elem2 = *Elem1##_IT.first.second ; \ - Elem1##_IT.second ; \ - Elem1##_IT.second = false) +#define FOR_EACH_2_T(TypeIt1,TypeElem1,Elem1,Coll1,TypeIt2,TypeElem2,Elem2,Coll2) \ + for(std::pair, bool> \ + Elem1##_IT(make_pair((Coll1).begin(), (Coll2).begin()), true) ; \ + Elem1##_IT.first.first != (Coll1).end() && \ + Elem1##_IT.first.second != (Coll2).end() ; \ + ++Elem1##_IT.first.first, ++Elem1##_IT.first.second, \ + Elem1##_IT.second = true) \ + for(TypeElem1 Elem1 = *Elem1##_IT.first.first ; \ + Elem1##_IT.second ; \ + Elem1##_IT.second = false) \ + for(TypeElem2 Elem2 = *Elem1##_IT.first.second ; \ + Elem1##_IT.second ; \ + Elem1##_IT.second = false) /// Iterate over two collections in parallel, their type must be declared with DECLARE_TYPEOF. /** Usage: FOR_EACH_2(e1,collect1, e2,collect2) { body-of-loop } */ -#define FOR_EACH_2(Elem1,Collection1, Elem2,Collection2) \ - FOR_EACH_2_T(TYPEOF_IT(Collection1), TYPEOF_REF(Collection1), Elem1, Collection1, \ - TYPEOF_IT(Collection2), TYPEOF_REF(Collection2), Elem2, Collection2) +#define FOR_EACH_2(Elem1,Collection1, Elem2,Collection2) \ + FOR_EACH_2_T(TYPEOF_IT(Collection1), TYPEOF_REF(Collection1), Elem1, Collection1, \ + TYPEOF_IT(Collection2), TYPEOF_REF(Collection2), Elem2, Collection2) /// Iterate over two constants collections in parallel, their type must be declared with DECLARE_TYPEOF. /** Usage: FOR_EACH_2_CONST(e1,collect1, e2,collect2) { body-of-loop } */ -#define FOR_EACH_2_CONST(Elem1,Collection1, Elem2,Collection2) \ - FOR_EACH_2_T(TYPEOF_CIT(Collection1), TYPEOF_CREF(Collection1), Elem1, Collection1, \ - TYPEOF_CIT(Collection2), TYPEOF_CREF(Collection2), Elem2, Collection2) +#define FOR_EACH_2_CONST(Elem1,Collection1, Elem2,Collection2) \ + FOR_EACH_2_T(TYPEOF_CIT(Collection1), TYPEOF_CREF(Collection1), Elem1, Collection1, \ + TYPEOF_CIT(Collection2), TYPEOF_CREF(Collection2), Elem2, Collection2) // ----------------------------------------------------------------------------- : EOF diff --git a/src/util/io/get_member.hpp b/src/util/io/get_member.hpp index 5bda2f2e..ab9fdb12 100644 --- a/src/util/io/get_member.hpp +++ b/src/util/io/get_member.hpp @@ -121,25 +121,25 @@ class GetMember : private GetDefaultMember { #define REFLECT_OBJECT_GET_DEFAULT_MEMBER_NOT(Cls) REFLECT_WRITE_NO(Cls,GetDefaultMember) #define REFLECT_OBJECT_GET_MEMBER_NOT(Cls) REFLECT_WRITE_NO(Cls,GetMember) -#define REFLECT_WRITE_YES(Cls, Tag) \ - template<> void Tag::handle(const Cls& object) { \ - const_cast(object).reflect(*this); \ - } \ - void Cls::reflect(Tag& tag) { \ - reflect_impl(tag); \ +#define REFLECT_WRITE_YES(Cls, Tag) \ + template<> void Tag::handle(const Cls& object) { \ + const_cast(object).reflect(*this); \ + } \ + void Cls::reflect(Tag& tag) { \ + reflect_impl(tag); \ } -#define REFLECT_WRITE_NO(Cls, Tag) \ - template<> void Tag::handle(const Cls& object) {} \ +#define REFLECT_WRITE_NO(Cls, Tag) \ + template<> void Tag::handle(const Cls& object) {} \ void Cls::reflect(Tag& tag) {} // ----------------------------------------------------------------------------- : Reflection for enumerations /// Implement enum reflection as used by GetMember -#define REFLECT_ENUM_GET_MEMBER(Enum) \ - template<> void GetDefaultMember::handle(const Enum& enum_) { \ - EnumGetMember egm(*this); \ - reflect_ ## Enum(const_cast(enum_), egm); \ +#define REFLECT_ENUM_GET_MEMBER(Enum) \ + template<> void GetDefaultMember::handle(const Enum& enum_) { \ + EnumGetMember egm(*this); \ + reflect_ ## Enum(const_cast(enum_), egm); \ } /// 'Tag' to be used when reflecting enumerations for GetMember diff --git a/src/util/io/reader.hpp b/src/util/io/reader.hpp index b29f52e0..77989024 100644 --- a/src/util/io/reader.hpp +++ b/src/util/io/reader.hpp @@ -244,27 +244,27 @@ void Reader::handle(IndexMap& m) { // ----------------------------------------------------------------------------- : Reflection /// Implement reflection as used by Reader -#define REFLECT_OBJECT_READER(Cls) \ - template<> void Reader::handle(Cls& object) { \ - object.reflect(*this); \ - } \ - void Cls::reflect(Reader& reader) { \ - reflect_impl(reader); \ +#define REFLECT_OBJECT_READER(Cls) \ + template<> void Reader::handle(Cls& object) { \ + object.reflect(*this); \ + } \ + void Cls::reflect(Reader& reader) { \ + reflect_impl(reader); \ } // ----------------------------------------------------------------------------- : Reflection for enumerations /// Implement enum reflection as used by Reader -#define REFLECT_ENUM_READER(Enum) \ - template<> void Reader::handle(Enum& enum_) { \ - EnumReader reader(getValue()); \ - reflect_ ## Enum(enum_, reader); \ - reader.warnIfNotDone(this); \ - } \ - void parse_enum(const String& value, Enum& out) { \ - EnumReader reader(value); \ - reflect_ ## Enum(out, reader); \ - reader.errorIfNotDone(); \ +#define REFLECT_ENUM_READER(Enum) \ + template<> void Reader::handle(Enum& enum_) { \ + EnumReader reader(getValue()); \ + reflect_ ## Enum(enum_, reader); \ + reader.warnIfNotDone(this); \ + } \ + void parse_enum(const String& value, Enum& out) { \ + EnumReader reader(value); \ + reflect_ ## Enum(out, reader); \ + reader.errorIfNotDone(); \ } /// 'Tag' to be used when reflecting enumerations for Reader diff --git a/src/util/io/writer.hpp b/src/util/io/writer.hpp index 43877f35..a9e09ea5 100644 --- a/src/util/io/writer.hpp +++ b/src/util/io/writer.hpp @@ -129,21 +129,21 @@ void Writer::handle(const IndexMap& m) { // ----------------------------------------------------------------------------- : Reflection /// Implement reflection as used by Writer -#define REFLECT_OBJECT_WRITER(Cls) \ - template<> void Writer::handle(const Cls& object) { \ - const_cast(object).reflect(*this); \ - } \ - void Cls::reflect(Writer& writer) { \ - reflect_impl(writer); \ +#define REFLECT_OBJECT_WRITER(Cls) \ + template<> void Writer::handle(const Cls& object) { \ + const_cast(object).reflect(*this); \ + } \ + void Cls::reflect(Writer& writer) { \ + reflect_impl(writer); \ } // ----------------------------------------------------------------------------- : Reflection for enumerations /// Implement enum reflection as used by Writer -#define REFLECT_ENUM_WRITER(Enum) \ - template<> void Writer::handle(const Enum& enum_) { \ - EnumWriter writer(*this); \ - reflect_ ## Enum(const_cast(enum_), writer); \ +#define REFLECT_ENUM_WRITER(Enum) \ + template<> void Writer::handle(const Enum& enum_) { \ + EnumWriter writer(*this); \ + reflect_ ## Enum(const_cast(enum_), writer); \ } /// 'Tag' to be used when reflecting enumerations for Writer