You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2013/01/03 08:41:03 UTC
svn commit: r1428191 [2/2] - in /tuscany/sca-cpp/trunk: ./ components/chat/
components/http/ components/queue/ components/webservice/ kernel/
modules/atom/ modules/http/ modules/json/ modules/oauth/ modules/rss/
modules/scdl/ modules/scheme/ patches/ s...
Modified: tuscany/sca-cpp/trunk/modules/rss/rss.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/rss/rss.hpp?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/rss/rss.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/rss/rss.hpp Thu Jan 3 07:41:02 2013
@@ -45,15 +45,16 @@ const value entry("entry");
* Convert a list of elements to a list of element values representing an RSS entry.
*/
const list<value> entryElementValues(const list<value>& e) {
- const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), e);
+ const list<value> lt = elementChildren("title", e);
const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
- const list<value> li = filter<value>(selector(mklist<value>(element, "link")), e);
+ const list<value> li = elementChildren("link", e);
const value i = isNil(li)? value(emptyString) : elementValue(car(li));
- const list<value> ld = filter<value>(selector(mklist<value>(element, "description")), e);
+ const list<value> ld = elementChildren("description", e);
return append<value>(nilListValue + element + entry
+ value(nilListValue + element + value("title") + t)
+ value(nilListValue + element + value("id") + i),
- isNil(ld)? nilListValue : mklist<value>(value(nilListValue + element + value("content") + elementValue(car(ld)))));
+ isNil(ld)? nilListValue : isAttribute(elementValue(car(ld)))? nilListValue :
+ mklist<value>(value(nilListValue + element + value("content") + elementValue(car(ld)))));
}
/**
@@ -91,10 +92,10 @@ const failable<list<value> > readRSSFeed
const list<value> f = content(xml::readElements(ilist));
if (isNil(f))
return mkfailure<list<value> >("Empty feed");
- const list<value> c = filter<value>(selector(mklist<value>(element, "channel")), car(f));
- const list<value> t = filter<value>(selector(mklist<value>(element, "title")), car(c));
- const list<value> i = filter<value>(selector(mklist<value>(element, "link")), car(c));
- const list<value> e = filter<value>(selector(mklist<value>(element, "item")), car(c));
+ const list<value> c = elementChildren("channel", car(f));
+ const list<value> t = elementChildren("title", car(c));
+ const list<value> i = elementChildren("link", car(c));
+ const list<value> e = elementChildren("item", car(c));
return mklist<value>(append<value>(nilListValue + element + feed
+ value(nilListValue + element + value("title") + elementValue(car(t)))
+ value(nilListValue + element + value("id") + elementValue(car(i))),
@@ -150,9 +151,9 @@ const failable<list<string> > writeRSSEn
*/
template<typename R> const failable<R> writeRSSFeed(const lambda<const R(const string&, const R)>& reduce, const R& initial, const list<value>& ll) {
const list<value> l = isNil(ll)? ll : (list<value>)car(ll);
- const list<value> lt = filter<value>(selector(mklist<value>(element, "title")), l);
+ const list<value> lt = elementChildren("title", l);
const value t = isNil(lt)? value(emptyString) : elementValue(car(lt));
- const list<value> li = filter<value>(selector(mklist<value>(element, "id")), l);
+ const list<value> li = elementChildren("id", l);
const value i = isNil(li)? value(emptyString) : elementValue(car(li));
const list<value> c = nilListValue
+ (nilListValue + element + "title" + t)
@@ -160,7 +161,7 @@ template<typename R> const failable<R> w
+ (nilListValue + element + "description" + t);
// Write RSS entries
- const list<value> le = filter<value>(selector(mklist<value>(element, entry)), l);
+ const list<value> le = elementChildren(entry, l);
if (isNil(le)) {
const list<value> fe = nilListValue
+ element + "rss" + (nilListValue + attribute + "version" + "2.0")
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=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scdl/scdl-test.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/scdl/scdl-test.cpp Thu Jan 3 07:41:02 2013
@@ -53,8 +53,8 @@ const bool testComponents() {
const value catalog = named(string("Catalog"), c);
assert(name(catalog) == string("Catalog"));
- const list<value> t = mkbtree(sort(nameToElementAssoc(c)));
- assert(assoctree<value>("Catalog", t) == mklist<value>("Catalog" , cadr(c)));
+ const list<value> t = mkrbtree(sort(nameToElementAssoc(c)));
+ assert(rbtreeAssoc<value>("Catalog", t) == mklist<value>("Catalog" , cadr(c)));
return true;
}
@@ -89,8 +89,8 @@ const bool testReferences() {
assert(uri(binding) == nilValue);
assert(bindingType(binding) == "binding.jsonrpc");
- const list<value> t = mkbtree(sort(referenceToTargetAssoc(references(store))));
- assert(assoctree<value>("shoppingCart", t) == mklist<value>(string("shoppingCart"), string("ShoppingCart/Cart")));
+ const list<value> t = mkrbtree(sort(referenceToTargetAssoc(references(store))));
+ assert(rbtreeAssoc<value>("shoppingCart", t) == mklist<value>(string("shoppingCart"), string("ShoppingCart/Cart")));
return true;
}
Modified: tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp Thu Jan 3 07:41:02 2013
@@ -26,9 +26,12 @@
* Script evaluator primitive functions.
*/
+#include <math.h>
+
#include "stream.hpp"
#include "function.hpp"
#include "list.hpp"
+#include "tree.hpp"
#include "value.hpp"
#include "parallel.hpp"
@@ -90,10 +93,30 @@ inline const value listProc(const list<v
}
inline const value assocProc(const list<value>& args) {
- return assoc(car(args), (list<list<value> >)cadr(args));
+ return assoc(car(args), (list<value>)cadr(args));
+}
+
+inline const value delAssocProc(const list<value>& args) {
+ return delAssoc(car(args), (list<value>)cadr(args));
+}
+
+inline const value substAssocProc(const list<value>& args) {
+ return substAssoc(car(args), (list<value>)cadr(args), (list<value>)caddr(args));
+}
+
+inline const value treeDelAssocProc(const list<value>& args) {
+ return treeDelAssoc((list<value>)car(args), (list<value>)cadr(args));
+}
+
+inline const value treeSubstAssocProc(const list<value>& args) {
+ return treeSubstAssoc((list<value>)car(args), (list<value>)cadr(args), (list<value>)caddr(args));
}
-inline const value nulProc(const list<value>& args) {
+inline const value treeSelectAssocProc(const list<value>& args) {
+ return treeSelectAssoc((list<value>)car(args), (list<value>)cadr(args));
+}
+
+inline const value nullProc(const list<value>& args) {
const value v(car(args));
if (isNil(v))
return true;
@@ -106,6 +129,14 @@ inline const value equalProc(const list<
return (bool)(car(args) == cadr(args));
}
+inline const value greaterProc(const list<value>& args) {
+ return (bool)(car(args) > cadr(args));
+}
+
+inline const value lesserProc(const list<value>& args) {
+ return (bool)(car(args) < cadr(args));
+}
+
inline const value addProc(const list<value>& args) {
if (isNil(cdr(args)))
return (double)car(args);
@@ -126,6 +157,10 @@ inline const value divProc(const list<va
return (double)car(args) / (double)cadr(args);
}
+inline const value sqrtProc(const list<value>& args) {
+ return (double)sqrt((double)car(args));
+}
+
inline const value displayProc(const list<value>& args) {
if (isNil(args)) {
displayStream() << endl;
@@ -216,14 +251,22 @@ inline const list<value> primitiveProced
+ "cdr"
+ "cons"
+ "list"
- + "nul"
+ + "null?"
+ "="
+ "equal?"
+ + "<"
+ + ">"
+ "+"
+ "-"
+ "*"
+ "/"
+ + "sqrt"
+ "assoc"
+ + "del-assoc"
+ + "subst-assoc"
+ + "tree-select-assoc"
+ + "tree-del-assoc"
+ + "tree-subst-assoc"
+ "cadr"
+ "caddr"
+ "cadddr"
@@ -242,14 +285,22 @@ inline const list<value> primitiveProced
+ primitiveProcedure(cdrProc)
+ primitiveProcedure(consProc)
+ primitiveProcedure(listProc)
- + primitiveProcedure(nulProc)
+ + primitiveProcedure(nullProc)
+ primitiveProcedure(equalProc)
+ primitiveProcedure(equalProc)
+ + primitiveProcedure(lesserProc)
+ + primitiveProcedure(greaterProc)
+ primitiveProcedure(addProc)
+ primitiveProcedure(subProc)
+ primitiveProcedure(mulProc)
+ primitiveProcedure(divProc)
+ + primitiveProcedure(sqrtProc)
+ primitiveProcedure(assocProc)
+ + primitiveProcedure(delAssocProc)
+ + primitiveProcedure(substAssocProc)
+ + primitiveProcedure(treeSelectAssocProc)
+ + primitiveProcedure(treeDelAssocProc)
+ + primitiveProcedure(treeSubstAssocProc)
+ primitiveProcedure(cadrProc)
+ primitiveProcedure(caddrProc)
+ primitiveProcedure(cadddrProc)
Modified: tuscany/sca-cpp/trunk/modules/scheme/test.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/test.scm?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/test.scm (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/test.scm Thu Jan 3 07:41:02 2013
@@ -22,7 +22,7 @@
; ATOMPub test case
(define (get id)
- (if (nul id)
+ (if (null? 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))))
Modified: tuscany/sca-cpp/trunk/patches/jansson-2.4.patch
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/patches/jansson-2.4.patch?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/patches/jansson-2.4.patch (original)
+++ tuscany/sca-cpp/trunk/patches/jansson-2.4.patch Thu Jan 3 07:41:02 2013
@@ -5,7 +5,7 @@
size_t length;
- ret = snprintf(buffer, size, "%.17g", value);
-+ ret = snprintf(buffer, size, "%g", value);
++ ret = snprintf(buffer, size, "%.16g", value);
if(ret < 0)
return -1;
Modified: tuscany/sca-cpp/trunk/samples/store-constdb/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-constdb/shopping-cart.scm?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-constdb/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/samples/store-constdb/shopping-cart.scm Thu Jan 3 07:41:02 2013
@@ -23,7 +23,7 @@
; Return an empty cart if not found
(define (getcart id cache)
(define cart (cache "get" (list id)))
- (if (nul cart)
+ (if (null? cart)
(list)
cart)
)
@@ -39,7 +39,7 @@
; Find an item in the cart
(define (find id cart)
- (if (nul cart)
+ (if (null? cart)
(list (list 'entry (list 'title "Item") (list 'id "0")))
(if (= id (cadr (caddr (car cart))))
(list (car cart))
@@ -48,7 +48,7 @@
; Get items from the cart
(define (get id cache)
- (if (nul id)
+ (if (null? id)
(list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache)))
(find (car id) (getcart cartId cache))
)
@@ -56,7 +56,7 @@
; Delete items from the cart
(define (delete id cache)
- (if (nul id)
+ (if (null? id)
(cache "delete" (list cartId))
true
)
@@ -69,7 +69,7 @@
; Sum the prices of a list of items
(define (sum items)
- (if (nul items)
+ (if (null? items)
0
(+ (price (car items)) (sum (cdr items))))
)
Modified: tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/test/items-result.txt
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/test/items-result.txt?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/test/items-result.txt (original)
+++ tuscany/sca-cpp/trunk/samples/store-cpp/htdocs/test/items-result.txt Thu Jan 3 07:41:02 2013
@@ -1,23 +1 @@
-{
- "id": 1,
- "result": [
- {
- "name": "Apple",
- "currencyCode": "USD",
- "currencySymbol": "$",
- "price": 2.99
- },
- {
- "name": "Orange",
- "currencyCode": "USD",
- "currencySymbol": "$",
- "price": 3.55
- },
- {
- "name": "Pear",
- "currencyCode": "USD",
- "currencySymbol": "$",
- "price": 1.55
- }
- ]
-}
\ No newline at end of file
+{"id":1,"result":[{"name":"Apple","currencyCode":"USD","currencySymbol":"$","price":2.99},{"name":"Orange","currencyCode":"USD","currencySymbol":"$","price":3.55},{"name":"Pear","currencyCode":"USD","currencySymbol":"$","price":1.55}]}
\ No newline at end of file
Modified: tuscany/sca-cpp/trunk/samples/store-python/htdocs/test/items-result.txt
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-python/htdocs/test/items-result.txt?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-python/htdocs/test/items-result.txt (original)
+++ tuscany/sca-cpp/trunk/samples/store-python/htdocs/test/items-result.txt Thu Jan 3 07:41:02 2013
@@ -1,23 +1 @@
-{
- "id": 1,
- "result": [
- {
- "name": "Mango",
- "currencyCode": "USD",
- "currencySymbol": "$",
- "price": 2.99
- },
- {
- "name": "Passion",
- "currencyCode": "USD",
- "currencySymbol": "$",
- "price": 3.55
- },
- {
- "name": "Kiwi",
- "currencyCode": "USD",
- "currencySymbol": "$",
- "price": 1.55
- }
- ]
-}
\ No newline at end of file
+{"id":1,"result":[{"name":"Mango","currencyCode":"USD","currencySymbol":"$","price":2.99},{"name":"Passion","currencyCode":"USD","currencySymbol":"$","price":3.55},{"name":"Kiwi","currencyCode":"USD","currencySymbol":"$","price":1.55}]}
\ No newline at end of file
Modified: tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/samples/store-scheme/shopping-cart.scm Thu Jan 3 07:41:02 2013
@@ -23,7 +23,7 @@
; Return an empty cart if not found
(define (getcart id cache)
(define cart (cache "get" (list id)))
- (if (nul cart)
+ (if (null? cart)
(list)
cart)
)
@@ -39,7 +39,7 @@
; Find an item in the cart
(define (find id cart)
- (if (nul cart)
+ (if (null? cart)
(list (list 'entry (list 'title "Item") (list 'id "0")))
(if (= id (cadr (caddr (car cart))))
(list (car cart))
@@ -48,7 +48,7 @@
; Get items from the cart
(define (get id cache)
- (if (nul id)
+ (if (null? id)
(list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache)))
(find (car id) (getcart cartId cache))
)
@@ -56,7 +56,7 @@
; Delete items from the cart
(define (delete id cache)
- (if (nul id)
+ (if (null? id)
(cache "delete" (list cartId))
true
)
@@ -69,7 +69,7 @@
; Sum the prices of a list of items
(define (sum items)
- (if (nul items)
+ (if (null? items)
0
(+ (price (car items)) (sum (cdr items))))
)
Modified: tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm?rev=1428191&r1=1428190&r2=1428191&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/samples/store-sql/shopping-cart.scm Thu Jan 3 07:41:02 2013
@@ -23,7 +23,7 @@
; Return an empty cart if not found
(define (getcart id cache)
(define cart (cache "get" (list id)))
- (if (nul cart)
+ (if (null? cart)
(list)
cart)
)
@@ -39,7 +39,7 @@
; Find an item in the cart
(define (find id cart)
- (if (nul cart)
+ (if (null? cart)
(list (list 'entry (list 'title "Item") (list 'id "0")))
(if (= id (cadr (caddr (car cart))))
(list (car cart))
@@ -48,7 +48,7 @@
; Get items from the cart
(define (get id cache)
- (if (nul id)
+ (if (null? id)
(list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache)))
(find (car id) (getcart cartId cache))
)
@@ -56,7 +56,7 @@
; Delete items from the cart
(define (delete id cache)
- (if (nul id)
+ (if (null? id)
(cache "delete" (list cartId))
true
)
@@ -69,7 +69,7 @@
; Sum the prices of a list of items
(define (sum items)
- (if (nul items)
+ (if (null? items)
0
(+ (price (car items)) (sum (cdr items))))
)