[gtkmm] Replace all operator bool() with operator void*().



commit c182608593e2d4799f523580a0532fbc68d296b2
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Apr 1 22:41:19 2011 +0200

    Replace all operator bool() with operator void*().
    
    * gtk/gtkmm/stockid.[h|cc]:
    * gtk/src/iconinfo.[hg|ccg]:
    * gtk/src/papersize.[hg|ccg]:
    * gtk/src/recentinfo.[hg|ccg]:
    * gtk/src/textiter.[hg|ccg]:
    * gtk/src/treeiter.hg:
    * gtk/src/treepath.[hg|ccg]:
    * gtk/src/treerowreference.[hg|ccg]: Use operator void*() instead of
    operator bool() because this avoids an implicit conversion to int instead of
    bool. This is apparently generally considered a good thing.

 ChangeLog                    |   16 ++++++++++++++++
 gtk/gtkmm/stockid.cc         |    4 ++--
 gtk/gtkmm/stockid.h          |    2 +-
 gtk/src/iconinfo.ccg         |    4 ++--
 gtk/src/iconinfo.hg          |    2 +-
 gtk/src/papersize.ccg        |    6 +++---
 gtk/src/papersize.hg         |    2 +-
 gtk/src/recentinfo.ccg       |    4 ++--
 gtk/src/recentinfo.hg        |    2 +-
 gtk/src/textiter.hg          |    6 +++---
 gtk/src/treeiter.ccg         |    8 ++++----
 gtk/src/treeiter.hg          |    6 +++---
 gtk/src/treepath.ccg         |    4 ++--
 gtk/src/treepath.hg          |    2 +-
 gtk/src/treerowreference.ccg |    4 ++--
 gtk/src/treerowreference.hg  |    2 +-
 16 files changed, 45 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a75ab12..da47731 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2011-04-01  Murray Cumming  <murrayc murrayc com>
+
+	Replace all operator bool() with operator void*().
+
+	* gtk/gtkmm/stockid.[h|cc]:
+	* gtk/src/iconinfo.[hg|ccg]:
+	* gtk/src/papersize.[hg|ccg]:
+	* gtk/src/recentinfo.[hg|ccg]:
+	* gtk/src/textiter.[hg|ccg]:
+	* gtk/src/treeiter.hg:
+	* gtk/src/treepath.[hg|ccg]:
+	* gtk/src/treerowreference.[hg|ccg]: Use operator void*() instead of 
+	operator bool() because this avoids an implicit conversion to int instead of 
+	bool. This is apparently generally considered a good thing. Daniel Elstner 
+	mentioned this at some point in the last year or so too.
+
 2011-03-26  Kalev Lember  <kalev smartlink ee>
 
 	Wrap a missing flag in GtkStateFlags
diff --git a/gtk/gtkmm/stockid.cc b/gtk/gtkmm/stockid.cc
index b215bcd..d2bae1c 100644
--- a/gtk/gtkmm/stockid.cc
+++ b/gtk/gtkmm/stockid.cc
@@ -59,9 +59,9 @@ StockID& StockID::operator=(const StockID& other)
   return *this;
 }
 
-StockID::operator bool() const
+StockID::operator void*() const
 {
-  return !(id_.empty());
+  return (void*)!(id_.empty());
 }
   
 bool StockID::equal(const StockID& rhs) const
diff --git a/gtk/gtkmm/stockid.h b/gtk/gtkmm/stockid.h
index 762d1c9..4de1f64 100644
--- a/gtk/gtkmm/stockid.h
+++ b/gtk/gtkmm/stockid.h
@@ -70,7 +70,7 @@ public:
 
   /** Tests whether the StockID is not empty.
    */
-  operator bool() const;
+  operator void*() const;
 
   /** Check if two StockIDs are equal.
    * @param rhs Another StockID.
diff --git a/gtk/src/iconinfo.ccg b/gtk/src/iconinfo.ccg
index beee4ca..12e1aae 100644
--- a/gtk/src/iconinfo.ccg
+++ b/gtk/src/iconinfo.ccg
@@ -41,9 +41,9 @@ std::vector<Gdk::Point> IconInfo::get_attach_points() const
   return std::vector<Gdk::Point> ();
 }
 
-IconInfo::operator bool() const
+IconInfo::operator void*() const
 {
-  return gobj() != 0;
+  return (void*)(gobj() != 0);
 }
 
 
diff --git a/gtk/src/iconinfo.hg b/gtk/src/iconinfo.hg
index d2c873d..ccc2129 100644
--- a/gtk/src/iconinfo.hg
+++ b/gtk/src/iconinfo.hg
@@ -42,7 +42,7 @@ public:
   _IGNORE(gtk_icon_info_new_for_pixbuf)
 
   ///Tests whether the IconInfo is valid.
-  operator bool() const;
+  operator void*() const;
 
   _WRAP_METHOD(int get_base_size() const, gtk_icon_info_get_base_size)
   _WRAP_METHOD(Glib::ustring get_filename() const, gtk_icon_info_get_filename)
diff --git a/gtk/src/papersize.ccg b/gtk/src/papersize.ccg
index 8d6b090..e61fd55 100644
--- a/gtk/src/papersize.ccg
+++ b/gtk/src/papersize.ccg
@@ -49,7 +49,7 @@ PaperSize::PaperSize(const Glib::ustring& name, const Glib::ustring& display_nam
                                      GtkUnit(unit)))
 {}
 
-//TODO: Add an operator bool() so we can detect if this succeeded:
+//TODO: Add an operator void*() so we can detect if this succeeded:
 //TODO: No, throw the error/exception instead.
 PaperSize::PaperSize(const Glib::KeyFile& key_file, const Glib::ustring& group_name)
 :
@@ -62,9 +62,9 @@ bool PaperSize::equal(const PaperSize& other) const
                                                     const_cast<GtkPaperSize*>(other.gobj()))));
 }
 
-PaperSize::operator bool() const
+PaperSize::operator void*() const
 {
-  return (gobj() != NULL);
+  return (void*)(gobj() != 0);
 }
 
 void PaperSize::save_to_key_file(Glib::KeyFile& key_file)
diff --git a/gtk/src/papersize.hg b/gtk/src/papersize.hg
index 3408459..6021721 100644
--- a/gtk/src/papersize.hg
+++ b/gtk/src/papersize.hg
@@ -71,7 +71,7 @@ public:
   /** Returns true if the PaperSize is a valid object.
    * @newin{2,12}
    */
-  operator bool() const;
+  operator void*() const;
 
   #m4 _CONVERSION(`GList*', `std::vector<PaperSize>',`Glib::ListHandler<PaperSize, PaperSizeTraits>::list_to_vector($3, Glib::OWNERSHIP_DEEP)')
   _WRAP_METHOD(static std::vector<PaperSize> get_paper_sizes(bool include_custom = true), gtk_paper_size_get_paper_sizes)
diff --git a/gtk/src/recentinfo.ccg b/gtk/src/recentinfo.ccg
index 8394998..ddc8f5f 100644
--- a/gtk/src/recentinfo.ccg
+++ b/gtk/src/recentinfo.ccg
@@ -22,9 +22,9 @@
 namespace Gtk
 {
 
-RecentInfo::operator bool() const
+RecentInfo::operator void*() const
 {
-  return gobj() != 0;
+  return (void*)(gobj() != 0);
 }
 
 std::vector<Glib::ustring> RecentInfo::get_applications() const
diff --git a/gtk/src/recentinfo.hg b/gtk/src/recentinfo.hg
index c6eedda..8f93559 100644
--- a/gtk/src/recentinfo.hg
+++ b/gtk/src/recentinfo.hg
@@ -53,7 +53,7 @@ public:
 //#ifndef DOXYGEN_SHOULD_SKIP_THIS
 //# if (!defined(GTKMM_DISABLE_DEPRECATED) || defined(GTKMM_COMPILATION))
   /// Tests whether the RecentInfo is valid.
-  operator bool() const;
+  operator void*() const;
 //# endif
 //#endif
 
diff --git a/gtk/src/textiter.hg b/gtk/src/textiter.hg
index cdd1cfa..513808e 100644
--- a/gtk/src/textiter.hg
+++ b/gtk/src/textiter.hg
@@ -76,7 +76,7 @@ public:
   inline value_type operator*() const;
 
   /** Alias for !is_end(). */
-  inline operator bool() const;
+  inline operator void*() const;
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
@@ -325,9 +325,9 @@ TextIter::value_type TextIter::operator*() const
 }
 
 inline
-TextIter::operator bool() const
+TextIter::operator void*() const
 {
-  return !is_end();
+  return (void*)!is_end();
 }
 
 template <class Predicate>
diff --git a/gtk/src/treeiter.ccg b/gtk/src/treeiter.ccg
index 6179589..8f9e3f8 100644
--- a/gtk/src/treeiter.ccg
+++ b/gtk/src/treeiter.ccg
@@ -137,12 +137,12 @@ bool TreeIter::equal(const TreeIter& other) const
          (gobject_.user_data3 == other.gobject_.user_data3);
 }
 
-TreeIter::operator bool() const
+TreeIter::operator void*() const
 {
   // Test whether the GtkTreeIter is valid and not an end iterator.  This check
   // is almost the same as the private VALID_ITER() macro in gtkliststore.c and
   // gtktreestore.c.
-  return (!is_end_ && gobject_.stamp != 0);
+  return (void*)(!is_end_ && gobject_.stamp != 0);
 }
 
 void TreeIter::setup_end_iterator(const TreeIter& last_valid)
@@ -215,9 +215,9 @@ void TreeRow::get_value_impl(int column, Glib::ValueBase& value) const
   model_->get_value_impl(*this, column, value);
 }
 
-TreeRow::operator bool() const
+TreeRow::operator void*() const
 {
-  return TreeIter::operator bool();
+  return (void*)TreeIter::operator void*();
 }
 
 
diff --git a/gtk/src/treeiter.hg b/gtk/src/treeiter.hg
index 8dc7bcd..6eb096f 100644
--- a/gtk/src/treeiter.hg
+++ b/gtk/src/treeiter.hg
@@ -120,7 +120,7 @@ public:
 
   /** Discover whether the iterator is valid, and not equal to end().
    */
-  operator bool() const;
+  operator void*() const;
 
   /** This is only useful when implementing a custom Gtk::TreeModel class.
    * Compare the iterator's stamp with your model's stamp to discover whether it is valid.
@@ -288,7 +288,7 @@ public:
 
   /** Discover whether this is a valid row.
    */
-  operator bool() const;
+  operator void*() const;
 
   /// Provides access to the underlying C GObject.  
   GtkTreeIter*       gobj()       { return TreeIter::gobj(); }
@@ -349,7 +349,7 @@ public:
 
   size_type size() const;
   bool empty() const;
-  operator bool() const { return !empty(); }
+  operator void*() const { return (void*)!empty(); }
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
diff --git a/gtk/src/treepath.ccg b/gtk/src/treepath.ccg
index e137c28..358f832 100644
--- a/gtk/src/treepath.ccg
+++ b/gtk/src/treepath.ccg
@@ -63,9 +63,9 @@ TreePath::size_type TreePath::size() const
   return gtk_tree_path_get_depth(gobject_);
 }
 
-TreePath::operator bool() const
+TreePath::operator void*() const
 {
-  return !empty();
+  return (void*)!empty();
 }
 
 bool TreePath::empty() const
diff --git a/gtk/src/treepath.hg b/gtk/src/treepath.hg
index a5ccafd..3c3b6a8 100644
--- a/gtk/src/treepath.hg
+++ b/gtk/src/treepath.hg
@@ -86,7 +86,7 @@ public:
   /** Checks that the path is not empty, by calling empty().
    * @newin{2,16}
    */
-  operator bool() const;
+  operator void*() const;
 
   template <class In> inline void assign(In pbegin, In pend);
   template <class In>        void append(In pbegin, In pend);
diff --git a/gtk/src/treerowreference.ccg b/gtk/src/treerowreference.ccg
index cc6832c..d12c220 100644
--- a/gtk/src/treerowreference.ccg
+++ b/gtk/src/treerowreference.ccg
@@ -29,9 +29,9 @@ TreeRowReference::TreeRowReference(const Glib::RefPtr<TreeModel>& model, const T
   gobject_ ( gtk_tree_row_reference_new(model->gobj(), const_cast<GtkTreePath*>(path.gobj())) )
 {}
 
-TreeRowReference::operator bool() const
+TreeRowReference::operator void*() const
 {
-  return is_valid();
+  return (void*)is_valid();
 }
 
 } // namespace Gtk
diff --git a/gtk/src/treerowreference.hg b/gtk/src/treerowreference.hg
index d42cf39..465804c 100644
--- a/gtk/src/treerowreference.hg
+++ b/gtk/src/treerowreference.hg
@@ -40,7 +40,7 @@ public:
   TreeRowReference(const Glib::RefPtr<TreeModel>& model, const TreeModel::Path& path);
 
   ///The same as is_valid().
-  operator bool() const;
+  operator void*() const;
 
   _WRAP_METHOD(TreeModel::Path get_path() const,  gtk_tree_row_reference_get_path)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]