Skip to content

Commit

Permalink
Add option for lowercase macros.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadden committed Jul 16, 2018
1 parent d7089e4 commit dab35bc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/alia/signals/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ lazy_apply(Function const& f, Arg0 const& arg0, Arg1 const& arg1)
Arg1>(f, arg0, arg1);
}

#define alia_method(m) [ ](auto const& x) { return x.m(); }
// alia_method(m) wraps a method name in a lambda so that it can be passed as a
// function object.
#define ALIA_METHOD(m) [](auto const& x) { return x.m(); }
#ifdef ALIA_LOWERCASE_MACROS
#define alia_method(m) ALIA_METHOD(m)
#endif

} // namespace alia

Expand Down
7 changes: 5 additions & 2 deletions src/alia/signals/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,11 @@ operator->*(
return field_signal<StructureSignal, Field>(structure, field);
}

// alia_field(x, f) is equivalent to x->*T::f where T is the value type of x.
#define alia_field(x, f) ((x)->*&std::decay<decltype(read_signal(x))>::type::f)
// ALIA_FIELD(x, f) is equivalent to x->*T::f where T is the value type of x.
#define ALIA_FIELD(x, f) ((x)->*&std::decay<decltype(read_signal(x))>::type::f)
#ifdef ALIA_LOWERCASE_MACROS
#define alia_field(x, f) ALIA_FIELD(x, f)
#endif

} // namespace alia

Expand Down
2 changes: 2 additions & 0 deletions unit_tests/signals/application.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define ALIA_LOWERCASE_MACROS

#include <alia/signals/application.hpp>

#include <catch.hpp>
Expand Down
2 changes: 2 additions & 0 deletions unit_tests/signals/operators.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define ALIA_LOWERCASE_MACROS

#include <alia/signals/operators.hpp>

#include <catch.hpp>
Expand Down

0 comments on commit dab35bc

Please sign in to comment.