summaryrefslogtreecommitdiff
path: root/matlab/src/Communicator.cpp
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2017-10-13 18:41:38 +0200
committerJose <jose@zeroc.com>2017-10-13 18:41:38 +0200
commitd46f067bb9efca15b3fc69ed81d54dbe59d6686e (patch)
tree5f5fab14cbf919c64a272a25944bbcefb324726a /matlab/src/Communicator.cpp
parentRemove extra ICE_MATLAB_API macros (diff)
downloadice-d46f067bb9efca15b3fc69ed81d54dbe59d6686e.tar.bz2
ice-d46f067bb9efca15b3fc69ed81d54dbe59d6686e.tar.xz
ice-d46f067bb9efca15b3fc69ed81d54dbe59d6686e.zip
Replace SELF/DEREF macros with deref template function
Diffstat (limited to 'matlab/src/Communicator.cpp')
-rw-r--r--matlab/src/Communicator.cpp44
1 files changed, 17 insertions, 27 deletions
diff --git a/matlab/src/Communicator.cpp b/matlab/src/Communicator.cpp
index e30e4375d5e..20249c20574 100644
--- a/matlab/src/Communicator.cpp
+++ b/matlab/src/Communicator.cpp
@@ -10,31 +10,21 @@
#include <Ice/Communicator.h>
#include <Ice/Proxy.h>
#include "ice.h"
-#include "Communicator.h"
#include "Future.h"
#include "Logger.h"
#include "ObjectPrx.h"
#include "Util.h"
-#define DEREF(x) (*(reinterpret_cast<shared_ptr<Ice::Communicator>*>(x)))
-#define SELF DEREF(self)
-
using namespace std;
using namespace IceMatlab;
-shared_ptr<Ice::Communicator>
-IceMatlab::getCommunicator(void* p)
-{
- return DEREF(p);
-}
-
extern "C"
{
mxArray*
Ice_Communicator_unref(void* self)
{
- delete &SELF;
+ delete reinterpret_cast<shared_ptr<Ice::Communicator>*>(self);
return 0;
}
@@ -43,7 +33,7 @@ Ice_Communicator_destroy(void* self)
{
try
{
- SELF->destroy();
+ deref<Ice::Communicator>(self)->destroy();
}
catch(const std::exception& ex)
{
@@ -56,7 +46,7 @@ mxArray*
Ice_Communicator_destroyAsync(void* self, void** future)
{
*future = 0;
- auto c = SELF;
+ auto c = deref<Ice::Communicator>(self);
auto f = make_shared<SimpleFuture>();
thread t([c, f]
@@ -72,7 +62,7 @@ Ice_Communicator_destroyAsync(void* self, void** future)
}
});
t.detach();
- *future = new shared_ptr<SimpleFuture>(f);
+ *future = new shared_ptr<SimpleFuture>(move(f));
return 0;
}
@@ -81,7 +71,7 @@ Ice_Communicator_stringToProxy(void* self, const char* s, void** proxy)
{
try
{
- auto p = SELF->stringToProxy(s);
+ auto p = deref<Ice::Communicator>(self)->stringToProxy(s);
if(p)
{
*proxy = createProxy(p);
@@ -105,7 +95,7 @@ Ice_Communicator_proxyToString(void* self, void* proxy)
try
{
auto p = getProxy(proxy);
- return createResultValue(createStringFromUTF8(SELF->proxyToString(p)));
+ return createResultValue(createStringFromUTF8(deref<Ice::Communicator>(self)->proxyToString(p)));
}
catch(const std::exception& ex)
{
@@ -119,7 +109,7 @@ Ice_Communicator_propertyToProxy(void* self, const char* prop, void** proxy)
{
try
{
- auto p = SELF->propertyToProxy(prop);
+ auto p = deref<Ice::Communicator>(self)->propertyToProxy(prop);
if(p)
{
*proxy = createProxy(p);
@@ -143,7 +133,7 @@ Ice_Communicator_proxyToProperty(void* self, void* proxy, const char* prop)
try
{
auto p = getProxy(proxy);
- auto d = SELF->proxyToProperty(p, prop);
+ auto d = deref<Ice::Communicator>(self)->proxyToProperty(p, prop);
return createResultValue(createStringMap(d));
}
catch(const std::exception& ex)
@@ -160,7 +150,7 @@ Ice_Communicator_identityToString(void* self, mxArray* id)
{
Ice::Identity ident;
getIdentity(id, ident);
- return createResultValue(createStringFromUTF8(SELF->identityToString(ident)));
+ return createResultValue(createStringFromUTF8(deref<Ice::Communicator>(self)->identityToString(ident)));
}
catch(const std::exception& ex)
{
@@ -174,7 +164,7 @@ Ice_Communicator_getProperties(void* self, void** props)
{
try
{
- auto p = SELF->getProperties();
+ auto p = deref<Ice::Communicator>(self)->getProperties();
*props = new shared_ptr<Ice::Properties>(move(p));
}
catch(const std::exception& ex)
@@ -189,7 +179,7 @@ Ice_Communicator_getLogger(void* self, void** logger)
{
try
{
- auto l = SELF->getLogger();
+ auto l = deref<Ice::Communicator>(self)->getLogger();
*logger = createLogger(l);
}
catch(const std::exception& ex)
@@ -204,7 +194,7 @@ Ice_Communicator_getDefaultRouter(void* self, void** proxy)
{
try
{
- auto p = SELF->getDefaultRouter();
+ auto p = deref<Ice::Communicator>(self)->getDefaultRouter();
if(p)
{
*proxy = createProxy(p);
@@ -231,7 +221,7 @@ Ice_Communicator_setDefaultRouter(void* self, void* proxy)
{
p = Ice::uncheckedCast<Ice::RouterPrx>(getProxy(proxy));
}
- SELF->setDefaultRouter(p);
+ deref<Ice::Communicator>(self)->setDefaultRouter(p);
}
catch(const std::exception& ex)
{
@@ -245,7 +235,7 @@ Ice_Communicator_getDefaultLocator(void* self, void** proxy)
{
try
{
- auto p = SELF->getDefaultLocator();
+ auto p = deref<Ice::Communicator>(self)->getDefaultLocator();
if(p)
{
*proxy = createProxy(p);
@@ -272,7 +262,7 @@ Ice_Communicator_setDefaultLocator(void* self, void* proxy)
{
p = Ice::uncheckedCast<Ice::LocatorPrx>(getProxy(proxy));
}
- SELF->setDefaultLocator(p);
+ deref<Ice::Communicator>(self)->setDefaultLocator(p);
}
catch(const std::exception& ex)
{
@@ -287,7 +277,7 @@ Ice_Communicator_flushBatchRequests(void* self, mxArray* mode)
try
{
auto m = static_cast<Ice::CompressBatch>(getEnumerator(mode, "Ice.CompressBatch"));
- SELF->flushBatchRequests(m);
+ deref<Ice::Communicator>(self)->flushBatchRequests(m);
}
catch(const std::exception& ex)
{
@@ -305,7 +295,7 @@ Ice_Communicator_flushBatchRequestsAsync(void* self, mxArray* mode, void** futur
try
{
auto m = static_cast<Ice::CompressBatch>(getEnumerator(mode, "Ice.CompressBatch"));
- function<void()> token = SELF->flushBatchRequestsAsync(
+ function<void()> token = deref<Ice::Communicator>(self)->flushBatchRequestsAsync(
m,
[f](exception_ptr e)
{