From 74aef8947b7b72eca797a2f55d39997cc7af9c25 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Fri, 24 Dec 2010 02:54:39 +0000 Subject: 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 --- sca-cpp/trunk/modules/scheme/Makefile.am | 12 +++++-- sca-cpp/trunk/modules/scheme/element-value.cpp | 46 ++++++++++++++++++++++++++ sca-cpp/trunk/modules/scheme/io.hpp | 7 +++- sca-cpp/trunk/modules/scheme/value-element.cpp | 46 ++++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 sca-cpp/trunk/modules/scheme/element-value.cpp create mode 100644 sca-cpp/trunk/modules/scheme/value-element.cpp (limited to 'sca-cpp/trunk/modules/scheme') 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 readIdentifierHelper(const list& 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 readStringHelper(const list& 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(); +} + -- cgit v1.2.3