Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch 
into lp:zorba.

Commit message:
API change - Fixed bug #938574 (changed the names and semantics of the 
NsScoping enum)

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/172205

API change - Fixed bug #938574 (changed the names and semantics of the 
NsScoping enum)
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/172205
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2013-06-28 03:52:18 +0000
+++ ChangeLog	2013-06-29 18:40:35 +0000
@@ -44,6 +44,7 @@
   * Fixed bug #1188100 (regex issues with 'q' flag in fn:tokenize)
   * Fixed invalid memory access error occuring during sequence type matching
     for user-defined types.
+  * API change - Fixed bug #938574 (changed the names and semantics of the NsScoping enum)
   * Fixed bug #1190710 (fn-format-date failures)
   * Fixed bug #1190407 (wrong rewrite of if-then-else return clause in case
     of general flwor)

=== modified file 'doc/cxx/examples/simple.cpp'
--- doc/cxx/examples/simple.cpp	2013-02-07 17:24:36 +0000
+++ doc/cxx/examples/simple.cpp	2013-06-29 18:40:35 +0000
@@ -274,7 +274,7 @@
 
       NsBindings lBindings;
       lChild.getNamespaceBindings(lBindings,
-                                  store::StoreConsts::ONLY_LOCAL_NAMESPACES);
+                                  store::StoreConsts::ONLY_LOCAL_BINDINGS);
       for (NsBindings::const_iterator ite = lBindings.begin();
            ite != lBindings.end(); ++ite) {
         std::cout << "  namespace binding " << ite->first

=== modified file 'include/zorba/item.h'
--- include/zorba/item.h	2013-06-15 02:57:08 +0000
+++ include/zorba/item.h	2013-06-29 18:40:35 +0000
@@ -316,18 +316,21 @@
     * The file \link simple.cpp \endlink contains some basic examples that demonstrate
     * the use of this function.
     *
-    * @param aBindings An STL list to receive the namespace bindings of this node (each
-    * represented as a std::pair<zorba::String,zorba::String> where the
-    * first string is the namespace prefix and the second is the namespace URI).
-    * @param aNsScoping An instance of NsScoping to declare which bindings to return:
-    * those local to the element; those local to all parent elements; or all bindings
-    * (the default).
+    * @param aBindings An std::vector to receive the namespace bindings of this
+    *        node (each represented as a std::pair<zorba::String,zorba::String>
+    *        where the first string is the namespace prefix and the second is the
+    *        namespace URI).
+    * @param scope A value to specify which bindings to return: all bindings (the
+    *        default); only those that are specified by the namespace declaration
+    *        attributes of the node (if any); or those that are implied by the
+    *        qnames of the node and its attributes plus those that are specified
+    *        by the namespace declaration attributes of the node (if any)
     * @throw ZorbaException if an error occured, e.g. the Item is not of type element.
     */
   void
-  getNamespaceBindings(NsBindings& aBindings,
-    store::StoreConsts::NsScoping aNsScoping = store::StoreConsts::ALL_NAMESPACES)
-    const;
+  getNamespaceBindings(
+      NsBindings& aBindings,
+      store::StoreConsts::NsScoping scope = store::StoreConsts::ALL_BINDINGS) const;
 
   /** \brief Get parent of this (node) Item.
    *
@@ -487,7 +490,7 @@
   store::Item * m_item;
 private:
   //for plan serialization
-  friend void zorba::serialization::operator&(zorba::serialization::Archiver &ar, Item &obj);
+  friend void zorba::serialization::operator&(zorba::serialization::Archiver& ar, Item& obj);
 };
 
 } // namespace zorba

=== modified file 'include/zorba/store_consts.h'
--- include/zorba/store_consts.h	2013-03-12 17:03:31 +0000
+++ include/zorba/store_consts.h	2013-06-29 18:40:35 +0000
@@ -98,11 +98,29 @@
 {
  public:
 
+  /**
+   * NsScoping defines the three values that can be given as arguments to
+   * the Item::getNamespaceBindings() method. The semantics of the three
+   * values are as follows:
+   *
+   * ALL_BINDINGS:
+   * All the namespace bindings of an element node, as defined by the W3C
+   * XQuery and XPath Data Model specification.
+   *
+   * ONLY_LOCAL_BINDINGS:
+   * The bindings that are implied by the qnames of an element node and its
+   * attributes, plus those that are specified by the namespace declaration
+   * attributes of the element node.
+   *
+   * ONLY_LOCALLY_DECLARED_BINDINGS:
+   * The bindings that are specified by the namespace declaration attributes
+   * of an element node.
+   */
   enum NsScoping
   {
-    ALL_NAMESPACES,
-    ONLY_LOCAL_NAMESPACES,
-    ONLY_PARENT_NAMESPACES
+    ALL_BINDINGS,
+    ONLY_LOCAL_BINDINGS,
+    ONLY_LOCALLY_DECLARED_BINDINGS
   };
 
   enum NodeKind

=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp	2013-06-18 10:23:52 +0000
+++ src/api/serialization/serializer.cpp	2013-06-29 18:40:35 +0000
@@ -1872,7 +1872,7 @@
     if (theSAX2ContentHandler)
     {
       item->getNamespaceBindings(local_nsBindings,
-                                 store::StoreConsts::ONLY_LOCAL_NAMESPACES);
+                                 store::StoreConsts::ONLY_LOCAL_BINDINGS);
 
       SAX2AttributesImpl attrs(const_cast<store::Item*>(item));
       ns_size = local_nsBindings.size();

=== modified file 'src/store/api/item.h'
--- src/store/api/item.h	2013-06-11 23:38:49 +0000
+++ src/store/api/item.h	2013-06-29 18:40:35 +0000
@@ -668,7 +668,7 @@
   virtual void
   getNamespaceBindings(
       NsBindings& bindings,
-      StoreConsts::NsScoping ns_scoping = StoreConsts::ALL_NAMESPACES) const;
+      StoreConsts::NsScoping ns_scoping = StoreConsts::ALL_BINDINGS) const;
 
   /** Accessor for element node
    *  @return  boolean?

=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp	2013-06-22 10:59:44 +0000
+++ src/store/naive/node_items.cpp	2013-06-29 18:40:35 +0000
@@ -3129,49 +3129,53 @@
 ********************************************************************************/
 void ElementNode::getNamespaceBindings(
     store::NsBindings& bindings,
-    store::StoreConsts::NsScoping ns_scoping) const
+    store::StoreConsts::NsScoping nsScoping) const
 {
   assert(bindings.empty());
   assert(theNsContext != NULL);
 
-  if (ns_scoping == store::StoreConsts::ONLY_LOCAL_NAMESPACES)
+  if (nsScoping == store::StoreConsts::ONLY_LOCAL_BINDINGS ||
+      nsScoping == store::StoreConsts::ONLY_LOCALLY_DECLARED_BINDINGS)
   {
-    const zstring& prefix = theName->getPrefix();
-    zstring ns;
-
-    bool found = getNsContext()->findBinding(prefix, ns);
-
-    // binding may be absent only if the prefix was empty and there was no
-    // default namespace declaration in scope.
-    ZORBA_ASSERT(prefix.empty() || prefix == "xml" || found);
-
-    if (found)
-      bindings.push_back(std::pair<zstring, zstring>(prefix, ns));
-      
-    const_iterator ite = attrsBegin();
-    const_iterator end = attrsEnd();
-
-    for (; ite != end; ++ite)
+    if (nsScoping == store::StoreConsts::ONLY_LOCAL_BINDINGS)
     {
-      const zstring& prefix = (*ite)->getNodeName()->getPrefix();
+      const zstring& prefix = theName->getPrefix();
+      zstring ns;
 
       bool found = getNsContext()->findBinding(prefix, ns);
 
+      // binding may be absent only if the prefix was empty and there was no
+      // default namespace declaration in scope.
       ZORBA_ASSERT(prefix.empty() || prefix == "xml" || found);
 
       if (found)
+        bindings.push_back(std::pair<zstring, zstring>(prefix, ns));
+      
+      const_iterator ite = attrsBegin();
+      const_iterator end = attrsEnd();
+
+      for (; ite != end; ++ite)
       {
-        store::NsBindings::const_iterator ite2 = bindings.begin();
-        store::NsBindings::const_iterator end2 = bindings.end();
-
-        for (; ite2 != end2; ++ite2)
+        const zstring& prefix = (*ite)->getNodeName()->getPrefix();
+
+        bool found = getNsContext()->findBinding(prefix, ns);
+
+        ZORBA_ASSERT(prefix.empty() || prefix == "xml" || found);
+
+        if (found)
         {
-          if (ite2->second == ns && ite2->first == prefix)
-            break;
+          store::NsBindings::const_iterator ite2 = bindings.begin();
+          store::NsBindings::const_iterator end2 = bindings.end();
+
+          for (; ite2 != end2; ++ite2)
+          {
+            if (ite2->second == ns && ite2->first == prefix)
+              break;
+          }
+
+          if (ite2 == end2)
+            bindings.push_back(std::pair<zstring, zstring>(prefix, ns));
         }
-
-        if (ite2 == end2)
-          bindings.push_back(std::pair<zstring, zstring>(prefix, ns));
       }
     }
 
@@ -3202,10 +3206,7 @@
     return;
   }
 
-  if (ns_scoping != store::StoreConsts::ONLY_PARENT_NAMESPACES)
-  {
-    bindings = theNsContext->getBindings();
-  }
+  bindings = theNsContext->getBindings();
 
   const NsBindingsContext* parentContext = theNsContext->getParent();
 

=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h	2013-06-11 23:38:49 +0000
+++ src/store/naive/node_items.h	2013-06-29 18:40:35 +0000
@@ -1079,8 +1079,8 @@
   store::Iterator_t getChildren() const;
 
   void getNamespaceBindings(
-        store::NsBindings& bindings,
-        store::StoreConsts::NsScoping scope = store::StoreConsts::ALL_NAMESPACES) const;
+      store::NsBindings& bindings,
+      store::StoreConsts::NsScoping scope = store::StoreConsts::ALL_BINDINGS) const;
 
   bool isInSubstitutionGroup() const { return (theFlags & IsInSubstGroup) != 0; }
 

=== modified file 'src/types/schema/revalidateUtils.cpp'
--- src/types/schema/revalidateUtils.cpp	2013-05-21 21:44:25 +0000
+++ src/types/schema/revalidateUtils.cpp	2013-06-29 18:40:35 +0000
@@ -476,9 +476,9 @@
     const store::Item *item)
 {
   store::NsBindings bindings;
-  item->getNamespaceBindings(bindings, store::StoreConsts::ONLY_LOCAL_NAMESPACES);
+  item->getNamespaceBindings(bindings, store::StoreConsts::ONLY_LOCAL_BINDINGS);
 
-  for (unsigned long i = 0; i < bindings.size(); i++)
+  for (csize i = 0; i < bindings.size(); i++)
   {
     schemaValidator.ns(bindings[i].first, bindings[i].second);
   }

=== modified file 'src/types/schema/validate.cpp'
--- src/types/schema/validate.cpp	2013-05-21 21:44:25 +0000
+++ src/types/schema/validate.cpp	2013-06-29 18:40:35 +0000
@@ -766,7 +766,7 @@
 {
   store::NsBindings bindings;
   item->getNamespaceBindings(bindings,
-                             store::StoreConsts::ONLY_LOCAL_NAMESPACES);
+                             store::StoreConsts::ONLY_LOCAL_BINDINGS);
 
   for (unsigned long i = 0; i < bindings.size(); i++)
   {

=== modified file 'src/zorbaserialization/serialize_zorba_types.cpp'
--- src/zorbaserialization/serialize_zorba_types.cpp	2013-06-21 01:06:29 +0000
+++ src/zorbaserialization/serialize_zorba_types.cpp	2013-06-29 18:40:35 +0000
@@ -1213,7 +1213,8 @@
       store::NsBindings ns_bindings;
 
       if (ar.is_serializing_out())
-        obj->getNamespaceBindings(ns_bindings, store::StoreConsts::ONLY_LOCAL_NAMESPACES);
+        obj->getNamespaceBindings(ns_bindings,
+                                  store::StoreConsts::ONLY_LOCALLY_DECLARED_BINDINGS);
 
       ar & ns_bindings;
       SERIALIZE_FIELD2(zstring, baseUri, getBaseURI);

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