Return-Path: X-Original-To: apmail-tuscany-dev-archive@www.apache.org Delivered-To: apmail-tuscany-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 95444E124 for ; Wed, 19 Dec 2012 21:00:30 +0000 (UTC) Received: (qmail 30847 invoked by uid 500); 19 Dec 2012 21:00:30 -0000 Delivered-To: apmail-tuscany-dev-archive@tuscany.apache.org Received: (qmail 30698 invoked by uid 500); 19 Dec 2012 21:00:29 -0000 Mailing-List: contact dev-help@tuscany.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tuscany.apache.org Delivered-To: mailing list dev@tuscany.apache.org Received: (qmail 30679 invoked by uid 99); 19 Dec 2012 21:00:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 21:00:29 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [212.227.126.186] (HELO moutng.kundenserver.de) (212.227.126.186) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Dec 2012 21:00:25 +0000 Received: from [15.136.120.31] (dslb-178-002-212-190.pools.arcor-ip.net [178.2.212.190]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0MORHR-1TiQbP1g1t-005mre; Wed, 19 Dec 2012 22:00:02 +0100 Subject: Re: Porting Tuscany C++ to C++11 and some code cleanup From: Thomas Gentsch To: dev@tuscany.apache.org In-Reply-To: References: <1353690145.2516.732.camel@parsley> <1353879062.2516.1164.camel@parsley> <1354297394.2683.969.camel@parsley> Content-Type: text/plain; charset="UTF-8" Date: Wed, 19 Dec 2012 22:00:01 +0100 Message-ID: <1355950801.2478.897.camel@parsley> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:SEWX9U9TdcICD1+qf1DorKazmD4PlniQ/eNldetPT9c BM+eFDmS7BajXoiigTV4ZUd0nG0vC6ThwFDTBWoDDMuyCMnZJX Kde8kF7esEzslF/MTdsbXQkPZFOo9oXBIXD/QkHWCAq6wo7aE9 KBIY77zSy3UusCP6TeU8xVLTia0AtS8IHzkI9jQtM15gS2w59p hbMVib9wSIsN/9bn0Elg1xl/Y/EIVwGzrDVmHTY+7FTAMaUUz6 RvzI8FaI6YGymYWKBwF4CKwwU7udwrETQ4OTHIgyxw4wv02p3i uAeehSw3XHnzB65nEplkwabpFEC5NsnMVAu1VMWe/cy9CD59JS Ao7pHi5jR/44I5Kb8HMk= X-Virus-Checked: Checked by ClamAV on apache.org Hi JS, I'm still looking through the docs, code, etc. I can find. One thing I discovered: it does not look to me as if SDO support has been removed from Java SCA, at least I found some related activity in 2011: http://www.mail-archive.com/user@tuscany.apache.org/msg03435.html http://www.mail-archive.com/dev@tuscany.apache.org/msg17116.html (the latter is quite funny because I actually submitted this against C++ but seems as if the same problem occurred with Java? :-) More later ... :-) Rgds, tge On Thu, 2012-12-06 at 01:04 -0800, Jean-Sebastien Delfino wrote: > On Fri, Nov 30, 2012 at 9:43 AM, Thomas Gentsch wrote: > > OK, many thx for this info! > > Regarding SDO - yes, I noticed that there was not a lot of > activity > during the last years. > Hello out there: Is there anybody else still using this? > > Rgd SDO as SCA-internal data-flow mechanism - what is being > used now? > I know about libxml2 (actually its being used in SCA/SDO :-), > nothing > yet about JSON, will read. > > > Hi Thomas, > > > Here's a short overview of what's used now. > > > Data read/write functions are provided for XML (using Libxml2 [1]), > JSON (using Mozilla SpiderMonkey but I've started to migrate to > Jansson [2]), and Lisp/Scheme S-expressions [3]. > > > Here's how to read XML in a C++ component: > age="21">johndoe(650)123-4567(415)765-4321 > > > // A list of strings containing the above XML doc, obtained from an > input stream for example > const list ls = ...; > > > // Read the XML doc (the failable<...> result type helps encapsulate > error handling) > // See below for a description of the 'value' data type > const failable fe = xml::readElements(ls); > > > // Assuming no failure, get and print the result > const value e = content(fe); > cout << e << endl; > > > The result is a list like follows (using the S-expression syntax here > for conciseness: element, customer, attribute, age are symbols, 21 is > a number, "johndoe" is a string, (x y) is a list of x, y): > ((element customer (attribute age "21") (element name "johndoe") > (element phone "(650)123-4567") (element phone "(415)765-4321"))) > > > The runtime is schema-less. You do not need an XML schema to > read/write any XML. > > > If you don't care about the XML element vs attribute representation > you can strip it like this: > const value v = elementsToValues(e); > to get this: > ((customer (@age "21") (name "johndoe") (phone ("(650)123-4567" > "(415)765-4321")))) > > > Note the @age attribute name, which follows the Badgerfish [4] > convention often used to name XML attributes in JSON documents for > example. > > The same data can be constructed and represented in the various > programming languages supported by the runtime, as follows: > > > C++: > list(list("customer", list("@age", 21), > list("name", string("johndoe")), list("phone", > list("(650)123-4567", "(415)765-4321")))); > using the following C++ types: > - string, similar to std::string but lighter and faster for small > strings, with builtin conversions from/to native char*; > - list, a lightweight list/lazy-list type with useful > Lisp/Scheme-like [5] functions incl. cons, car, cdr, map, filter, > reduce, assoc, etc; > - lambda, a function type similar to std::function but > lighter and faster; > - value, a dynamic value type (type can be number, boolean, symbol, > string, list, lambda)>, value*) with builtin > conversions from/to native double, bool, char*, C++ lambdas and > pointers. > > > Python: > ((customer, ("'@age" 21), ("'name", "johndoe") (phone, > ("(650)123-4567" "(415)765-4321"))),) > using Python tuples [6] and native Python data types for strings, > numbers and booleans. > > > JavaScript / JSON: > {"customer":{"@age":"21","name":"johndoe","phone":["(650)123-4567","(415)765-4321"]}} > using JSON arrays and native Javascript types. > > > Scheme: > ((customer (@age "21") (name "johndoe") (phone ("(650)123-4567" > "(415)765-4321")))) > just an S-expression. > > > Java (there's experimental support for running Java components on the > C++ runtime): > list(list("'customer", list("'@age", 21), list("'name", "johndoe"), > list("'phone", list("(650)123-4567", "(415)765-4321")))); > using java.lang.Iterable [7] for lists and native Java data types for > strings, numbers and booleans (the list(...) function is a static > 'builder' function returning a java.lang.Iterable.) > > > To summarize: fast and schemaless support for XML, JSON and > S-expressions, with lightweight representation using lists and simple > types in the supported programming languages. > > > Hope that helps. > > > [1] http://www.xmlsoft.org > [2] http://www.digip.org/jansson/ > [3] http://en.wikipedia.org/wiki/S-expression > [4] http://badgerfish.ning.com > [5] http://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Lists.html#Lists > [6] http://docs.python.org/2/tutorial/datastructures.html#tuples-and-sequences > [7] http://docs.oracle.com/javase/6/docs/api/java/lang/Iterable.html > > > - Jean-Sebastien