Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0F9CEC5FD for ; Thu, 11 Jul 2013 07:48:16 +0000 (UTC) Received: (qmail 48861 invoked by uid 500); 11 Jul 2013 07:48:16 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 47551 invoked by uid 500); 11 Jul 2013 07:48:08 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 46309 invoked by uid 99); 11 Jul 2013 07:48:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jul 2013 07:48:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Jul 2013 07:48:01 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 137732388900; Thu, 11 Jul 2013 07:47:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1502137 - in /subversion/trunk/subversion/bindings/cxxhl/src/aprwrap: array.hpp hash.hpp impl.cpp Date: Thu, 11 Jul 2013 07:47:40 -0000 To: commits@subversion.apache.org From: brane@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130711074741.137732388900@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: brane Date: Thu Jul 11 07:47:40 2013 New Revision: 1502137 URL: http://svn.apache.org/r1502137 Log: Minor enhancements to C++HL infrastructure. * subversion/bindings/cxxhl/src/aprwrap/array.hpp (Array::Array): When constructing an array proxy from an APR array, double-check that the element size and value type match. (ConstArray::ConstArray): Likewise. * subversion/bindings/cxxhl/src/aprwrap/hash.hpp (Hash::iterate): Move declaration to the top of the class. (Hash::Key): Constrain friendshipt to Hash::iterate. (Hash::Key::Key): Replace private constructor with a downcast conversion constructor. (Hash::Iteration::operator()): Use the new conversion constructor. * subversion/bindings/cxxhl/src/aprwrap/impl.cpp (Hash::iterate): Rename argument 'pool' to 'scratch_pool'. Modified: subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/array.hpp subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/hash.hpp subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/impl.cpp Modified: subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/array.hpp URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/array.hpp?rev=1502137&r1=1502136&r2=1502137&view=diff ============================================================================== --- subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/array.hpp (original) +++ subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/array.hpp Thu Jul 11 07:47:40 2013 @@ -67,9 +67,13 @@ public: /** * Create a new proxy for the APR array @a array. */ - explicit Array(apr_array_header_t* array) throw() + explicit Array(apr_array_header_t* array) throw(std::invalid_argument) : m_array(array) - {} + { + if (m_array->elt_size != sizeof(value_type)) + throw std::invalid_argument( + _("APR array element size does not match template parameter")); + } /** * @return The wrapped APR array. @@ -223,7 +227,8 @@ public: /** * Create a new proxy for the APR array @a array. */ - explicit ConstArray(const apr_array_header_t* array) throw() + explicit ConstArray(const apr_array_header_t* array) + throw(std::invalid_argument) : inherited(const_cast(array)) {} Modified: subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/hash.hpp URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/hash.hpp?rev=1502137&r1=1502136&r2=1502137&view=diff ============================================================================== --- subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/hash.hpp (original) +++ subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/hash.hpp Thu Jul 11 07:47:40 2013 @@ -44,6 +44,16 @@ template<> class Hash { public: + struct Iteration; + + /** + * Iterate over all the key-value pairs in the hash table, invoking + * @a callback for each pair. + * Uses @a scratch_pool for temporary allocations. + */ + void iterate(Iteration& callback, const Pool& scratch_pool); + +public: /** * Proxy for a key in an APR hash table. * This is a template specialization for the default hash key type. @@ -83,7 +93,7 @@ public: /** * The hash table wrapper must be able to call the protected constructor. */ - friend class Hash; + friend void Hash::iterate(Hash::Iteration&, const Pool&); private: const key_type m_key; ///< Immutable reference to the key @@ -164,13 +174,6 @@ public: virtual bool operator() (const Key& key, value_type value) = 0; }; - /** - * Iterate over all the key-value pairs in the hash table, invoking - * @a callback for each pair. - * Uses @a scratch_pool for temporary allocations. - */ - void iterate(Iteration& callback, const Pool& scratch_pool); - protected: typedef const void* const_value_type; @@ -213,6 +216,12 @@ public: { typedef Hash::Key inherited; + /** + * The wrapper must be able to call the private constructor and + * convert references to the base class. + */ + friend class Hash; + public: typedef const K* key_type; typedef inherited::size_type size_type; @@ -239,17 +248,11 @@ public: private: /** - * Constructor used by the hash table wrapper. - * Does not make assumptions about the key size. + * Conversion constructor used by the derived iteration class. */ - Key(key_type key, size_type size) throw() - : inherited(key, size) + explicit Key(const inherited::Key& that) throw() + : inherited(that) {} - - /** - * The hash table wrapper must be able to call the private constructor. - */ - friend class Hash; }; public: @@ -335,9 +338,7 @@ public: virtual bool operator() (const inherited::Key& raw_key, inherited::value_type raw_value) { - return (*this)( - Key(static_cast(raw_key.get()), raw_key.size()), - static_cast(raw_value)); + return (*this)(Key(raw_key), static_cast(raw_value)); } }; Modified: subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/impl.cpp URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/impl.cpp?rev=1502137&r1=1502136&r2=1502137&view=diff ============================================================================== --- subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/impl.cpp (original) +++ subversion/trunk/subversion/bindings/cxxhl/src/aprwrap/impl.cpp Thu Jul 11 07:47:40 2013 @@ -89,9 +89,9 @@ apr_pool_t* Pool::get_root_pool() throw( // void Hash::iterate(Hash::Iteration& callback, - const Pool& pool) + const Pool& scratch_pool) { - for (apr_hash_index_t* hi = apr_hash_first(pool.get(), m_hash); + for (apr_hash_index_t* hi = apr_hash_first(scratch_pool.get(), m_hash); hi; hi = apr_hash_next(hi)) { key_type key;