diff options
author | Matthew Newhook <matthew@zeroc.com> | 2015-02-18 10:29:49 -0330 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2015-02-18 10:29:49 -0330 |
commit | b55ce15878456e3d2f0656bcd6abd5a55c6774b1 (patch) | |
tree | e7e771a3d90ae7295f20bf0622b72c72cc3a85e0 /py/modules/IcePy/Slice.cpp | |
parent | Fixed ObjC build (diff) | |
download | ice-b55ce15878456e3d2f0656bcd6abd5a55c6774b1.tar.bz2 ice-b55ce15878456e3d2f0656bcd6abd5a55c6774b1.tar.xz ice-b55ce15878456e3d2f0656bcd6abd5a55c6774b1.zip |
Changes for brew, python PyPI packaging and ruby gem packaging.
Diffstat (limited to 'py/modules/IcePy/Slice.cpp')
-rw-r--r-- | py/modules/IcePy/Slice.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/py/modules/IcePy/Slice.cpp b/py/modules/IcePy/Slice.cpp index 3d8862182fd..9adccc5e4c3 100644 --- a/py/modules/IcePy/Slice.cpp +++ b/py/modules/IcePy/Slice.cpp @@ -14,6 +14,7 @@ #include <Util.h> #include <Slice/Preprocessor.h> #include <Slice/PythonUtil.h> +#include <Slice/Util.h> #include <IceUtil/Options.h> // @@ -199,3 +200,60 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) Py_INCREF(Py_None); return Py_None; } + +extern "C" +PyObject* +IcePy_compile(PyObject* /*self*/, PyObject* args) +{ + PyObject* list = 0; + if(!PyArg_ParseTuple(args, STRCAST("O!"), &PyList_Type, &list)) + { + return 0; + } + + vector<string> argSeq; + if(list) + { + if(!listToStringSeq(list, argSeq)) + { + return 0; + } + } + + char** argv = new char*[argSeq.size()]; + for(size_t i = 0; i < argSeq.size(); ++i) + { + argv[i] = const_cast<char*>(argSeq[i].c_str()); + } + + int rc; + try + { + rc = Slice::Python::compile(static_cast<int>(argSeq.size()), argv); + } + catch(const std::exception& ex) + { + getErrorStream() << argv[0] << ": error:" << ex.what() << endl; + rc = EXIT_FAILURE; + } + catch(const std::string& msg) + { + getErrorStream() << argv[0] << ": error:" << msg << endl; + rc = EXIT_FAILURE; + } + catch(const char* msg) + { + getErrorStream() << argv[0] << ": error:" << msg << endl; + rc = EXIT_FAILURE; + } + catch(...) + { + getErrorStream() << argv[0] << ": error:" << "unknown exception" << endl; + rc = EXIT_FAILURE; + } + + delete[] argv; + + // PyInt_FromLong doesn't exist in python 3. + return PyLong_FromLong(rc); +} |