diff options
Diffstat (limited to 'sca-cpp')
-rw-r--r-- | sca-cpp/trunk/components/cache/mcache.hpp | 16 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/Makefile.am | 2 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/Makefile.am (renamed from sca-cpp/trunk/modules/eval/Makefile.am) | 0 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/driver.hpp (renamed from sca-cpp/trunk/modules/eval/driver.hpp) | 14 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/environment.hpp (renamed from sca-cpp/trunk/modules/eval/environment.hpp) | 8 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/eval-shell.cpp (renamed from sca-cpp/trunk/modules/eval/eval-shell.cpp) | 2 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/eval-test.cpp (renamed from sca-cpp/trunk/modules/eval/eval-test.cpp) | 18 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/eval.hpp (renamed from sca-cpp/trunk/modules/eval/eval.hpp) | 16 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/io.hpp (renamed from sca-cpp/trunk/modules/eval/io.hpp) | 8 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/primitive.hpp (renamed from sca-cpp/trunk/modules/eval/primitive.hpp) | 23 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd (renamed from sca-cpp/trunk/modules/eval/tuscany-sca-1.1-implementation-eval.xsd) | 0 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/server/mod-cpp.hpp | 6 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/server/mod-eval.cpp | 6 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/server/mod-scheme.hpp (renamed from sca-cpp/trunk/modules/server/mod-scm.hpp) | 20 | ||||
-rw-r--r-- | sca-cpp/trunk/test/store-script/Makefile.am | 2 | ||||
-rw-r--r-- | sca-cpp/trunk/test/store-script/store-script-test.cpp | 18 |
16 files changed, 83 insertions, 76 deletions
diff --git a/sca-cpp/trunk/components/cache/mcache.hpp b/sca-cpp/trunk/components/cache/mcache.hpp index 3f32a47964..fac9c7dbb3 100644 --- a/sca-cpp/trunk/components/cache/mcache.hpp +++ b/sca-cpp/trunk/components/cache/mcache.hpp @@ -39,7 +39,7 @@ #include "value.hpp" #include "monad.hpp" #include "debug.hpp" -#include "../../modules/eval/eval.hpp" +#include "../../modules/scheme/eval.hpp" namespace tuscany { namespace cache { @@ -97,8 +97,8 @@ const failable<bool> post(const value& key, const value& val, const MemCached& c debug(key, "cache::post::key"); debug(val, "cache::post::value"); - const string ks(eval::writeValue(key)); - const string vs(eval::writeValue(val)); + const string ks(scheme::writeValue(key)); + const string vs(scheme::writeValue(val)); const apr_status_t rc = apr_memcache_add(cache.mc, c_str(ks), const_cast<char*>(c_str(vs)), length(vs), 0, 27); if (rc != APR_SUCCESS) return mkfailure<bool>("Could not add entry"); @@ -114,8 +114,8 @@ const failable<bool> put(const value& key, const value& val, const MemCached& ca debug(key, "cache::put::key"); debug(val, "cache::put::value"); - const string ks(eval::writeValue(key)); - const string vs(eval::writeValue(val)); + const string ks(scheme::writeValue(key)); + const string vs(scheme::writeValue(val)); const apr_status_t rc = apr_memcache_set(cache.mc, c_str(ks), const_cast<char*>(c_str(vs)), length(vs), 0, 27); if (rc != APR_SUCCESS) return mkfailure<bool>("Could not add entry"); @@ -130,7 +130,7 @@ const failable<bool> put(const value& key, const value& val, const MemCached& ca const failable<value> get(const value& key, const MemCached& cache) { debug(key, "cache::get::key"); - const string ks(eval::writeValue(key)); + const string ks(scheme::writeValue(key)); apr_pool_t* vpool; const apr_status_t pc = apr_pool_create(&vpool, cache.pool); if (pc != APR_SUCCESS) @@ -144,7 +144,7 @@ const failable<value> get(const value& key, const MemCached& cache) { return mkfailure<value>("Could not get entry"); } - const value val(eval::readValue(string(data, size))); + const value val(scheme::readValue(string(data, size))); apr_pool_destroy(vpool); debug(val, "cache::get::result"); @@ -157,7 +157,7 @@ const failable<value> get(const value& key, const MemCached& cache) { const failable<bool> del(const value& key, const MemCached& cache) { debug(key, "cache::delete::key"); - const string ks(eval::writeValue(key)); + const string ks(scheme::writeValue(key)); const apr_status_t rc = apr_memcache_delete(cache.mc, c_str(ks), 0); if (rc != APR_SUCCESS) return mkfailure<bool>("Could not delete entry"); diff --git a/sca-cpp/trunk/modules/Makefile.am b/sca-cpp/trunk/modules/Makefile.am index 3b2d60b93a..0c3b67347f 100644 --- a/sca-cpp/trunk/modules/Makefile.am +++ b/sca-cpp/trunk/modules/Makefile.am @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -SUBDIRS = atom eval json scdl http server +SUBDIRS = atom scheme json scdl http server includedir = $(prefix)/include/modules nobase_include_HEADERS = */*.hpp diff --git a/sca-cpp/trunk/modules/eval/Makefile.am b/sca-cpp/trunk/modules/scheme/Makefile.am index ecf2a6e332..ecf2a6e332 100644 --- a/sca-cpp/trunk/modules/eval/Makefile.am +++ b/sca-cpp/trunk/modules/scheme/Makefile.am diff --git a/sca-cpp/trunk/modules/eval/driver.hpp b/sca-cpp/trunk/modules/scheme/driver.hpp index 2d1badf501..629a561453 100644 --- a/sca-cpp/trunk/modules/eval/driver.hpp +++ b/sca-cpp/trunk/modules/scheme/driver.hpp @@ -19,8 +19,8 @@ /* $Rev$ $Date$ */ -#ifndef tuscany_eval_driver_hpp -#define tuscany_eval_driver_hpp +#ifndef tuscany_scheme_driver_hpp +#define tuscany_scheme_driver_hpp /** * Script evaluator main driver loop. @@ -31,7 +31,7 @@ #include "eval.hpp" namespace tuscany { -namespace eval { +namespace scheme { const string evalOutputPrompt("; "); const string evalInputPrompt("=> "); @@ -53,15 +53,15 @@ const bool userPrint(const value val, ostream& out) { return true; } -const value evalDriverLoop(istream& in, ostream& out, Env& globalEnv, const gc_pool& pool) { +const value evalDriverLoop(istream& in, ostream& out, Env& env, const gc_pool& pool) { promptForInput(evalInputPrompt, out); value input = readValue(in); if (isNil(input)) return input; - const value output = evalExpr(input, globalEnv, pool); + const value output = evalExpr(input, env, pool); announceOutput(evalOutputPrompt, out); userPrint(output, out); - return evalDriverLoop(in, out, globalEnv, pool); + return evalDriverLoop(in, out, env, pool); } const bool evalDriverRun(istream& in, ostream& out, const gc_pool& pool) { @@ -73,4 +73,4 @@ const bool evalDriverRun(istream& in, ostream& out, const gc_pool& pool) { } } -#endif /* tuscany_eval_driver_hpp */ +#endif /* tuscany_scheme_driver_hpp */ diff --git a/sca-cpp/trunk/modules/eval/environment.hpp b/sca-cpp/trunk/modules/scheme/environment.hpp index 29bb3b64da..aa4517115d 100644 --- a/sca-cpp/trunk/modules/eval/environment.hpp +++ b/sca-cpp/trunk/modules/scheme/environment.hpp @@ -19,8 +19,8 @@ /* $Rev$ $Date$ */ -#ifndef tuscany_eval_environment_hpp -#define tuscany_eval_environment_hpp +#ifndef tuscany_scheme_environment_hpp +#define tuscany_scheme_environment_hpp /** * Script evaluator environment implementation. @@ -33,7 +33,7 @@ #include <string> namespace tuscany { -namespace eval { +namespace scheme { typedef value Frame; typedef list<value> Env; @@ -176,4 +176,4 @@ const value lookupVariableValue(const value& var, const Env& env) { } } -#endif /* tuscany_eval_environment_hpp */ +#endif /* tuscany_scheme_environment_hpp */ diff --git a/sca-cpp/trunk/modules/eval/eval-shell.cpp b/sca-cpp/trunk/modules/scheme/eval-shell.cpp index f73ac61250..58c0dd14bc 100644 --- a/sca-cpp/trunk/modules/eval/eval-shell.cpp +++ b/sca-cpp/trunk/modules/scheme/eval-shell.cpp @@ -31,6 +31,6 @@ int main() { tuscany::gc_scoped_pool pool; - tuscany::eval::evalDriverRun(tuscany::cin, tuscany::cout, pool); + tuscany::scheme::evalDriverRun(tuscany::cin, tuscany::cout, pool); return 0; } diff --git a/sca-cpp/trunk/modules/eval/eval-test.cpp b/sca-cpp/trunk/modules/scheme/eval-test.cpp index 3cf16f602f..cd90dc8863 100644 --- a/sca-cpp/trunk/modules/eval/eval-test.cpp +++ b/sca-cpp/trunk/modules/scheme/eval-test.cpp @@ -29,7 +29,7 @@ #include "driver.hpp" namespace tuscany { -namespace eval { +namespace scheme { bool testEnv() { gc_scoped_pool pool; @@ -217,14 +217,14 @@ bool testEvalGC() { int main() { tuscany::cout << "Testing..." << tuscany::endl; - tuscany::eval::testEnv(); - tuscany::eval::testEnvGC(); - tuscany::eval::testRead(); - tuscany::eval::testWrite(); - tuscany::eval::testEval(); - tuscany::eval::testEvalExpr(); - tuscany::eval::testEvalLambda(); - tuscany::eval::testEvalGC(); + tuscany::scheme::testEnv(); + tuscany::scheme::testEnvGC(); + tuscany::scheme::testRead(); + tuscany::scheme::testWrite(); + tuscany::scheme::testEval(); + tuscany::scheme::testEvalExpr(); + tuscany::scheme::testEvalLambda(); + tuscany::scheme::testEvalGC(); tuscany::cout << "OK" << tuscany::endl; return 0; diff --git a/sca-cpp/trunk/modules/eval/eval.hpp b/sca-cpp/trunk/modules/scheme/eval.hpp index ea6e2da13a..05293a53d3 100644 --- a/sca-cpp/trunk/modules/eval/eval.hpp +++ b/sca-cpp/trunk/modules/scheme/eval.hpp @@ -19,8 +19,8 @@ /* $Rev$ $Date$ */ -#ifndef tuscany_eval_eval_hpp -#define tuscany_eval_eval_hpp +#ifndef tuscany_scheme_eval_hpp +#define tuscany_scheme_eval_hpp /** * Core script evaluation logic. @@ -34,7 +34,7 @@ #include "environment.hpp" namespace tuscany { -namespace eval { +namespace scheme { const value evalExpr(const value& exp, Env& env, const gc_pool& pool); @@ -267,11 +267,11 @@ const list<value> quotedParameters(const list<value>& p) { /** * Evaluate an expression against a script provided as a list of values. */ -const value evalScriptLoop(const value& expr, const list<value>& script, eval::Env& globalEnv, const gc_pool& pool) { +const value evalScriptLoop(const value& expr, const list<value>& script, scheme::Env& env, const gc_pool& pool) { if (isNil(script)) - return eval::evalExpr(expr, globalEnv, pool); - eval::evalExpr(car(script), globalEnv, pool); - return evalScriptLoop(expr, cdr(script), globalEnv, pool); + return scheme::evalExpr(expr, env, pool); + scheme::evalExpr(car(script), env, pool); + return evalScriptLoop(expr, cdr(script), env, pool); } const value evalScript(const value& expr, const value& script, Env& env, const gc_pool& pool) { @@ -287,4 +287,4 @@ const value evalScript(const value& expr, istream& is, Env& env, const gc_pool& } } -#endif /* tuscany_eval_eval_hpp */ +#endif /* tuscany_scheme_eval_hpp */ diff --git a/sca-cpp/trunk/modules/eval/io.hpp b/sca-cpp/trunk/modules/scheme/io.hpp index 0c2abb3af9..5e5397cfeb 100644 --- a/sca-cpp/trunk/modules/eval/io.hpp +++ b/sca-cpp/trunk/modules/scheme/io.hpp @@ -19,8 +19,8 @@ /* $Rev$ $Date$ */ -#ifndef tuscany_eval_io_hpp -#define tuscany_eval_io_hpp +#ifndef tuscany_scheme_io_hpp +#define tuscany_scheme_io_hpp /** * Script evaluator IO functions. @@ -35,7 +35,7 @@ #include "primitive.hpp" namespace tuscany { -namespace eval { +namespace scheme { const value rightParenthesis(mklist<value>(")")); const value leftParenthesis(mklist<value>("(")); @@ -214,4 +214,4 @@ const value readScript(istream& in) { } } -#endif /* tuscany_eval_io_hpp */ +#endif /* tuscany_scheme_io_hpp */ diff --git a/sca-cpp/trunk/modules/eval/primitive.hpp b/sca-cpp/trunk/modules/scheme/primitive.hpp index 75d691c4ac..95db5dd7a2 100644 --- a/sca-cpp/trunk/modules/eval/primitive.hpp +++ b/sca-cpp/trunk/modules/scheme/primitive.hpp @@ -19,8 +19,8 @@ /* $Rev$ $Date$ */ -#ifndef tuscany_eval_primitive_hpp -#define tuscany_eval_primitive_hpp +#ifndef tuscany_scheme_primitive_hpp +#define tuscany_scheme_primitive_hpp /** * Script evaluator primitive functions. @@ -34,14 +34,21 @@ #include "value.hpp" namespace tuscany { -namespace eval { +namespace scheme { const value primitiveSymbol("primitive"); const value quoteSymbol("'"); const value lambdaSymbol("lambda"); -ostream* displayOutStream = &cout; -ostream* logOutStream = &cerr; +#ifdef _REENTRANT +__thread +#endif +ostream* displayOutStream = NULL; + +#ifdef _REENTRANT +__thread +#endif +ostream* logOutStream = NULL; const bool setupDisplay(ostream& out) { displayOutStream = &out; @@ -49,6 +56,8 @@ const bool setupDisplay(ostream& out) { } ostream& displayStream() { + if (displayOutStream == NULL) + return cout; return *displayOutStream; } @@ -58,6 +67,8 @@ const bool setupLog(ostream& out) { } ostream& logStream() { + if (logOutStream == NULL) + return cerr; return *logOutStream; } @@ -261,4 +272,4 @@ const value makeLambda(const list<value>& parameters, const list<value>& body) { } } -#endif /* tuscany_eval_primitive_hpp */ +#endif /* tuscany_scheme_primitive_hpp */ diff --git a/sca-cpp/trunk/modules/eval/tuscany-sca-1.1-implementation-eval.xsd b/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd index bbf4935346..bbf4935346 100644 --- a/sca-cpp/trunk/modules/eval/tuscany-sca-1.1-implementation-eval.xsd +++ b/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd diff --git a/sca-cpp/trunk/modules/server/mod-cpp.hpp b/sca-cpp/trunk/modules/server/mod-cpp.hpp index 17d44e1428..93abd84590 100644 --- a/sca-cpp/trunk/modules/server/mod-cpp.hpp +++ b/sca-cpp/trunk/modules/server/mod-cpp.hpp @@ -36,13 +36,12 @@ #include "debug.hpp" #include "monad.hpp" #include "dynlib.hpp" -#include "../eval/driver.hpp" +#include "../scheme/driver.hpp" #include "../http/httpd.hpp" namespace tuscany { namespace server { -namespace modeval { -namespace cpp { +namespace modcpp { /** * Evaluate a C++ component implementation function. @@ -75,6 +74,5 @@ const failable<lambda<value(const list<value>&)> > readImplementation(const stri } } } -} #endif /* tuscany_modcpp_hpp */ diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp index 8e8870dd52..c5e71e108c 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.cpp +++ b/sca-cpp/trunk/modules/server/mod-eval.cpp @@ -36,7 +36,7 @@ #include "../scdl/scdl.hpp" #include "../http/curl.hpp" #include "../http/httpd.hpp" -#include "mod-scm.hpp" +#include "mod-scheme.hpp" #include "mod-cpp.hpp" extern "C" { @@ -275,9 +275,9 @@ const list<value> proxies(const list<value>& refs, const string& base) { */ const failable<lambda<value(const list<value>&)> > readImplementation(const string& itype, const string& path, const list<value>& px) { if (contains(itype, ".scheme")) - return scm::readImplementation(path, px); + return modscheme::readImplementation(path, px); if (contains(itype, ".cpp")) - return cpp::readImplementation(path, px); + return modcpp::readImplementation(path, px); return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype); } diff --git a/sca-cpp/trunk/modules/server/mod-scm.hpp b/sca-cpp/trunk/modules/server/mod-scheme.hpp index 887b1de968..13b4ac5760 100644 --- a/sca-cpp/trunk/modules/server/mod-scm.hpp +++ b/sca-cpp/trunk/modules/server/mod-scheme.hpp @@ -34,14 +34,13 @@ #include "value.hpp" #include "debug.hpp" #include "monad.hpp" -#include "../eval/primitive.hpp" -#include "../eval/driver.hpp" +#include "../scheme/primitive.hpp" +#include "../scheme/driver.hpp" #include "../http/httpd.hpp" namespace tuscany { namespace server { -namespace modeval { -namespace scm { +namespace modscheme { /** * Convert proxy lambdas to evaluator primitive procedures. @@ -49,7 +48,7 @@ namespace scm { const list<value> primitiveProcedures(const list<value>& l) { if (isNil(l)) return l; - return cons<value>(mklist<value>(eval::primitiveSymbol, car(l)), primitiveProcedures(cdr(l))); + return cons<value>(mklist<value>(scheme::primitiveSymbol, car(l)), primitiveProcedures(cdr(l))); } /** @@ -58,14 +57,14 @@ const list<value> primitiveProcedures(const list<value>& l) { struct evalImplementation { const value impl; const list<value> px; - evalImplementation(const value& impl, const list<value>& px) : impl(impl), px(eval::quotedParameters(primitiveProcedures(px))) { + evalImplementation(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(eval::quotedParameters(cdr(params)), px)); + const value expr = cons<value>(car(params), append(scheme::quotedParameters(cdr(params)), px)); debug(expr, "modeval::scm::evalImplementation::input"); gc_pool pool(gc_current_pool()); - eval::Env globalEnv = eval::setupEnvironment(pool); - const value val = eval::evalScript(expr, impl, globalEnv, pool); + scheme::Env globalEnv = scheme::setupEnvironment(pool); + const value val = scheme::evalScript(expr, impl, globalEnv, pool); debug(val, "modeval::scm::evalImplementation::result"); if (isNil(val)) return mklist<value>(value(), string("Could not evaluate expression")); @@ -80,7 +79,7 @@ const failable<lambda<value(const list<value>&)> > readImplementation(const stri ifstream is(path); if (fail(is)) return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + path); - const value impl = eval::readScript(is); + 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)); @@ -89,6 +88,5 @@ const failable<lambda<value(const list<value>&)> > readImplementation(const stri } } } -} #endif /* tuscany_modscm_hpp */ diff --git a/sca-cpp/trunk/test/store-script/Makefile.am b/sca-cpp/trunk/test/store-script/Makefile.am index 7e8413ba91..fc6a1f88fb 100644 --- a/sca-cpp/trunk/test/store-script/Makefile.am +++ b/sca-cpp/trunk/test/store-script/Makefile.am @@ -17,7 +17,7 @@ noinst_PROGRAMS = store-script-test -INCLUDES = -I. -I$(top_builddir)/kernel -I$(top_builddir)/modules/eval -I${LIBXML2_INCLUDE} -I${APR_INCLUDE} -I${JS_INCLUDE} +INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE} -I${JS_INCLUDE} store_script_test_SOURCES = store-script-test.cpp store_script_test_LDADD = -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -L${JS_LIB} -lmozjs diff --git a/sca-cpp/trunk/test/store-script/store-script-test.cpp b/sca-cpp/trunk/test/store-script/store-script-test.cpp index a85b661b43..05aefcaf8c 100644 --- a/sca-cpp/trunk/test/store-script/store-script-test.cpp +++ b/sca-cpp/trunk/test/store-script/store-script-test.cpp @@ -28,9 +28,9 @@ #include "stream.hpp" #include "string.hpp" #include "list.hpp" -#include "driver.hpp" #include "xml.hpp" -#include "../json/json.hpp" +#include "../../modules/scheme/driver.hpp" +#include "../../modules/json/json.hpp" namespace store { @@ -41,7 +41,7 @@ bool testScript() { ifstream is("store-script.scm"); ostringstream os; - eval::evalDriverRun(is, os, pool); + scheme::evalDriverRun(is, os, pool); assert(contains(str(os), "(\"Sample Feed\" \"")); assert(contains(str(os), "\" (\"Item\" \"")); assert(contains(str(os), "\" ((javaClass \"services.Item\") (name \"Orange\") (currencyCode \"USD\") (currencySymbol \"$\") (price 3.55))) (\"Item\" \"")); @@ -54,10 +54,10 @@ bool testEval() { gc_scoped_pool pool; ifstream is("store-script.scm"); ostringstream os; - eval::setupDisplay(os); - eval::Env globalEnv = eval::setupEnvironment(pool); + scheme::setupDisplay(os); + scheme::Env globalEnv = scheme::setupEnvironment(pool); const value exp(mklist<value>("storeui_service", string("getcatalog"))); - const value val = eval::evalScript(exp, is, globalEnv, pool); + const value val = scheme::evalScript(exp, is, globalEnv, pool); ostringstream vs; vs << val; @@ -68,11 +68,11 @@ bool testEval() { gc_scoped_pool pool; ifstream is("store-script.scm"); ostringstream os; - eval::setupDisplay(os); + scheme::setupDisplay(os); - eval::Env globalEnv = eval::setupEnvironment(pool); + scheme::Env globalEnv = scheme::setupEnvironment(pool); const value exp(mklist<value>("storeui_service", string("gettotal"))); - const value res = eval::evalScript(exp, is, globalEnv, pool); + const value res = scheme::evalScript(exp, is, globalEnv, pool); ostringstream rs; rs << res; |