From b00fe2747627bc95ac8d1d548e0621930a1775a2 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sun, 17 Jan 2010 09:02:29 +0000 Subject: 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 --- sca-cpp/trunk/components/cache/mcache.composite | 2 +- sca-cpp/trunk/components/cache/mcache.cpp | 2 +- .../components/webservice/webservice.composite | 2 +- sca-cpp/trunk/components/webservice/webservice.cpp | 8 ++-- sca-cpp/trunk/modules/python/domain-test.composite | 4 +- sca-cpp/trunk/modules/python/mod-python.cpp | 11 +++--- sca-cpp/trunk/modules/python/mod-python.hpp | 30 ++++++++------- .../tuscany-sca-1.1-implementation-python.xsd | 2 +- sca-cpp/trunk/modules/scdl/scdl-test.cpp | 2 +- sca-cpp/trunk/modules/scdl/test.composite | 11 ++---- .../scheme/tuscany-sca-1.1-implementation-eval.xsd | 43 ---------------------- .../tuscany-sca-1.1-implementation-scheme.xsd | 43 ++++++++++++++++++++++ sca-cpp/trunk/modules/server/domain-test.composite | 6 +-- sca-cpp/trunk/modules/server/impl-test.cpp | 2 +- sca-cpp/trunk/modules/server/mod-cpp.hpp | 31 +++++++++------- sca-cpp/trunk/modules/server/mod-eval.cpp | 11 +++--- sca-cpp/trunk/modules/server/mod-eval.hpp | 8 ++-- sca-cpp/trunk/modules/server/mod-scheme.hpp | 30 ++++++++------- sca-cpp/trunk/test/store-python/currency.composite | 32 ---------------- sca-cpp/trunk/test/store-python/store.composite | 11 +++--- sca-cpp/trunk/test/store-scheme/currency.composite | 32 ---------------- sca-cpp/trunk/test/store-scheme/store.composite | 11 +++--- 22 files changed, 138 insertions(+), 196 deletions(-) delete mode 100644 sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd create mode 100644 sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-scheme.xsd delete mode 100644 sca-cpp/trunk/test/store-python/currency.composite delete mode 100644 sca-cpp/trunk/test/store-scheme/currency.composite (limited to 'sca-cpp/trunk') diff --git a/sca-cpp/trunk/components/cache/mcache.composite b/sca-cpp/trunk/components/cache/mcache.composite index 99364104fb..3a838abc79 100644 --- a/sca-cpp/trunk/components/cache/mcache.composite +++ b/sca-cpp/trunk/components/cache/mcache.composite @@ -23,7 +23,7 @@ name="mcache"> - + diff --git a/sca-cpp/trunk/components/cache/mcache.cpp b/sca-cpp/trunk/components/cache/mcache.cpp index 3e8fdeb294..46f707ee19 100644 --- a/sca-cpp/trunk/components/cache/mcache.cpp +++ b/sca-cpp/trunk/components/cache/mcache.cpp @@ -89,7 +89,7 @@ const failable del(const list& params) { extern "C" { -const tuscany::value eval(const tuscany::list& params) { +const tuscany::value apply(const tuscany::list& params) { const tuscany::value func(car(params)); if (func == "get") return tuscany::cache::get(cdr(params)); diff --git a/sca-cpp/trunk/components/webservice/webservice.composite b/sca-cpp/trunk/components/webservice/webservice.composite index 3e6be1fae6..9498a26b53 100644 --- a/sca-cpp/trunk/components/webservice/webservice.composite +++ b/sca-cpp/trunk/components/webservice/webservice.composite @@ -23,7 +23,7 @@ name="webservice"> - + diff --git a/sca-cpp/trunk/components/webservice/webservice.cpp b/sca-cpp/trunk/components/webservice/webservice.cpp index 769df9e258..f4606afdd8 100644 --- a/sca-cpp/trunk/components/webservice/webservice.cpp +++ b/sca-cpp/trunk/components/webservice/webservice.cpp @@ -34,9 +34,9 @@ namespace tuscany { namespace webservice { /** - * Evaluate a Web service function / operation. + * Apply a Web service function / operation. */ -const failable eval(const value& func, unused const list& params) { +const failable apply(const value& func, unused const list& params) { return tuscany::mkfailure(tuscany::string("Function not supported: ") + func); } @@ -45,8 +45,8 @@ const failable eval(const value& func, unused const list& params) extern "C" { -const tuscany::value eval(const tuscany::list& params) { - return tuscany::webservice::eval(car(params), cdr(params)); +const tuscany::value apply(const tuscany::list& params) { + return tuscany::webservice::apply(car(params), cdr(params)); } } diff --git a/sca-cpp/trunk/modules/python/domain-test.composite b/sca-cpp/trunk/modules/python/domain-test.composite index 7318f96520..a0e92dfb0c 100644 --- a/sca-cpp/trunk/modules/python/domain-test.composite +++ b/sca-cpp/trunk/modules/python/domain-test.composite @@ -23,14 +23,14 @@ name="domain-test"> - + - + diff --git a/sca-cpp/trunk/modules/python/mod-python.cpp b/sca-cpp/trunk/modules/python/mod-python.cpp index 1352c50c11..1c35467b4b 100644 --- a/sca-cpp/trunk/modules/python/mod-python.cpp +++ b/sca-cpp/trunk/modules/python/mod-python.cpp @@ -37,14 +37,15 @@ namespace server { namespace modeval { /** - * Return a configured component implementation. - * For now only Scheme and C++ implementations are supported. + * Evaluate a Python component implementation and convert it to an applicable + * lambda function. */ -const failable&)> > readImplementation(const string& itype, const string& path, const list& px) { +const failable&)> > evalImplementation(const string& path, const value& impl, const list& px) { + const string itype(elementName(impl)); if (contains(itype, ".python")) - return modpython::readImplementation(path, px); + return modpython::evalImplementation(path, impl, px); if (contains(itype, ".cpp")) - return modcpp::readImplementation(path, px); + return modcpp::evalImplementation(path, impl, px); return mkfailure&)> >(string("Unsupported implementation type: ") + itype); } diff --git a/sca-cpp/trunk/modules/python/mod-python.hpp b/sca-cpp/trunk/modules/python/mod-python.hpp index a56232d641..e67b9a4a93 100644 --- a/sca-cpp/trunk/modules/python/mod-python.hpp +++ b/sca-cpp/trunk/modules/python/mod-python.hpp @@ -23,7 +23,7 @@ #define tuscany_modpython_hpp /** - * Evaluation functions used by mod-eval to evaluate implementation.python + * Evaluation functions used by mod-eval to evaluate Python * component implementations. */ @@ -41,18 +41,18 @@ namespace server { namespace modpython { /** - * Evaluate a script component implementation function. + * Apply a Python component implementation function. */ -struct evalImplementation { +struct applyImplementation { PyObject* impl; const list px; - evalImplementation(PyObject* impl, const list& px) : impl(impl), px(px) { + applyImplementation(PyObject* impl, const list& px) : impl(impl), px(px) { } const value operator()(const list& params) const { const value expr = append(params, px); - debug(expr, "modeval::python::evalImplementation::input"); + debug(expr, "modeval::python::applyImplementation::input"); const failable val = python::evalScript(expr, impl); - debug(val, "modeval::python::evalImplementation::result"); + debug(val, "modeval::python::applyImplementation::result"); if (!hasContent(val)) return mklist(value(), reason(val)); return mklist(content(val)); @@ -60,16 +60,18 @@ struct evalImplementation { }; /** - * Read a script component implementation. + * Evaluate a Python component implementation and convert it to an applicable + * lambda function. */ -const failable&)> > readImplementation(const string& path, const list& px) { - ifstream is(path); +const failable&)> > evalImplementation(const string& path, const value& impl, const list& px) { + const string fpath(path + attributeValue("script", impl)); + ifstream is(fpath); if (fail(is)) - return mkfailure&)> >(string("Could not read implementation: ") + path); - const failable impl = python::readScript(path, is); - if (!hasContent(impl)) - return mkfailure&)> >(reason(impl)); - return lambda&)>(evalImplementation(content(impl), px)); + return mkfailure&)> >(string("Could not read implementation: ") + fpath); + const failable script = python::readScript(fpath, is); + if (!hasContent(script)) + return mkfailure&)> >(reason(script)); + return lambda&)>(applyImplementation(content(script), px)); } } diff --git a/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd b/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd index 95ffc4f743..24d5e224bc 100644 --- a/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd +++ b/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd @@ -34,7 +34,7 @@ - + diff --git a/sca-cpp/trunk/modules/scdl/scdl-test.cpp b/sca-cpp/trunk/modules/scdl/scdl-test.cpp index d6034d1e2f..e8ee77eb4e 100644 --- a/sca-cpp/trunk/modules/scdl/scdl-test.cpp +++ b/sca-cpp/trunk/modules/scdl/scdl-test.cpp @@ -48,7 +48,7 @@ bool testComponents() { assert(name(store) == string("Store")); const value impl = implementation(store); assert(uri(impl) == string("store.html")); - assert(implementationType(impl) == "t:implementation.widget"); + assert(implementationType(impl) == "t:implementation.scheme"); const value catalog = named(string("Catalog"), c); assert(name(catalog) == string("Catalog")); diff --git a/sca-cpp/trunk/modules/scdl/test.composite b/sca-cpp/trunk/modules/scdl/test.composite index b315f23f9a..92e8f64ca5 100644 --- a/sca-cpp/trunk/modules/scdl/test.composite +++ b/sca-cpp/trunk/modules/scdl/test.composite @@ -23,7 +23,7 @@ name="store"> - + @@ -39,7 +39,7 @@ - + USD @@ -48,20 +48,17 @@ - + - - - - + diff --git a/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd b/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd deleted file mode 100644 index bbf4935346..0000000000 --- a/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-scheme.xsd b/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-scheme.xsd new file mode 100644 index 0000000000..4c2a30a55a --- /dev/null +++ b/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-scheme.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/trunk/modules/server/domain-test.composite b/sca-cpp/trunk/modules/server/domain-test.composite index d5b0dae511..1635f1f6cf 100644 --- a/sca-cpp/trunk/modules/server/domain-test.composite +++ b/sca-cpp/trunk/modules/server/domain-test.composite @@ -23,21 +23,21 @@ name="domain-test"> - + - + - + diff --git a/sca-cpp/trunk/modules/server/impl-test.cpp b/sca-cpp/trunk/modules/server/impl-test.cpp index ad8953bf12..748e5f3837 100644 --- a/sca-cpp/trunk/modules/server/impl-test.cpp +++ b/sca-cpp/trunk/modules/server/impl-test.cpp @@ -58,7 +58,7 @@ const failable echo(const list& params) { extern "C" { -const tuscany::value eval(const tuscany::list& params) { +const tuscany::value apply(const tuscany::list& params) { const tuscany::value func(car(params)); if (func == "get") return tuscany::server::get(cdr(params)); diff --git a/sca-cpp/trunk/modules/server/mod-cpp.hpp b/sca-cpp/trunk/modules/server/mod-cpp.hpp index 416ccabf39..f10b91dc28 100644 --- a/sca-cpp/trunk/modules/server/mod-cpp.hpp +++ b/sca-cpp/trunk/modules/server/mod-cpp.hpp @@ -23,7 +23,7 @@ #define tuscany_modcpp_hpp /** - * Evaluation functions used by mod-eval to evaluate implementation.cpp + * Evaluation functions used by mod-eval to evaluate C++ * component implementations. */ @@ -32,6 +32,7 @@ #include "function.hpp" #include "list.hpp" +#include "element.hpp" #include "value.hpp" #include "monad.hpp" #include "dynlib.hpp" @@ -43,31 +44,35 @@ namespace server { namespace modcpp { /** - * Evaluate a C++ component implementation function. + * Apply a C++ component implementation function. */ -struct evalImplementation { +struct applyImplementation { const lib ilib; const lambda&)> impl; const list px; - evalImplementation(const lib& ilib, const lambda&)>& impl, const list& px) : ilib(ilib), impl(impl), px(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::evalImplementation::input"); + debug(params, "modeval::cpp::applyImplementation::input"); const value val = impl(append(params, px)); - debug(val, "modeval::cpp::evalImplementation::result"); + debug(val, "modeval::cpp::applyImplementation::result"); return val; } }; /** - * Read a C++ component implementation. + * Evaluate a C++ component implementation and convert it to + * an applicable lambda function. */ -const failable&)> > readImplementation(const string& path, const list& px) { - const lib ilib(*(new (gc_new()) lib(path + dynlibExt))); - const failable&)> > impl(dynlambda&)>("eval", ilib)); - if (!hasContent(impl)) - return impl; - return lambda&)>(evalImplementation(ilib, content(impl), px)); +const failable&)> > evalImplementation(const string& path, const value& impl, const list& px) { + const value ipath(attributeValue("path", impl)); + const value iname(attributeValue("library", impl)); + const string fpath(isNil(ipath)? path + iname : path + ipath + "/" + iname); + const lib ilib(*(new (gc_new()) lib(fpath + dynlibExt))); + const failable&)> > evalf(dynlambda&)>("apply", ilib)); + if (!hasContent(evalf)) + return evalf; + return lambda&)>(applyImplementation(ilib, content(evalf), px)); } } diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp index 936c68d70f..54ca171ec4 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.cpp +++ b/sca-cpp/trunk/modules/server/mod-eval.cpp @@ -37,14 +37,15 @@ namespace server { namespace modeval { /** - * Return a configured component implementation. - * For now only Scheme and C++ implementations are supported. + * Evaluate a Scheme or C++ component implementation and convert it to an + * applicable lambda function. */ -const failable&)> > readImplementation(const string& itype, const string& path, const list& px) { +const failable&)> > evalImplementation(const string& path, const value& impl, const list& px) { + const string itype(elementName(impl)); if (contains(itype, ".scheme")) - return modscheme::readImplementation(path, px); + return modscheme::evalImplementation(path, impl, px); if (contains(itype, ".cpp")) - return modcpp::readImplementation(path, px); + return modcpp::evalImplementation(path, impl, px); return mkfailure&)> >(string("Unsupported implementation type: ") + itype); } diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index 4f95977fea..f5c4266cc1 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -279,11 +279,10 @@ const list proxies(const list& refs, const string& base) { return cons(mkproxy(car(refs), base), proxies(cdr(refs), base)); } -extern const failable&)> > readImplementation(const string& itype, const string& path, const list& px); +extern const failable&)> > evalImplementation(const string& cpath, const value& impl, const list& px); const value confImplementation(DirConf& dc, ServerConf& sc, server_rec& server, const value& comp) { const value impl = scdl::implementation(comp); - const string path = dc.contributionPath + string(scdl::uri(impl)); // Convert component references to configured proxy lambdas ostringstream base; @@ -296,8 +295,9 @@ const value confImplementation(DirConf& dc, ServerConf& sc, server_rec& server, base << sc.wiringServerName << "/references/" << string(scdl::name(comp)) << "/"; const list px(proxies(scdl::references(comp), str(base))); - // Read and configure the implementation - const failable&)> > cimpl(readImplementation(elementName(impl), path, px)); + // Evaluate the component implementation and convert it to an + // applicable lambda function + const failable&)> > cimpl(evalImplementation(dc.contributionPath, impl, px)); if (!hasContent(cimpl)) return reason(cimpl); return content(cimpl); 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 primitiveProcedures(const list& l) { } /** - * Evaluate a scheme component implementation function. + * Apply a Scheme component implementation function. */ -struct evalImplementation { +struct applyImplementation { const value impl; const list px; - evalImplementation(const value& impl, const list& px) : impl(impl), px(scheme::quotedParameters(primitiveProcedures(px))) { + applyImplementation(const value& impl, const list& px) : impl(impl), px(scheme::quotedParameters(primitiveProcedures(px))) { } const value operator()(const list& params) const { const value expr = cons(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(), string("Could not evaluate expression")); return mklist(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&)> > readImplementation(const string& path, const list& px) { - ifstream is(path); +const failable&)> > evalImplementation(const string& path, const value& impl, const list& px) { + const string fpath(path + attributeValue("script", impl)); + ifstream is(fpath); if (fail(is)) - return mkfailure&)> >(string("Could not read implementation: ") + path); - const value impl = scheme::readScript(is); - if (isNil(impl)) - return mkfailure&)> >(string("Could not read implementation: ") + path); - return lambda&)>(evalImplementation(impl, px)); + return mkfailure&)> >(string("Could not read implementation: ") + fpath); + const value script = scheme::readScript(is); + if (isNil(script)) + return mkfailure&)> >(string("Could not read implementation: ") + fpath); + return lambda&)>(applyImplementation(script, px)); } } diff --git a/sca-cpp/trunk/test/store-python/currency.composite b/sca-cpp/trunk/test/store-python/currency.composite deleted file mode 100644 index 17066e9626..0000000000 --- a/sca-cpp/trunk/test/store-python/currency.composite +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - diff --git a/sca-cpp/trunk/test/store-python/store.composite b/sca-cpp/trunk/test/store-python/store.composite index 8ea2dec373..abf43433d5 100644 --- a/sca-cpp/trunk/test/store-python/store.composite +++ b/sca-cpp/trunk/test/store-python/store.composite @@ -23,8 +23,7 @@ name="store"> - - + @@ -34,7 +33,7 @@ - + USD @@ -43,7 +42,7 @@ - + @@ -54,14 +53,14 @@ - + - + diff --git a/sca-cpp/trunk/test/store-scheme/currency.composite b/sca-cpp/trunk/test/store-scheme/currency.composite deleted file mode 100644 index eaea331dbe..0000000000 --- a/sca-cpp/trunk/test/store-scheme/currency.composite +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - diff --git a/sca-cpp/trunk/test/store-scheme/store.composite b/sca-cpp/trunk/test/store-scheme/store.composite index cc00ae2d65..64ceaa2a24 100644 --- a/sca-cpp/trunk/test/store-scheme/store.composite +++ b/sca-cpp/trunk/test/store-scheme/store.composite @@ -23,8 +23,7 @@ name="store"> - - + @@ -34,7 +33,7 @@ - + USD @@ -43,7 +42,7 @@ - + @@ -54,14 +53,14 @@ - + - + -- cgit v1.2.3