diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-17 09:02:29 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-17 09:02:29 +0000 |
commit | b00fe2747627bc95ac8d1d548e0621930a1775a2 (patch) | |
tree | 64561e332127d72763850196be5f0538cac9b8bb /sca-cpp/trunk/modules/server/mod-scheme.hpp | |
parent | 9cb610814d58da1ba2617f78e36e9635f2e7d508 (diff) |
Cleaned up test composite files. Adjusted C++ implementation elements to match the spec. Minor refactoring/terminology cleanup in HTTPD modules, renamed readImplementation to evalImplementation and evalImplementation to applyImplementation.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@900071 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/server/mod-scheme.hpp')
-rw-r--r-- | sca-cpp/trunk/modules/server/mod-scheme.hpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sca-cpp/trunk/modules/server/mod-scheme.hpp b/sca-cpp/trunk/modules/server/mod-scheme.hpp index 5c6ea9ef7d..fd03ebb43e 100644 --- a/sca-cpp/trunk/modules/server/mod-scheme.hpp +++ b/sca-cpp/trunk/modules/server/mod-scheme.hpp @@ -23,7 +23,7 @@ #define tuscany_modscheme_hpp /** - * Evaluation functions used by mod-eval to evaluate implementation.scheme + * Evaluation functions used by mod-eval to evaluate Scheme * component implementations. */ @@ -50,19 +50,19 @@ const list<value> primitiveProcedures(const list<value>& l) { } /** - * Evaluate a scheme component implementation function. + * Apply a Scheme component implementation function. */ -struct evalImplementation { +struct applyImplementation { const value impl; const list<value> px; - evalImplementation(const value& impl, const list<value>& px) : impl(impl), px(scheme::quotedParameters(primitiveProcedures(px))) { + applyImplementation(const value& impl, const list<value>& px) : impl(impl), px(scheme::quotedParameters(primitiveProcedures(px))) { } const value operator()(const list<value>& params) const { const value expr = cons<value>(car(params), append(scheme::quotedParameters(cdr(params)), px)); - debug(expr, "modeval::scheme::evalImplementation::input"); + debug(expr, "modeval::scheme::applyImplementation::input"); scheme::Env env = scheme::setupEnvironment(); const value val = scheme::evalScript(expr, impl, env); - debug(val, "modeval::scheme::evalImplementation::result"); + debug(val, "modeval::scheme::applyImplementation::result"); if (isNil(val)) return mklist<value>(value(), string("Could not evaluate expression")); return mklist<value>(val); @@ -70,16 +70,18 @@ struct evalImplementation { }; /** - * Read a scheme component implementation. + * Evaluate a Scheme component implementation and convert it to an + * applicable lambda function. */ -const failable<lambda<value(const list<value>&)> > readImplementation(const string& path, const list<value>& px) { - ifstream is(path); +const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) { + const string fpath(path + attributeValue("script", impl)); + ifstream is(fpath); if (fail(is)) - return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + path); - const value impl = scheme::readScript(is); - if (isNil(impl)) - return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + path); - return lambda<value(const list<value>&)>(evalImplementation(impl, px)); + return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath); + const value script = scheme::readScript(is); + if (isNil(script)) + return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath); + return lambda<value(const list<value>&)>(applyImplementation(script, px)); } } |