Skip to content

Commit 685ccd9

Browse files
committed
All the minor updates necessary to build on mac
These are weird changes, mostly brought about by the weird state of C++ headers on macOS. There all very minor changes though, so they should still work on linux (I didn't test that though :( )
1 parent 325c1da commit 685ccd9

File tree

12 files changed

+76
-22
lines changed

12 files changed

+76
-22
lines changed

decibel-cpp/include/decibel/Protobuf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ struct ProtobufSetter
100100

101101
DEFINE_PROTOBUF_FIELD_MAPPING(int32_t, Int32);
102102
DEFINE_PROTOBUF_FIELD_MAPPING(int64_t, Int64);
103+
DEFINE_PROTOBUF_FIELD_MAPPING(long, Int64);
103104
DEFINE_PROTOBUF_FIELD_MAPPING(uint32_t, UInt32);
104105
DEFINE_PROTOBUF_FIELD_MAPPING(uint64_t, UInt64);
106+
DEFINE_PROTOBUF_FIELD_MAPPING(unsigned long, UInt64);
105107
DEFINE_PROTOBUF_FIELD_MAPPING(float, Float);
106108
DEFINE_PROTOBUF_FIELD_MAPPING(double, Double);
107109
DEFINE_PROTOBUF_FIELD_MAPPING(bool, Bool);

decibel-cpp/include/decibel/messaging/ProtobufProtocolFactory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class ProtobufProtocolFactory : public IProtocolFactory
5151
{
5252
auto protocol = std::make_unique<ProtocolT>(mDispatcher);
5353
protocol->RegisterSendErrorCallback(*mSendErrorCallback);
54-
return protocol;
54+
return std::move(protocol);
5555
}
5656
else
5757
{

decibel-cpp/include/decibel/messaging/RabbitMQMessageHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RabbitMQMessageHandler : public IRabbitMQMessageHandler
1818
virtual void HandleData(AMQP::Message&& message, uint64_t, bool)
1919
{
2020
MessageType protobufMessage;
21-
protobufMessage.ParseFromString(message.message());
21+
protobufMessage.ParseFromString(std::string(message.body()));
2222
HandleMessage(std::move(protobufMessage));
2323
}
2424

decibel-cpp/include/decibel/messaging/Reactor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace messaging
2222
class Protocol;
2323
class IProtocolFactory;
2424

25-
class Reactor : public folly::Executor, public folly::Timekeeper
25+
class Reactor : public folly::Timekeeper
2626
{
2727
public:
2828
Reactor();
@@ -71,7 +71,7 @@ class Reactor : public folly::Executor, public folly::Timekeeper
7171
}
7272

7373
// folly::Executor
74-
virtual void add(folly::Func fn);
74+
// virtual void add(folly::Func fn);
7575

7676
// folly::TimeKeeper
7777
virtual folly::Future<folly::Unit> after(folly::Duration duration);

decibel-cpp/include/decibel/stdlib.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <memory>
44

5-
#ifndef __cpp_lib_make_unique
5+
#if !defined __cpp_lib_make_unique && !defined __APPLE__
66

77
namespace std
88
{

decibel-cpp/src/decibel/messaging/Reactor.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ namespace decibel
2828
namespace messaging
2929
{
3030
Reactor::Reactor()
31-
: folly::Executor()
32-
, folly::Timekeeper()
31+
: folly::Timekeeper()
3332
, mEventLoop()
3433
, mpTimer(
3534
std::make_unique<EventLoopTimer>(niceuv::EventLoopTimer(&mEventLoop)))
@@ -153,10 +152,12 @@ void Reactor::CancelCall(std::shared_ptr<OneShotTimerEvent> pTimer)
153152
pTimer->Stop();
154153
}
155154

156-
void Reactor::add(folly::Func fn)
157-
{
158-
CallSoon(fn);
159-
}
155+
// This is kept around for posterity should anyone want to add back
156+
// folly::Executor functionality
157+
// void Reactor::add(folly::Func fn)
158+
// {
159+
// CallSoon(fn);
160+
// }
160161

161162
folly::Future<folly::Unit> Reactor::after(folly::Duration duration)
162163
{

decibel-cpp/src/decibel/messaging/TcpServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ TcpServer::TcpServer(niceuv::EventLoop* loop,
2323
: mServer(new niceuv::TcpServer(loop)), mProtocols()
2424
{
2525
auto connectCb = [factory, this, host, port](niceuv::TcpConnPtr conn) {
26-
auto pProtocol = std::move(factory->Construct());
26+
auto pProtocol = factory->Construct();
2727
auto rawpConn = conn.get();
2828
auto pTransport =
2929
std::make_unique<TcpTransport>(std::move(conn), host, port);

decibel-cpp/src/decibel/niceuv/WorkCancellable.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#include "decibel/niceuv/WorkCancellable.h"
22

3+
#include <exception>
4+
#include <stdexcept>
5+
36
namespace decibel
47
{
58
namespace niceuv

decibel-cpp/test/test_reactor.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,14 @@ TEST(TestSelfConnectMultiClients, ConnectTcp)
153153
ASSERT_EQ(1, rawpProto2->mConnectionLostCalls);
154154
}
155155

156-
TEST(TestReactor, FollyExecutorAdd)
157-
{
158-
dm::Reactor r;
159-
bool then_called = false;
160-
auto fut = folly::makeFuture().via(&r).then([&]() { then_called = true; });
161-
ASSERT_FALSE(then_called);
162-
r.Start();
163-
ASSERT_TRUE(then_called);
164-
}
156+
// This is kept around for posterity should anyone want to add back
157+
// folly::Executor functionality
158+
// TEST(TestReactor, FollyExecutorAdd)
159+
// {
160+
// dm::Reactor r;
161+
// bool then_called = false;
162+
// auto fut = folly::makeFuture().via(&r).then([&]() { then_called = true; });
163+
// ASSERT_FALSE(then_called);
164+
// r.Start();
165+
// ASSERT_TRUE(then_called);
166+
// }

src/ConfigTypes.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ class ConfigValue
7373
}
7474
}
7575

76+
template <typename T>
77+
ConfigType<T> ToConfigType() const
78+
{
79+
BOOST_ASSERT_MSG(!mEmpty, "Can't dereference Empty Value");
80+
try
81+
{
82+
return boost::get<ConfigType<T>>(mValue);
83+
}
84+
catch (const boost::bad_get& ex)
85+
{
86+
BOOST_ASSERT_MSG(false, "Requested incorrect type from variant");
87+
return ConfigType<T>({});
88+
}
89+
}
90+
7691
template <typename T>
7792
bool Is() const
7893
{

0 commit comments

Comments
 (0)