summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/samples
diff options
context:
space:
mode:
Diffstat (limited to 'sca-cpp/trunk/samples')
-rw-r--r--sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp22
-rw-r--r--sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp14
-rw-r--r--sca-cpp/trunk/samples/store-java/Makefile.am9
-rw-r--r--sca-cpp/trunk/samples/store-scheme/Makefile.am2
-rw-r--r--sca-cpp/trunk/samples/store-scheme/script-test.cpp14
5 files changed, 29 insertions, 32 deletions
diff --git a/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp b/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp
index 9907650316..16f01cd85c 100644
--- a/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp
+++ b/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp
@@ -35,27 +35,19 @@ namespace store {
/**
* Returns the catalog.
*/
-struct convert {
- const lambda<value(const list<value>&)> converter;
- const string currency;
- convert(const lambda<value(const list<value>&)>& converter, const string& currency) : converter(converter), currency(currency) {
- }
- const value operator()(const value& price) const {
- return converter(mklist<value>("convert", string("USD"), currency, price));
- }
-};
-
const list<value> mkfruit(const string& name, const string& code, const string& symbol, const double price) {
- return list<value>() +
+ return nilListValue +
mklist<value>("name", name) + mklist<value>("currencyCode", code) + mklist<value>("currencySymbol", symbol) + mklist<value>("price", price);
}
-const failable<value> items(const lambda<value(const list<value>&)>& converter, const lambda<value(const list<value>&)>& currencyCode) {
- const string currency(currencyCode(list<value>()));
+const failable<value> items(const lvvlambda& converter, const lvvlambda& currencyCode) {
+ const string currency(currencyCode(nilListValue));
const string symbol(converter(mklist<value>("symbol", currency)));
- const lambda<value(const value&)> conv(convert(converter, currency));
+ const vvlambda conv = [converter, currency](const value& price) -> const value {
+ return converter(mklist<value>("convert", string("USD"), currency, price));
+ };
- return value(list<value>() +
+ return value(nilListValue +
mkfruit("Apple", currency, symbol, conv(2.99)) +
mkfruit("Orange", currency, symbol, conv(3.55)) +
mkfruit("Pear", currency, symbol, conv(1.55)));
diff --git a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
index 2771d7cd9c..e65aa0d392 100644
--- a/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
+++ b/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
@@ -38,7 +38,7 @@ const string cartId("1234");
* Get the shopping cart from the cache. Return an empty
* cart if not found.
*/
-const list<value> getcart(const value& id, const lambda<value(const list<value>&)>& cache) {
+const list<value> getcart(const value& id, const lvvlambda& cache) {
const value cart = cache(mklist<value>("get", mklist<value>(id)));
cerr << "cart value: " << cart << "\n";
const failable<value> fcart = cart;
@@ -46,14 +46,14 @@ const list<value> getcart(const value& id, const lambda<value(const list<value>&
cerr << "cart content: " << content(fcart) << "\n";
cerr << "cart reason: " << reason(fcart) << "\n";
if (isNil(cart))
- return value(list<value>());
+ return value(nilListValue);
return (list<value>)cart;
}
/**
* Post a new item to the cart. Create a new cart if necessary.
*/
-const failable<value> post(unused const list<value>& collection, const value& item, const lambda<value(const list<value>&)>& cache) {
+const failable<value> post(unused const list<value>& collection, const value& item, const lvvlambda& cache) {
const value id(mkuuid());
const list<value> newItem(mklist<value>("entry", cadr<value>(car<value>(item)), mklist<value>("id", id), cadddr<value>(car<value>(item))));
const list<value> cart(cons<value>(newItem, getcart(cartId, cache)));
@@ -75,7 +75,7 @@ const value find(const value& id, const list<value>& cart) {
/**
* Return items from the cart.
*/
-const failable<value> get(const list<value>& id, const lambda<value(const list<value>&)>& cache) {
+const failable<value> get(const list<value>& id, const lvvlambda& cache) {
if (isNil(id))
return value(mklist<value>(append(mklist<value>("feed", mklist<value>("title", string("Your Cart")), mklist<value>("id", cartId)), getcart(cartId, cache))));
return find(car(id), getcart(cartId, cache));
@@ -84,10 +84,10 @@ const failable<value> get(const list<value>& id, const lambda<value(const list<v
/**
* Delete items from the cart.
*/
-const failable<value> del(const list<value>& id, unused const lambda<value(const list<value>&)>& cache) {
+const failable<value> del(const list<value>& id, unused const lvvlambda& cache) {
if (isNil(id))
return cache(mklist<value>("delete", mklist<value>(cartId)));
- return value(true);
+ return trueValue;
}
/**
@@ -109,7 +109,7 @@ const double sum(const list<value>& items) {
/**
* Return the total price of the items in the cart.
*/
-const failable<value> total(const lambda<value(const list<value>&)>& cache) {
+const failable<value> total(const lvvlambda& cache) {
const list<value> cart(getcart(cartId, cache));
return value(sum(cart));
}
diff --git a/sca-cpp/trunk/samples/store-java/Makefile.am b/sca-cpp/trunk/samples/store-java/Makefile.am
index f32ae72812..3db20ac390 100644
--- a/sca-cpp/trunk/samples/store-java/Makefile.am
+++ b/sca-cpp/trunk/samples/store-java/Makefile.am
@@ -22,11 +22,16 @@ if WANT_JAVA
dist_sample_SCRIPTS = start stop ssl-start
sampledir=$(prefix)/samples/store-java
-AM_JAVACFLAGS = -cp ${top_builddir}/modules/java/libmod-tuscany-java-${PACKAGE_VERSION}.jar:${JAVAROOT}
dist_sample_JAVA = store/*.java
+
+SUFFIXES = .class
+AM_JAVACFLAGS = -cp ${top_builddir}/modules/java/libmod-tuscany-java-${PACKAGE_VERSION}.jar:${JAVAROOT}
+.java.class:
+ ${JAVAC} ${AM_JAVACFLAGS} store/*.java
+
CLEANFILES = *.stamp store/*.class
-nobase_dist_sample_DATA = store.composite htdocs/*.html store/*.*
+nobase_dist_sample_DATA = store.composite htdocs/*.html store/*.java store/CurrencyConverterImpl.class store/CurrencyConverter.class store/FruitsCatalogImpl.class store/ShoppingCartImpl.class
dist_noinst_SCRIPTS = server-test
TESTS = server-test
diff --git a/sca-cpp/trunk/samples/store-scheme/Makefile.am b/sca-cpp/trunk/samples/store-scheme/Makefile.am
index 2330d45422..36aa8ecb2d 100644
--- a/sca-cpp/trunk/samples/store-scheme/Makefile.am
+++ b/sca-cpp/trunk/samples/store-scheme/Makefile.am
@@ -25,6 +25,6 @@ EXTRA_DIST = script-test.scm
dist_noinst_SCRIPTS = server-test
noinst_PROGRAMS = script-test
script_test_SOURCES = script-test.cpp
-script_test_LDFLAGS = -lxml2 -lmozjs
+script_test_LDFLAGS = -lxml2 -ljansson
TESTS = script-test server-test
diff --git a/sca-cpp/trunk/samples/store-scheme/script-test.cpp b/sca-cpp/trunk/samples/store-scheme/script-test.cpp
index 0d5a9ccf9d..676865e771 100644
--- a/sca-cpp/trunk/samples/store-scheme/script-test.cpp
+++ b/sca-cpp/trunk/samples/store-scheme/script-test.cpp
@@ -28,16 +28,16 @@
#include "stream.hpp"
#include "string.hpp"
#include "list.hpp"
-#include "xml.hpp"
-#include "../../modules/scheme/driver.hpp"
+#include "../../modules/xml/xml.hpp"
#include "../../modules/json/json.hpp"
+#include "../../modules/scheme/driver.hpp"
namespace store {
using namespace tuscany;
-bool testScript() {
- gc_scoped_pool pool;
+const bool testScript() {
+ const gc_scoped_pool pool;
ifstream is("script-test.scm");
ostringstream os;
@@ -49,9 +49,9 @@ bool testScript() {
return true;
}
-bool testEval() {
+const bool testEval() {
{
- gc_scoped_pool pool;
+ const gc_scoped_pool pool;
ifstream is("script-test.scm");
ostringstream os;
scheme::setupDisplay(os);
@@ -65,7 +65,7 @@ bool testEval() {
}
{
- gc_scoped_pool pool;
+ const gc_scoped_pool pool;
ifstream is("script-test.scm");
ostringstream os;
scheme::setupDisplay(os);