[gtkmm] operator const void*(): Use GINT_TO_POINTER().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] operator const void*(): Use GINT_TO_POINTER().
- Date: Tue, 5 Apr 2011 12:03:57 +0000 (UTC)
commit 75081c69aed948998c2564d0adc7c53e73b931a3
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Apr 5 14:03:44 2011 +0200
operator const void*(): Use GINT_TO_POINTER().
* gtk/gtkmm/stockid.[h|cc]:
* gtk/src/iconinfo.hg:
* gtk/src/papersize.hg:
* gtk/src/textiter.hg:
* gtk/src/treeiter.hg:
* gtk/src/treepath.hg:
* gtk/src/treerowreference.hg: Use GINT_TO_POINTER() instead of a
(const void*) cast, to avoid problems on unusual platforms.
Daniel Elstner suggested this.
ChangeLog | 14 ++++++++++++++
gtk/gtkmm/stockid.cc | 5 ++---
gtk/src/iconinfo.ccg | 2 +-
gtk/src/papersize.ccg | 2 +-
gtk/src/textiter.hg | 21 ++++++++++-----------
gtk/src/treeiter.ccg | 2 +-
gtk/src/treeiter.hg | 5 ++++-
gtk/src/treepath.ccg | 2 +-
gtk/src/treerowreference.ccg | 2 +-
9 files changed, 35 insertions(+), 20 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8535ad6..f3d5535 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-04-05 Murray Cumming <murrayc murrayc com>
+
+ operator const void*(): Use GINT_TO_POINTER().
+
+ * gtk/gtkmm/stockid.[h|cc]:
+ * gtk/src/iconinfo.hg:
+ * gtk/src/papersize.hg:
+ * gtk/src/textiter.hg:
+ * gtk/src/treeiter.hg:
+ * gtk/src/treepath.hg:
+ * gtk/src/treerowreference.hg: Use GINT_TO_POINTER() instead of a
+ (const void*) cast, to avoid problems on unusual platforms.
+ Daniel Elstner suggested this.
+
2011-04-04 Murray Cumming <murrayc murrayc com>
Use a BoolExpr typedef to make operator const void* clearer.
diff --git a/gtk/gtkmm/stockid.cc b/gtk/gtkmm/stockid.cc
index 54571ec..4cc8aa6 100644
--- a/gtk/gtkmm/stockid.cc
+++ b/gtk/gtkmm/stockid.cc
@@ -61,9 +61,9 @@ StockID& StockID::operator=(const StockID& other)
StockID::operator const void*() const
{
- return (const void*)!(id_.empty());
+ return !(id_.empty()) ? GINT_TO_POINTER(1) : 0 ;
}
-
+
bool StockID::equal(const StockID& rhs) const
{
// Do an exact per-byte comparison:
@@ -82,4 +82,3 @@ const char* StockID::get_c_str() const
}
} // namespace Gtk
-
diff --git a/gtk/src/iconinfo.ccg b/gtk/src/iconinfo.ccg
index 70a8348..e1ea454 100644
--- a/gtk/src/iconinfo.ccg
+++ b/gtk/src/iconinfo.ccg
@@ -43,7 +43,7 @@ std::vector<Gdk::Point> IconInfo::get_attach_points() const
IconInfo::operator const void*() const
{
- return (const void*)(gobj() != 0);
+ return gobj() ? GINT_TO_POINTER(1) : 0;
}
diff --git a/gtk/src/papersize.ccg b/gtk/src/papersize.ccg
index 3dce4e3..9ce1824 100644
--- a/gtk/src/papersize.ccg
+++ b/gtk/src/papersize.ccg
@@ -64,7 +64,7 @@ bool PaperSize::equal(const PaperSize& other) const
PaperSize::operator const void*() const
{
- return (const void*)(gobj() != 0);
+ return gobj() ? GINT_TO_POINTER(1) : 0;
}
void PaperSize::save_to_key_file(Glib::KeyFile& key_file)
diff --git a/gtk/src/textiter.hg b/gtk/src/textiter.hg
index e5acc04..4b05f94 100644
--- a/gtk/src/textiter.hg
+++ b/gtk/src/textiter.hg
@@ -50,7 +50,7 @@ class TextMark;
*
* You can iterate over characters, words, lines, and sentences,
* but operator*() and operator++() deal only in characters.
- *
+ *
* @ingroup TextView
*/
class TextIter
@@ -75,9 +75,9 @@ public:
/** Alias for get_char(). */
inline value_type operator*() const;
- /** This typedef is just to make it more obvious that
+ /** This typedef is just to make it more obvious that
* our operator const void* should be used like operator bool().
- */
+ */
typedef const void* BoolExpr;
/** Alias for !is_end()
@@ -132,7 +132,7 @@ public:
_WRAP_METHOD(std::vector< Glib::RefPtr<TextMark> > get_marks(), gtk_text_iter_get_marks)
#m4 _CONVERSION(`GSList*',`std::vector< Glib::RefPtr<const TextMark> >',`Glib::SListHandler<Glib::RefPtr<const TextMark> >::slist_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
_WRAP_METHOD(std::vector< Glib::RefPtr<const TextMark> > get_marks() const, gtk_text_iter_get_marks)
-
+
_WRAP_METHOD(Glib::RefPtr<TextChildAnchor> get_child_anchor(), gtk_text_iter_get_child_anchor, refreturn)
_WRAP_METHOD(Glib::RefPtr<const TextChildAnchor> get_child_anchor() const, gtk_text_iter_get_child_anchor, refreturn)
@@ -150,7 +150,7 @@ public:
_WRAP_METHOD(bool has_tag(const Glib::RefPtr<const TextTag>& tag) const, gtk_text_iter_has_tag)
bool has_tag() const;
-
+
_WRAP_METHOD(std::vector< Glib::RefPtr<TextTag> > get_tags(), gtk_text_iter_get_tags)
_WRAP_METHOD(std::vector< Glib::RefPtr<const TextTag> > get_tags() const, gtk_text_iter_get_tags)
@@ -195,7 +195,7 @@ public:
//TODO: Now that there are so many *_visible_ versions of the methods, maybe we should
//just add a visible=false parameter and therefore halve the number of methods. murrayc
-
+
_WRAP_METHOD(bool forward_visible_word_end(), gtk_text_iter_forward_visible_word_end)
_WRAP_METHOD(bool backward_visible_word_start(), gtk_text_iter_backward_visible_word_start)
_WRAP_METHOD(bool forward_visible_word_ends(int count), gtk_text_iter_forward_visible_word_ends)
@@ -239,7 +239,7 @@ public:
TextIter& match_start,
TextIter& match_end,
const TextIter& limit) const, gtk_text_iter_forward_search)
-
+
/** Same as forward_search(), but searchs to the end.
*
* @param str A search string.
@@ -247,7 +247,7 @@ public:
* @param match_start Return location for start of match, or <tt>0</tt>.
* @param match_end Return location for end of match, or <tt>0</tt>.
* @return Whether a match was found.
- */
+ */
bool forward_search(const Glib::ustring& str, TextSearchFlags flags, TextIter& match_start, TextIter& match_end) const;
_WRAP_METHOD(bool backward_search(const Glib::ustring& str,
@@ -262,7 +262,7 @@ public:
* @param match_start Return location for start of match, or <tt>0</tt>.
* @param match_end Return location for end of match, or <tt>0</tt>.
* @return Whether a match was found.
- */
+ */
bool backward_search(const Glib::ustring& str, TextSearchFlags flags, TextIter& match_start, TextIter& match_end) const;
_WRAP_METHOD(int compare(const TextIter& rhs) const, gtk_text_iter_compare)
@@ -338,7 +338,7 @@ TextIter::value_type TextIter::operator*() const
inline
TextIter::operator BoolExpr() const
{
- return (const void*)!is_end();
+ return !is_end() ? GINT_TO_POINTER(1) : 0;
}
template <class Predicate>
@@ -376,4 +376,3 @@ bool TextIter::backward_find_char(const Predicate& predicate)
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
} // namespace Gtk
-
diff --git a/gtk/src/treeiter.ccg b/gtk/src/treeiter.ccg
index de469b4..ddf76ed 100644
--- a/gtk/src/treeiter.ccg
+++ b/gtk/src/treeiter.ccg
@@ -142,7 +142,7 @@ TreeIter::operator const 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 (const void*)(!is_end_ && gobject_.stamp != 0);
+ return (!is_end_ && gobject_.stamp) ? GINT_TO_POINTER(1) : 0;
}
void TreeIter::setup_end_iterator(const TreeIter& last_valid)
diff --git a/gtk/src/treeiter.hg b/gtk/src/treeiter.hg
index ebcbbbf..4832f5f 100644
--- a/gtk/src/treeiter.hg
+++ b/gtk/src/treeiter.hg
@@ -382,7 +382,10 @@ public:
* do_something()
* @endcode
*/
- operator BoolExpr() const { return (const void*)!empty(); }
+ operator BoolExpr() const
+ {
+ return !empty() ? GINT_TO_POINTER(1) : 0;
+ }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
diff --git a/gtk/src/treepath.ccg b/gtk/src/treepath.ccg
index 2d8f960..150fabb 100644
--- a/gtk/src/treepath.ccg
+++ b/gtk/src/treepath.ccg
@@ -65,7 +65,7 @@ TreePath::size_type TreePath::size() const
TreePath::operator const void*() const
{
- return (const void*)!empty();
+ return !empty() ? GINT_TO_POINTER(1) : 0;
}
bool TreePath::empty() const
diff --git a/gtk/src/treerowreference.ccg b/gtk/src/treerowreference.ccg
index 4167ebb..3ab58eb 100644
--- a/gtk/src/treerowreference.ccg
+++ b/gtk/src/treerowreference.ccg
@@ -31,7 +31,7 @@ TreeRowReference::TreeRowReference(const Glib::RefPtr<TreeModel>& model, const T
TreeRowReference::operator const void*() const
{
- return (const void*)is_valid();
+ return is_valid() ? GINT_TO_POINTER(1) : 0;
}
} // namespace Gtk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]