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

Commit message:
fixed implementation of copy-namespaces mode in static_context (the old one was 
ugly and buggy)

Requested reviews:
  Markos Zaharioudakis (markos-za)

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

fixed implementation of copy-namespaces mode in static_context (the old one was 
ugly and buggy)
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/127753
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp	2012-09-25 10:20:31 +0000
+++ src/api/staticcontextimpl.cpp	2012-10-03 13:05:44 +0000
@@ -558,12 +558,17 @@
 boundary_space_mode_t
 StaticContextImpl::getBoundarySpacePolicy( ) const
 {
-  try {
+  try 
+  {
     return theCtx->boundary_space_mode()==StaticContextConsts::preserve_space?
       preserve_space:strip_space;
-  } catch (ZorbaException const& e) {
+  }
+  catch (ZorbaException const& e)
+  {
     ZorbaImpl::notifyError(theDiagnosticHandler, e);
-  } catch (std::exception const& e) {
+  }
+  catch (std::exception const& e)
+  {
     ZorbaImpl::notifyError(theDiagnosticHandler, e.what());
   }
   return preserve_space;
@@ -571,34 +576,39 @@
 
 
 bool
-StaticContextImpl::setCopyNamespacesMode( preserve_mode_t preserve,
-                                          inherit_mode_t inherit )
+StaticContextImpl::setCopyNamespacesMode(
+    preserve_mode_t preserve,
+    inherit_mode_t inherit)
 {
   ZORBA_TRY
-    if ( preserve == preserve_ns )
-      theCtx->set_preserve_mode(StaticContextConsts::preserve_ns);
-    else
-      theCtx->set_preserve_mode(StaticContextConsts::no_preserve_ns);
-
-    if ( inherit == inherit_ns )
-      theCtx->set_inherit_mode(StaticContextConsts::inherit_ns);
-    else
-      theCtx->set_inherit_mode(StaticContextConsts::no_inherit_ns);
+  {
+    if (preserve == preserve_ns)
+      theCtx->set_preserve_ns(true);
+    else
+      theCtx->set_preserve_ns(false);
+
+    if (inherit == inherit_ns)
+      theCtx->set_inherit_ns(true);
+    else
+      theCtx->set_inherit_ns(true);
+
     return true;
+  }
   ZORBA_CATCH
   return false;
 }
 
 
 void
-StaticContextImpl::getCopyNamespacesMode( preserve_mode_t& preserve,
-                                          inherit_mode_t& inherit ) const
+StaticContextImpl::getCopyNamespacesMode(
+    preserve_mode_t& preserve,
+    inherit_mode_t& inherit) const
 {
   ZORBA_TRY
-    preserve = theCtx->preserve_mode()==StaticContextConsts::preserve_ns?
-                    preserve_ns:no_preserve_ns;
-    inherit = theCtx->inherit_mode()==StaticContextConsts::inherit_ns?
-                    inherit_ns:no_inherit_ns;
+  {
+    preserve = (theCtx->preserve_ns() ? preserve_ns : no_preserve_ns);
+    inherit = (theCtx->inherit_ns() ? inherit_ns : no_inherit_ns);
+  }
   ZORBA_CATCH
 }
 

=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h	2012-09-17 00:36:37 +0000
+++ src/api/staticcontextimpl.h	2012-10-03 13:05:44 +0000
@@ -37,9 +37,6 @@
   --------
   rchandle to the internal static_context obj that is wrapped by "this".
 
-  theSctxMap :
-  ------------
-
   theMaxVarId :
   -------------
   If loadProlog() is called on "this", the compiler will store in theMaxVarId
@@ -63,19 +60,17 @@
   friend class XQueryImpl;   // needed for accessing theSctxMap
 
 protected:
-  static_context_t                    theCtx;
-
-  CompilerCB                        * theCompilerCB;
-
-  //std::map<csize, static_context_t>   theSctxMap;
-
-  ulong                               theMaxVarId;
-
-  DiagnosticHandler                 * theDiagnosticHandler;
-  bool                                theUserDiagnosticHandler;
+  static_context_t                      theCtx;
+
+  CompilerCB                          * theCompilerCB;
+
+  ulong                                 theMaxVarId;
+
+  DiagnosticHandler                   * theDiagnosticHandler;
+  bool                                  theUserDiagnosticHandler;
 
   // allow for lazy creation
-  mutable StaticCollectionManagerImpl* theCollectionMgr;
+  mutable StaticCollectionManagerImpl * theCollectionMgr;
 
 private:
   StaticContextImpl(const StaticContextImpl&);

=== modified file 'src/compiler/parser/xquery_parser.y'
--- src/compiler/parser/xquery_parser.y	2012-09-28 09:27:17 +0000
+++ src/compiler/parser/xquery_parser.y	2012-10-03 13:05:44 +0000
@@ -1344,30 +1344,22 @@
 CopyNamespacesDecl :
     DECLARE COPY_NAMESPACES  PRESERVE  COMMA  INHERIT
     {
-      $$ = new CopyNamespacesDecl(LOC(@$),
-                                  StaticContextConsts::preserve_ns,
-                                  StaticContextConsts::inherit_ns);
+      $$ = new CopyNamespacesDecl(LOC(@$), true, true);
     }
   |
     DECLARE COPY_NAMESPACES  PRESERVE  COMMA  NO_INHERIT
     {
-      $$ = new CopyNamespacesDecl(LOC(@$),
-                                  StaticContextConsts::preserve_ns,
-                                  StaticContextConsts::no_inherit_ns);
+      $$ = new CopyNamespacesDecl(LOC(@$), true, false);
     }
   |
     DECLARE COPY_NAMESPACES  NO_PRESERVE  COMMA  INHERIT
     {
-      $$ = new CopyNamespacesDecl(LOC(@$),
-                                  StaticContextConsts::no_preserve_ns,
-                                  StaticContextConsts::inherit_ns);
+      $$ = new CopyNamespacesDecl(LOC(@$), false, true);
     }
   |
     DECLARE COPY_NAMESPACES  NO_PRESERVE  COMMA  NO_INHERIT
     {
-      $$ = new CopyNamespacesDecl(LOC(@$),
-                                  StaticContextConsts::no_preserve_ns,
-                                  StaticContextConsts::no_inherit_ns);
+      $$ = new CopyNamespacesDecl(LOC(@$), false, false);
     }
 ;
 

=== modified file 'src/compiler/parsetree/parsenode_print_xquery_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2012-09-17 00:36:37 +0000
+++ src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2012-10-03 13:05:44 +0000
@@ -237,29 +237,17 @@
 void* begin_visit(const CopyNamespacesDecl& n)
 {
   os << "declare copy-namespaces ";
-  switch(n.get_preserve_mode())
-  {
-  case StaticContextConsts::preserve_ns:
+
+  if (n.preserve_ns())
     os << "preserve,";
-    break;
-  case StaticContextConsts::no_preserve_ns:
+  else
     os << "no-preserve,";
-    break;
-  default:
-    ZORBA_ASSERT(false);
-  }
 
-  switch(n.get_inherit_mode())
-  {
-  case StaticContextConsts::inherit_ns:
+  if (n.inherit_ns())
     os << "inherit";
-    break;
-  case StaticContextConsts::no_inherit_ns:
+  else
     os << "no-inherit";
-    break;
-  default:
-    ZORBA_ASSERT(false);
-  }
+
   return 0;
 }
 

=== modified file 'src/compiler/parsetree/parsenodes.cpp'
--- src/compiler/parsetree/parsenodes.cpp	2012-09-28 07:55:38 +0000
+++ src/compiler/parsetree/parsenodes.cpp	2012-10-03 13:05:44 +0000
@@ -362,18 +362,18 @@
   [20] InheritMode ::=  "inherit" | "no-inherit"
 ********************************************************************************/
 CopyNamespacesDecl::CopyNamespacesDecl(
-    const QueryLoc& loc_,
-    StaticContextConsts::preserve_mode_t _preserve_mode,
-    StaticContextConsts::inherit_mode_t  _inherit_mode)
+    const QueryLoc& loc,
+    bool preserve_ns,
+    bool inherit_ns)
   :
-  parsenode(loc_),
-  preserve_mode(_preserve_mode),
-  inherit_mode(_inherit_mode)
+  parsenode(loc),
+  thePreserveNamespaces(preserve_ns),
+  theInheritNamespaces(inherit_ns)
 {
 }
 
 
-void CopyNamespacesDecl::accept( parsenode_visitor &v ) const
+void CopyNamespacesDecl::accept(parsenode_visitor& v) const
 {
   BEGIN_VISITOR();
   END_VISITOR();

=== modified file 'src/compiler/parsetree/parsenodes.h'
--- src/compiler/parsetree/parsenodes.h	2012-09-28 07:55:38 +0000
+++ src/compiler/parsetree/parsenodes.h	2012-10-03 13:05:44 +0000
@@ -525,20 +525,15 @@
 class CopyNamespacesDecl : public parsenode
 {
 protected:
-  StaticContextConsts::preserve_mode_t preserve_mode;
-  StaticContextConsts::inherit_mode_t inherit_mode;
+  bool thePreserveNamespaces;
+  bool theInheritNamespaces;
 
 public:
-  CopyNamespacesDecl(
-    const QueryLoc&,
-    StaticContextConsts::preserve_mode_t preserve_mode,
-    StaticContextConsts::inherit_mode_t  inherit_mode);
-
-  StaticContextConsts::preserve_mode_t get_preserve_mode() const
-  { return preserve_mode; }
-
-  StaticContextConsts::inherit_mode_t  get_inherit_mode() const
-  { return inherit_mode; }
+  CopyNamespacesDecl(const QueryLoc&, bool preserve_ns, bool inherit_ns);
+
+  bool preserve_ns() const { return thePreserveNamespaces; }
+
+  bool inherit_ns() const { return theInheritNamespaces; }
 
   void accept(parsenode_visitor&) const;
 };

=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
--- src/compiler/rewriter/rules/nodeid_rules.cpp	2012-10-02 22:50:57 +0000
+++ src/compiler/rewriter/rules/nodeid_rules.cpp	2012-10-03 13:05:44 +0000
@@ -590,7 +590,11 @@
       // Serialization may or may not be a "safe" op.
       static_context* sctx = node->get_sctx();
 
+<<<<<<< TREE
       if (sctx->preserve_mode() == StaticContextConsts::preserve_ns)
+=======
+      if (sctx->preserve_ns() && sctx->inherit_ns())
+>>>>>>> MERGE-SOURCE
       {
         if (sctx->inherit_mode() == StaticContextConsts::inherit_ns)
         {
@@ -678,8 +682,12 @@
 
     static_context* sctx = e->get_sctx();
 
+<<<<<<< TREE
     if (sctx->preserve_mode() == StaticContextConsts::preserve_ns &&
         sctx->inherit_mode() == StaticContextConsts::inherit_ns)
+=======
+    if (sctx->preserve_ns())
+>>>>>>> MERGE-SOURCE
     {
       csize numPairs = e->num_pairs();
       for (csize i = 0; i < numPairs; ++i)
@@ -704,8 +712,12 @@
 
     static_context* sctx = e->get_sctx();
 
+<<<<<<< TREE
     if (sctx->preserve_mode() == StaticContextConsts::preserve_ns &&
         sctx->inherit_mode() == StaticContextConsts::inherit_ns)
+=======
+    if (sctx->preserve_ns())
+>>>>>>> MERGE-SOURCE
     {
       std::vector<expr*> sources;
       theSourceFinder->findNodeSources(e->get_expr(), &udfCaller, sources);
@@ -881,8 +893,8 @@
         (e->get_expr_kind() == insert_expr_kind ||
          (e->get_expr_kind() == replace_expr_kind &&
           static_cast<replace_expr*>(e)->getType() == store::UpdateConsts::NODE)) &&
-        (sctx->inherit_mode() != StaticContextConsts::no_inherit_ns ||
-         sctx->preserve_mode() != StaticContextConsts::no_preserve_ns))
+        sctx->inherit_ns() &&
+        sctx->preserve_ns())
     {
       std::vector<expr*> sources;
       theSourceFinder->findNodeSources(e->getSourceExpr(), &udfCaller, sources);
@@ -898,8 +910,12 @@
 
     static_context* sctx = e->get_sctx();
 
+<<<<<<< TREE
     if (sctx->preserve_mode() == StaticContextConsts::preserve_ns &&
         sctx->inherit_mode() == StaticContextConsts::inherit_ns)
+=======
+    if (sctx->preserve_ns())
+>>>>>>> MERGE-SOURCE
     {
       std::vector<copy_clause*>::const_iterator ite = e->begin();
       std::vector<copy_clause*>::const_iterator end = e->end();

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-09-28 19:16:51 +0000
+++ src/compiler/translator/translator.cpp	2012-10-03 13:05:44 +0000
@@ -2677,8 +2677,8 @@
 void end_visit(const CopyNamespacesDecl& v, void* /*visit_state*/)
 {
   TRACE_VISIT_OUT();
-  theSctx->set_inherit_mode(v.get_inherit_mode ());
-  theSctx->set_preserve_mode(v.get_preserve_mode ());
+  theSctx->set_inherit_ns(v.inherit_ns());
+  theSctx->set_preserve_ns(v.preserve_ns());
 }
 
 

=== modified file 'src/context/root_static_context.cpp'
--- src/context/root_static_context.cpp	2012-09-17 00:36:37 +0000
+++ src/context/root_static_context.cpp	2012-10-03 13:05:44 +0000
@@ -100,8 +100,8 @@
   set_default_collation(W3C_CODEPT_COLLATION_NS, QueryLoc::null);
 
   set_construction_mode(StaticContextConsts::cons_preserve);
-  set_inherit_mode(StaticContextConsts::inherit_ns);
-  set_preserve_mode(StaticContextConsts::preserve_ns);
+  set_inherit_ns(true);
+  set_preserve_ns(true);
 
   set_ordering_mode(StaticContextConsts::ordered);
 

=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp	2012-10-02 14:05:36 +0000
+++ src/context/static_context.cpp	2012-10-03 13:05:44 +0000
@@ -680,8 +680,8 @@
   theXQueryVersion(StaticContextConsts::xquery_version_unknown),
   theXPathCompatibility(StaticContextConsts::xpath_unknown),
   theConstructionMode(StaticContextConsts::cons_unknown),
-  theInheritMode(StaticContextConsts::inherit_unknown),
-  thePreserveMode(StaticContextConsts::preserve_unknown),
+  theInheritNamespaces(true),
+  thePreserveNamespaces(true),
   theOrderingMode(StaticContextConsts::ordering_unknown),
   theEmptyOrderMode(StaticContextConsts::empty_order_unknown),
   theBoundarySpaceMode(StaticContextConsts::boundary_space_unknown),
@@ -727,8 +727,8 @@
   theXQueryVersion(StaticContextConsts::xquery_version_unknown),
   theXPathCompatibility(StaticContextConsts::xpath_unknown),
   theConstructionMode(StaticContextConsts::cons_unknown),
-  theInheritMode(StaticContextConsts::inherit_unknown),
-  thePreserveMode(StaticContextConsts::preserve_unknown),
+  theInheritNamespaces(parent->theInheritNamespaces),
+  thePreserveNamespaces(parent->thePreserveNamespaces),
   theOrderingMode(StaticContextConsts::ordering_unknown),
   theEmptyOrderMode(StaticContextConsts::empty_order_unknown),
   theBoundarySpaceMode(StaticContextConsts::boundary_space_unknown),
@@ -779,8 +779,8 @@
   theXQueryVersion(StaticContextConsts::xquery_version_unknown),
   theXPathCompatibility(StaticContextConsts::xpath_unknown),
   theConstructionMode(StaticContextConsts::cons_unknown),
-  theInheritMode(StaticContextConsts::inherit_unknown),
-  thePreserveMode(StaticContextConsts::preserve_unknown),
+  theInheritNamespaces(true),
+  thePreserveNamespaces(true),
   theOrderingMode(StaticContextConsts::ordering_unknown),
   theEmptyOrderMode(StaticContextConsts::empty_order_unknown),
   theBoundarySpaceMode(StaticContextConsts::boundary_space_unknown),
@@ -1101,8 +1101,8 @@
   SERIALIZE_ENUM(StaticContextConsts::xquery_version_t, theXQueryVersion);
   SERIALIZE_ENUM(StaticContextConsts::xpath_compatibility_t, theXPathCompatibility);
   SERIALIZE_ENUM(StaticContextConsts::construction_mode_t, theConstructionMode);
-  SERIALIZE_ENUM(StaticContextConsts::inherit_mode_t, theInheritMode);
-  SERIALIZE_ENUM(StaticContextConsts::preserve_mode_t, thePreserveMode);
+  ar & theInheritNamespaces;
+  ar & thePreserveNamespaces;
   SERIALIZE_ENUM(StaticContextConsts::ordering_mode_t, theOrderingMode);
   SERIALIZE_ENUM(StaticContextConsts::empty_order_mode_t, theEmptyOrderMode);
   SERIALIZE_ENUM(StaticContextConsts::boundary_space_mode_t, theBoundarySpaceMode);
@@ -3756,58 +3756,36 @@
 /***************************************************************************//**
 
 ********************************************************************************/
-StaticContextConsts::inherit_mode_t static_context::inherit_mode() const
-{
-  const static_context* sctx = this;
-
-  while (sctx != NULL)
-  {
-    if (sctx->theInheritMode != StaticContextConsts::inherit_unknown)
-      return sctx->theInheritMode;
-
-    sctx = sctx->theParent;
-  }
-
-  ZORBA_ASSERT(false);
-  return StaticContextConsts::inherit_unknown;
-}
-
-
-/***************************************************************************//**
-
-********************************************************************************/
-void static_context::set_inherit_mode(StaticContextConsts::inherit_mode_t v)
-{
-  theInheritMode = v;
-}
-
-
-/***************************************************************************//**
-
-********************************************************************************/
-StaticContextConsts::preserve_mode_t static_context::preserve_mode() const
-{
-  const static_context* sctx = this;
-
-  while (sctx != NULL)
-  {
-    if (sctx->thePreserveMode != StaticContextConsts::preserve_unknown)
-      return sctx->thePreserveMode;
-
-    sctx = sctx->theParent;
-  }
-
-  ZORBA_ASSERT(false);
-  return StaticContextConsts::preserve_unknown;
-}
-
-
-/***************************************************************************//**
-
-********************************************************************************/
-void static_context::set_preserve_mode(StaticContextConsts::preserve_mode_t v)
-{
-  thePreserveMode = v;
+bool static_context::inherit_ns() const
+{
+  return theInheritNamespaces;
+}
+
+
+/***************************************************************************//**
+
+********************************************************************************/
+void static_context::set_inherit_ns(bool v)
+{
+  theInheritNamespaces = v;
+}
+
+
+/***************************************************************************//**
+
+********************************************************************************/
+bool static_context::preserve_ns() const
+{
+  return thePreserveNamespaces;
+}
+
+
+/***************************************************************************//**
+
+********************************************************************************/
+void static_context::set_preserve_ns(bool v)
+{
+  thePreserveNamespaces = v;
 }
 
 

=== modified file 'src/context/static_context.h'
--- src/context/static_context.h	2012-09-19 18:18:02 +0000
+++ src/context/static_context.h	2012-10-03 13:05:44 +0000
@@ -634,9 +634,9 @@
 
   StaticContextConsts::construction_mode_t   theConstructionMode;
 
-  StaticContextConsts::inherit_mode_t        theInheritMode;
+  bool                                       theInheritNamespaces;
 
-  StaticContextConsts::preserve_mode_t       thePreserveMode;
+  bool                                       thePreserveNamespaces;
 
   StaticContextConsts::ordering_mode_t       theOrderingMode;
 
@@ -1038,13 +1038,13 @@
 
   void set_construction_mode(StaticContextConsts::construction_mode_t v);
 
-  StaticContextConsts::inherit_mode_t inherit_mode() const;
-
-  void set_inherit_mode(StaticContextConsts::inherit_mode_t v);
-
-  StaticContextConsts::preserve_mode_t preserve_mode() const;
-
-  void set_preserve_mode(StaticContextConsts::preserve_mode_t v);
+  bool inherit_ns() const;
+
+  void set_inherit_ns(bool v);
+
+  bool preserve_ns() const;
+
+  void set_preserve_ns(bool);
 
   StaticContextConsts::ordering_mode_t ordering_mode() const;
 

=== modified file 'src/context/static_context_consts.h'
--- src/context/static_context_consts.h	2012-09-17 00:36:37 +0000
+++ src/context/static_context_consts.h	2012-10-03 13:05:44 +0000
@@ -50,20 +50,6 @@
     cons_strip
   };
 
-  enum inherit_mode_t
-  {
-    inherit_unknown,
-    inherit_ns,
-    no_inherit_ns
-  };
-
-  enum preserve_mode_t
-  { 
-    preserve_unknown,
-    preserve_ns,
-    no_preserve_ns
-  };
-
   enum ordering_mode_t
   {
     ordering_unknown,

=== modified file 'src/functions/func_jsoniq_functions_impl.cpp'
--- src/functions/func_jsoniq_functions_impl.cpp	2012-09-25 15:03:46 +0000
+++ src/functions/func_jsoniq_functions_impl.cpp	2012-10-03 13:05:44 +0000
@@ -42,7 +42,7 @@
   static_context* sctx = fo->get_sctx();
 
   if (producer == 2 &&
-      (sctx->preserve_mode() != StaticContextConsts::no_preserve_ns ||
+      (sctx->preserve_ns() ||
        sctx->construction_mode() != StaticContextConsts::cons_preserve))
   {
     return true;
@@ -57,8 +57,7 @@
 ********************************************************************************/
 bool op_zorba_json_object_insert::mustCopyInputNodes(expr* fo, csize producer) const
 {
-  if (producer == 2 &&
-      fo->get_sctx()->preserve_mode() != StaticContextConsts::no_preserve_ns)
+  if (producer == 2 && fo->get_sctx()->preserve_ns())
   {
     return true;
   }
@@ -75,7 +74,7 @@
   static_context* sctx = fo->get_sctx();
 
   if (producer == 2 &&
-      (sctx->preserve_mode() != StaticContextConsts::no_preserve_ns ||
+      (sctx->preserve_ns() ||
        sctx->construction_mode() != StaticContextConsts::cons_preserve))
   {
     return true;
@@ -107,7 +106,7 @@
   static_context* sctx = fo->get_sctx();
 
   if (producer == 2 &&
-      (sctx->preserve_mode() != StaticContextConsts::no_preserve_ns ||
+      (sctx->preserve_ns() ||
        sctx->construction_mode() != StaticContextConsts::cons_preserve))
   {
     return true;

=== modified file 'src/functions/func_nodes_impl.cpp'
--- src/functions/func_nodes_impl.cpp	2012-09-12 16:26:03 +0000
+++ src/functions/func_nodes_impl.cpp	2012-10-03 13:05:44 +0000
@@ -47,8 +47,8 @@
 {
   static_context* lSctx = fo->get_sctx();
   return
-    lSctx->preserve_mode() == StaticContextConsts::no_preserve_ns ||
-    lSctx->construction_mode() == StaticContextConsts::cons_strip;
+    (lSctx->preserve_ns() == false ||
+     lSctx->construction_mode() == StaticContextConsts::cons_strip);
 }
  
 } /* namespace zorba */

=== modified file 'src/runtime/collections/collections_base.cpp'
--- src/runtime/collections/collections_base.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/collections/collections_base.cpp	2012-10-03 13:05:44 +0000
@@ -52,8 +52,8 @@
 {
   copyMode.set(true, 
                sctx->construction_mode() == StaticContextConsts::cons_preserve,
-               sctx->preserve_mode() == StaticContextConsts::preserve_ns,
-               sctx->inherit_mode() == StaticContextConsts::inherit_ns);
+               sctx->preserve_ns(),
+               sctx->inherit_ns());
 }
 
 } /* namespace zorba */

=== modified file 'src/runtime/core/apply_updates.cpp'
--- src/runtime/core/apply_updates.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/core/apply_updates.cpp	2012-10-03 13:05:44 +0000
@@ -199,7 +199,7 @@
     // Apply updates
     pul->setValidator(&validator);
     pul->setICChecker(&icChecker);
-    bool inherit = (sctx->inherit_mode() == StaticContextConsts::inherit_ns);
+    bool inherit = sctx->inherit_ns();
     pul->applyUpdates(inherit);
 
     // Rebuild the indices that must be rebuilt from scratch

=== modified file 'src/runtime/core/constructors.cpp'
--- src/runtime/core/constructors.cpp	2012-09-28 07:26:34 +0000
+++ src/runtime/core/constructors.cpp	2012-10-03 13:05:44 +0000
@@ -102,11 +102,9 @@
   theTypePreserve =
     (theSctx->construction_mode() == StaticContextConsts::cons_preserve ? true : false);
 
-  theNsPreserve =
-    (theSctx->preserve_mode() == StaticContextConsts::preserve_ns ? true : false);
+  theNsPreserve = theSctx->preserve_ns();
 
-  theNsInherit =
-    (theSctx->inherit_mode() == StaticContextConsts::inherit_ns ? true : false);
+  theNsInherit = theSctx->inherit_ns();
 }
 
 
@@ -293,11 +291,9 @@
   theTypePreserve =
     (theSctx->construction_mode() == StaticContextConsts::cons_preserve ? true : false);
 
-  theNsPreserve =
-    (theSctx->preserve_mode() == StaticContextConsts::preserve_ns ? true : false);
+  theNsPreserve = theSctx->preserve_ns();
 
-  theNsInherit =
-    (theSctx->inherit_mode() == StaticContextConsts::inherit_ns ? true : false);
+  theNsInherit = theSctx->inherit_ns();
 }
 
 

=== modified file 'src/runtime/introspection/sctx_impl.cpp'
--- src/runtime/introspection/sctx_impl.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/introspection/sctx_impl.cpp	2012-10-03 13:05:44 +0000
@@ -435,12 +435,12 @@
   PlanIteratorState* state;
   zstring inherit, preserve;
 
-  if (theSctx->inherit_mode() == StaticContextConsts::inherit_ns)
+  if (theSctx->inherit_ns())
     inherit = "inherit";
   else
     inherit = "no-inherit";
 
-  if (theSctx->preserve_mode() == StaticContextConsts::preserve_ns)
+  if (theSctx->preserve_ns())
     preserve = "preserve";
   else
     preserve = "no-preserve";

=== modified file 'src/runtime/json/json_constructors.cpp'
--- src/runtime/json/json_constructors.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/json/json_constructors.cpp	2012-10-03 13:05:44 +0000
@@ -296,7 +296,7 @@
     store::CopyMode copymode;
     copymode.set(true,
                  (theSctx->construction_mode() == StaticContextConsts::cons_preserve),
-                 (theSctx->preserve_mode() == StaticContextConsts::preserve_ns),
+                 theSctx->preserve_ns(),
                  true);
 
     for (csize i = 0; i < numPairs; ++i)

=== modified file 'src/runtime/json/jsoniq_functions_impl.cpp'
--- src/runtime/json/jsoniq_functions_impl.cpp	2012-09-27 05:38:32 +0000
+++ src/runtime/json/jsoniq_functions_impl.cpp	2012-10-03 13:05:44 +0000
@@ -1254,8 +1254,9 @@
 
   copymode.set(true,
                theSctx->construction_mode() == StaticContextConsts::cons_preserve,
-               theSctx->preserve_mode() == StaticContextConsts::preserve_ns,
-               theSctx->inherit_mode() == StaticContextConsts::inherit_ns);
+               theSctx->preserve_ns(),
+               theSctx->inherit_ns());
+
   if (content->isNode() || content->isJSONItem())
   {
     content = content->copy(NULL, copymode);
@@ -1298,8 +1299,8 @@
 
   copymode.set(true, 
                theSctx->construction_mode() == StaticContextConsts::cons_preserve,
-               theSctx->preserve_mode() == StaticContextConsts::preserve_ns,
-               theSctx->inherit_mode() == StaticContextConsts::inherit_ns);
+               theSctx->preserve_ns(),
+               theSctx->inherit_ns());
 
   while (consumeNext(member, theChildren[2].getp(), planState))
   {
@@ -1346,8 +1347,8 @@
 
   copymode.set(true, 
                theSctx->construction_mode() == StaticContextConsts::cons_preserve,
-               theSctx->preserve_mode() == StaticContextConsts::preserve_ns,
-               theSctx->inherit_mode() == StaticContextConsts::inherit_ns);
+               theSctx->preserve_ns(),
+               theSctx->inherit_ns());
 
   while (consumeNext(member, theChildren[1].getp(), planState))
   {
@@ -1479,9 +1480,9 @@
   if (theCopyInput && (newValue->isNode() || newValue->isJSONItem()))
   {
     copymode.set(true, 
-      theSctx->construction_mode() == StaticContextConsts::cons_preserve,
-      theSctx->preserve_mode() == StaticContextConsts::preserve_ns,
-      theSctx->inherit_mode() == StaticContextConsts::inherit_ns);
+                 theSctx->construction_mode() == StaticContextConsts::cons_preserve,
+                 theSctx->preserve_ns(),
+                 theSctx->inherit_ns());
 
     newValue = newValue->copy(NULL, copymode);
   }

=== modified file 'src/runtime/nodes/nodes_impl.cpp'
--- src/runtime/nodes/nodes_impl.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/nodes/nodes_impl.cpp	2012-10-03 13:05:44 +0000
@@ -801,9 +801,9 @@
   store::Item_t lItem;
   store::CopyMode lCopyMode;
   lCopyMode.set(true, 
-    theSctx->construction_mode() == StaticContextConsts::cons_preserve,
-    theSctx->preserve_mode() == StaticContextConsts::preserve_ns,
-    theSctx->inherit_mode() == StaticContextConsts::inherit_ns);
+                theSctx->construction_mode() == StaticContextConsts::cons_preserve,
+                theSctx->preserve_ns(),
+                theSctx->inherit_ns());
 
   PlanIteratorState *state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

=== modified file 'src/runtime/update/update.cpp'
--- src/runtime/update/update.cpp	2012-09-17 00:36:37 +0000
+++ src/runtime/update/update.cpp	2012-10-03 13:05:44 +0000
@@ -136,10 +136,8 @@
 
   typePreserve = (theSctx->construction_mode() == StaticContextConsts::cons_preserve ?
                   true : false);
-  nsPreserve = (theSctx->preserve_mode() == StaticContextConsts::preserve_ns ?
-                true : false);
-  nsInherit = (theSctx->inherit_mode() == StaticContextConsts::inherit_ns ?
-               true : false);
+  nsPreserve = theSctx->preserve_ns();
+  nsInherit = theSctx->inherit_ns();
 
   lCopyMode.set(theDoCopy, typePreserve, nsPreserve, nsInherit);
   
@@ -395,10 +393,8 @@
   
   typePreserve = (theSctx->construction_mode() == StaticContextConsts::cons_preserve ?
                   true : false);
-  nsPreserve = (theSctx->preserve_mode() == StaticContextConsts::preserve_ns ?
-                true : false);
-  nsInherit = (theSctx->inherit_mode() == StaticContextConsts::inherit_ns ?
-               true : false);
+  nsPreserve = theSctx->preserve_ns();
+  nsInherit = theSctx->inherit_ns();
 
   lCopyMode.set(theDoCopy, typePreserve, nsPreserve, nsInherit);
 
@@ -684,8 +680,7 @@
 
   if (!consumeNext(lNewname, theChild1, aPlanState))
   {
-    throw XQUERY_EXCEPTION(
-      err::XPTY0004,
+    throw XQUERY_EXCEPTION(err::XPTY0004,
       ERROR_PARAMS( ZED( EmptySeqNoCastToQName ) ),
       ERROR_LOC( loc )
     );
@@ -693,8 +688,7 @@
 
   if (consumeNext(temp, theChild1, aPlanState))
   {
-    throw XQUERY_EXCEPTION(
-      err::XPTY0004,
+    throw XQUERY_EXCEPTION(err::XPTY0004,
       ERROR_PARAMS( ZED( SeqNoCastToQName ) ),
       ERROR_LOC( loc )
     );
@@ -839,10 +833,8 @@
 
   typePreserve = (theSctx->construction_mode() == StaticContextConsts::cons_preserve ?
                   true : false);
-  nsPreserve = (theSctx->preserve_mode() == StaticContextConsts::preserve_ns ?
-                true : false);
-  nsInherit = (theSctx->inherit_mode() == StaticContextConsts::inherit_ns ?
-               true : false);
+  nsPreserve = theSctx->preserve_ns();
+  nsInherit = theSctx->inherit_ns();
 
   copymode.set(true, typePreserve, nsPreserve, nsInherit);
 

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