Matthias Brantner has proposed merging lp:~zorba-coders/zorba/bug-item_accessor 
into lp:zorba.

Commit message:
fixed bug in item accessor with only one argument

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Till Westmann (tillw)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-item_accessor/+merge/157491
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-item_accessor/+merge/157491
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/functions/pregenerated/func_jsoniq_functions.cpp'
--- src/functions/pregenerated/func_jsoniq_functions.cpp	2013-03-15 19:28:34 +0000
+++ src/functions/pregenerated/func_jsoniq_functions.cpp	2013-04-05 22:58:24 +0000
@@ -161,7 +161,7 @@
   std::vector<PlanIter_t>& argv,
   expr& ann) const
 {
-  return new JSONItemAccessorIterator(sctx, loc, argv[0], argv[1]);
+  return new JSONItemAccessorIterator(sctx, loc, argv);
 }
 
 #endif

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2013-03-24 20:40:03 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2013-04-05 22:58:24 +0000
@@ -1184,9 +1184,11 @@
   JSONItemAccessorIteratorState* state;
   DEFAULT_STACK_INIT(JSONItemAccessorIteratorState, state, planState);
 
-  consumeNext(input, theChild0.getp(), planState);
+  consumeNext(input, theChildren[0].getp(), planState);
   ZORBA_ASSERT(input->isJSONArray() || input->isJSONObject());
-  if (consumeNext(selector, theChild1.getp(), planState))
+
+  if (theChildren.size() == 2 &&
+      consumeNext(selector, theChildren[1].getp(), planState))
   {
     if (input->isJSONArray())
     {

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.cpp'
--- src/runtime/json/pregenerated/jsoniq_functions.cpp	2013-03-15 19:28:34 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.cpp	2013-04-05 22:58:24 +0000
@@ -395,7 +395,7 @@
 void JSONItemAccessorIterator::serialize(::zorba::serialization::Archiver& ar)
 {
   serialize_baseclass(ar,
-  (BinaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>*)this);
+  (NaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>*)this);
 }
 
 
@@ -403,8 +403,11 @@
 {
   v.beginVisit(*this);
 
-  theChild0->accept(v);
-theChild1->accept(v);
+  std::vector<PlanIter_t>::const_iterator lIter = theChildren.begin();
+  std::vector<PlanIter_t>::const_iterator lEnd = theChildren.end();
+  for ( ; lIter != lEnd; ++lIter ){
+    (*lIter)->accept(v);
+  }
 
   v.endVisit(*this);
 }

=== modified file 'src/runtime/json/pregenerated/jsoniq_functions.h'
--- src/runtime/json/pregenerated/jsoniq_functions.h	2013-03-24 20:40:03 +0000
+++ src/runtime/json/pregenerated/jsoniq_functions.h	2013-04-05 22:58:24 +0000
@@ -530,22 +530,22 @@
   void reset(PlanState&);
 };
 
-class JSONItemAccessorIterator : public BinaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>
+class JSONItemAccessorIterator : public NaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>
 { 
 public:
   SERIALIZABLE_CLASS(JSONItemAccessorIterator);
 
   SERIALIZABLE_CLASS_CONSTRUCTOR2T(JSONItemAccessorIterator,
-    BinaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>);
+    NaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>);
 
   void serialize( ::zorba::serialization::Archiver& ar);
 
   JSONItemAccessorIterator(
     static_context* sctx,
     const QueryLoc& loc,
-    PlanIter_t& child1, PlanIter_t& child2)
+    std::vector<PlanIter_t>& children)
     : 
-    BinaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>(sctx, loc, child1, child2)
+    NaryBaseIterator<JSONItemAccessorIterator, JSONItemAccessorIteratorState>(sctx, loc, children)
   {}
 
   virtual ~JSONItemAccessorIterator();

=== modified file 'src/runtime/spec/json/jsoniq_functions.xml'
--- src/runtime/spec/json/jsoniq_functions.xml	2013-03-24 20:40:03 +0000
+++ src/runtime/spec/json/jsoniq_functions.xml	2013-04-05 22:58:24 +0000
@@ -430,7 +430,7 @@
 /*******************************************************************************
 ********************************************************************************/
 -->
-<zorba:iterator name="JSONItemAccessorIterator" arity="binary"
+<zorba:iterator name="JSONItemAccessorIterator"
   preprocessorGuard="#ifdef ZORBA_WITH_JSON">
 
   <zorba:function isDeterministic="true">

=== added file 'test/rbkt/ExpQueryResults/zorba/jsoniq/descendant-objects.xml.res'
--- test/rbkt/ExpQueryResults/zorba/jsoniq/descendant-objects.xml.res	1970-01-01 00:00:00 +0000
+++ test/rbkt/ExpQueryResults/zorba/jsoniq/descendant-objects.xml.res	2013-04-05 22:58:24 +0000
@@ -0,0 +1,1 @@
+foo bar blub 42

=== added file 'test/rbkt/Queries/zorba/jsoniq/descendant-objects.jq'
--- test/rbkt/Queries/zorba/jsoniq/descendant-objects.jq	1970-01-01 00:00:00 +0000
+++ test/rbkt/Queries/zorba/jsoniq/descendant-objects.jq	2013-04-05 22:58:24 +0000
@@ -0,0 +1,25 @@
+jsoniq version "1.0";
+
+declare function local:descendant-objects($i as json-item) as object*
+{
+ typeswitch($i)
+ case object return (
+     $i,
+     for $k in keys($i)
+     let $v := $i.$k
+     where $v instance of json-item
+     return local:descendant-objects($v)
+   )
+ case array return (
+     for $v in $i()
+     where $v instance of json-item
+     return local:descendant-objects($v)
+   )
+ default return ()
+};
+
+let $o := (
+  { "foo" : 42, "bar" : { "blub" : 23 } },
+  { "foo" : 42, "bar" : { "42" : 23 } })
+return
+distinct-values($o ! local:descendant-objects($$) ! $$())

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to