tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1419985 [4/5] - in /tuscany/sca-cpp/trunk: ./ etc/ kernel/ modules/ modules/atom/ modules/rss/ modules/scdl/ modules/scheme/ modules/xml/
Date Tue, 11 Dec 2012 03:51:12 GMT
Modified: tuscany/sca-cpp/trunk/modules/scdl/scdl-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scdl/scdl-test.cpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scdl/scdl-test.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scdl/scdl-test.cpp Tue Dec 11 03:51:03 2012
@@ -33,15 +33,15 @@
 namespace tuscany {
 namespace scdl {
 
-bool testComposite() {
+const bool testComposite() {
     ifstream is("test.composite");
-    const list<value> c = readXML(streamList(is));
+    const list<value> c = content(xml::readElements(streamList(is)));
     return true;
 }
 
-bool testComponents() {
+const bool testComponents() {
     ifstream is("test.composite");
-    const list<value> c = components(readXML(streamList(is)));
+    const list<value> c = components(content(xml::readElements(streamList(is))));
     assert(length(c) == 4);
 
     const value store = car(c);
@@ -58,9 +58,9 @@ bool testComponents() {
     return true;
 }
 
-bool testServices() {
+const bool testServices() {
     ifstream is("test.composite");
-    const list<value> c = components(readXML(streamList(is)));
+    const list<value> c = components(content(xml::readElements(streamList(is))));
     const value store = car(c);
 
     assert(length(services(store)) == 1);
@@ -74,9 +74,9 @@ bool testServices() {
     return true;
 }
 
-bool testReferences() {
+const bool testReferences() {
     ifstream is("test.composite");
-    const list<value> c = components(readXML(streamList(is)));
+    const list<value> c = components(content(xml::readElements(streamList(is))));
     const value store = car(c);
 
     assert(length(references(store)) == 3);
@@ -86,7 +86,7 @@ bool testReferences() {
 
     assert(length(bindings(catalog)) == 1);
     const value binding = car(bindings(catalog));
-    assert(uri(binding) == value());
+    assert(uri(binding) == nilValue);
     assert(bindingType(binding) == "binding.jsonrpc");
 
     const list<value> t = mkbtree(sort(referenceToTargetAssoc(references(store))));
@@ -94,9 +94,9 @@ bool testReferences() {
     return true;
 }
 
-bool testProperties() {
+const bool testProperties() {
     ifstream is("test.composite");
-    const list<value> c = components(readXML(streamList(is)));
+    const list<value> c = components(content(xml::readElements(streamList(is))));
     const value catalog = named(string("Catalog"), c);
 
     assert(length(properties(catalog)) == 1);
@@ -110,7 +110,7 @@ bool testProperties() {
 }
 
 int main() {
-    tuscany::gc_scoped_pool p;
+    const tuscany::gc_scoped_pool p;
     tuscany::cout << "Testing..." << tuscany::endl;
 
     tuscany::scdl::testComposite();

Modified: tuscany/sca-cpp/trunk/modules/scdl/scdl.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scdl/scdl.hpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scdl/scdl.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scdl/scdl.hpp Tue Dec 11 03:51:03 2012
@@ -30,7 +30,7 @@
 #include "list.hpp"
 #include "value.hpp"
 #include "monad.hpp"
-#include "xml.hpp"
+#include "../modules/xml/xml.hpp"
 
 namespace tuscany {
 namespace scdl {
@@ -82,33 +82,26 @@ const list<value> nameToElementAssoc(con
 /**
  * Returns the scdl declaration with the given name.
  */
-struct filterName {
-    const value n;
-    filterName(const value& n) : n(n) {
-    }
-    const bool operator()(const value& v) const {
+const value named(const value& n, const value& l) {
+    const vblambda filterName = [n](const value& v) -> const bool {
         return name(v) == n;
-    }
-};
-
-const value named(const value& name, const value& l) {
-    const list<value> c = filter<value>(filterName(name), l);
+    };
+    const list<value> c = filter<value>(filterName, l);
     if (isNil(c))
-        return value();
+        return nilValue;
     return car(c);
 }
 
 /**
  * Returns the implementation of a component.
  */
-const bool filterImplementation(const value& v) {
-    return isElement(v) && contains(string(cadr<value>(v)), "implementation.");
-}
-
 const value implementation(const value& l) {
+    const vblambda filterImplementation = [](const value& v) -> const bool {
+        return isElement(v) && contains(string(cadr<value>(v)), "implementation.");
+    };
     const list<value> n = filter<value>(filterImplementation, l);
     if (isNil(n))
-        return value();
+        return nilValue;
     return car(n);
 }
 
@@ -156,7 +149,7 @@ const list<value> bindings(const value& 
  */
 const value bindingsTarget(const list<value>& l) {
     if (isNil(l))
-        return value();
+        return nilValue;
     const value u = uri(car(l));
     if (!isNil(u))
         return u;

Modified: tuscany/sca-cpp/trunk/modules/scheme/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/Makefile.am?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/Makefile.am Tue Dec 11 03:51:03 2012
@@ -30,18 +30,18 @@ value_element_LDFLAGS = 
 element_value_SOURCES = element-value.cpp
 element_value_LDFLAGS = 
 
-xml_value_SOURCES = xml-value.cpp
-xml_value_LDFLAGS = -lxml2
+xml_element_SOURCES = xml-element.cpp
+xml_element_LDFLAGS = -lxml2
 
-value_xml_SOURCES = value-xml.cpp
-value_xml_LDFLAGS = -lxml2
+element_xml_SOURCES = element-xml.cpp
+element_xml_LDFLAGS = -lxml2
 
 json_value_SOURCES = json-value.cpp
-json_value_LDFLAGS = -lmozjs 
+json_value_LDFLAGS = -ljansson 
 
 value_json_SOURCES = value-json.cpp
-value_json_LDFLAGS = -lmozjs 
+value_json_LDFLAGS = -ljansson 
 
 noinst_PROGRAMS = scheme-test
-mod_PROGRAMS = scheme-shell element-value value-element xml-value value-xml json-value value-json
+mod_PROGRAMS = scheme-shell element-value value-element xml-element element-xml json-value value-json
 TESTS = scheme-test

Modified: tuscany/sca-cpp/trunk/modules/scheme/driver.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/driver.hpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/driver.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/driver.hpp Tue Dec 11 03:51:03 2012
@@ -55,7 +55,7 @@ const bool userPrint(const value val, os
 
 const value evalDriverLoop(istream& in, ostream& out, Env& env) {
     promptForInput(evalInputPrompt, out);
-    value input = readValue(in);
+    const value input = content(readValue(in));
     if (isNil(input))
         return input;
     const value output = evalExpr(input, env);

Modified: tuscany/sca-cpp/trunk/modules/scheme/element-value.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/element-value.cpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/element-value.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/element-value.cpp Tue Dec 11 03:51:03 2012
@@ -31,9 +31,9 @@
 namespace tuscany {
 namespace scheme {
 
-int elementValue() {
-    const value v = elementsToValues(readValue(cin));
-    cout << writeValue(v);
+const int elementValue() {
+    const value v = elementsToValues(content(readValue(cin)));
+    write(content(writeValue(v)), cout);
     return 0;
 }
 

Copied: tuscany/sca-cpp/trunk/modules/scheme/element-xml.cpp (from r1361918, tuscany/sca-cpp/trunk/modules/scheme/value-xml.cpp)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/element-xml.cpp?p2=tuscany/sca-cpp/trunk/modules/scheme/element-xml.cpp&p1=tuscany/sca-cpp/trunk/modules/scheme/value-xml.cpp&r1=1361918&r2=1419985&rev=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/value-xml.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/element-xml.cpp Tue Dec 11 03:51:03 2012
@@ -25,15 +25,15 @@
 
 #include "fstream.hpp"
 #include "string.hpp"
-#include "xml.hpp"
 #include "element.hpp"
+#include "../xml/xml.hpp"
 #include "eval.hpp"
 
 namespace tuscany {
 namespace scheme {
 
-int valueXML() {
-    failable<list<string> > s = writeXML(readValue(cin));
+const int valueXML() {
+    const failable<list<string> > s = xml::writeElements(content(readValue(cin)));
     if (!hasContent(s)) {
         cerr << reason(s) << " : " << rcode(s);
         return 1;

Modified: tuscany/sca-cpp/trunk/modules/scheme/environment.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/environment.hpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/environment.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/environment.hpp Tue Dec 11 03:51:03 2012
@@ -45,7 +45,7 @@ const value setSymbol("set!");
 const value dotSymbol(".");
 
 const Env theEmptyEnvironment() {
-    return list<value>();
+    return nilListValue;
 }
 
 const bool isDefinition(const value& exp) {
@@ -68,11 +68,11 @@ const gc_ptr<Frame> firstFrame(const Env
     return car(env);
 }
 
-list<value> frameVariables(const Frame& frame) {
+const list<value> frameVariables(const Frame& frame) {
     return car((list<value> )frame);
 }
 
-list<value> frameValues(const Frame& frame) {
+const list<value> frameValues(const Frame& frame) {
     return cdr((list<value> )frame);
 }
 
@@ -103,8 +103,7 @@ const Frame makeBinding(const Frame& fra
 }
 
 const gc_ptr<Frame> makeFrame(const list<value>& variables, const list<value> values) {
-    gc_ptr<Frame> frame = new (gc_new<Frame>()) Frame();
-    *frame = value(makeBinding(cons(value(list<value>()), list<value>()), variables, values));
+    const gc_ptr<Frame> frame = new (gc_new<Frame>()) Frame(makeBinding(cons(value(nilListValue), nilListValue), variables, values));
     return frame;
 }
 
@@ -120,7 +119,7 @@ const value definitionValue(const value&
     const list<value> exps(exp);
     if(isSymbol(car(cdr(exps)))) {
         if (isNil(cdr(cdr(exps))))
-            return value();
+            return nilValue;
         return car(cdr(cdr(exps)));
     }
     const list<value> lexps(car(cdr(exps)));
@@ -140,7 +139,8 @@ const Frame addBindingToFrame(const valu
 }
 
 const bool defineVariable(const value& var, const value& val, Env& env) {
-    *firstFrame(env) = addBindingToFrame(var, val, *firstFrame(env));
+    const Frame newFrame = addBindingToFrame(var, val, *firstFrame(env));
+    setvalue(*firstFrame(env), addBindingToFrame(var, val, *firstFrame(env)));
     return true;
 }
 
@@ -168,7 +168,7 @@ const value lookupEnvScan(const value& v
 const value lookupEnvLoop(const value& var, const Env& env) {
     if(env == theEmptyEnvironment()) {
         logStream() << "Unbound variable " << var << endl;
-        return value();
+        return nilValue;
     }
     return lookupEnvScan(var, frameVariables(*firstFrame(env)), frameValues(*firstFrame(env)), env);
 }

Modified: tuscany/sca-cpp/trunk/modules/scheme/eval.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/eval.hpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/eval.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/eval.hpp Tue Dec 11 03:51:03 2012
@@ -147,7 +147,7 @@ const value applyProcedure(const value& 
         return evalSequence(procedureBody(procedure), env);
     }
     logStream() << "Unknown procedure type " << procedure << endl;
-    return value();
+    return nilValue;
 }
 
 const value sequenceToExp(const list<value> exps) {
@@ -209,16 +209,16 @@ const value expandClauses(const list<val
         if(isNil(rest))
             return sequenceToExp(condActions(first));
         logStream() << "else clause isn't last " << clauses << endl;
-        return value();
+        return nilValue;
     }
     return makeIf(condPredicate(first), sequenceToExp(condActions(first)), expandClauses(rest));
 }
 
-value condToIf(const value& exp) {
+const value condToIf(const value& exp) {
     return expandClauses(condClauses(exp));
 }
 
-value evalIf(const value& exp, Env& env) {
+const value evalIf(const value& exp, Env& env) {
     if(isTrue(evalExpr(ifPredicate(exp), env)))
         return evalExpr(ifConsequent(exp), env);
     return evalExpr(ifAlternative(exp), env);
@@ -255,7 +255,7 @@ const value evalExpr(const value& exp, E
         return applyProcedure(evalExpr(operat(exp), env), operandValues);
     }
     logStream() << "Unknown expression type " << exp << endl;
-    return value();
+    return nilValue;
 }
 
 const list<value> quotedParameters(const list<value>& p) {

Modified: tuscany/sca-cpp/trunk/modules/scheme/io.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/io.hpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/io.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/io.hpp Tue Dec 11 03:51:03 2012
@@ -37,39 +37,38 @@
 namespace tuscany {
 namespace scheme {
 
-const value rightParenthesis(mklist<value>(")"));
-const value leftParenthesis(mklist<value>("("));
-const value comment(mklist<value>(";"));
+const value rightParenthesis(")");
+const value leftParenthesis("(");
 
-const double stringToNumber(const string& str) {
+inline const double stringToNumber(const string& str) {
     return atof(c_str(str));
 }
 
-const bool isWhitespace(const char ch) {
+inline const bool isWhitespace(const char ch) {
     return ch != -1 && isspace(ch);
 }
 
-const bool isIdentifierStart(const char ch) {
+inline const bool isIdentifierStart(const char ch) {
     return ch != -1 && !isspace(ch) && !isdigit(ch);
 }
 
-const bool isIdentifierPart(const char ch) {
+inline const bool isIdentifierPart(const char ch) {
     return ch != -1 && !isspace(ch) && ch != '(' && ch != ')';
 }
 
-const bool isDigit(const char ch) {
+inline const bool isDigit(const char ch) {
     return isdigit(ch) || ch == '.';
 }
 
-const bool isLeftParenthesis(const value& token) {
+inline const bool isLeftParenthesis(const value& token) {
     return leftParenthesis == token;
 }
 
-const bool isRightParenthesis(const value& token) {
+inline const bool isRightParenthesis(const value& token) {
     return rightParenthesis == token;
 }
 
-const char readChar(istream& in) {
+inline const char readChar(istream& in) {
     if(in.eof()) {
         return -1;
     }
@@ -77,14 +76,14 @@ const char readChar(istream& in) {
     return c;
 }
 
-const char peekChar(istream& in) {
+inline const char peekChar(istream& in) {
     if(eof(in))
         return -1;
     char c = (char)peek(in);
     return c;
 }
 
-const bool isQuote(const value& token) {
+inline const bool isQuote(const value& token) {
     return token == quoteSymbol;
 }
 
@@ -93,9 +92,9 @@ const value readQuoted(istream& in);
 const value readIdentifier(const char chr, istream& in);
 const value readString(istream& in);
 const value readNumber(const char chr, istream& in);
-const value readValue(istream& in);
+const failable<value> readValue(istream& in);
 
-const failable<value> readToken(istream& in) {
+inline const failable<value> readToken(istream& in) {
     const char firstChar = readChar(in);
     if(isWhitespace(firstChar))
         return readToken(in);
@@ -119,18 +118,19 @@ const failable<value> readToken(istream&
     return readToken(in);
 }
 
-const failable<value> skipComment(istream& in) {
-    const char nextChar = readChar(in);
-    if (nextChar == '\n')
-        return readToken(in);
-    return skipComment(in);
+inline const failable<value> skipComment(istream& in) {
+    while(true) {
+        const char nextChar = readChar(in);
+        if (nextChar == '\n')
+            return readToken(in);
+    }
 }
 
-const value readQuoted(istream& in) {
-    return mklist(quoteSymbol, readValue(in));
+inline const value readQuoted(istream& in) {
+    return mklist(quoteSymbol, content(readValue(in)));
 }
 
-const list<value> readList(const list<value>& listSoFar, istream& in) {
+inline const list<value> readList(const list<value>& listSoFar, istream& in) {
     const failable<value> ftoken = readToken(in);
     if (!hasContent(ftoken))
         return reverse(listSoFar);
@@ -142,95 +142,97 @@ const list<value> readList(const list<va
     return readList(cons(token, listSoFar), in);
 }
 
-const string listToString(const list<char>& l) {
-    if(isNil(l))
-        return "";
-    const char buf[1] = { car(l) };
-    return string(buf, 1) + listToString(cdr(l));
-}
-
-const list<char> readIdentifierHelper(const list<char>& listSoFar, istream& in) {
-    const char nextChar = peekChar(in);
-    if(isIdentifierPart(nextChar))
-        return readIdentifierHelper(cons(readChar(in), listSoFar), in);
-    return reverse(listSoFar);
+inline const string readIdentifierHelper(const char chr, istream& in) {
+    ostringstream buf;
+    buf << chr;
+    while(true) {
+        const char nextChar = peekChar(in);
+        if(!isIdentifierPart(nextChar))
+            return str(buf);
+        buf << readChar(in);
+    }
 }
 
-const value readIdentifier(const char chr, istream& in) {
-    const value val = c_str(listToString(readIdentifierHelper(mklist(chr), in)));
+inline const value readIdentifier(const char chr, istream& in) {
+    const value val = c_str(readIdentifierHelper(chr, in));
     if (val == "false")
         return value((bool)false);
     if (val == "true")
         return value((bool)true);
     if (val == "nil")
-        return value();
+        return nilValue;
     return val;
 }
 
-const list<char> readStringHelper(const list<char>& listSoFar, istream& in) {
-    const char nextChar = readChar(in);
-    if(nextChar == -1 || nextChar == '"')
-        return reverse(listSoFar);
-    if (nextChar == '\\') {
-        const char escapedChar = readChar(in);
-        if (escapedChar == -1)
-            return reverse(listSoFar);
-        return readStringHelper(cons(escapedChar, listSoFar), in);
+inline const value readString(istream& in) {
+    ostringstream buf;
+    while(true) {
+        const char nextChar = readChar(in);
+        if(nextChar == -1 || nextChar == '"')
+            return (value)str(buf);
+        if (nextChar == '\\') {
+            const char escapedChar = readChar(in);
+            if (escapedChar == -1)
+                return (value)str(buf);
+            buf << escapedChar;
+        }
+        buf << nextChar;
     }
-    return readStringHelper(cons(nextChar, listSoFar), in);
-}
-
-const value readString(istream& in) {
-    return listToString(readStringHelper(list<char>(), in));
 }
 
-const list<char> readNumberHelper(const list<char>& listSoFar, istream& in) {
-    const char nextChar = peekChar(in);
-    if(isDigit(nextChar))
-        return readNumberHelper(cons(readChar(in), listSoFar), in);
-    return reverse(listSoFar);
-}
-
-const value readNumber(const char chr, istream& in) {
-    return stringToNumber(listToString(readNumberHelper(mklist(chr), in)));
+inline const value readNumber(const char chr, istream& in) {
+    ostringstream buf;
+    buf << chr;
+    while(true) {
+        const char nextChar = peekChar(in);
+        if(!isDigit(nextChar))
+            return stringToNumber(str(buf));
+        buf << readChar(in);
+    }
 }
 
-const value readValue(istream& in) {
+inline const failable<value> readValue(istream& in) {
     const failable<value> fnextToken = readToken(in);
     if (!hasContent(fnextToken))
-        return value();
+        return nilValue;
     const value nextToken = content(fnextToken);
     if(isLeftParenthesis(nextToken))
-        return readList(list<value>(), in);
+        return (value)readList(nilListValue, in);
     return nextToken;
 }
 
-const value readValue(const string s) {
+inline const failable<value> readValue(const string& s) {
     istringstream in(s);
     const failable<value> fnextToken = readToken(in);
     if (!hasContent(fnextToken))
-        return value();
+        return nilValue;
     const value nextToken = content(fnextToken);
     if(isLeftParenthesis(nextToken))
-        return readList(list<value>(), in);
+        return (value)readList(nilListValue, in);
     return nextToken;
 }
 
-const bool writeValue(const value& val, ostream& out) {
+inline const failable<value> readValue(const list<string>& l) {
+    ostringstream os;
+    write(l, os);
+    return readValue(str(os));
+}
+
+inline const failable<ostream&> writeValue(const value& val, ostream& out) {
     out << val;
-    return true;
+    return out;
 }
 
-const string writeValue(const value& val) {
+inline const failable<list<string> > writeValue(const value& val) {
     ostringstream out;
     out << val;
-    return str(out);
+    return mklist<string>(str(out));
 }
 
-const value readScript(istream& in) {
-    const value val = readValue(in);
+inline const value readScript(istream& in) {
+    const value val = content(readValue(in));
     if (isNil(val))
-        return list<value>();
+        return nilListValue;
     return cons(val, (list<value>)readScript(in));
 }
 

Modified: tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp Tue Dec 11 03:51:03 2012
@@ -40,7 +40,7 @@ const value quoteSymbol("'");
 const value lambdaSymbol("lambda");
 
 #ifdef WANT_THREADS
-perthread_ptr<ostream> displayOutStream;
+const perthread_ptr<ostream> displayOutStream;
 #else
 ostream* displayOutStream = NULL;
 #endif
@@ -51,49 +51,49 @@ perthread_ptr<ostream> logOutStream;
 ostream* logOutStream = NULL;
 #endif
 
-const bool setupDisplay(ostream& out) {
+inline const bool setupDisplay(ostream& out) {
     displayOutStream = &out;
     return true;
 }
 
-ostream& displayStream() {
+inline ostream& displayStream() {
     if (displayOutStream == NULL)
         return cout;
     return *displayOutStream;
 }
 
-const bool setupLog(ostream& out) {
+inline const bool setupLog(ostream& out) {
     logOutStream = &out;
     return true;
 }
 
-ostream& logStream() {
+inline ostream& logStream() {
     if (logOutStream == NULL)
         return cerr;
     return *logOutStream;
 }
 
-const value carProc(const list<value>& args) {
+inline const value carProc(const list<value>& args) {
     return car((list<value> )car(args));
 }
 
-const value cdrProc(const list<value>& args) {
+inline const value cdrProc(const list<value>& args) {
     return cdr((list<value> )car(args));
 }
 
-const value consProc(const list<value>& args) {
+inline const value consProc(const list<value>& args) {
     return cons(car(args), (list<value> )cadr(args));
 }
 
-const value listProc(const list<value>& args) {
+inline const value listProc(const list<value>& args) {
     return args;
 }
 
-const value assocProc(const list<value>& args) {
+inline const value assocProc(const list<value>& args) {
     return assoc(car(args), (list<list<value> >)cadr(args));
 }
 
-const value nulProc(const list<value>& args) {
+inline const value nulProc(const list<value>& args) {
     const value v(car(args));
     if (isNil(v))
         return true;
@@ -102,31 +102,31 @@ const value nulProc(const list<value>& a
     return false;
 }
 
-const value equalProc(const list<value>& args) {
+inline const value equalProc(const list<value>& args) {
     return (bool)(car(args) == cadr(args));
 }
 
-const value addProc(const list<value>& args) {
+inline const value addProc(const list<value>& args) {
     if (isNil(cdr(args)))
         return (double)car(args);
     return (double)car(args) + (double)cadr(args);
 }
 
-const value subProc(const list<value>& args) {
+inline const value subProc(const list<value>& args) {
     if (isNil(cdr(args)))
         return (double)0 - (double)car(args);
     return (double)car(args) - (double)cadr(args);
 }
 
-const value mulProc(const list<value>& args) {
+inline const value mulProc(const list<value>& args) {
     return (double)car(args) * (double)cadr(args);
 }
 
-const value divProc(const list<value>& args) {
+inline const value divProc(const list<value>& args) {
     return (double)car(args) / (double)cadr(args);
 }
 
-const value displayProc(const list<value>& args) {
+inline const value displayProc(const list<value>& args) {
     if (isNil(args)) {
         displayStream() << endl;
         return true;
@@ -135,7 +135,7 @@ const value displayProc(const list<value
     return displayProc(cdr(args));
 }
 
-const value logProc(const list<value>& args) {
+inline const value logProc(const list<value>& args) {
     if (isNil(args)) {
         logStream() << endl;
         return true;
@@ -144,52 +144,52 @@ const value logProc(const list<value>& a
     return logProc(cdr(args));
 }
 
-const value uuidProc(unused const list<value>& args) {
+inline const value uuidProc(unused const list<value>& args) {
     return mkuuid();
 }
 
-const value cadrProc(const list<value>& args) {
+inline const value cadrProc(const list<value>& args) {
     return cadr((list<value> )car(args));
 }
 
-const value caddrProc(const list<value>& args) {
+inline const value caddrProc(const list<value>& args) {
     return caddr((list<value> )car(args));
 }
 
-const value cadddrProc(const list<value>& args) {
+inline const value cadddrProc(const list<value>& args) {
     return cadddr((list<value> )car(args));
 }
 
-const value cddrProc(const list<value>& args) {
+inline const value cddrProc(const list<value>& args) {
     return cddr((list<value> )car(args));
 }
 
-const value cdddrProc(const list<value>& args) {
+inline const value cdddrProc(const list<value>& args) {
     return cdddr((list<value> )car(args));
 }
 
-const value appendProc(const list<value>& args) {
+inline const value appendProc(const list<value>& args) {
     return append((list<value> )car(args), (list<value>)cadr(args));
 }
 
-const value startProc(unused const list<value>& args) {
-    return lambda<value(const list<value>&)>();
+inline const value startProc(unused const list<value>& args) {
+    return lvvlambda();
 }
 
-const value stopProc(unused const list<value>& args) {
-    return lambda<value(const list<value>&)>();
+inline const value stopProc(unused const list<value>& args) {
+    return lvvlambda();
 }
 
-const value applyPrimitiveProcedure(const value& proc, list<value>& args) {
-    const lambda<value(const list<value>&)> func(cadr((list<value>)proc));
+inline const value applyPrimitiveProcedure(const value& proc, list<value>& args) {
+    const lvvlambda func(cadr((list<value>)proc));
     return func(args);
 }
 
-const bool isPrimitiveProcedure(const value& proc) {
+inline const bool isPrimitiveProcedure(const value& proc) {
     return isTaggedList(proc, primitiveSymbol);
 }
 
-const bool isSelfEvaluating(const value& exp) {
+inline const bool isSelfEvaluating(const value& exp) {
     if(isNil(exp))
         return true;
     if(isNumber(exp))
@@ -203,15 +203,15 @@ const bool isSelfEvaluating(const value&
     return false;
 }
 
-const value primitiveImplementation(const list<value>& proc) {
+inline const value primitiveImplementation(const list<value>& proc) {
     return car(cdr(proc));
 }
 
-template<typename F> const value primitiveProcedure(const F& f) {
-    return mklist<value>(primitiveSymbol, (lambda<value(const list<value>&)>)f);
+template<typename F> inline const value primitiveProcedure(const F& f) {
+    return mklist<value>(primitiveSymbol, (lvvlambda)f);
 }
 
-const list<value> primitiveProcedureNames() {
+inline const list<value> primitiveProcedureNames() {
     return mklist<value>("car")
     + "cdr"
     + "cons"
@@ -237,7 +237,7 @@ const list<value> primitiveProcedureName
     + "stop";
 }
 
-const list<value> primitiveProcedureObjects() {
+inline const list<value> primitiveProcedureObjects() {
     return mklist(primitiveProcedure(carProc))
     + primitiveProcedure(cdrProc)
     + primitiveProcedure(consProc)
@@ -263,23 +263,23 @@ const list<value> primitiveProcedureObje
     + primitiveProcedure(stopProc);
 }
 
-const bool isFalse(const value& exp) {
+inline const bool isFalse(const value& exp) {
     return (bool)exp == false;
 }
 
-const bool isTrue(const value& exp) {
+inline const bool isTrue(const value& exp) {
     return (bool)exp == true;
 }
 
-const bool isQuoted(const value& exp) {
+inline const bool isQuoted(const value& exp) {
     return isTaggedList(exp, quoteSymbol);
 }
 
-const value textOfQuotation(const value& exp) {
+inline const value textOfQuotation(const value& exp) {
     return car(cdr((list<value> )exp));
 }
 
-const value makeLambda(const list<value>& parameters, const list<value>& body) {
+inline const value makeLambda(const list<value>& parameters, const list<value>& body) {
     return cons(lambdaSymbol, cons<value>(parameters, body));
 }
 

Modified: tuscany/sca-cpp/trunk/modules/scheme/scheme-shell.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/scheme-shell.cpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/scheme-shell.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/scheme-shell.cpp Tue Dec 11 03:51:03 2012
@@ -30,7 +30,7 @@
 #include "driver.hpp"
 
 int main() {
-    tuscany::gc_scoped_pool pool;
+    const tuscany::gc_scoped_pool pool;
     tuscany::scheme::evalDriverRun(tuscany::cin, tuscany::cout);
     return 0;
 }

Modified: tuscany/sca-cpp/trunk/modules/scheme/scheme-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/scheme-test.cpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/scheme-test.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/scheme-test.cpp Tue Dec 11 03:51:03 2012
@@ -26,14 +26,16 @@
 #include <assert.h>
 #include "stream.hpp"
 #include "string.hpp"
+#include "perf.hpp"
 #include "driver.hpp"
+#include "scheme-test.hpp"
 
 namespace tuscany {
 namespace scheme {
 
-bool testEnv() {
-    gc_scoped_pool pool;
-    Env globalEnv = list<value>();
+const bool testEnv() {
+    const gc_scoped_pool pool;
+    Env globalEnv = nilListValue;
     Env env = extendEnvironment(mklist<value>("a"), mklist<value>(1), globalEnv);
     defineVariable("x", env, env);
     assert(lookupVariableValue(value("x"), env) == env);
@@ -41,7 +43,7 @@ bool testEnv() {
     return true;
 }
 
-bool testEnvGC() {
+const bool testEnvGC() {
     resetLambdaCounters();
     resetListCounters();
     resetValueCounters();
@@ -52,49 +54,49 @@ bool testEnvGC() {
     return true;
 }
 
-bool testRead() {
+const bool testRead() {
     istringstream is("abcd");
-    assert(readValue(is) == "abcd");
+    assert(content(readValue(is)) == "abcd");
 
     istringstream is2("123");
-    assert(readValue(is2) == value(123));
+    assert(content(readValue(is2)) == value(123));
 
     istringstream is3("(abcd)");
-    assert(readValue(is3) == mklist(value("abcd")));
+    assert(content(readValue(is3)) == mklist(value("abcd")));
 
     istringstream is4("(abcd xyz)");
-    assert(readValue(is4) == mklist<value>("abcd", "xyz"));
+    assert(content(readValue(is4)) == mklist<value>("abcd", "xyz"));
 
     istringstream is5("(abcd (xyz tuv))");
-    assert(readValue(is5) == mklist<value>("abcd", mklist<value>("xyz", "tuv")));
+    assert(content(readValue(is5)) == mklist<value>("abcd", mklist<value>("xyz", "tuv")));
 
     return true;
 }
 
-bool testWrite() {
+const bool testWrite() {
     {
-        const list<value> i = list<value>()
-                + (list<value>() + "item" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"
-                    + (list<value>() + "item"
-                        + (list<value>() + "name" + "Apple")
-                        + (list<value>() + "price" + "$2.99")))
-                + (list<value>() + "item" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c"
-                    + (list<value>() + "item"
-                        + (list<value>() + "name" + "Orange")
-                        + (list<value>() + "price" + "$3.55")));
+        const list<value> i = nilListValue
+                + (nilListValue + "item" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"
+                    + (nilListValue + "item"
+                        + (nilListValue + "name" + "Apple")
+                        + (nilListValue + "price" + "$2.99")))
+                + (nilListValue + "item" + "cart-53d67a61-aa5e-4e5e-8401-39edeba8b83c"
+                    + (nilListValue + "item"
+                        + (nilListValue + "name" + "Orange")
+                        + (nilListValue + "price" + "$3.55")));
         const list<value> a = cons<value>("Feed", cons<value>("feed-1234", i));
         ostringstream os;
         writeValue(a, os);
         istringstream is(str(os));
-        assert(readValue(is) == a);
+        assert(content(readValue(is)) == a);
     }
     {
-        const list<value> i = mklist<value>("x", value());
+        const list<value> i = mklist<value>("x", nilValue);
         const list<value> a = mklist<value>(i);
         ostringstream os;
         writeValue(a, os);
         istringstream is(str(os));
-        assert(readValue(is) == a);
+        assert(content(readValue(is)) == a);
     }
     return true;
 }
@@ -147,8 +149,8 @@ const string evalOutput(const string& sc
     return str(os);
 }
 
-bool testEval() {
-    gc_scoped_pool pool;
+const bool testEval() {
+    const gc_scoped_pool pool;
     assert(contains(evalOutput(testSchemeNumber), "testNumber ok"));
     assert(contains(evalOutput(testSchemeString), "testString ok"));
     assert(contains(evalOutput(testSchemeDefinition), "testDefinition ok"));
@@ -161,8 +163,8 @@ bool testEval() {
     return true;
 }
 
-bool testEvalExpr() {
-    gc_scoped_pool pool;
+const bool testEvalExpr() {
+    const gc_scoped_pool pool;
     const value exp = mklist<value>("+", 2, 3);
     Env env = setupEnvironment();
     const value r = evalExpr(exp, env);
@@ -170,8 +172,8 @@ bool testEvalExpr() {
     return true;
 }
 
-bool testEvalRun() {
-    gc_scoped_pool pool;
+const bool testEvalRun() {
+    const gc_scoped_pool pool;
     evalDriverRun(cin, cout);
     return true;
 }
@@ -188,8 +190,8 @@ const string testReturnLambda(
 const string testCallLambda(
   "(define (testCallLambda l x y) (l x y))");
 
-bool testEvalLambda() {
-    gc_scoped_pool pool;
+const bool testEvalLambda() {
+    const gc_scoped_pool pool;
     Env env = setupEnvironment();
 
     const value trl = mklist<value>("testReturnLambda");
@@ -208,7 +210,18 @@ bool testEvalLambda() {
     return true;
 }
 
-bool testEvalGC() {
+const bool testEvalScript() {
+    const gc_scoped_pool pool;
+    Env env = setupEnvironment();
+    ifstream is("test.scm");
+    const value script = readScript(is);
+    const value expr = mklist<value>("echo", string("x"));
+    const value res = evalScript(expr, script, env);
+    assert(res == string("x"));
+    return true;
+}
+
+const bool testEvalGC() {
     resetLambdaCounters();
     resetListCounters();
     resetValueCounters();
@@ -221,11 +234,55 @@ bool testEvalGC() {
     return true;
 }
 
+const string testCustomer = "((customer (@name \"jdoe\") (account (id \"1234\") (@balance 1000)) (address (@city \"san francisco\") (@state \"ca\"))))";
+
+const bool testReadWrite() {
+    const gc_scoped_pool pool;
+
+    istringstream is(testCustomer);
+    const value r = content(readValue(is));
+
+    ostringstream os;
+    writeValue(r, os);
+    //assert(str(os) == testCustomer);
+    return true;
+}
+
+const bool testReadWritePerf() {
+    const gc_scoped_pool pool;
+
+    const blambda rwl = blambda(testReadWrite);
+    cout << "Scheme read + write test " << time(rwl, 5, 200) << " ms" << endl;
+
+    return true;
+}
+
+const bool testReadWriteBigDoc() {
+    const gc_scoped_pool pool;
+
+    istringstream is(testBigDoc);
+    const value r = content(readValue(is));
+
+    ostringstream os;
+    writeValue(r, os);
+    //assert(str(os) == testBigDoc);
+    return true;
+}
+
+const bool testReadWriteBigDocPerf() {
+    const gc_scoped_pool pool;
+
+    const blambda rwl = blambda(testReadWriteBigDoc);
+    cout << "Scheme big doc read + write test " << time(rwl, 5, 200) << " ms" << endl;
+
+    return true;
+}
+
 }
 }
 
 int main() {
-    tuscany::gc_scoped_pool p;
+    const tuscany::gc_scoped_pool p;
     tuscany::cout << "Testing..." << tuscany::endl;
 
     tuscany::scheme::testEnv();
@@ -235,7 +292,10 @@ int main() {
     tuscany::scheme::testEval();
     tuscany::scheme::testEvalExpr();
     tuscany::scheme::testEvalLambda();
+    tuscany::scheme::testEvalScript();
     tuscany::scheme::testEvalGC();
+    tuscany::scheme::testReadWritePerf();
+    tuscany::scheme::testReadWriteBigDocPerf();
 
     tuscany::cout << "OK" << tuscany::endl;
     return 0;

Added: tuscany/sca-cpp/trunk/modules/scheme/scheme-test.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/scheme-test.hpp?rev=1419985&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/scheme-test.hpp (added)
+++ tuscany/sca-cpp/trunk/modules/scheme/scheme-test.hpp Tue Dec 11 03:51:03 2012
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * Test Scheme doc.
+ */
+
+namespace tuscany {
+namespace scheme {
+
+const string testBigDoc = "((feed (title \"Search Results\") (id \"search\") (entry (title \"An empty app template\") (id \"new\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"An empty test app\") (id \"test\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Check my public social data\") (id \"me360\") (author \"admin@example.com\") (updated \"Apr 28, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"nearme\") (id \"nearme\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"nearme2\") (id \"nearme2\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Our photos of an event\") (id \"ourphotos\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (
 stats (description \"Sample app\")))) (entry (title \"My online store\") (id \"shoppingcart\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Slice\") (id \"slice\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test animation components\") (id \"testanimation\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test database components\") (id \"testdb\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test event components\") (id \"testevents\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test HTTP components\") (id \"testhttp\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (de
 scription \"Sample app\")))) (entry (title \"Test logic components\") (id \"testlogic\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test search components\") (id \"testsearch\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test HTTP components\") (id \"testhttp\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test social components\") (id \"testsocial\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test text processing components\") (id \"testtext\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test URL components\") (id \"testurl\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (cont
 ent (stats (description \"Sample app\")))) (entry (title \"Test values and lists\") (id \"testvalues\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test widgets\") (id \"testwidgets\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test more widgets\") (id \"testwidgets2\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test HTML generator components\") (id \"testwidgets3\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"jsdtest\") (id \"jsdtest\") (author \"jsdelfino\") (updated \"Jul 27, 2012\") (content (stats (description \"Test app\")))) (entry (title \"SMS send service\") (id \"twsms\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description
  \"Sample app\")))) (entry (title \"boao\") (id \"boao\") (author \"jsdelfino\") (updated \"2012-10-12T12:06:59+00:00\") (content (stats (description \"Sample app\")))) (entry (title \"An empty test app\") (id \"test\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"An empty app template\") (id \"new\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"nearme\") (id \"nearme\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"nearme2\") (id \"nearme2\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Our photos of an event\") (id \"ourphotos\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"My online store\") (id
  \"shoppingcart\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Slice\") (id \"slice\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test animation components\") (id \"testanimation\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test database components\") (id \"testdb\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test event components\") (id \"testevents\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test social components\") (id \"testsocial\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test HTTP components\") (id
  \"testhttp\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test logic components\") (id \"testlogic\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test search components\") (id \"testsearch\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test HTTP components\") (id \"testhttp\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test text processing components\") (id \"testtext\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test URL components\") (id \"testurl\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test values and l
 ists\") (id \"testvalues\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test widgets\") (id \"testwidgets\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test more widgets\") (id \"testwidgets2\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Test HTML generator components\") (id \"testwidgets3\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"test9\") (id \"test9\") (author \"jsdelfino\") (updated \"2012-09-25T06:17:18+00:00\") (content (stats (description \"Sample app\")))) (entry (title \"SMS send service\") (id \"twsms\") (author \"admin@example.com\") (updated \"Jan 01, 2012\") (content (stats (description \"Sample app\")))) (entry (title \"Check my public social data\"
 ) (id \"me360\") (author \"admin@example.com\") (updated \"Apr 28, 2012\") (content (stats (description \"Sample app\"))))))";
+
+
+}
+}
+

Added: tuscany/sca-cpp/trunk/modules/scheme/test.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/test.scm?rev=1419985&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/test.scm (added)
+++ tuscany/sca-cpp/trunk/modules/scheme/test.scm Tue Dec 11 03:51:03 2012
@@ -0,0 +1,44 @@
+;  Licensed to the Apache Software Foundation (ASF) under one
+;  or more contributor license agreements.  See the NOTICE file
+;  distributed with this work for additional information
+;  regarding copyright ownership.  The ASF licenses this file
+;  to you under the Apache License, Version 2.0 (the
+;  "License"); you may not use this file except in compliance
+;  with the License.  You may obtain a copy of the License at
+;  
+;    http://www.apache.org/licenses/LICENSE-2.0
+;    
+;  Unless required by applicable law or agreed to in writing,
+;  software distributed under the License is distributed on an
+;  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+;  KIND, either express or implied.  See the License for the
+;  specific language governing permissions and limitations
+;  under the License.
+
+; JSON-RPC test case
+
+(define (echo x) x)
+
+; ATOMPub test case
+
+(define (get id)
+  (if (nul id)
+    '((feed (title "Sample Feed") (id "123456789") (entry
+       (((title "Item") (id "111") (content (item (name "Apple") (currencyCode "USD") (currencySymbol "$") (price 2.99))))
+        ((title "Item") (id "222") (content (item (name "Orange") (currencyCode "USD") (currencySymbol "$") (price 3.55))))
+        ((title "Item") (id "333") (content (item (name "Pear") (currencyCode "USD") (currencySymbol "$") (price 1.55))))))))
+    
+    (list (list 'entry '(title "Item") (list 'id (car id)) '(content (item (name "Apple") (currencyCode "USD") (currencySymbol "$") (price 2.99))))))
+)
+
+(define (post collection item)
+  '("123456789")
+)
+
+(define (put id item)
+  true
+)
+
+(define (delete id)
+  true
+)

Modified: tuscany/sca-cpp/trunk/modules/scheme/value-element.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/value-element.cpp?rev=1419985&r1=1419984&r2=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/value-element.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/value-element.cpp Tue Dec 11 03:51:03 2012
@@ -31,9 +31,9 @@
 namespace tuscany {
 namespace scheme {
 
-int valueElement() {
-    const value v = valuesToElements(readValue(cin));
-    cout << writeValue(v);
+const int valueElement() {
+    const value v = valuesToElements(content(readValue(cin)));
+    write(content(writeValue(v)), cout);
     return 0;
 }
 

Copied: tuscany/sca-cpp/trunk/modules/scheme/xml-element.cpp (from r1361918, tuscany/sca-cpp/trunk/modules/scheme/xml-value.cpp)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/xml-element.cpp?p2=tuscany/sca-cpp/trunk/modules/scheme/xml-element.cpp&p1=tuscany/sca-cpp/trunk/modules/scheme/xml-value.cpp&r1=1361918&r2=1419985&rev=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/xml-value.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/xml-element.cpp Tue Dec 11 03:51:03 2012
@@ -25,16 +25,16 @@
 
 #include "fstream.hpp"
 #include "string.hpp"
-#include "xml.hpp"
 #include "element.hpp"
+#include "../xml/xml.hpp"
 #include "eval.hpp"
 
 namespace tuscany {
 namespace scheme {
 
-int xmlValue() {
-    const value v = readXML(streamList(cin));
-    cout << writeValue(v);
+const int xmlValue() {
+    const value v = content(xml::readElements(streamList(cin)));
+    write(content(writeValue(v)), cout);
     return 0;
 }
 

Copied: tuscany/sca-cpp/trunk/modules/xml/Makefile.am (from r1361918, tuscany/sca-cpp/trunk/modules/Makefile.am)
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/xml/Makefile.am?p2=tuscany/sca-cpp/trunk/modules/xml/Makefile.am&p1=tuscany/sca-cpp/trunk/modules/Makefile.am&r1=1361918&r2=1419985&rev=1419985&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/modules/xml/Makefile.am Tue Dec 11 03:51:03 2012
@@ -15,5 +15,15 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-SUBDIRS = scheme atom rss js json scdl http server python opencl java openid oauth wsgi
+incl_HEADERS = *.hpp
+incldir = $(prefix)/include/modules/xml
+
+xml_test_SOURCES = xml-test.cpp
+xml_test_LDFLAGS = -lxml2
+
+xsd_test_SOURCES = xsd-test.cpp
+xsd_test_LDFLAGS = -lxml2
+
+noinst_PROGRAMS = xml-test xsd-test
+TESTS = xml-test
 

Added: tuscany/sca-cpp/trunk/modules/xml/test.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/xml/test.xml?rev=1419985&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/xml/test.xml (added)
+++ tuscany/sca-cpp/trunk/modules/xml/test.xml Tue Dec 11 03:51:03 2012
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feed><title>Search Results</title><id>search</id><entry><title>An empty app template</title><id>new</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>An empty test app</title><id>test</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Check my public social data</title><id>me360</id><author>admin@example.com</author><updated>Apr 28, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme</title><id>nearme</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme2</title><id>nearme2</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app<
 /description></stats></content></entry><entry><title>Our photos of an event</title><id>ourphotos</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>My online store</title><id>shoppingcart</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Slice</title><id>slice</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test animation components</title><id>testanimation</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test database components</title><id>testdb</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><d
 escription>Sample app</description></stats></content></entry><entry><title>Test event components</title><id>testevents</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTTP components</title><id>testhttp</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test logic components</title><id>testlogic</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test search components</title><id>testsearch</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTTP components</title><id>testhttp</id><author>admin@example.com</author><updated>Jan 0
 1, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test social components</title><id>testsocial</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test text processing components</title><id>testtext</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test URL components</title><id>testurl</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test values and lists</title><id>testvalues</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test widgets</title><id>testwidgets</id><author>adm
 in@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test more widgets</title><id>testwidgets2</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTML generator components</title><id>testwidgets3</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>jsdtest</title><id>jsdtest</id><author>jsdelfino</author><updated>Jul 27, 2012</updated><content><stats><description>Test app</description></stats></content></entry><entry><title>SMS send service</title><id>twsms</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>boao</title><id>boao</id><author>jsdelfino</au
 thor><updated>2012-10-12T12:06:59+00:00</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>An empty test app</title><id>test</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>An empty app template</title><id>new</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme</title><id>nearme</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme2</title><id>nearme2</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Our photos of an event</title><id>ourphotos</id><author>admin@example.com</a
 uthor><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>My online store</title><id>shoppingcart</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Slice</title><id>slice</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test animation components</title><id>testanimation</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test database components</title><id>testdb</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test event components</title><id>testevents</id><autho
 r>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test social components</title><id>testsocial</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTTP components</title><id>testhttp</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test logic components</title><id>testlogic</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test search components</title><id>testsearch</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTTP compo
 nents</title><id>testhttp</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test text processing components</title><id>testtext</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test URL components</title><id>testurl</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test values and lists</title><id>testvalues</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test widgets</title><id>testwidgets</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></en
 try><entry><title>Test more widgets</title><id>testwidgets2</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTML generator components</title><id>testwidgets3</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>test9</title><id>test9</id><author>jsdelfino</author><updated>2012-09-25T06:17:18+00:00</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>SMS send service</title><id>twsms</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Check my public social data</title><id>me360</id><author>admin@example.com</author><updated>Apr 28, 2012</updated><content><stats><description>Sample app</descripti
 on></stats></content></entry></feed>

Added: tuscany/sca-cpp/trunk/modules/xml/xml-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/xml/xml-test.cpp?rev=1419985&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/xml/xml-test.cpp (added)
+++ tuscany/sca-cpp/trunk/modules/xml/xml-test.cpp Tue Dec 11 03:51:03 2012
@@ -0,0 +1,373 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * Test XML handling functions.
+ */
+
+#include <assert.h>
+#include "stream.hpp"
+#include "string.hpp"
+#include "list.hpp"
+#include "value.hpp"
+#include "element.hpp"
+#include "perf.hpp"
+#include "xml.hpp"
+#include "xml-test.hpp"
+
+namespace tuscany {
+namespace xml {
+
+const string currencyXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://services\" name=\"currency\">"
+ "<component name=\"CurrencyConverterWebService\">"
+  "<implementation.java class=\"services.CurrencyConverterImpl\"/>"
+  "<service name=\"CurrencyConverter\">"
+   "<binding.ws/>"
+  "</service>"
+ "</component>"
+ "<component name=\"CurrencyConverterWebService2\">"
+  "<implementation.java class=\"services.CurrencyConverterImpl2\"/>"
+  "<service name=\"CurrencyConverter2\">"
+    "<binding.atom/>"
+  "</service>"
+  "<property name=\"currency\">US</property>"
+ "</component>"
+"</composite>\n";
+
+const string customerXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<customer>"
+ "<name>jdoe</name>"
+ "<address>"
+  "<city>san francisco</city>"
+  "<state>ca</state>"
+ "</address>"
+ "<account>"
+  "<id>1234</id>"
+  "<balance>1000</balance>"
+ "</account>"
+ "<account>"
+  "<id>6789</id>"
+  "<balance>2000</balance>"
+ "</account>"
+ "<account>"
+  "<id>4567</id>"
+  "<balance>3000</balance>"
+ "</account>"
+"</customer>\n";
+
+const string abcXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<a>"
+ "<m>abc</m>"
+ "<m>def</m>"
+ "<m>xyz</m>"
+ "<m>tuv</m>"
+"</a>\n";
+
+const string xyzXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<a>"
+ "<m>"
+  "<id>123</id>"
+  "<name>abc</name>"
+ "</m>"
+ "<m>"
+  "<id>234</id>"
+  "<name>def</name>"
+ "</m>"
+ "<m>"
+  "<id>345</id>"
+  "<name>xyz</name>"
+ "</m>"
+ "<m>"
+  "<id>456</id>"
+  "<name>tuv</name>"
+ "</m>"
+"</a>\n";
+
+const string boolXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<x>true</x>\n";
+
+const string numberXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<x>123.4</x>\n";
+
+const bool isName(const value& token) {
+    return isTaggedList(token, attribute) && attributeName(token) == "name";
+}
+
+const bool testReadXML() {
+    {
+        istringstream is(customerXML);
+        const list<value> c = content(readElements(streamList(is)));
+    }
+    {
+        istringstream is(currencyXML);
+        const list<value> c = content(readElements(streamList(is)));
+
+        const value composite = car(c);
+        assert(isTaggedList(composite, element));
+        assert(elementName(composite) == "composite");
+        assert(attributeValue(car(filter<value>(isName, elementChildren(composite)))) == string("currency"));
+    }
+    {
+        istringstream is(boolXML);
+        const list<value> c = content(readElements(streamList(is)));
+        assert(caddr<value>(car(c)) == value(true));
+    }
+    {
+        istringstream is(numberXML);
+        const list<value> c = content(readElements(streamList(is)));
+        assert(caddr<value>(car(c)) == value(123.4));
+    }
+    return true;
+}
+
+ostream* xmlWriter(const string& s, ostream* os) {
+    (*os) << s;
+    return os;
+}
+
+const bool testWriteXML() {
+    {
+        istringstream is(customerXML);
+        const list<value> c = content(readElements(streamList(is)));
+        ostringstream os;
+        writeElements<ostream*>(xmlWriter, &os, c);
+        assert(str(os) == customerXML);
+    }
+    {
+        istringstream is(currencyXML);
+        const list<value> c = content(readElements(streamList(is)));
+        ostringstream os;
+        writeElements<ostream*>(xmlWriter, &os, c);
+        assert(str(os) == currencyXML);
+    }
+    return true;
+}
+
+const bool testElements() {
+    {
+        const list<value> ad = mklist<value>(mklist<value>("city", string("san francisco")), mklist<value>("state", string("ca")));
+        const list<value> ac1 = mklist<value>(mklist<value>("id", string("1234")), mklist<value>("balance", 1000));
+        const list<value> ac2 = mklist<value>(mklist<value>("id", string("6789")), mklist<value>("balance", 2000));
+        const list<value> ac3 = mklist<value>(mklist<value>("id", string("4567")), mklist<value>("balance", 3000));
+        {
+            const list<value> c = mklist<value>(mklist<value>("customer", mklist<value>("name", string("jdoe")), cons<value>("address", ad), mklist<value>("account", mklist<value>(ac1, ac2, ac3))));
+            const list<value> e = valuesToElements(c);
+            const list<value> v = elementsToValues(e);
+            assert(v == c);
+
+            ostringstream os;
+            writeElements<ostream*>(xmlWriter, &os, e);
+            assert(str(os) == customerXML);
+        }
+        {
+            const list<value> c = mklist<value>(mklist<value>("customer", mklist<value>("name", string("jdoe")), cons<value>("address", ad), cons<value>("account", ac1), cons<value>("account", ac2), cons<value>("account", ac3)));
+            const list<value> e = valuesToElements(c);
+            const list<value> v = elementsToValues(e);
+
+            ostringstream os;
+            writeElements<ostream*>(xmlWriter, &os, e);
+            assert(str(os) == customerXML);
+        }
+    }
+    {
+        istringstream is(abcXML);
+        const list<value> c = content(readElements(streamList(is)));
+        const list<value> v = elementsToValues(c);
+        const list<value> e = valuesToElements(v);
+        ostringstream os;
+        writeElements<ostream*>(xmlWriter, &os, e);
+        assert(str(os) == abcXML);
+    }
+    {
+        istringstream is(xyzXML);
+        const list<value> c = content(readElements(streamList(is)));
+        const list<value> v = elementsToValues(c);
+        const list<value> e = valuesToElements(v);
+        ostringstream os;
+        writeElements<ostream*>(xmlWriter, &os, e);
+        assert(str(os) == xyzXML);
+    }
+    {
+        istringstream is(customerXML);
+        const list<value> c = content(readElements(streamList(is)));
+        const list<value> v = elementsToValues(c);
+        const list<value> e = valuesToElements(v);
+        ostringstream os;
+        writeElements<ostream*>(xmlWriter, &os, e);
+        assert(str(os) == customerXML);
+    }
+    return true;
+}
+
+const bool testValues() {
+    {
+        const list<value> l = mklist<value>(nilListValue + "ns1:echoString" + (nilListValue + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo")) + (nilListValue + "text" + string("Hello World!")));
+        const list<value> e = valuesToElements(l);
+        const failable<list<string> > lx = writeElements(e);
+        ostringstream os;
+        write(content(lx), os);
+        istringstream is(str(os));
+        const list<value> x = content(readElements(streamList(is)));
+        const list<value> v = elementsToValues(x);
+        assert(v == l);
+    }
+    return true;
+}
+
+const bool testReadWrite() {
+    const gc_scoped_pool pool;
+
+    istringstream is(customerXML);
+    const list<string> il = streamList(is);
+    const list<value> r = elementsToValues(content(readElements(il)));
+
+    ostringstream os;
+    writeElements<ostream*>(xmlWriter, &os, valuesToElements(r));
+    //assert(str(os) == customerXML);
+    return true;
+}
+
+const bool testReadWritePerf() {
+    const gc_scoped_pool pool;
+
+    const blambda rwl = blambda(testReadWrite);
+    cout << "XML read + write test " << time(rwl, 5, 200) << " ms" << endl;
+
+    return true;
+}
+
+const bool testReadWriteBigDoc() {
+    const gc_scoped_pool pool;
+
+    istringstream is(testBigDoc);
+    const list<string> il = streamList(is);
+    const list<value> r = elementsToValues(content(readElements(il)));
+
+    ostringstream os;
+    writeElements<ostream*>(xmlWriter, &os, valuesToElements(r));
+    //assert(str(os) == testBigDoc);
+    return true;
+}
+
+const bool testReadWriteBigDocPerf() {
+    const gc_scoped_pool pool;
+
+    const blambda rwl = blambda(testReadWriteBigDoc);
+    cout << "XML big doc read + write test " << time(rwl, 5, 200) << " ms" << endl;
+
+    return true;
+}
+
+const string customersXML =
+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+"<customers>"
+ "<customer>"
+  "<name>jane doe</name>"
+  "<address>"
+   "<city>san francisco</city>"
+   "<state>ca</state>"
+  "</address>"
+  "<account>"
+   "<id>1234</id>"
+   "<balance>1000</balance>"
+  "</account>"
+  "<account>"
+   "<id>6789</id>"
+   "<balance>4000</balance>"
+  "</account>"
+ "</customer>"
+ "<customer>"
+  "<name>john doe</name>"
+  "<address>"
+   "<city>new york</city>"
+   "<state>ny</state>"
+  "</address>"
+  "<account>"
+   "<id>5678</id>"
+   "<balance>2000</balance>"
+  "</account>"
+  "<account>"
+   "<id>4321</id>"
+   "<balance>1000</balance>"
+  "</account>"
+ "</customer>"
+"</customers>\n";
+
+const bool testQuery() {
+    {
+        const gc_scoped_pool pool;
+
+        // Read XML doc containing customers
+        istringstream is(customersXML);
+        const list<value> c = content(readElements(streamList(is)));
+        //cout << c << endl;
+
+        // Map list of customers to a list of (customer name, customer balance) pairs
+        const list<value> nb = map<value, value>([](value e) -> const value {
+
+            // Map list of accounts to a list of balances
+            list<value> bals = map<value, value>([](value e) -> const value { 
+                return (double)elementValue(elementChild("balance", e));
+            }, elementChildren("account", e));
+
+            // Reduce list of balances to compute customer balance
+            value total = reduce<value, value>([](value accum, value v) -> const value {
+                return (double)accum + (double)v;
+            }, value(0), bals);
+
+            // Return (customer name, customer balance) pair
+            return mklist<value>(elementValue(elementChild("name", e)), total);
+
+        }, elementChildren("customer", elementChild("customers", c)));
+
+        // The resulting list of (customer name, customer balance) pairs
+        //cout << nb << endl;
+        assert(nb == mklist<value>(mklist<value>("jane doe", 5000), mklist<value>("john doe", 3000)));
+    }
+    return true;
+}
+
+}
+}
+
+int main() {
+    const tuscany::gc_scoped_pool p;
+    tuscany::cout << "Testing..." << tuscany::endl;
+
+    tuscany::xml::testReadXML();
+    tuscany::xml::testWriteXML();
+    tuscany::xml::testElements();
+    tuscany::xml::testValues();
+    tuscany::xml::testReadWritePerf();
+    tuscany::xml::testReadWriteBigDocPerf();
+    tuscany::xml::testQuery();
+
+    tuscany::cout << "OK" << tuscany::endl;
+
+    return 0;
+}

Added: tuscany/sca-cpp/trunk/modules/xml/xml-test.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/xml/xml-test.hpp?rev=1419985&view=auto
==============================================================================
--- tuscany/sca-cpp/trunk/modules/xml/xml-test.hpp (added)
+++ tuscany/sca-cpp/trunk/modules/xml/xml-test.hpp Tue Dec 11 03:51:03 2012
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * Test XML doc.
+ */
+
+namespace tuscany {
+namespace xml {
+
+const string testBigDoc = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feed><title>Search Results</title><id>search</id><entry><title>An empty app template</title><id>new</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>An empty test app</title><id>test</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Check my public social data</title><id>me360</id><author>admin@example.com</author><updated>Apr 28, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme</title><id>nearme</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme2</title><id>nearme2</id><author>admin@example.com</author>
 <updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Our photos of an event</title><id>ourphotos</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>My online store</title><id>shoppingcart</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Slice</title><id>slice</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test animation components</title><id>testanimation</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test database components</title><id>testdb</id><author>admi
 n@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test event components</title><id>testevents</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTTP components</title><id>testhttp</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test logic components</title><id>testlogic</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test search components</title><id>testsearch</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTTP components</
 title><id>testhttp</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test social components</title><id>testsocial</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test text processing components</title><id>testtext</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test URL components</title><id>testurl</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test values and lists</title><id>testvalues</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></
 entry><entry><title>Test widgets</title><id>testwidgets</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test more widgets</title><id>testwidgets2</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTML generator components</title><id>testwidgets3</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>jsdtest</title><id>jsdtest</id><author>jsdelfino</author><updated>Jul 27, 2012</updated><content><stats><description>Test app</description></stats></content></entry><entry><title>SMS send service</title><id>twsms</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></conte
 nt></entry><entry><title>boao</title><id>boao</id><author>jsdelfino</author><updated>2012-10-12T12:06:59+00:00</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>An empty test app</title><id>test</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>An empty app template</title><id>new</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme</title><id>nearme</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>nearme2</title><id>nearme2</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Our p
 hotos of an event</title><id>ourphotos</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>My online store</title><id>shoppingcart</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Slice</title><id>slice</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test animation components</title><id>testanimation</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test database components</title><id>testdb</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></ent
 ry><entry><title>Test event components</title><id>testevents</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test social components</title><id>testsocial</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTTP components</title><id>testhttp</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test logic components</title><id>testlogic</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test search components</title><id>testsearch</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample a
 pp</description></stats></content></entry><entry><title>Test HTTP components</title><id>testhttp</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test text processing components</title><id>testtext</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test URL components</title><id>testurl</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test values and lists</title><id>testvalues</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test widgets</title><id>testwidgets</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><con
 tent><stats><description>Sample app</description></stats></content></entry><entry><title>Test more widgets</title><id>testwidgets2</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Test HTML generator components</title><id>testwidgets3</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>test9</title><id>test9</id><author>jsdelfino</author><updated>2012-09-25T06:17:18+00:00</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>SMS send service</title><id>twsms</id><author>admin@example.com</author><updated>Jan 01, 2012</updated><content><stats><description>Sample app</description></stats></content></entry><entry><title>Check my public social data</title><id>me360</id><author>admin@example.com</author><updated>A
 pr 28, 2012</updated><content><stats><description>Sample app</description></stats></content></entry></feed>\n";
+
+}
+}
+



Mime
View raw message