Add a C++ client for presents.
It provides code generators for streamables, services and receivers, but not DObject. It uses Apple's CFNetwork for its sockets and builds with XCode, so it's limited to OS X and iOS. It should be straightforward to replace both to make it cross-platform. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6264 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -3,3 +3,6 @@ genservice=com.threerings.presents.tools.GenServiceTask
|
||||
genreceiver=com.threerings.presents.tools.GenReceiverTask
|
||||
instream=com.threerings.presents.tools.InstrumentStreamableTask
|
||||
genascript=com.threerings.presents.tools.GenActionScriptTask
|
||||
gencppservice=com.threerings.presents.tools.cpp.GenCPPServiceTask
|
||||
gencppstreamable=com.threerings.presents.tools.cpp.GenCPPStreamableTask
|
||||
gencppreceiver=com.threerings.presents.tools.cpp.GenCPPReceiverTask
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "presents/stable.h"
|
||||
#include "{{decoderName}}.h"
|
||||
#include "{{receiverName}}.h"
|
||||
{{#includes}}
|
||||
#include "{{this}}"
|
||||
{{/includes}}
|
||||
|
||||
using namespace {{namespace}};
|
||||
|
||||
{{decoderName}}::{{decoderName}} (Shared<{{receiverName}}> receiver) :
|
||||
InvocationDecoder("{{receiverCode}}"),
|
||||
_receiver(receiver)
|
||||
{
|
||||
}
|
||||
|
||||
void {{decoderName}}::dispatchNotification(int8 methodId, const std::vector< Shared<Streamable> >& args)
|
||||
{
|
||||
switch(methodId) {
|
||||
{{#methods}}
|
||||
case {{-index}}:
|
||||
_receiver->{{methodName}} ( {{vectorArguments}} );
|
||||
return;
|
||||
{{/methods}}
|
||||
default:
|
||||
LOG_INFO("{{decoderName}} got unknown method: %d", methodId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "presents/InvocationDecoder.h"
|
||||
|
||||
{{#namespaces}}
|
||||
namespace {{this}} { {{/namespaces}}
|
||||
|
||||
class {{receiverName}};
|
||||
|
||||
class {{decoderName}} : public presents::InvocationDecoder {
|
||||
public:
|
||||
{{decoderName}}(Shared<{{receiverName}}> receiver);
|
||||
void dispatchNotification(int8 methodId, const std::vector< Shared<Streamable> >& args);
|
||||
|
||||
protected:
|
||||
Shared<{{receiverName}}> _receiver;
|
||||
};
|
||||
|
||||
{{#namespaces}}
|
||||
}{{/namespaces}}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "presents/stable.h"
|
||||
#include "{{name}}.h"
|
||||
#include "presents/PresentsClient.h"
|
||||
{{#includes}}
|
||||
#include "{{this}}"
|
||||
{{/includes}}
|
||||
|
||||
using namespace {{namespace}};
|
||||
|
||||
DEFINE_STREAMABLE("{{javaName}}", {{name}});
|
||||
|
||||
{{#methods}}
|
||||
void {{name}}::{{methodName}} ({{clientArguments}})
|
||||
{
|
||||
typedef std::vector< Shared<Streamable> > StreamableList;
|
||||
Shared<StreamableList> args(new StreamableList);
|
||||
{{#serviceArguments}}
|
||||
args->push_back({{this}});
|
||||
{{/serviceArguments}}
|
||||
args->push_back(getSharedThis());
|
||||
client->sendRequest(invOid, invCode, {{-index}}, args);
|
||||
}
|
||||
|
||||
{{/methods}}
|
||||
Shared<{{name}}> {{name}}::getSharedThis()
|
||||
{
|
||||
return shared_from_this();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "presents/Streamable.h"
|
||||
#include "presents/ObjectInputStream.h"
|
||||
#include "presents/ObjectOutputStream.h"
|
||||
#include "presents/data/InvocationMarshaller.h"
|
||||
#include "presents/streamers/StreamableStreamer.h"
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
{{#includes}}
|
||||
#include "{{this}}"
|
||||
{{/includes}}
|
||||
|
||||
{{#namespaces}}namespace {{this}} { {{/namespaces}}
|
||||
|
||||
|
||||
class {{name}} : public presents::data::InvocationMarshaller, public boost::enable_shared_from_this<{{name}}> {
|
||||
public:
|
||||
DECLARE_STREAMABLE();
|
||||
|
||||
virtual ~{{name}} () {}
|
||||
|
||||
{{#methods}}
|
||||
void {{methodName}} ({{clientArguments}});
|
||||
{{/methods}}
|
||||
protected:
|
||||
Shared<{{name}}> getSharedThis();
|
||||
};
|
||||
|
||||
{{#namespaces}}
|
||||
}{{/namespaces}}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "{{decoderName}}.h"
|
||||
{{#includes}}
|
||||
#include "{{this}}"
|
||||
{{/includes}}
|
||||
|
||||
{{#namespaces}}namespace {{this}} { {{/namespaces}}
|
||||
|
||||
|
||||
class {{receiverName}} {
|
||||
public:
|
||||
typedef {{decoderName}} Decoder;
|
||||
|
||||
{{#methods}}
|
||||
virtual void {{methodName}} ({{arguments}}) = 0;
|
||||
{{/methods}}
|
||||
};
|
||||
|
||||
{{#namespaces}}
|
||||
}{{/namespaces}}
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "presents/stable.h"
|
||||
#include "{{name}}.h"
|
||||
{{#includes}}
|
||||
#include "{{this}}"
|
||||
{{/includes}}
|
||||
|
||||
using namespace {{namespace}};
|
||||
|
||||
DEFINE_STREAMABLE("{{javaName}}", {{name}});
|
||||
|
||||
void {{name}}::readObject (ObjectInputStream& {{inStreamArg}})
|
||||
{
|
||||
{{#superclassStreamable}}
|
||||
{{super}}::readObject(in);
|
||||
{{/superclassStreamable}}
|
||||
{{#fields}}
|
||||
{{name}} = {{reader}};
|
||||
{{/fields}}
|
||||
}
|
||||
|
||||
void {{name}}::writeObject (ObjectOutputStream& {{outStreamArg}}) const
|
||||
{
|
||||
{{#superclassStreamable}}
|
||||
{{super}}::writeObject(out);
|
||||
{{/superclassStreamable}}
|
||||
{{#fields}}
|
||||
{{writer}};
|
||||
{{/fields}}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "presents/Streamable.h"
|
||||
#include "presents/ObjectInputStream.h"
|
||||
#include "presents/ObjectOutputStream.h"
|
||||
#include "presents/streamers/StreamableStreamer.h"
|
||||
|
||||
{{#includes}}
|
||||
#include "{{this}}"
|
||||
{{/includes}}
|
||||
|
||||
{{#namespaces}}
|
||||
namespace {{this}} { {{/namespaces}}
|
||||
|
||||
|
||||
class {{name}} : public {{super}} {
|
||||
public:
|
||||
DECLARE_STREAMABLE();
|
||||
|
||||
{{#fields}}
|
||||
{{type.type}} {{name}};
|
||||
{{/fields}}
|
||||
|
||||
virtual void readObject(ObjectInputStream& in);
|
||||
virtual void writeObject(ObjectOutputStream& out) const;
|
||||
};
|
||||
|
||||
{{#namespaces}}
|
||||
}{{/namespaces}}
|
||||
Reference in New Issue
Block a user