From 86b1de85536e93c59a25702a5a2d3e384202ffd2 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 11 Dec 2012 04:03:29 +0000 Subject: More changes to port to C++11, adjust to use the new JSON support, and cleanup rest of the modules. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1419987 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/server/mod-cpp.hpp | 47 +++++++++++++------------------- 1 file changed, 19 insertions(+), 28 deletions(-) (limited to 'sca-cpp/trunk/modules/server/mod-cpp.hpp') diff --git a/sca-cpp/trunk/modules/server/mod-cpp.hpp b/sca-cpp/trunk/modules/server/mod-cpp.hpp index 8cae35e493..1321466383 100644 --- a/sca-cpp/trunk/modules/server/mod-cpp.hpp +++ b/sca-cpp/trunk/modules/server/mod-cpp.hpp @@ -54,47 +54,38 @@ const list failableResult(const value& func, const list& v) { const value reason = cadr(v); if (length(reason) == 0) { if (func == "start" || func == "stop") - return mklist(lambda&)>()); - return mklist(value(), string("Function not supported: ") + func); + return mklist(lvvlambda()); + return mklist(nilValue, string("Function not supported: ") + (string)func); } return v; } -struct applyImplementation { - const lib ilib; - const lambda&)> impl; - const list px; - - applyImplementation(const lib& ilib, const lambda&)>& impl, const list& px) : ilib(ilib), impl(impl), px(px) { - } - - const value operator()(const list& params) const { - debug(params, "modeval::cpp::applyImplementation::input"); - - // Apply the component implementation function - const value val = failableResult(car(params), impl(append(params, px))); - - debug(val, "modeval::cpp::applyImplementation::result"); - return val; - } -}; - /** * Evaluate a C++ component implementation and convert it to * an applicable lambda function. */ -const failable&)> > evalImplementation(const string& path, const value& impl, const list& px) { +const failable evalImplementation(const string& path, const value& impl, const list& px) { // Configure the implementation's lambda function const value ipath(attributeValue("path", impl)); const value iname(attributeValue("library", impl)); - const string fpath(isNil(ipath)? path + iname : path + ipath + "/" + iname); + const string fpath(isNil(ipath)? path + (string)iname : path + (string)ipath + "/" + (string)iname); const lib ilib(*(new (gc_new()) lib(fpath + dynlibExt))); - const failable&)> > evalf(dynlambda&)>("apply", ilib)); - if (!hasContent(evalf)) - return evalf; - const lambda&)> l(applyImplementation(ilib, content(evalf), px)); - return l; + const failable fappl(dynlambda&)>("apply", ilib)); + if (!hasContent(fappl)) + return fappl; + const lvvlambda appl = content(fappl); + + const lvvlambda applyImplementation = [ilib, appl, px](const list& params) -> const value { + debug(params, "modeval::cpp::applyImplementation::params"); + + // Apply the component implementation function + const value val = failableResult(car(params), appl(append(params, px))); + + debug(val, "modeval::cpp::applyImplementation::result"); + return val; + }; + return applyImplementation; } } -- cgit v1.2.3