wrapper unnecessary! std::function<> can handle member function pointer directly. Yay!

JSON-54
Roker 2017-11-29 23:06:45 +01:00
parent c4000901cb
commit 1cda54c636
3 changed files with 2 additions and 32 deletions

View File

@ -163,8 +163,8 @@ const FunctionMap functions = {
FP( "OpenPGP_list_keyinfo", new Func<PEP_STATUS, In<PEP_SESSION,false>, In<const char*>, Out<stringpair_list_t*>> ( &OpenPGP_list_keyinfo) ),
FP( "Event Listener & Results", new Separator ),
FP( "registerEventListener" , new Func<PEP_STATUS, In<Context*, false>, In<std::string>, In<unsigned>, In<std::string>> ( &JsonAdapter::registerEventListener2) ),
FP( "unregisterEventListener", new Func<PEP_STATUS, In<Context*, false>, In<std::string>, In<unsigned>, In<std::string>> ( &JsonAdapter::unregisterEventListener2) ),
FP( "registerEventListener" , new Func<void, In<JsonAdapter*, false>, In<std::string>, In<unsigned>, In<std::string>> ( &JsonAdapter::registerEventListener) ),
FP( "unregisterEventListener", new Func<void, In<JsonAdapter*, false>, In<std::string>, In<unsigned>, In<std::string>> ( &JsonAdapter::unregisterEventListener) ),
FP( "deliverHandshakeResult" , new Func<PEP_STATUS, In<PEP_SESSION,false>, In<pEp_identity*>, In<sync_handshake_result>> (&deliverHandshakeResult) ),
// my own example function that does something useful. :-)

View File

@ -680,32 +680,6 @@ void JsonAdapter::augment(json_spirit::Object& returnObject)
}
PEP_STATUS JsonAdapter::registerEventListener2(Context* ctx, std::string address, unsigned port, std::string securityContext)
{
JsonAdapter* ja = dynamic_cast<JsonAdapter*>(ctx);
if(!ja)
{
return PEP_STATUS(-42);
}
ja->registerEventListener(address, port, securityContext);
return PEP_STATUS_OK;
}
PEP_STATUS JsonAdapter::unregisterEventListener2(Context* ctx, std::string address, unsigned port, std::string securityContext)
{
JsonAdapter* ja = dynamic_cast<JsonAdapter*>(ctx);
if(!ja)
{
return PEP_STATUS(-42);
}
ja->unregisterEventListener(address, port, securityContext);
return PEP_STATUS_OK;
}
void JsonAdapter::registerEventListener(const std::string& address, unsigned port, const std::string& securityContext)
{
const auto key = std::make_pair(address, port);

View File

@ -22,10 +22,6 @@ public:
JsonAdapter(const JsonAdapter&) = delete;
void operator=(const JsonAdapter&) = delete;
// just static trampolines to call the member functions below
static PEP_STATUS registerEventListener2(Context* ctx, std::string address, unsigned port, std::string securityContext);
static PEP_STATUS unregisterEventListener2(Context* ctx, std::string address, unsigned port, std::string securityContext);
void registerEventListener(const std::string& address, unsigned port, const std::string& securityContext);
void unregisterEventListener(const std::string& address, unsigned port, const std::string& securityContext);