Author: brane
Date: Tue Jun 11 11:31:05 2013
New Revision: 1491748

URL: http://svn.apache.org/r1491748
Log:
Massively change coding style in C++HL, using CamelCase for classes,
and restructuring namespaces; seasoned with functional changes in the
same commit for greater `svn blame` notoriety.

Item: Namespace changed from: subversion::cxxhl::version_1_9_dev
                          to: apache::subversion::
      Rationale: Namespace-based versioning doesn't really work in C ++.

Item: All class names changed from this_format to ThisFormat.
      Rationale: Easier to distinguish between classes and functions/methods.

Item: Namespace alias svn:: renamed to SVN::
      Rationale: Looks better with CamelCase class names.

Item: Imported weak_ptr<> and enable_shared_from_this into the compat namespace.
      Rationale: More smart pointer sanity.

Functional changes:
* subversion/bindings/cxxhl/src/exception.cpp (Error::throw_svn_error):
   Throw a Cancelled exception if SVN_ERR_CANCELLED appears anywhere in
   the error stack, not just at the top (because, realistically, it's
   more likely to be at the bottom of the stack).
 (<anonymous>::handle_one_error): Show symbolic error names in debug mode.

* subversion/bindings/cxxhl/tests/test_exception.cpp: Adjust the tests
   for the changed cancellation signalling semantics and compare trace
   output with the results of svn_handle_error2.

Modified:
    subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl.hpp
    subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/_compat.hpp
    subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp
    subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/tristate.hpp
    subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp
    subversion/trunk/subversion/bindings/cxxhl/src/tristate.cpp
    subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp

Modified: subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl.hpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl.hpp?rev=1491748&r1=1491747&r2=1491748&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl.hpp (original)
+++ subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl.hpp Tue Jun 11 
11:31:05 2013
@@ -32,6 +32,6 @@
 #include "svncxxhl/exception.hpp"
 #include "svncxxhl/tristate.hpp"
 
-namespace svn = ::subversion::cxxhl::version_1_9_dev;
+namespace SVN = ::apache::subversion::cxxhl;
 
 #endif  // SVN_CXXHL_HPP

Modified: 
subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/_compat.hpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/_compat.hpp?rev=1491748&r1=1491747&r2=1491748&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/_compat.hpp 
(original)
+++ subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/_compat.hpp Tue 
Jun 11 11:31:05 2013
@@ -28,64 +28,76 @@
 #ifndef SVN_CXXHL_COMPAT_HPP
 #define SVN_CXXHL_COMPAT_HPP
 
-// Configuration test: std::shared_ptr<>
+// Configuration test: std::shared_ptr<> and friends
 // Currently detects: clang++, g++, msvc-2010+
-#ifndef SVN_CXXHL_HAVE_STD_SHARED_PTR
+#ifndef SVN_CXXHL_HAVE_STD_SMART_PTRS
 #  if   (defined(__clang__) && __cplusplus >= 201103L) \
      || (defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)) \
      || (defined(_MSC_VER) && _MSC_VER >= 1600)
-#    define SVN_CXXHL_HAVE_STD_SHARED_PTR
+#    define SVN_CXXHL_HAVE_STD_SMART_PTRS
 #  endif  // config test: std::shared_ptr<>
-#endif  // SVN_CXXHL_HAVE_STD_SHARED_PTR
+#endif  // SVN_CXXHL_HAVE_STD_SMART_PTRS
 
-// Configuration test: std::tr1::shared_ptr<>
+// Configuration test: std::tr1::shared_ptr<> and friends
 // Currently detects: clang++, g++
-#ifndef SVN_CXXHL_HAVE_STD_SHARED_PTR
-#  ifndef SVN_CXXHL_HAVE_STD_TR1_SHARED_PTR
+#ifndef SVN_CXXHL_HAVE_STD_SMART_PTRS
+#  ifndef SVN_CXXHL_HAVE_STD_TR1_SMART_PTRS
 #    if   defined(__GNUC__) \
        && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1)
-#      define SVN_CXXHL_HAVE_STD_TR1_SHARED_PTR
+#      define SVN_CXXHL_HAVE_STD_TR1_SMART_PTRS
 #    endif  // config test: std::tr1::shared_ptr<>
-#  endif  // SVN_CXXHL_HAVE_STD_TR1_SHARED_PTR
-#endif  // SVN_CXXHL_HAVE_STD_SHARED_PTR
+#  endif  // SVN_CXXHL_HAVE_STD_TR1_SMART_PTRS
+#endif  // SVN_CXXHL_HAVE_STD_SMART_PTRS
 
 
-#if defined(SVN_CXXHL_HAVE_STD_SHARED_PTR)
+#if defined(SVN_CXXHL_HAVE_STD_SMART_PTRS)
 
 #include <memory>
+namespace apache {
 namespace subversion {
 namespace cxxhl {
 namespace compat {
+using std::weak_ptr;
 using std::shared_ptr;
+using std::enable_shared_from_this;
 } // namespace compat
 } // namespace cxxhl
 } // namespace subversion
+} // namespace apache
 
-#elif defined(SVN_CXXHL_HAVE_STD_TR1_SHARED_PTR)
+#elif defined(SVN_CXXHL_HAVE_STD_TR1_SMART_PTRS)
 
 #include <tr1/memory>
+namespace apache {
 namespace subversion {
 namespace cxxhl {
 namespace compat {
+using std::tr1::weak_ptr;
 using std::tr1::shared_ptr;
+using std::tr1::enable_shared_from_this;
 } // namespace compat
 } // namespace cxxhl
 } // namespace subversion
+} // namespace apache
 
 #else
-// We need shared_ptr<> from somewhere. If we cannot find it in ::std
-// given known compiler characteristics, then try boost as a last
-// resort.
+// We need smart pointers from somewhere. If we cannot find them in
+// ::std given known compiler characteristics, then try Boost as a
+// last resort.
 
 #include <boost/shared_ptr.hpp>
+namespace apache {
 namespace subversion {
 namespace cxxhl {
 namespace compat {
+using boost::weak_ptr;
 using boost::shared_ptr;
+using boost::enable_shared_from_this;
 } // namespace compat
 } // namespace cxxhl
 } // namespace subversion
+} // namespace apache
 
-#endif  // SVN_CXXHL_HAVE_STD_SHARED_PTR
+#endif  // SVN_CXXHL_HAVE_STD_SMART_PTRS
 
 #endif  // SVN_CXXHL_COMPAT_HPP

Modified: 
subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp?rev=1491748&r1=1491747&r2=1491748&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp 
(original)
+++ subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/exception.hpp 
Tue Jun 11 11:31:05 2013
@@ -38,6 +38,7 @@
 // Forward declaration of implementation-specific structure
 struct svn_error_t;
 
+namespace apache {
 namespace subversion {
 namespace cxxhl {
 
@@ -45,22 +46,20 @@ namespace compat {} // Announce the comp
 
 namespace detail {
 // Forward declaration of implementation-specific structure
-class error_description;
+class ErrorDescription;
 } // namespace detail
 
-namespace version_1_9_dev {
-
-class error : public std::exception
+class Error : public std::exception
 {
 public:
-  typedef compat::shared_ptr<error> shared_ptr;
+  typedef compat::shared_ptr<Error> shared_ptr;
 
-  error(const char* description, int error_code);
-  error(const char* description, int error_code, shared_ptr nested_error);
+  Error(const char* description, int error_code);
+  Error(const char* description, int error_code, shared_ptr nested_error);
 
-  error(const error& that) throw();
-  error& operator=(const error& that) throw();
-  virtual ~error() throw();
+  Error(const Error& that) throw();
+  Error& operator=(const Error& that) throw();
+  virtual ~Error() throw();
 
   /**
    * Returns the error code associated with the exception.
@@ -83,18 +82,18 @@ public:
    * describes the location in the source code where the error was
    * generated from.
    */
-  typedef std::pair<int, std::string> message;
+  typedef std::pair<int, std::string> Message;
 
   /**
    * The list of messages associated with an error.
    */
-  typedef std::vector<message> message_list;
+  typedef std::vector<Message> MessageList;
 
   /**
    * Returns the complete list of error messages, including those from
    * nested exceptions.
    */
-  virtual message_list messages() const
+  virtual MessageList messages() const
     {
       return compile_messages(false);
     }
@@ -106,7 +105,7 @@ public:
    * Traceback is only available if the Subversion libraries were
    * compiled with tracing enabled.
    */
-  virtual message_list traced_messages() const
+  virtual MessageList traced_messages() const
     {
       return compile_messages(true);
     }
@@ -116,29 +115,29 @@ public:
   static void throw_svn_error(svn_error_t*);
 
 protected:
-  error(int error_code, detail::error_description* description) throw();
+  Error(int error_code, detail::ErrorDescription* description) throw();
 
 private:
-  std::vector<message> compile_messages(bool show_traces) const;
+  MessageList compile_messages(bool show_traces) const;
 
   int m_errno;                /**< The (SVN or APR) error code. */
   shared_ptr m_nested;        /**< Optional pointer to nessted error. */
   /** Error description and trace location information. */
-  detail::error_description* m_description;
+  detail::ErrorDescription* m_description;
 };
 
-class cancelled : public error
+class Cancelled : public Error
 {
-  friend void error::throw_svn_error(svn_error_t*);
+  friend void Error::throw_svn_error(svn_error_t*);
 
 protected:
-  cancelled(int error_code, detail::error_description* description) throw()
-    : error(error_code, description)
+  Cancelled(int error_code, detail::ErrorDescription* description) throw()
+    : Error(error_code, description)
     {}
 };
 
-} // namespace version_1_9_dev
 } // namespace cxxhl
 } // namespace subversion
+} // namespace apache
 
 #endif  // SVN_CXXHL_EXCEPTION_HPP

Modified: 
subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/tristate.hpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/tristate.hpp?rev=1491748&r1=1491747&r2=1491748&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/tristate.hpp 
(original)
+++ subversion/trunk/subversion/bindings/cxxhl/include/svncxxhl/tristate.hpp 
Tue Jun 11 11:31:05 2013
@@ -28,37 +28,37 @@
 #ifndef SVN_CXXHL_TRISTATE_HPP
 #define SVN_CXXHL_TRISTATE_HPP
 
+namespace apache {
 namespace subversion {
 namespace cxxhl {
-namespace version_1_9_dev {
 
-class tristate
+class Tristate
 {
 public:
-  static const tristate TRUE;
-  static const tristate FALSE;
-  static const tristate UNKNOWN;
+  static const Tristate TRUE;
+  static const Tristate FALSE;
+  static const Tristate UNKNOWN;
 
-  tristate(const tristate& that) throw()
+  Tristate(const Tristate& that) throw()
     : m_value(that.m_value)
     {}
 
-  bool operator==(const tristate& that) const throw()
+  bool operator==(const Tristate& that) const throw()
     { return m_value == that.m_value; }
 
-  bool operator!=(const tristate& that) const throw()
+  bool operator!=(const Tristate& that) const throw()
     { return !(*this == that); }
 
   bool known() const throw()
     { return *this != UNKNOWN; }
 
 private:
-  explicit tristate(short int value) throw();
+  explicit Tristate(short int value) throw();
   short int m_value;
 };
 
-} // namespace version_1_9_dev
 } // namespace cxxhl
 } // namespace subversion
+} // namespace apache
 
 #endif  // SVN_CXXHL_TRISTATE_HPP

Modified: subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp?rev=1491748&r1=1491747&r2=1491748&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp (original)
+++ subversion/trunk/subversion/bindings/cxxhl/src/exception.cpp Tue Jun 11 
11:31:05 2013
@@ -37,23 +37,24 @@
 #undef TRUE
 #undef FALSE
 
+namespace apache {
 namespace subversion {
 namespace cxxhl {
 
 namespace detail {
 
-class error_description
+class ErrorDescription
 {
 public:
-  static error_description* create(const char* message,
-                                   const char *loc_file, long loc_line,
-                                   bool trace_link)
+  static ErrorDescription* create(const char* message,
+                                  const char *loc_file, long loc_line,
+                                  bool trace_link)
     {
       bool empty_message = (message == NULL);
       const std::size_t length = (empty_message ? 0 : std::strlen(message));
-      void *memblock = ::operator new(length + sizeof(error_description));
+      void *memblock = ::operator new(length + sizeof(ErrorDescription));
 
-      error_description* description = new(memblock) error_description(
+      ErrorDescription* description = new(memblock) ErrorDescription(
           loc_file, loc_line, trace_link, empty_message);
       if (length)
         std::memcpy(description->m_message, message, length);
@@ -61,23 +62,23 @@ public:
       return description;
     }
 
-  static error_description* create(const char* message)
+  static ErrorDescription* create(const char* message)
     {
       return create(message, NULL, 0, false);
     }
 
-  error_description* reference() throw()
+  ErrorDescription* reference() throw()
     {
       if (this)
         svn_atomic_inc(&m_refcount);
       return this;
     }
 
-  error_description* dereference() throw()
+  ErrorDescription* dereference() throw()
     {
       if (this && 0 == svn_atomic_dec(&m_refcount))
         {
-          this->~error_description();
+          this->~ErrorDescription();
           ::operator delete(this, std::nothrow);
           return NULL;
         }
@@ -90,8 +91,8 @@ public:
   bool trace() const throw() { return m_trace; }
 
 private:
-  error_description(const char *loc_file, long loc_line,
-                    bool trace_link, bool empty_message) throw()
+  ErrorDescription(const char *loc_file, long loc_line,
+                   bool trace_link, bool empty_message) throw()
     : m_loc_file(loc_file),
       m_loc_line(loc_line),
       m_trace(trace_link),
@@ -99,7 +100,7 @@ private:
       m_refcount(0)
     {}
 
-  ~error_description() throw() {}
+  ~ErrorDescription() throw() {}
 
   const char* m_loc_file;
   long m_loc_line;
@@ -113,27 +114,25 @@ private:
 } // namespace detail
 
 
-namespace version_1_9_dev {
-
-error::error(const char* description, int error_code)
+Error::Error(const char* description, int error_code)
   : m_errno(error_code),
-    m_description(detail::error_description::create(description)->reference())
+    m_description(detail::ErrorDescription::create(description)->reference())
 {}
 
-error::error(const char* description, int error_code,
-             error::shared_ptr nested_error)
+Error::Error(const char* description, int error_code,
+             Error::shared_ptr nested_error)
   : m_errno(error_code),
     m_nested(nested_error),
-    m_description(detail::error_description::create(description)->reference())
+    m_description(detail::ErrorDescription::create(description)->reference())
 {}
 
-error::error(const error& that) throw()
+Error::Error(const Error& that) throw()
   : m_errno(that.m_errno),
     m_nested(that.m_nested),
     m_description(that.m_description->reference())
 {}
 
-error& error::operator=(const error& that) throw()
+Error& Error::operator=(const Error& that) throw()
 {
   if (this == &that)
     return *this;
@@ -141,29 +140,28 @@ error& error::operator=(const error& tha
   // This in-place destroy+copy implementation of the assignment
   // operator is safe because both the destructor and the copy
   // constructor do not throw exceptions.
-  this->~error();
-  return *new(this) error(that);
+  this->~Error();
+  return *new(this) Error(that);
 }
 
-error::~error() throw()
+Error::~Error() throw()
 {
   m_description->dereference();
 }
 
-const char* error::what() const throw()
+const char* Error::what() const throw()
 {
   return m_description->what();
 }
 
-error::error(int error_code, detail::error_description* description) throw()
+Error::Error(int error_code, detail::ErrorDescription* description) throw()
   : m_errno(error_code),
     m_description(description)
 {}
 
-void error::throw_svn_error(svn_error_t* err)
+void Error::throw_svn_error(svn_error_t* err)
 {
-  const bool throw_cancelled = (err->apr_err == SVN_ERR_CANCELLED);
-  detail::error_description* description = NULL;
+  detail::ErrorDescription* description = NULL;
   try
     {
       // Be very careful when creating the error descriptions, so that
@@ -174,33 +172,36 @@ void error::throw_svn_error(svn_error_t*
       shared_ptr nested;
       shared_ptr* current = &nested;
 
+      bool cancelled = (err->apr_err == SVN_ERR_CANCELLED);
       for (svn_error_t* next = err->child; next; next = next->child)
         {
-          description = detail::error_description::create(
+          description = detail::ErrorDescription::create(
               next->message, next->file, next->line,
               svn_error__is_tracing_link(next));
           description->reference();
-          current->reset(new error(next->apr_err, description));
+          current->reset(new Error(next->apr_err, description));
           description = NULL;
           current = &(*current)->m_nested;
+          if (next->apr_err == SVN_ERR_CANCELLED)
+            cancelled = true;
         }
 
       const int apr_err = err->apr_err;
-      description = detail::error_description::create(
+      description = detail::ErrorDescription::create(
           err->message, err->file, err->line,
           svn_error__is_tracing_link(err));
       description->reference();
       svn_error_clear(err);
-      if (throw_cancelled)
+      if (cancelled)
         {
-          cancelled converted = cancelled(apr_err, description);
+          Cancelled converted = Cancelled(apr_err, description);
           description = NULL;
           converted.m_nested = nested;
           throw converted;
         }
       else
         {
-          error converted = error(apr_err, description);
+          Error converted = Error(apr_err, description);
           description = NULL;
           converted.m_nested = nested;
           throw converted;
@@ -215,8 +216,8 @@ void error::throw_svn_error(svn_error_t*
 
 
 namespace {
-void handle_one_error(error::message_list& ml, bool show_traces,
-                      int error_code, detail::error_description* descr,
+void handle_one_error(Error::MessageList& ml, bool show_traces,
+                      int error_code, detail::ErrorDescription* descr,
                       apr_pool_t* pool)
 {
   if (show_traces && descr->file())
@@ -234,8 +235,20 @@ void handle_one_error(error::message_lis
         buffer << file_utf8 << ':' << descr->line();
       else
         buffer << "svn:<undefined>";
-      buffer << ": (apr_err=" << error_code << ')';
-      ml.push_back(error::message(0, buffer.str()));
+      if (descr->trace())
+        buffer << ',';
+      else
+        {
+#ifdef SVN_DEBUG
+          if (const char *const symbolic_name =
+              svn_error_symbolic_name(error_code))
+            //if (symbolic_name)
+            buffer << ": (apr_err=" << symbolic_name << ')';
+          else
+#endif
+            buffer << ": (apr_err=" << error_code << ')';
+        }
+      ml.push_back(Error::Message(0, buffer.str()));
     }
 
   if (descr->trace())
@@ -264,22 +277,22 @@ void handle_one_error(error::message_lis
             }
         }
     }
-  ml.push_back(error::message(error_code, std::string(description)));
+  ml.push_back(Error::Message(error_code, std::string(description)));
 }
 } // anonymous namespace
 
-error::message_list error::compile_messages(bool show_traces) const
+Error::MessageList Error::compile_messages(bool show_traces) const
 {
   // Determine the maximum size of the returned list
-  message_list::size_type max_length = 0;
-  for (const error* err = this; err; err = err->m_nested.get())
+  MessageList::size_type max_length = 0;
+  for (const Error* err = this; err; err = err->m_nested.get())
     {
       if (show_traces && m_description->file())
         ++max_length;                   // We will display an error location
       if (!m_description->trace())
         ++max_length;                   // Traces do not emit a message line
     }
-  message_list ml;
+  MessageList ml;
   ml.reserve(max_length);
 
   // This vector holds a list of all error codes that we've printed
@@ -291,7 +304,7 @@ error::message_list error::compile_messa
   apr_pool_create(&pool, NULL);
   try
     {
-      for (const error* err = this; err; err = err->m_nested.get())
+      for (const Error* err = this; err; err = err->m_nested.get())
         {
           if (!err->m_description->what())
             {
@@ -317,6 +330,6 @@ error::message_list error::compile_messa
   return ml;
 }
 
-} // namespace version_1_9_dev
 } // namespace cxxhl
 } // namespace subversion
+} // namespace apache

Modified: subversion/trunk/subversion/bindings/cxxhl/src/tristate.cpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/src/tristate.cpp?rev=1491748&r1=1491747&r2=1491748&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/src/tristate.cpp (original)
+++ subversion/trunk/subversion/bindings/cxxhl/src/tristate.cpp Tue Jun 11 
11:31:05 2013
@@ -27,18 +27,18 @@
 #undef TRUE
 #undef FALSE
 
+namespace apache {
 namespace subversion {
 namespace cxxhl {
-namespace version_1_9_dev {
 
-tristate::tristate(short value) throw()
+Tristate::Tristate(short value) throw()
     : m_value(value)
 {}
 
-const tristate tristate::TRUE = tristate(svn_tristate_true);
-const tristate tristate::FALSE = tristate(svn_tristate_false);
-const tristate tristate::UNKNOWN = tristate(svn_tristate_unknown);
+const Tristate Tristate::TRUE = Tristate(svn_tristate_true);
+const Tristate Tristate::FALSE = Tristate(svn_tristate_false);
+const Tristate Tristate::UNKNOWN = Tristate(svn_tristate_unknown);
 
-} // namespace version_1_9_dev
 } // namespace cxxhl
 } // namespace subversion
+} // namespace apache

Modified: subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp?rev=1491748&r1=1491747&r2=1491748&view=diff
==============================================================================
--- subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp 
(original)
+++ subversion/trunk/subversion/bindings/cxxhl/tests/test_exception.cpp Tue Jun 
11 11:31:05 2013
@@ -20,6 +20,7 @@
  */
 
 #include <algorithm>
+#include <cstdio>
 #include <iomanip>
 #include <ios>
 #include <iostream>
@@ -30,7 +31,7 @@
 #include "svn_error.h"
 
 namespace {
-void trace(const svn::error::message& msg)
+void trace(const SVN::Error::Message& msg)
 {
   std::cout << "    ";
   if (msg.first)
@@ -40,17 +41,48 @@ void trace(const svn::error::message& ms
   std::cout << msg.second << std::endl;
 }
 
-void traceall(const char *message, const svn::error& err)
+void traceall(const char *message, const SVN::Error& err)
 {
-  typedef svn::error::message_list message_list;
+  typedef SVN::Error::MessageList MessageList;
   std::cout << message << std::endl;
   std::cout << "Traced Messages:" << std::endl;
-  message_list ml = err.traced_messages();
+  MessageList ml = err.traced_messages();
   std::for_each(ml.begin(), ml.end(), trace);
   std::cout << "Just Messages:" << std::endl;
   ml = err.messages();
   std::for_each(ml.begin(), ml.end(), trace);
 }
+
+void tracecheck(svn_error_t* err)
+{
+  std::cout << "C-API handler:" << std::endl;
+  svn_handle_error2(err, stdout, false, "    test_exception");
+  svn_error_clear(err);
+}
+
+svn_error_t* make_cancel_test_error()
+{
+  svn_error_t* err;
+  err = svn_error_create(SVN_ERR_CANCELLED, NULL, NULL);
+  err = svn_error_create(SVN_ERR_CANCELLED, err, NULL);
+  err = svn_error_trace(err);
+  err = svn_error_create(SVN_ERR_TEST_FAILED, err, "original message");
+  err = svn_error_create(SVN_ERR_BASE, err, "wrapper message");
+  err = svn_error_trace(err);
+  return err;
+}
+
+svn_error_t* make_error_test_error()
+{
+  svn_error_t* err;
+  err = svn_error_create(SVN_ERR_TEST_FAILED, NULL, "original message");
+  err = svn_error_create(SVN_ERR_BASE, err, "wrapper message");
+  err = svn_error_trace(err);
+  err = svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, err, NULL);
+  err = svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, err, NULL);
+  err = svn_error_trace(err);
+  return err;
+}
 } // anonymous namespace
 
 
@@ -58,22 +90,18 @@ bool test_cancel()
 {
   try
     {
-      svn_error_t* err;
-      err = svn_error_create(SVN_ERR_TEST_FAILED, NULL, "original message");
-      err = svn_error_create(SVN_ERR_BASE, err, "wrapper message");
-      err = svn_error_create(SVN_ERR_CANCELLED, err, NULL);
-      err = svn_error_create(SVN_ERR_CANCELLED, err, NULL);
-      err = svn_error_trace(err);
-      svn::error::throw_svn_error(err);
+      SVN::Error::throw_svn_error(make_cancel_test_error());
     }
-  catch (const svn::cancelled& err)
+  catch (const SVN::Cancelled& err)
     {
-      traceall("Caught: CANCEL", err);
+      traceall("Caught: CANCELLED", err);
+      tracecheck(make_cancel_test_error());
       return true;
     }
-  catch (const svn::error& err)
+  catch (const SVN::Error& err)
     {
       traceall("Caught: ERROR", err);
+      tracecheck(make_cancel_test_error());
       return false;
     }
   catch (...)
@@ -87,24 +115,18 @@ int test_error()
 {
   try
     {
-      svn_error_t* err;
-      err = svn_error_create(SVN_ERR_TEST_FAILED, NULL, "original message");
-      err = svn_error_create(SVN_ERR_BASE, err, "wrapper message");
-      err = svn_error_create(SVN_ERR_CANCELLED, err, NULL);
-      err = svn_error_create(SVN_ERR_CANCELLED, err, NULL);
-      err = svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, err, NULL);
-      err = svn_error_create(SVN_ERR_UNSUPPORTED_FEATURE, err, NULL);
-      err = svn_error_trace(err);
-      svn::error::throw_svn_error(err);
+      SVN::Error::throw_svn_error(make_error_test_error());
     }
-  catch (const svn::cancelled& err)
+  catch (const SVN::Cancelled& err)
     {
-      traceall("Caught: CANCEL", err);
+      traceall("Caught: CANCELLED", err);
+      tracecheck(make_error_test_error());
       return false;
     }
-  catch (const svn::error& err)
+  catch (const SVN::Error& err)
     {
       traceall("Caught: ERROR", err);
+      tracecheck(make_error_test_error());
       return true;
     }
   catch (...)


Reply via email to