← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~paul-lucas/zorba/pjl-misc into lp:zorba

 

Paul J. Lucas has proposed merging lp:~paul-lucas/zorba/pjl-misc into lp:zorba.

Commit message:
Added functions that take "location" as an argument.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/148031

Added functions that take "location" as an argument.
-- 
https://code.launchpad.net/~paul-lucas/zorba/pjl-misc/+merge/148031
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/diagnostics/xquery_exception.h'
--- src/diagnostics/xquery_exception.h	2013-02-07 02:58:15 +0000
+++ src/diagnostics/xquery_exception.h	2013-02-12 19:18:22 +0000
@@ -187,6 +187,30 @@
  * actually an XQueryException.
  *
  * @param ze The ZorbaException to set the location of.
+ * @param loc The location.
+ * @param overwrite If \c false, sets the location only if the exception
+ * doesn't already have one; if \c true, always sets the location even if the
+ * exception already has one.
+ */
+inline void set_source( ZorbaException &ze,
+                        internal::diagnostic::location const &loc,
+                        bool overwrite = true ) {
+  set_source(
+    ze,
+    loc.file(),
+    loc.line(),
+    loc.column(),
+    loc.line_end(),
+    loc.column_end(),
+    overwrite
+  );
+}
+
+/**
+ * Sets the XQuery source location of the given ZorbaException but only if it's
+ * actually an XQueryException.
+ *
+ * @param ze The ZorbaException to set the location of.
  * @param loc The query location.
  * @param overwrite If \c false, sets the location only if the exception
  * doesn't already have one; if \c true, always sets the location even if the
@@ -291,6 +315,32 @@
  * it.
  *
  * @param ze The ZorbaException to set the location of.
+ * @param loc The location.
+ * @param overwrite If \c false, sets the location only if the exception
+ * doesn't already have one; if \c true, always sets the location even if the
+ * exception already has one.
+ */
+inline void set_data( ZorbaException &ze,
+                      internal::diagnostic::location const &loc,
+                      bool overwrite = true ) {
+  set_data(
+    ze,
+    loc.file(),
+    loc.line(),
+    loc.column(),
+    loc.line_end(),
+    loc.column_end(),
+    overwrite
+  );
+}
+
+/**
+ * Sets the data location of the given ZorbaException but only if it's actually
+ * an XQueryException.  If it's actually a ZorbaException, constructs a new
+ * XQueryException (copying the information from the ZorbaException) and throws
+ * it.
+ *
+ * @param ze The ZorbaException to set the location of.
  * @param loc The query location.
  * @param overwrite If \c false, sets the location only if the exception
  * doesn't already have one; if \c true, always sets the location even if the
@@ -397,6 +447,32 @@
  * ZorbaException) and throws it.
  *
  * @param ze The ZorbaException to set the location of.
+ * @param loc The location.
+ * @param overwrite If \c false, sets the location only if the exception
+ * doesn't already have one; if \c true, always sets the location even if the
+ * exception already has one.
+ */
+inline void set_applied( ZorbaException &ze,
+                         internal::diagnostic::location const &loc,
+                         bool overwrite = true ) {
+  set_applied(
+    ze,
+    loc.file(),
+    loc.line(),
+    loc.column(),
+    loc.line_end(),
+    loc.column_end(),
+    overwrite
+  );
+}
+
+/**
+ * Sets the XQuery "applied at" location of the given ZorbaException but only
+ * if it's actually an XQueryException.  If it's actually a ZorbaException,
+ * constructs a new XQueryException (copying the information from the
+ * ZorbaException) and throws it.
+ *
+ * @param ze The ZorbaException to set the location of.
  * @param loc The query location.
  * @param overwrite If \c false, sets the location only if the exception
  * doesn't already have one; if \c true, always sets the location even if the

=== modified file 'src/runtime/json/common.cpp'
--- src/runtime/json/common.cpp	2013-02-07 03:44:12 +0000
+++ src/runtime/json/common.cpp	2013-02-12 19:18:22 +0000
@@ -18,7 +18,6 @@
 #include <zorba/xquery_exception.h>
 
 #include "store/api/iterator.h"
-#include "util/json_parser.h"
 
 #include "common.h"
 
@@ -45,13 +44,6 @@
   return found;
 }
 
-void set_data( XQueryException *xe, json::exception const &je ) {
-  json::location const &loc( je.get_loc() );
-  xe->set_data(
-    loc.file(), loc.line(), loc.column(), loc.line_end(), loc.column_end()
-  );
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 
 #if ZORBA_DEBUG_JSON

=== modified file 'src/runtime/json/common.h'
--- src/runtime/json/common.h	2013-02-07 03:44:12 +0000
+++ src/runtime/json/common.h	2013-02-12 19:18:22 +0000
@@ -20,9 +20,11 @@
 #include <iostream>
 #include <stack>
 
+#include "diagnostics/xquery_exception.h"
 #include "store/api/item.h"
 #include "store/api/item_factory.h"
 #include "util/indent.h"
+#include "util/json_parser.h"
 #include "util/omanip.h"
 #include "zorbatypes/zstring.h"
 
@@ -59,7 +61,9 @@
 bool get_attribute_value( store::Item_t const &element, char const *att_name,
                           zstring *att_value );
 
-void set_data( XQueryException*, json::exception const& );
+inline void set_data( XQueryException *xe, json::exception const &je ) {
+  set_data( *xe, je.get_loc() );
+}
 
 typedef std::ostream& (*std_omanip_type)(std::ostream&);
 


Follow ups