You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2010/10/18 16:24:02 UTC
svn commit: r1023810 - in /subversion/branches/object-model/subversion:
bindings/c++/include/Types.h tests/libsvn++/util-test.cpp
Author: hwright
Date: Mon Oct 18 14:24:01 2010
New Revision: 1023810
URL: http://svn.apache.org/viewvc?rev=1023810&view=rev
Log:
On the object-model branch:
Add an implicit boolean conversion to help facilitate storing and comparing
the NULL pointer.
* subversion/bindings/c++/include/Types.h
(CStructWrapper): Add an implicit conversion to the wrapped type.
(CommitInfo, Lock, ClientNotifyInfo, Version): Add implicit boolean
conversion.
* subversion/tests/libsvn++/util-test.cpp
(test_null_objects): New.
(test_funcs): Run new test.
Modified:
subversion/branches/object-model/subversion/bindings/c++/include/Types.h
subversion/branches/object-model/subversion/tests/libsvn++/util-test.cpp
Modified: subversion/branches/object-model/subversion/bindings/c++/include/Types.h
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/bindings/c%2B%2B/include/Types.h?rev=1023810&r1=1023809&r2=1023810&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/bindings/c++/include/Types.h (original)
+++ subversion/branches/object-model/subversion/bindings/c++/include/Types.h Mon Oct 18 14:24:01 2010
@@ -115,6 +115,7 @@ class CStructWrapper
inline const T& operator* () const { return *m_data->ptr(); }
inline const T* operator-> () const { return m_data->ptr(); }
+ inline operator T const *() const { return m_data->ptr(); }
private:
RefCounter<T, DUP> *m_data;
@@ -132,6 +133,11 @@ class CommitInfo
{
}
+ inline operator bool () const
+ {
+ return m_info != NULL;
+ }
+
inline Revision
getRevision() const
{
@@ -176,6 +182,11 @@ class Lock
{
}
+ inline operator bool () const
+ {
+ return m_lock != NULL;
+ }
+
inline std::string
getPath() const
{
@@ -231,6 +242,11 @@ class ClientNotifyInfo
{
}
+ inline operator bool () const
+ {
+ return m_notify != NULL;
+ }
+
// ### This is only temporary
inline const svn_wc_notify_t *
to_c() const
@@ -251,6 +267,11 @@ class Version
{
}
+ inline operator bool () const
+ {
+ return m_version != NULL;
+ }
+
inline std::string
getTag()
{
Modified: subversion/branches/object-model/subversion/tests/libsvn++/util-test.cpp
URL: http://svn.apache.org/viewvc/subversion/branches/object-model/subversion/tests/libsvn%2B%2B/util-test.cpp?rev=1023810&r1=1023809&r2=1023810&view=diff
==============================================================================
--- subversion/branches/object-model/subversion/tests/libsvn++/util-test.cpp (original)
+++ subversion/branches/object-model/subversion/tests/libsvn++/util-test.cpp Mon Oct 18 14:24:01 2010
@@ -196,6 +196,18 @@ test_struct_wrapping(apr_pool_t *p)
return SVN_NO_ERROR;
}
+static svn_error_t *
+test_null_objects(apr_pool_t *p)
+{
+ Lock lock(NULL);
+ std::string path;
+
+ if (lock)
+ path = lock.getPath();
+
+ return SVN_NO_ERROR;
+}
+
/* The test table. */
struct svn_test_descriptor_t test_funcs[] =
@@ -215,5 +227,7 @@ struct svn_test_descriptor_t test_funcs[
"test various map to hash transforms"),
SVN_TEST_PASS2(test_struct_wrapping,
"test our ref-counted struct wrappers"),
+ SVN_TEST_PASS2(test_null_objects,
+ "test wrapping of various NULL objects"),
SVN_TEST_NULL
};