Markos Zaharioudakis has proposed merging lp:~markos-za/zorba/bugs2 into 
lp:zorba.

Requested reviews:
  Federico Cavalieri (fcavalieri)

For more details, see:
https://code.launchpad.net/~markos-za/zorba/bugs2/+merge/78834
-- 
https://code.launchpad.net/~markos-za/zorba/bugs2/+merge/78834
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp	2011-10-10 10:08:58 +0000
+++ src/runtime/nodes/nodes_impl.cpp	2011-10-10 13:07:34 +0000
@@ -34,6 +34,7 @@
 namespace zorba {
 
 /*******************************************************************************
+
 ********************************************************************************/
 bool
 NodeReferenceIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const
@@ -42,17 +43,19 @@
   store::Item_t lGenerateIdentifier;
   zstring lNodeId;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, aPlanState);
 
   consumeNext(lNode, theChildren[0].getp(), aPlanState);
 
-  STACK_PUSH(GENV_STORE.getReference(aResult, lNode), state);
+  STACK_PUSH(GENV_STORE.getNodeReference(aResult, lNode), state);
 
   STACK_END (state);
 }
 
+
 /*******************************************************************************
+
 ********************************************************************************/
 bool
 NodeByReferenceIterator::nextImpl(store::Item_t& result, PlanState& planState) const
@@ -60,7 +63,7 @@
   store::Item_t lUUID;
   bool haveResult;
 
-  PlanIteratorState *state;
+  PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);
 
   consumeNext(lUUID, theChildren[0].getp(), planState);
@@ -378,8 +381,8 @@
       zstring uri_string, lRes;
       if(consumeNext(item, theChildren[0].getp(), planState))
       {
-        store::Item_t   item_uri;
-        if (GENV_STORE.getReference(item_uri, item.getp()))
+        store::Item_t item_uri;
+        if (GENV_STORE.getNodeReference(item_uri, item.getp()))
         {
           uri_string = item_uri->getStringValue();
           // need to convert the opaque uri into a valid ncname

=== modified file 'src/store/api/store.h'
--- src/store/api/store.h	2011-09-30 11:31:23 +0000
+++ src/store/api/store.h	2011-10-10 13:07:34 +0000
@@ -95,7 +95,7 @@
    * @param node XDM node
    * @return the identifier as an item of type xs:anyURI
    */
-  virtual bool getReference(Item_t& result, Item* node) = 0;
+  virtual bool getNodeReference(Item_t& result, Item* node) = 0;
 
   /**
    * Returns whether a reference has already been generated for the given node.

=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp	2011-10-10 10:08:58 +0000
+++ src/store/naive/node_items.cpp	2011-10-10 13:07:34 +0000
@@ -1543,7 +1543,7 @@
   InternalNode(store::StoreConsts::elementNode)
 {
   theName.transfer(nodeName);
-  setHaveValue();
+  setHaveTypedValue();
   resetRecursive();
 
   if (numBindings > 0)
@@ -1592,10 +1592,10 @@
 
     if (haveTypedValue)
     {
-      setHaveValue();
+      setHaveTypedValue();
 
       if (haveEmptyValue)
-        setHaveEmptyValue();
+        setHaveEmptyTypedValue();
     }
 
     if (isInSubstGroup)
@@ -1741,9 +1741,9 @@
   if (copymode.theTypePreserve)
   {
     typeName = getType();
-    haveValue = this->haveValue();
-    haveEmptyValue = this->haveEmptyValue();
-    inSubstGroup = this->isInSubstitutionGroup();
+    haveValue = haveTypedValue();
+    haveEmptyValue = haveEmptyTypedValue();
+    inSubstGroup = isInSubstitutionGroup();
   }
   else
   {
@@ -2187,11 +2187,11 @@
 ********************************************************************************/
 void ElementNode::getTypedValue(store::Item_t& val, store::Iterator_t& iter) const
 {
-  if (haveValue())
+  if (haveTypedValue())
   {
     TextNode* textChild;
 
-    if (haveEmptyValue())
+    if (haveEmptyTypedValue())
     {
       val = NULL;
       iter = NULL;
@@ -3470,7 +3470,7 @@
     }    
   }
 
-  ZORBA_ASSERT(p->haveValue() && !p->haveEmptyValue());
+  ZORBA_ASSERT(p->haveTypedValue() && !p->haveEmptyTypedValue());
 
   setTypedValue(content);
   if (isListValue)

=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h	2011-10-05 18:52:55 +0000
+++ src/store/naive/node_items.h	2011-10-10 13:07:34 +0000
@@ -309,31 +309,57 @@
 public:
   enum NodeFlags
   {
-    NodeKindMask        =   0x7,
-    IsId                =   0x8,
-    IsIdRefs            =   0x10,
-    HaveTypedValue      =   0x20,    // for element nodes only
-    HaveEmptyValue      =   0x40,    // for element nodes only
-    IsTyped             =   0x80,    // for text nodes only
-    HaveListValue       =   0x100,   // for text and attribute nodes only
-
-    HaveLocalBindings   =   0x200,   // for element nodes only
-    HaveBaseUri         =   0x400,   // for element nodes only
-    IsBaseUri           =   0x800,   // for attribute nodes only
-    IsHidden            =   0x1000,  // for attribute nodes only
-    IsInSubstGroup      =   0x2000,  // for element nodes only
+    // Encodes the kind of the node (document, element, attribute, etc.)
+    NodeKindMask          = 0x7,
+
+    // For element nodes only.
+    HaveLocalBindings     = 0x80,
+
+    // For element nodes only.
+    HaveBaseUri           = 0x10,
+
+    // For element nodes only. Set if the target element node has a typed value.
+    // The only case when an element node does not have a typed value is when 
+    // the type of the node is complex with complex content, but with no mixed 
+    //content allowed.
+    HaveTypedValue        = 0x20,
+
+    // For element nodes only. Set if the target element node has a complex 
+    // type with empty content. In this case, the typed value of the node is
+    // the empty sequence.
+    HaveEmptyTypedValue   = 0x40,
+
+    // For text nodes only. Set if the text node is actually used to store the
+    // typed value of its parent element node. In such a case, the remaining
+    // children (if any) of the parent node can be comment and/or pi nodes only.
+    IsTyped               = 0x80,
+
+    // For text and attribute nodes only. Set if the typed value stored in the
+    // node is actually a sequence of atomic items.
+    HaveListValue         = 0x100,
+
+    // For attribute nodes only.
+    IsBaseUri             = 0x800,
+
+    // For attribute nodes only.
+    IsHidden              = 0x1000,
+
+    // For element nodes only.
+    IsInSubstGroup        = 0x2000,
 
     // For element nodes only. The flag is set for a node N if there is another
     // node M in its subtree such that N and M have the same name.
-    IsRecursive         =   0x4000,
+    IsRecursive           = 0x4000,
 
 #ifndef EMBEDED_TYPE
     // For element and attribute nodes only. The flag is set if the node has
     // a type other than untyped (for elements) or untypedAtomic (for attributes)
-    HaveType            =   0x8000,
+    HaveType              = 0x8000,
 #endif
 
-    HaveReference       = 0x10000
+    // For any kind of node. Set if an identifier has been generated for the node
+    // (see SimpleStore::getNodeReference() method).
+    HaveReference         = 0x10000
   };
 
 protected:
@@ -496,13 +522,18 @@
 
   void setFlags(uint32_t flags) { theFlags = flags; }
 
-  bool haveReference() const         { return (theFlags & HaveReference) != 0; }
-  void setHaveReference()            { theFlags |= HaveReference; }
-  void resetHaveReference()          { theFlags &= ~HaveReference; }
+  bool haveReference() const { return (theFlags & HaveReference) != 0; }
+
+  void setHaveReference() { theFlags |= HaveReference; }
+
+  void resetHaveReference() { theFlags &= ~HaveReference; }
 
 #ifndef ZORBA_NO_FULL_TEXT
-  FTTokenIterator_t getTokens( TokenizerProvider const&, Tokenizer::Numbers&,
-                               locale::iso639_1::type, bool = false ) const;
+  FTTokenIterator_t getTokens( 
+      TokenizerProvider const&,
+      Tokenizer::Numbers&,
+      locale::iso639_1::type,
+      bool = false ) const;
 #endif /* ZORBA_NO_FULL_TEXT */
 
 protected:
@@ -897,32 +928,33 @@
   void setHaveBaseUri()         { theFlags |= HaveBaseUri; }
   void resetHaveBaseUri()       { theFlags &= ~HaveBaseUri; }
 
-  void setHaveValue()           { theFlags |= HaveTypedValue; }
-  void resetHaveValue()         { theFlags &= ~HaveTypedValue; }
-  bool haveValue() const        { return (theFlags & HaveTypedValue) != 0; }
-  void setHaveEmptyValue()      { theFlags |= HaveEmptyValue; }
-  void resetHaveEmptyValue()    { theFlags &= ~HaveEmptyValue; }
-  bool haveEmptyValue() const   { return (theFlags & HaveEmptyValue) != 0; }
+  void setHaveTypedValue()      { theFlags |= HaveTypedValue; }
+  void resetHaveTypedValue()    { theFlags &= ~HaveTypedValue; }
+  bool haveTypedValue() const   { return (theFlags & HaveTypedValue) != 0; }
+
+  void setHaveEmptyTypedValue()      { theFlags |= HaveEmptyTypedValue; }
+  void resetHaveEmptyTypedValue()    { theFlags &= ~HaveEmptyTypedValue; }
+  bool haveEmptyTypedValue() const   { return (theFlags & HaveEmptyTypedValue) != 0; }
 
   bool haveTypedTypedValue(TextNode*&) const;
 
   TextNode* getUniqueTextChild() const;
 
-  void setInSubstGroup()        { theFlags |= IsInSubstGroup; }
+  void setInSubstGroup() { theFlags |= IsInSubstGroup; }
 
-  void resetInSubstGroup()      { theFlags &= ~IsInSubstGroup; }
+  void resetInSubstGroup() { theFlags &= ~IsInSubstGroup; }
 
 #ifndef EMBEDED_TYPE
-  bool haveType() const         { return (theFlags & HaveType) != 0; }
-
-  void setHaveType()            { theFlags |= HaveType; }
-
-  void resetHaveType()          { theFlags &= ~HaveType; }
+  bool haveType() const { return (theFlags & HaveType) != 0; }
+
+  void setHaveType() { theFlags |= HaveType; }
+
+  void resetHaveType() { theFlags &= ~HaveType; }
 #endif
 
-  bool isRecursive() const      { return (theFlags & IsRecursive) != 0; }
+  bool isRecursive() const { return (theFlags & IsRecursive) != 0; }
 
-  void resetRecursive()         { theFlags &= ~IsRecursive; }
+  void resetRecursive() { theFlags &= ~IsRecursive; }
 
   void setRecursive()
   {

=== modified file 'src/store/naive/node_updates.cpp'
--- src/store/naive/node_updates.cpp	2011-09-23 14:26:00 +0000
+++ src/store/naive/node_updates.cpp	2011-10-10 13:07:34 +0000
@@ -660,8 +660,8 @@
       undoList.resize(++undoSize);
       undoList[undoSize - 1].transfer(tinfo);
 
-      n->setHaveValue();
-      n->resetHaveEmptyValue();
+      n->setHaveTypedValue();
+      n->resetHaveEmptyTypedValue();
       n->resetInSubstGroup();
 
       revalidationNode = currNode;

=== modified file 'src/store/naive/pul_primitives.cpp'
--- src/store/naive/pul_primitives.cpp	2011-09-27 06:25:16 +0000
+++ src/store/naive/pul_primitives.cpp	2011-10-10 13:07:34 +0000
@@ -480,29 +480,33 @@
     textChild->setText(textValue);
   }
 
-  if (theHaveValue)
+  if (theHaveTypedValue)
   {
-    target->setHaveValue();
-
-    if (theHaveEmptyValue)
-      target->setHaveEmptyValue();
-
-    if (theHaveTypedValue)
+    target->setHaveTypedValue();
+
+    if (theHaveEmptyTypedValue)
+      target->setHaveEmptyTypedValue();
+    else
+      target->resetHaveEmptyTypedValue();
+
+    if (theHaveTypedTypedValue)
     {
       TextNode* textChild = target->getUniqueTextChild();
 
       textChild->setTypedValue(theTypedValue);
-      if (theHaveListValue)
+      if (theHaveListTypedValue)
         textChild->setHaveListValue();
     }
   }
   else
   {
-    target->resetHaveValue();
+    target->resetHaveTypedValue();
   }
 
   if (theIsInSubstitutionGroup)
     target->setInSubstGroup();
+  else
+    target->resetInSubstGroup();
 }
 
 

=== modified file 'src/store/naive/pul_primitives.h'
--- src/store/naive/pul_primitives.h	2011-09-15 13:11:51 +0000
+++ src/store/naive/pul_primitives.h	2011-10-10 13:07:34 +0000
@@ -673,17 +673,37 @@
 
 
 /*******************************************************************************
-  theHaveValue      : True if the target element node has a typed value. The only
-                      case when an element node does not have a typed value is
-                      when the type of the node is complex with complex content,
-                      but with no mixed content allowed.
-  theHaveEmptyValue : True if the target element node has a complex type with
-                      empty content.
-  theHaveTypedValue : True if the target element node has a typed value whose
-                      type is not untypedAtomic. Note: This can happen only if
-                      the type of the target element node has simple content.
-  theHaveListValue  : True if theHaveTypedValue is true, and the type of the
-                      typed value is a list type. 
+  theTypeName:
+  ------------
+  The qname of this node's data type.
+
+  theTypedValue:
+  --------------
+
+  theHaveTypedValue:
+  ------------------
+  True if the target element node has a typed value. The only case when an 
+  element node does not have a typed value is when the type of the node is 
+  complex with complex content, but with no mixed content allowed.
+
+  theHaveEmptyTypedValue:
+  -----------------------
+  True if the target element node has a complex type with empty content. In
+  this case, the typed value of the node is the empty sequence.
+
+  theHaveTypedTypedValue:
+  ------------------
+  True if the target element node has a typed value whose type is not 
+  untypedAtomic. Note: This can happen only if the type of the target element
+  node has simple content.
+
+  theHaveListTypedValue: 
+  -----------------
+  True if theHaveTypedTypedValue is true, and the type of the typed value is a
+  list type. 
+
+  theIsInSubstitutionGroup:
+  -------------------------
 ********************************************************************************/
 class UpdSetElementType : public UpdatePrimitive
 {
@@ -692,11 +712,14 @@
 
 protected:
   store::Item_t            theTypeName;
+
   store::Item_t            theTypedValue;
-  bool                     theHaveValue;
-  bool                     theHaveEmptyValue;
+
   bool                     theHaveTypedValue;
-  bool                     theHaveListValue;
+  bool                     theHaveEmptyTypedValue;
+  bool                     theHaveTypedTypedValue;
+  bool                     theHaveListTypedValue;
+
   bool                     theIsInSubstitutionGroup;
 
   UpdSetElementType(
@@ -705,17 +728,17 @@
         store::Item_t&  target,
         store::Item_t&  typeName,
         store::Item_t&  typedValue,
-        bool            haveValue,
-        bool            haveEmptyValue,
         bool            haveTypedValue,
-        bool            haveListValue,
+        bool            haveEmptyTypedValue,
+        bool            haveTypedTypedValue,
+        bool            haveListTypedValue,
         bool            isInSubstitutionGroup)
     :
     UpdatePrimitive(pul, aLoc, target),
-    theHaveValue(haveValue),
-    theHaveEmptyValue(haveEmptyValue),
     theHaveTypedValue(haveTypedValue),
-    theHaveListValue(haveListValue),
+    theHaveEmptyTypedValue(haveEmptyTypedValue),
+    theHaveTypedTypedValue(haveTypedTypedValue),
+    theHaveListTypedValue(haveListTypedValue),
     theIsInSubstitutionGroup(isInSubstitutionGroup)
   {
     theTypeName.transfer(typeName);

=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp	2011-10-10 10:08:58 +0000
+++ src/store/naive/simple_store.cpp	2011-10-10 13:07:34 +0000
@@ -1348,7 +1348,7 @@
  @param node XDM node
  @return the identifier as an item of type xs:anyURI
 ********************************************************************************/
-bool SimpleStore::getReference(store::Item_t& result, store::Item* node)
+bool SimpleStore::getNodeReference(store::Item_t& result, store::Item* node)
 {
   XmlNode* xmlNode = static_cast<XmlNode*>(node);
 

=== modified file 'src/store/naive/simple_store.h'
--- src/store/naive/simple_store.h	2011-10-10 10:08:58 +0000
+++ src/store/naive/simple_store.h	2011-10-10 13:07:34 +0000
@@ -341,7 +341,7 @@
 
   /* ------------------------ Node Reference Management ---------------------------*/
 
-  bool getReference(store::Item_t& result, store::Item* node);
+  bool getNodeReference(store::Item_t& result, store::Item* node);
 
   bool hasReference(const store::Item* node);
 

-- 
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