summaryrefslogtreecommitdiff
path: root/matlab/src/IceMatlab/Init.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'matlab/src/IceMatlab/Init.cpp')
-rw-r--r--matlab/src/IceMatlab/Init.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/matlab/src/IceMatlab/Init.cpp b/matlab/src/IceMatlab/Init.cpp
new file mode 100644
index 00000000000..e9fe0b57256
--- /dev/null
+++ b/matlab/src/IceMatlab/Init.cpp
@@ -0,0 +1,94 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#define EXPORT_FCNS
+
+#include <Ice/Ice.h>
+#include <Ice/RegisterPlugins.h>
+#include "icematlab.h"
+#include "Util.h"
+
+using namespace std;
+using namespace IceMatlab;
+
+extern "C"
+{
+
+EXPORTED_FUNCTION mxArray*
+Ice_initialize(mxArray* args, void* propsImpl, void** r)
+{
+ try
+ {
+ Ice::StringSeq a;
+ getStringList(args, a);
+
+ //
+ // Collect InitializationData members.
+ //
+ Ice::InitializationData id;
+
+ //
+ // Properties
+ //
+ if(propsImpl)
+ {
+ id.properties = *(reinterpret_cast<shared_ptr<Ice::Properties>*>(propsImpl));
+ }
+
+ shared_ptr<Ice::Communicator> c = Ice::initialize(a, id);
+ *r = new shared_ptr<Ice::Communicator>(c);
+ return createResultValue(createStringList(a));
+ }
+ catch(const std::exception& ex)
+ {
+ return createResultException(convertException(ex));
+ }
+ return 0;
+}
+
+EXPORTED_FUNCTION mxArray*
+Ice_stringToIdentity(mxArray* s)
+{
+ try
+ {
+ Ice::Identity id = Ice::stringToIdentity(getStringFromUTF16(s));
+ return createResultValue(createIdentity(id));
+ }
+ catch(const std::exception& ex)
+ {
+ return createResultException(convertException(ex));
+ }
+ return 0;
+}
+
+EXPORTED_FUNCTION mxArray*
+Ice_identityToString(mxArray* id)
+{
+ try
+ {
+ Ice::Identity ident;
+ getIdentity(id, ident);
+ return createResultValue(createStringFromUTF8(Ice::identityToString(ident)));
+ }
+ catch(const std::exception& ex)
+ {
+ return createResultException(convertException(ex));
+ }
+ return 0;
+}
+
+//
+// This function exists so that mex may be used to compile the library. It is not otherwise needed.
+//
+void
+mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
+{
+}
+
+}