diff options
author | randomdan <randomdan@localhost> | 2014-04-17 19:12:31 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2014-04-17 19:12:31 +0000 |
commit | e90b9d87de5a5bf180fd2921a3b456d872ff27d8 (patch) | |
tree | b0f0025cd63da92c85d0e3e99bfe2921116089aa | |
parent | Support writing variable types to streams natively (diff) | |
download | project2-e90b9d87de5a5bf180fd2921a3b456d872ff27d8.tar.bz2 project2-e90b9d87de5a5bf180fd2921a3b456d872ff27d8.tar.xz project2-e90b9d87de5a5bf180fd2921a3b456d872ff27d8.zip |
Support optional parameters for ICE function calls
-rw-r--r-- | project2/ice/slice2Rows.cpp | 18 | ||||
-rw-r--r-- | project2/ice/slice2Task.cpp | 15 |
2 files changed, 24 insertions, 9 deletions
diff --git a/project2/ice/slice2Rows.cpp b/project2/ice/slice2Rows.cpp index 9646f17..a90b643 100644 --- a/project2/ice/slice2Rows.cpp +++ b/project2/ice/slice2Rows.cpp @@ -49,15 +49,23 @@ Slice2Rows::visitOperation(const Slice::OperationPtr & o) fprintf(code, "ice @ %%p\", \n"); fprintf(code, "\t\t\t\t\t\t\t\t__PRETTY_FUNCTION__, "); BOOST_FOREACH(const auto & p, o->parameters()) { - fprintf(code, "%s(ec).as<std::string>(), ", p->name().c_str()); + fprintf(code, "%s(ec), ", p->name().c_str()); } fprintf(code, "ice);\n"); fprintf(code, "\t\t\t\t\t\tIce::Context ctx;\n"); BOOST_FOREACH(const auto & p, o->parameters()) { - fprintf(code, "\t\t\t\t\t\tauto _%s = IceConvert< %s >::FromVariable(%s(ec));\n", - p->name().c_str(), - Slice::typeToString(p->type()).c_str(), - p->name().c_str()); + if (p->optional()) { + fprintf(code, "\t\t\t\t\t\tauto _%s = IceConvert< ::IceUtil::Optional< %s > >::FromVariable(%s(ec));\n", + p->name().c_str(), + Slice::typeToString(p->type()).c_str(), + p->name().c_str()); + } + else { + fprintf(code, "\t\t\t\t\t\tauto _%s = IceConvert< %s >::FromVariable(%s(ec));\n", + p->name().c_str(), + Slice::typeToString(p->type()).c_str(), + p->name().c_str()); + } } fprintf(code, "\t\t\t\t\t\tIceRowState<decltype(service->%s(", o->name().c_str()); BOOST_FOREACH(const auto & p, o->parameters()) { diff --git a/project2/ice/slice2Task.cpp b/project2/ice/slice2Task.cpp index 53ad8b4..54f05a8 100644 --- a/project2/ice/slice2Task.cpp +++ b/project2/ice/slice2Task.cpp @@ -50,15 +50,22 @@ Slice2Task::visitOperation(const Slice::OperationPtr & o) fprintf(code, "ice @ %%p\", \n"); fprintf(code, "\t\t\t\t\t\t\t\t__PRETTY_FUNCTION__, "); BOOST_FOREACH(const auto & p, o->parameters()) { - fprintf(code, "%s(ec).as<std::string>(), ", p->name().c_str()); + fprintf(code, "%s(ec), ", p->name().c_str()); } fprintf(code, "ice);\n"); fprintf(code, "\t\t\t\t\t\tIce::Context ctx;\n"); fprintf(code, "\t\t\t\t\t\tservice->%s(", o->name().c_str()); BOOST_FOREACH(const auto & p, o->parameters()) { - fprintf(code, "IceConvert< %s >::ToVariable(%s(ec)), ", - Slice::typeToString(p->type()).c_str(), - p->name().c_str()); + if (p->optional()) { + fprintf(code, "IceConvert< ::IceUtil::Optional< %s > >::FromVariable(%s(ec)), ", + Slice::typeToString(p->type()).c_str(), + p->name().c_str()); + } + else { + fprintf(code, "IceConvert< %s >::FromVariable(%s(ec)), ", + Slice::typeToString(p->type()).c_str(), + p->name().c_str()); + } } fprintf(code, "ctx);\n"); fprintf(code, "\t\t\t\t\t}\n\n"); |