summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/scheme
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-12-24 02:54:39 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-12-24 02:54:39 +0000
commit74aef8947b7b72eca797a2f55d39997cc7af9c25 (patch)
tree60992d5a27fb7d10e2e6b280cad4dfde9256c043 /sca-cpp/trunk/modules/scheme
parente5f662ac57fa2c54882245e1c568e0982abab4fb (diff)
Fix roundtripping of JSON arrays, booleans and numbers, ATOM / RSS feed detection, and support REST-style JSON and XML payloads in server handler and client proxy.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1052432 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/scheme')
-rw-r--r--sca-cpp/trunk/modules/scheme/Makefile.am12
-rw-r--r--sca-cpp/trunk/modules/scheme/element-value.cpp46
-rw-r--r--sca-cpp/trunk/modules/scheme/io.hpp7
-rw-r--r--sca-cpp/trunk/modules/scheme/value-element.cpp46
4 files changed, 107 insertions, 4 deletions
diff --git a/sca-cpp/trunk/modules/scheme/Makefile.am b/sca-cpp/trunk/modules/scheme/Makefile.am
index 42c872f1cd..8e2141e724 100644
--- a/sca-cpp/trunk/modules/scheme/Makefile.am
+++ b/sca-cpp/trunk/modules/scheme/Makefile.am
@@ -22,11 +22,17 @@ eval_test_SOURCES = eval-test.cpp
eval_shell_SOURCES = eval-shell.cpp
+value_element_SOURCES = value-element.cpp
+value_element_LDFLAGS =
+
+element_value_SOURCES = element-value.cpp
+element_value_LDFLAGS =
+
xml_value_SOURCES = xml-value.cpp
-xml_value_LDFLAGS = -lxml2
+xml_value_LDFLAGS = -lxml2
value_xml_SOURCES = value-xml.cpp
-value_xml_LDFLAGS = -lxml2
+value_xml_LDFLAGS = -lxml2
json_value_SOURCES = json-value.cpp
json_value_LDFLAGS = -lmozjs
@@ -34,5 +40,5 @@ json_value_LDFLAGS = -lmozjs
value_json_SOURCES = value-json.cpp
value_json_LDFLAGS = -lmozjs
-noinst_PROGRAMS = eval-test eval-shell xml-value value-xml json-value value-json
+noinst_PROGRAMS = eval-test eval-shell element-value value-element xml-value value-xml json-value value-json
TESTS = eval-test
diff --git a/sca-cpp/trunk/modules/scheme/element-value.cpp b/sca-cpp/trunk/modules/scheme/element-value.cpp
new file mode 100644
index 0000000000..8a443dbdb2
--- /dev/null
+++ b/sca-cpp/trunk/modules/scheme/element-value.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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$ */
+
+/**
+ * Convert a scheme value representing an element to a value.
+ */
+
+#include "fstream.hpp"
+#include "string.hpp"
+#include "element.hpp"
+#include "eval.hpp"
+
+namespace tuscany {
+namespace scheme {
+
+int elementValue() {
+ const value v = elementsToValues(readValue(cin));
+ cout << writeValue(v);
+ return 0;
+}
+
+}
+}
+
+int main() {
+ return tuscany::scheme::elementValue();
+}
+
diff --git a/sca-cpp/trunk/modules/scheme/io.hpp b/sca-cpp/trunk/modules/scheme/io.hpp
index 5e5397cfeb..6928739d17 100644
--- a/sca-cpp/trunk/modules/scheme/io.hpp
+++ b/sca-cpp/trunk/modules/scheme/io.hpp
@@ -154,7 +154,12 @@ const list<char> readIdentifierHelper(const list<char>& listSoFar, istream& in)
}
const value readIdentifier(const char chr, istream& in) {
- return c_str(listToString(readIdentifierHelper(mklist(chr), in)));
+ const value val = c_str(listToString(readIdentifierHelper(mklist(chr), in)));
+ if (val == "false")
+ return value((bool)false);
+ if (val == "true")
+ return value((bool)true);
+ return val;
}
const list<char> readStringHelper(const list<char>& listSoFar, istream& in) {
diff --git a/sca-cpp/trunk/modules/scheme/value-element.cpp b/sca-cpp/trunk/modules/scheme/value-element.cpp
new file mode 100644
index 0000000000..a4acdaf2d7
--- /dev/null
+++ b/sca-cpp/trunk/modules/scheme/value-element.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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$ */
+
+/**
+ * Convert a scheme value to a value representing an element.
+ */
+
+#include "fstream.hpp"
+#include "string.hpp"
+#include "element.hpp"
+#include "eval.hpp"
+
+namespace tuscany {
+namespace scheme {
+
+int valueElement() {
+ const value v = valuesToElements(readValue(cin));
+ cout << writeValue(v);
+ return 0;
+}
+
+}
+}
+
+int main() {
+ return tuscany::scheme::valueElement();
+}
+