Skip to content

Commit

Permalink
Replace $ with _ in rpl::mappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 20, 2017
1 parent ac99318 commit eb8800f
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/boxes/change_phone_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void createErrorLabel(

using namespace rpl::mappers;
saved->shownValue()
| rpl::filter($1 == false)
| rpl::filter(_1 == false)
| rpl::take(1)
| rpl::start_with_done(
std::move(destroy),
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/data/data_peer_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ inline auto RestrictionValue(
inline auto CanWriteValue(UserData *user) {
using namespace rpl::mappers;
return PeerFlagValue(user, MTPDuser::Flag::f_deleted)
| rpl::map(!$1);
| rpl::map(!_1);
}

inline auto CanWriteValue(ChatData *chat) {
Expand All @@ -166,7 +166,7 @@ inline auto CanWriteValue(ChatData *chat) {
| MTPDchat::Flag::f_left
| MTPDchat::Flag::f_kicked;
return PeerFlagsValue(chat, mask)
| rpl::map(!$1);
| rpl::map(!_1);
}

inline auto CanWriteValue(ChannelData *channel) {
Expand Down
8 changes: 4 additions & 4 deletions Telegram/SourceFiles/info/info_content_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ContentWidget::ContentWidget(
rpl::combine(
_controller->wrapValue(),
_controller->searchEnabledByContent(),
($1 == Wrap::Layer) && $2)
(_1 == Wrap::Layer) && _2)
| rpl::start_with_next([this](bool shown) {
refreshSearchField(shown);
}, lifetime());
Expand Down Expand Up @@ -135,7 +135,7 @@ Ui::RpWidget *ContentWidget::doSetInnerWidget(
_scroll->scrollTopValue(),
_scroll->heightValue(),
_inner->desiredHeightValue(),
tuple($1, $1 + $2, $3))
tuple(_1, _1 + _2, _3))
| rpl::start_with_next([inner = _inner](
int top,
int bottom,
Expand Down Expand Up @@ -163,15 +163,15 @@ rpl::producer<int> ContentWidget::desiredHeightValue() const {
return rpl::combine(
_inner->desiredHeightValue(),
_scrollTopSkip.value())
| rpl::map($1 + $2);
| rpl::map(_1 + _2);
}

rpl::producer<bool> ContentWidget::desiredShadowVisibility() const {
using namespace rpl::mappers;
return rpl::combine(
_scroll->scrollTopValue(),
_scrollTopSkip.value())
| rpl::map(($1 > 0) || ($2 > 0));
| rpl::map((_1 > 0) || (_2 > 0));
}

bool ContentWidget::hasTopBarShadow() const {
Expand Down
8 changes: 4 additions & 4 deletions Telegram/SourceFiles/info/info_wrap_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ void WrapWidget::startInjectingActivePeerProfiles() {
rpl::combine(
_wrap.value(),
_controller->window()->activePeer.value())
| rpl::filter(($1 == Wrap::Side) && ($2 != nullptr))
| rpl::map($2)
| rpl::filter((_1 == Wrap::Side) && (_2 != nullptr))
| rpl::map(_2)
| rpl::start_with_next([this](not_null<PeerData*> peer) {
injectActivePeerProfile(peer);
}, lifetime());
Expand Down Expand Up @@ -554,7 +554,7 @@ rpl::producer<bool> WrapWidget::topShadowToggledValue() const {
//return rpl::combine(
// _controller->wrapValue(),
// _desiredShadowVisibilities.events() | rpl::flatten_latest(),
// ($1 == Wrap::Side) || $2);
// (_1 == Wrap::Side) || _2);
return _desiredShadowVisibilities.events()
| rpl::flatten_latest();
}
Expand All @@ -564,7 +564,7 @@ rpl::producer<int> WrapWidget::desiredHeightForContent() const {
return rpl::combine(
_content->desiredHeightValue(),
topWidget()->heightValue(),
$1 + $2);
_1 + _2);
}

rpl::producer<SelectedItems> WrapWidget::selectedListValue() const {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/info/media/info_media_buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ inline auto AddCountedButton(
)->setDuration(
st::infoSlideDuration
)->toggleOn(
rpl::duplicate(forked) | rpl::map($1 > 0)
rpl::duplicate(forked) | rpl::map(_1 > 0)
);
tracker.track(button);
return button;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void InnerWidget::setScrollHeightValue(rpl::producer<int> value) {
std::move(value),
_listTops.events_starting_with(_list->topValue())
| rpl::flatten_latest(),
$1 - $2));
_1 - _2));
}

} // namespace Media
Expand Down
8 changes: 4 additions & 4 deletions Telegram/SourceFiles/info/profile/info_profile_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ Ui::MultiSlideTracker DetailsFiller::fillUserButtons(
auto sendMessageVisible = rpl::combine(
_controller->wrapValue(),
window->historyPeer.value(),
($1 != Wrap::Side) || ($2 != user));
(_1 != Wrap::Side) || (_2 != user));
auto sendMessage = [window, user] {
window->showPeerHistory(
user,
Expand Down Expand Up @@ -359,7 +359,7 @@ Ui::MultiSlideTracker DetailsFiller::fillChannelButtons(
auto viewChannelVisible = rpl::combine(
_controller->wrapValue(),
window->historyPeer.value(),
($1 != Wrap::Side) || ($2 != channel));
(_1 != Wrap::Side) || (_2 != channel));
auto viewChannel = [=] {
window->showPeerHistory(
channel,
Expand Down Expand Up @@ -589,7 +589,7 @@ void ActionsFiller::addJoinChannelAction(
not_null<ChannelData*> channel) {
using namespace rpl::mappers;
auto joinVisible = AmInChannelValue(channel)
| rpl::map(!$1)
| rpl::map(!_1)
| rpl::start_spawning(_wrap->lifetime());
AddActionButton(
_wrap,
Expand Down Expand Up @@ -724,7 +724,7 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
Data::PeerFullFlagValue(
channel,
MTPDchannelFull::Flag::f_can_view_participants),
($1 > 0) && $2);
(_1 > 0) && _2);
auto membersText = MembersCountValue(channel)
| rpl::map([](int count) {
return lng_chat_status_members(lt_count, count);
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/info/profile/info_profile_cover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void Cover::setupChildGeometry() {
rpl::combine(
toggleShownValue(),
widthValue(),
$2)
_2)
| rpl::start_with_next([this](int newWidth) {
_userpic->moveToLeft(
st::infoProfilePhotoLeft,
Expand Down Expand Up @@ -441,7 +441,7 @@ void SharedMediaCover::createLabel() {
rpl::combine(
toggleShownValue(),
widthValue(),
$2)
_2)
| rpl::start_with_next([this, weak = label.data()](int newWidth) {
auto availableWidth = newWidth
- st::infoBlockHeaderPosition.x()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool InnerWidget::canHideDetailsEver() const {
rpl::producer<bool> InnerWidget::canHideDetails() const {
using namespace rpl::mappers;
return MembersCountValue(_peer)
| rpl::map($1 > 0);
| rpl::map(_1 > 0);
}

object_ptr<Ui::RpWidget> InnerWidget::setupContent(
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/info/profile/info_profile_members.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void Members::setupButtons() {
});

//auto searchShown = MembersCountValue(_peer)
// | rpl::map($1 >= kEnableSearchMembersAfterCount)
// | rpl::map(_1 >= kEnableSearchMembersAfterCount)
// | rpl::distinct_until_changed()
// | rpl::start_spawning(lifetime());
//_search->showOn(rpl::duplicate(searchShown));
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/info/profile/info_profile_values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ rpl::producer<bool> CanAddContactValue(
return rpl::combine(
IsContactValue(user),
CanShareContactValue(user),
!$1 && $2);
!_1 && _2);
}

rpl::producer<bool> AmInChannelValue(
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/mainwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ MainWidget::MainWidget(
? Data::CanWriteValue(peer)
: rpl::single(false);
return std::move(canWrite)
| rpl::map(tuple(peer, $1));
| rpl::map(tuple(peer, _1));
})
| rpl::flatten_latest()
| rpl::start_with_next([this](PeerData *peer, bool canWrite) {
Expand Down
4 changes: 2 additions & 2 deletions Telegram/SourceFiles/rpl/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class filter_helper<producer<bool, FilterError, FilterGenerator>> {
auto operator()(producer<Value, Error, Generator> &&initial) {
using namespace mappers;
return combine(std::move(initial), std::move(_filterer))
| filter($2)
| map($1_of_two);
| filter(_2)
| map(_1_of_two);
}

private:
Expand Down
46 changes: 13 additions & 33 deletions Telegram/SourceFiles/rpl/mappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class value_mapper : public base_mapper {
public:
template <typename OtherType>
constexpr value_mapper(OtherType &&value)
: _value(std::forward<OtherType>(value)) {
: _value(std::forward<OtherType>(value)) {
}

template <typename ...Args>
Expand All @@ -87,11 +87,6 @@ class value_mapper : public base_mapper {

};

template <typename Type>
inline value_mapper<std::decay_t<Type>> make_value_mapper(Type &&value) {
return { std::forward<Type>(value) };
}

template <typename Type>
struct wrap_mapper {
using type = std::conditional_t<
Expand Down Expand Up @@ -475,33 +470,18 @@ tuple_mapper<Args...> tuple(Args &&...args) {

namespace mappers {

constexpr const details::argument_mapper<0> $1;
constexpr const details::argument_mapper<1> $2;
constexpr const details::argument_mapper<2> $3;
constexpr const details::argument_mapper<3> $4;
constexpr const details::argument_mapper<4> $5;
constexpr const details::argument_mapper<5> $6;
constexpr const details::argument_mapper<6> $7;
constexpr const details::argument_mapper<7> $8;
constexpr const details::argument_mapper<8> $9;
constexpr const details::argument_mapper<9> $10;
constexpr const details::argument_mapper<10> $11;
constexpr const details::argument_mapper<11> $12;
constexpr const details::argument_mapper<12> $13;
constexpr const details::argument_mapper<13> $14;
constexpr const details::argument_mapper<14> $15;
constexpr const details::argument_mapper<15> $16;
constexpr const details::argument_mapper<16> $17;
constexpr const details::argument_mapper<17> $18;
constexpr const details::argument_mapper<18> $19;
constexpr const details::argument_mapper<19> $20;

template <typename Type>
inline auto $val(Type &&value) {
return details::make_value_mapper(std::forward<Type>(value));
}

constexpr const auto $1_of_two = ((void)$2, $1);
constexpr const details::argument_mapper<0> _1;
constexpr const details::argument_mapper<1> _2;
constexpr const details::argument_mapper<2> _3;
constexpr const details::argument_mapper<3> _4;
constexpr const details::argument_mapper<4> _5;
constexpr const details::argument_mapper<5> _6;
constexpr const details::argument_mapper<6> _7;
constexpr const details::argument_mapper<7> _8;
constexpr const details::argument_mapper<8> _9;
constexpr const details::argument_mapper<9> _10;

constexpr const auto _1_of_two = ((void)_2, _1);

} // namespace mappers
} // namespace rpl
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/rpl/operators_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
a.events(),
b.events(),
c.events(),
$1 + $2 + $3 + 10)
_1 + _2 + _3 + 10)
| start_with_next([=](int value) {
*sum += std::to_string(value);
}, lifetime);
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/settings/settings_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Layer::Layer()

using namespace rpl::mappers;
_fixedBarShadow->toggleOn(_scroll->scrollTopValue()
| rpl::map($1 > 0));
| rpl::map(_1 > 0));
}

void Layer::setCloseClickHandler(base::lambda<void()> callback) {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/ui/abstract_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AbstractButton::AbstractButton(QWidget *parent) : RpWidget(parent) {

using namespace rpl::mappers;
shownValue()
| rpl::filter($1 == false)
| rpl::filter(_1 == false)
| rpl::start_with_next([this] { clearState(); }, lifetime());
}

Expand Down

0 comments on commit eb8800f

Please sign in to comment.