Skip to content

Commit

Permalink
changed some references to pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
Niall Ryan authored and Niall Ryan committed Jun 5, 2010
1 parent 179b32c commit 8296cac
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 38 deletions.
10 changes: 5 additions & 5 deletions Cpp/ProtoBufRemote/Generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class name##Proxy : public ::ProtoBufRemote::Proxy \
{ \
public: \
name##Proxy(::ProtoBufRemote::RpcClient& client) : ::ProtoBufRemote::Proxy(client, #name) { } \
name##Proxy(::ProtoBufRemote::RpcClient* client) : ::ProtoBufRemote::Proxy(client, #name) { } \
BOOST_PP_SEQ_FOR_EACH(PBR_X_PROXY_METHOD, ~, methods) \
};

Expand Down Expand Up @@ -121,21 +121,21 @@
m_parameters.Add().PBR_X_PARAM_SET_FUNC(param) (BOOST_PP_CAT(p, i)); \

#define PBR_X_METHOD_CALL(method) \
::ProtoBufRemote::PendingCall* call = m_client.Call(m_serviceName, BOOST_PP_STRINGIZE(PBR_X_METHOD_NAME(method)), \
::ProtoBufRemote::PendingCall* call = m_client->Call(m_serviceName, BOOST_PP_STRINGIZE(PBR_X_METHOD_NAME(method)), \
m_parameters); \
call->Wait(); \
BOOST_PP_IF(PBR_X_PARAM_IS_RESULT_PTR(PBR_X_METHOD_RETURN(method)), \
call->GetResult()->PBR_X_PARAM_GET_FUNC(PBR_X_METHOD_RETURN(method))(resultPtr); \
m_client.ReleaseCall(call); \
m_client->ReleaseCall(call); \
, \
PBR_X_PARAM_TYPE(PBR_X_METHOD_RETURN(method)) result \
= call->GetResult()->PBR_X_PARAM_GET_FUNC(PBR_X_METHOD_RETURN(method))(); \
m_client.ReleaseCall(call); \
m_client->ReleaseCall(call); \
return result; \
)

#define PBR_X_METHOD_CALLWITHOUTRESULT(method) \
m_client.CallWithoutResult(m_serviceName, BOOST_PP_STRINGIZE(PBR_X_METHOD_NAME(method)), m_parameters);
m_client->CallWithoutResult(m_serviceName, BOOST_PP_STRINGIZE(PBR_X_METHOD_NAME(method)), m_parameters);


//stub
Expand Down
8 changes: 4 additions & 4 deletions Cpp/ProtoBufRemote/MutableParameterList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

namespace ProtoBufRemote {

MutableParameterList::MutableParameterList(RpcMessage& message)
: ParameterList(message), m_message(message)
MutableParameterList::MutableParameterList(RpcMessage* message)
: ParameterList(*message), m_message(message)
{
}

void MutableParameterList::Clear()
{
m_message.mutable_call_message()->clear_parameters();
m_message->mutable_call_message()->clear_parameters();
}

MutableParameter MutableParameterList::Add()
{
RpcMessage::Parameter* paramMessage = m_message.mutable_call_message()->add_parameters();
RpcMessage::Parameter* paramMessage = m_message->mutable_call_message()->add_parameters();
return MutableParameter(paramMessage);
}

Expand Down
4 changes: 2 additions & 2 deletions Cpp/ProtoBufRemote/MutableParameterList.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ namespace ProtoBufRemote {
class MutableParameterList : public ParameterList
{
public:
MutableParameterList(RpcMessage& message);
MutableParameterList(RpcMessage* message);

void Clear();

MutableParameter Add();

private:
RpcMessage& m_message;
RpcMessage* m_message;
};

}
Expand Down
2 changes: 1 addition & 1 deletion Cpp/ProtoBufRemote/ParameterList.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ParameterList
private:
friend RpcClient;

RpcMessage& GetMessage() const { return const_cast<RpcMessage&>(m_message); }
RpcMessage* GetMessage() const { return const_cast<RpcMessage*>(&m_message); }

const RpcMessage& m_message;
};
Expand Down
6 changes: 3 additions & 3 deletions Cpp/ProtoBufRemote/Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ class RpcClient;
class Proxy
{
public:
Proxy(RpcClient& client, const char* serviceName)
: m_client(client), m_serviceName(serviceName), m_parameters(m_message)
Proxy(RpcClient* client, const char* serviceName)
: m_client(client), m_serviceName(serviceName), m_parameters(&m_message)
{
}

protected:
RpcClient& m_client;
RpcClient* m_client;
std::string m_serviceName;
RpcMessage m_message;
MutableParameterList m_parameters;
Expand Down
16 changes: 8 additions & 8 deletions Cpp/ProtoBufRemote/RpcClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ PendingCall* RpcClient::Call(const std::string& service, const std::string& meth
{
assert(m_controller);

RpcMessage& message = parameters.GetMessage();
RpcMessage* message = parameters.GetMessage();
int id = m_nextId++;
message.set_id(id);
RpcMessage::Call* callMessage = message.mutable_call_message();
message->set_id(id);
RpcMessage::Call* callMessage = message->mutable_call_message();
callMessage->set_service(service);
callMessage->set_method(method);
callMessage->set_expects_result(true);

PendingCall* call = new PendingCall(id);
m_pendingCalls.insert(std::make_pair(id, call));

m_controller->Send(message);
m_controller->Send(*message);

return call;
}
Expand All @@ -46,13 +46,13 @@ void RpcClient::CallWithoutResult(const std::string& service, const std::string&
{
assert(m_controller);

RpcMessage& message = parameters.GetMessage();
message.set_id(m_nextId++);
RpcMessage::Call* callMessage = message.mutable_call_message();
RpcMessage* message = parameters.GetMessage();
message->set_id(m_nextId++);
RpcMessage::Call* callMessage = message->mutable_call_message();
callMessage->set_service(service);
callMessage->set_method(method);
callMessage->set_expects_result(false);
m_controller->Send(message);
m_controller->Send(*message);
}

void RpcClient::ReceiveResult(const RpcMessage& resultMessage)
Expand Down
4 changes: 2 additions & 2 deletions Cpp/ProtoBufRemoteTest/ProxyGeneratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool IsDoStuffParameterListCorrect(const ParameterList& paramList)
TEST(ProxyGeneratorTest, Call)
{
MockRpcClient client;
SampleService2Proxy proxy(client);
SampleService2Proxy proxy(&client);

PendingCall call(0);
RpcMessage::Parameter resultParam;
Expand All @@ -51,7 +51,7 @@ TEST(ProxyGeneratorTest, Call)
TEST(ProxyGeneratorTest, CallWithoutResult)
{
MockRpcClient client;
SampleService2Proxy proxy(client);
SampleService2Proxy proxy(&client);

EXPECT_CALL(client, CallWithoutResult("SampleService2", "DoStuff", Truly(IsDoStuffParameterListCorrect)));

Expand Down
4 changes: 2 additions & 2 deletions Cpp/ProtoBufRemoteTest/ProxyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool IsDoStuffParameterListCorrect(const ParameterList& paramList)
TEST(ProxyTest, Call)
{
MockRpcClient client;
SampleServiceProxy proxy(client);
SampleServiceProxy proxy(&client);

PendingCall call(0);
RpcMessage::Parameter resultParam;
Expand All @@ -46,7 +46,7 @@ TEST(ProxyTest, Call)
TEST(ProxyTest, CallWithoutResult)
{
MockRpcClient client;
SampleServiceProxy proxy(client);
SampleServiceProxy proxy(&client);

EXPECT_CALL(client, CallWithoutResult("SampleService", "DoStuff", Truly(IsDoStuffParameterListCorrect)));

Expand Down
4 changes: 2 additions & 2 deletions Cpp/ProtoBufRemoteTest/RpcClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TEST_F(RpcClientTest, CallWithoutResult)
Property(&RpcMessage::call_message, Property(&RpcMessage::Call::expects_result, Eq(false))))));

RpcMessage message;
MutableParameterList parameters(message);
MutableParameterList parameters(&message);
parameters.Add().SetInt(42);
m_client->CallWithoutResult("ServiceName", "MethodName", parameters);
}
Expand All @@ -80,7 +80,7 @@ TEST_F(RpcClientTest, Call)
.WillOnce(Invoke(this, &RpcClientTest::SendResult));

RpcMessage message;
MutableParameterList parameters(message);
MutableParameterList parameters(&message);
parameters.Add().SetInt(42);
PendingCall* call = m_client->Call("ServiceName", "MethodName", parameters);
call->Wait();
Expand Down
8 changes: 4 additions & 4 deletions Cpp/ProtoBufRemoteTest/SampleServiceProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class SampleServiceProxy : public ProtoBufRemote::Proxy
{
public:
SampleServiceProxy(ProtoBufRemote::RpcClient& client)
SampleServiceProxy(ProtoBufRemote::RpcClient* client)
: ProtoBufRemote::Proxy(client, "SampleService")
{
}
Expand All @@ -16,18 +16,18 @@ class SampleServiceProxy : public ProtoBufRemote::Proxy
{
m_parameters.Clear();
m_parameters.Add().SetInt(x);
ProtoBufRemote::PendingCall* call = m_client.Call(m_serviceName, "GetSquare", m_parameters);
ProtoBufRemote::PendingCall* call = m_client->Call(m_serviceName, "GetSquare", m_parameters);
call->Wait();
int result = call->GetResult()->GetInt();
m_client.ReleaseCall(call);
m_client->ReleaseCall(call);
return result;
}

void DoStuff(const std::string& str)
{
m_parameters.Clear();
m_parameters.Add().SetString(str);
m_client.CallWithoutResult(m_serviceName, "DoStuff", m_parameters);
m_client->CallWithoutResult(m_serviceName, "DoStuff", m_parameters);
}
};

Expand Down
10 changes: 5 additions & 5 deletions Cpp/ProtoBufRemoteTest/StubGeneratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST(StubGeneratorTest, Call)
EXPECT_CALL(service, GetSquare(5)).WillOnce(Return(25));

RpcMessage message;
MutableParameterList parameters(message);
MutableParameterList parameters(&message);
parameters.Add().SetInt(5);
RpcMessage::Parameter resultMessage;
MutableParameter result(&resultMessage);
Expand All @@ -57,7 +57,7 @@ TEST(StubGeneratorTest, CallWithoutResult)
EXPECT_CALL(service, DoStuff("hello"));

RpcMessage message;
MutableParameterList parameters(message);
MutableParameterList parameters(&message);
parameters.Add().SetString("hello");

bool isSuccess = service.Call("DoStuff", parameters, NULL);
Expand All @@ -70,7 +70,7 @@ TEST(StubGeneratorTest, CallUnknownMethod)
MockSampleService2 service;

RpcMessage message;
MutableParameterList parameters(message);
MutableParameterList parameters(&message);

bool isSuccess = service.Call("NotAMethod", parameters, NULL);

Expand All @@ -82,7 +82,7 @@ TEST(StubGeneratorTest, CallWrongParameterCount)
MockSampleService2 service;

RpcMessage message;
MutableParameterList parameters(message);
MutableParameterList parameters(&message);
parameters.Add().SetInt(5);
parameters.Add().SetInt(6);
RpcMessage::Parameter resultMessage;
Expand All @@ -98,7 +98,7 @@ TEST(StubGeneratorTest, CallWrongParameterType)
MockSampleService2 service;

RpcMessage message;
MutableParameterList parameters(message);
MutableParameterList parameters(&message);
parameters.Add().SetString("hello");
RpcMessage::Parameter resultMessage;
MutableParameter result(&resultMessage);
Expand Down

0 comments on commit 8296cac

Please sign in to comment.