This commit is contained in:
Alex Yatskov 2012-02-19 18:47:09 -08:00
parent 2deb0a628c
commit 59ce0b59d4
9 changed files with 39 additions and 38 deletions

View File

@ -35,7 +35,7 @@ using namespace metacall;
#define TEST_UNICODE
#define TEST_ANSI
//#define TEST_C_STRING
#define TEST_C_STRING
#define TEST_BASIC_STRING
@ -85,20 +85,18 @@ int main(int, char *[]) {
return 1;
}
server.binding()->bind(FPARAM(testCStrAnsi));
server.binding()->bind(FPARAM(testCStrUnicode));
server.binding()->bind(FPARAM(testBasicStringAnsi));
server.binding()->bind(FPARAM(testBasicStringUnicode));
Binding& binding = server.binding();
Protocol& protocol = client.protocol();
do {
Protocol* const protocol = client.protocol();
//
// C string
//
#ifdef TEST_C_STRING
{
binding.bind(FPARAM(testCStrAnsi));
binding.bind(FPARAM(testCStrUnicode));
//
// ANSI
//
@ -106,7 +104,7 @@ int main(int, char *[]) {
{
const char* strings[] = { "Hello world", "", NULL };
for (int i = 0; i < 3; ++i) {
protocol->invoke("testCStrAnsi", strings[i]);
protocol.invoke("testCStrAnsi", strings[i]);
}
}
#endif
@ -117,7 +115,7 @@ int main(int, char *[]) {
{
const wchar_t* strings[] = { L"Hello world", L"", NULL };
for (int i = 0; i < 3; ++i) {
protocol->invoke("testCStrUnicode", strings[i]);
protocol.invoke("testCStrUnicode", strings[i]);
}
}
#endif
@ -130,6 +128,9 @@ int main(int, char *[]) {
//
#ifdef TEST_BASIC_STRING
{
binding.bind(FPARAM(testBasicStringAnsi));
binding.bind(FPARAM(testBasicStringUnicode));
//
// ANSI
//
@ -137,7 +138,7 @@ int main(int, char *[]) {
{
std::string strings[] = { std::string("Hello world"), std::string() };
for (int i = 0; i < 2; ++i) {
protocol->invoke("testBasicStringAnsi", strings[i]);
protocol.invoke("testBasicStringAnsi", strings[i]);
}
}
#endif
@ -148,7 +149,7 @@ int main(int, char *[]) {
{
std::wstring strings[] = { std::wstring(L"Hello world"), std::wstring() };
for (int i = 0; i < 2; ++i) {
protocol->invoke("testBasicStringUnicode", strings[i]);
protocol.invoke("testBasicStringUnicode", strings[i]);
}
}
#endif

View File

@ -76,20 +76,20 @@ bool Client::connected() const {
return m_socket.connected();
}
const Protocol* Client::protocol() const {
return &m_protocol;
const Protocol& Client::protocol() const {
return m_protocol;
}
Protocol* Client::protocol() {
return &m_protocol;
Protocol& Client::protocol() {
return m_protocol;
}
const Binding* Client::binding() const {
return &m_binding;
const Binding& Client::binding() const {
return m_binding;
}
Binding* Client::binding() {
return &m_binding;
Binding& Client::binding() {
return m_binding;
}

View File

@ -41,10 +41,10 @@ public:
void disconnect();
bool connected() const;
const Protocol* protocol() const;
Protocol* protocol();
const Binding* binding() const;
Binding* binding();
const Protocol& protocol() const;
Protocol& protocol();
const Binding& binding() const;
Binding& binding();
private:
Socket m_socket;

View File

@ -127,7 +127,7 @@ struct PacketInvokeReply {
enum {
FLAG_UNBOUND_FUNC = 1 << 0,
FLAG_INVALID_ARGS = 1 << 1,
FLAG_INVALID_ARGS = 1 << 1
};
bool serialize(Serializer* serializer) const {

View File

@ -40,7 +40,7 @@ Protocol::Protocol(Stream* stream, Binding* binding) :
}
void Protocol::advance() {
if (!m_stream->socket()->connected()) {
if (!m_stream->socket().connected()) {
return;
}

View File

@ -48,12 +48,12 @@ void Server::advance() {
advanceConnected();
}
const Binding* Server::binding() const {
return &m_binding;
const Binding& Server::binding() const {
return m_binding;
}
Binding* Server::binding() {
return &m_binding;
Binding& Server::binding() {
return m_binding;
}
bool Server::start(int serverPort, int clientsMax) {

View File

@ -63,8 +63,8 @@ public:
bool clients(ClientId id, ClientData* data) const;
ClientId clientActive() const;
int clientCount() const;
const Binding* binding() const;
Binding* binding();
const Binding& binding() const;
Binding& binding();
private:
struct ClientEntry : public ClientData {

View File

@ -110,12 +110,12 @@ Stream::State Stream::peek(PacketHeader* header, int* headerSize) {
return STATE_READY;
}
const Socket* Stream::socket() const {
return m_socket;
const Socket& Stream::socket() const {
return *m_socket;
}
Socket* Stream::socket() {
return m_socket;
Socket& Stream::socket() {
return *m_socket;
}

View File

@ -53,8 +53,8 @@ class Stream {
State receive(T* packet);
State peek(PacketHeader* header, int* headerSize);
const Socket* socket() const;
Socket* socket();
const Socket& socket() const;
Socket& socket();
private:
Socket* m_socket;