From a3ab1c18017bb08329e73918f9f502ea00cdb447 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Oct 2006 22:03:53 +0000 Subject: [PATCH] renamed IsRefTo() to IsSameAs() (do complain if this is not more clear) and changed its signature to take a const reference instead of a pointer which simplifies the code and makes it safer as well git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42776 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 +- docs/latex/wx/object.tex | 11 +++++++---- docs/latex/wx/trefcount.tex | 2 +- include/wx/mac/carbon/pen.h | 2 +- include/wx/msw/pen.h | 2 +- include/wx/object.h | 5 ++--- include/wx/os2/pen.h | 2 +- include/wx/palmos/pen.h | 2 +- include/wx/variant.h | 4 ++-- src/common/wincmn.cpp | 2 +- src/generic/wizard.cpp | 2 +- src/gtk/brush.cpp | 2 +- src/gtk1/brush.cpp | 2 +- src/mac/carbon/brush.cpp | 2 +- src/mac/carbon/window.cpp | 2 +- src/mgl/brush.cpp | 2 +- src/mgl/pen.cpp | 2 +- src/msw/brush.cpp | 2 +- src/x11/brush.cpp | 2 +- 19 files changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3827c1c331..4d19f0f087 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -30,7 +30,7 @@ Changes in behaviour which may result in compilation errors used to work in somewhat unexpected way as it compared only internal pointers and not the object data. The code using it will have to be updated: * If the object was compared with wxNullXXX, use IsOk() method instead - * If valid object need to be compated, use IsRefTo() to reproduce the old + * If valid object need to be compated, use IsSameAs() to reproduce the old behaviour or change the code to avoid comparing bitmaps &c - wxFontData::GetColour() now returns a const colour. - wxDC objects can't be created directly now (this never worked, now it doesn't diff --git a/docs/latex/wx/object.tex b/docs/latex/wx/object.tex index 4332aa6a02..e5999513cd 100644 --- a/docs/latex/wx/object.tex +++ b/docs/latex/wx/object.tex @@ -116,12 +116,15 @@ this one or is derived from it. bool tmp = obj->IsKindOf(CLASSINFO(wxFrame)); \end{verbatim} -\membersection{wxObject::IsRefTo}\label{wxobjectisrefto} +\membersection{wxObject::IsSameAs}\label{wxobjectissameas} -\func{bool}{IsRefTo}{\param{const wxObject *}{ obj}} +\func{bool}{IsSameAs}{\param{const wxObject\& }{ obj}} -Returns \true if this object is referencing the \arg{obj}'s data. -Note that this function only does a {\tt shallow} comparison. +Returns \true if this object has the same data pointer as \arg{obj}. Notice +that \true is returned if the data pointers are \NULL in both objects. + +This function only does a \emph{shallow} comparison, i.e. it doesn't compare +the objects pointed to by the data pointers of these objects. \membersection{wxObject::Ref}\label{wxobjectref} diff --git a/docs/latex/wx/trefcount.tex b/docs/latex/wx/trefcount.tex index eb280c5c78..c051acc1b1 100644 --- a/docs/latex/wx/trefcount.tex +++ b/docs/latex/wx/trefcount.tex @@ -35,7 +35,7 @@ That's why not all reference-counted wxWidgets classes provide comparison operat Also note that if you only need to do a {\tt shallow} comparison between two \helpref{wxObject}{wxobject}-derived classes, you should not use the $==$ and $!=$ operators -but rather the \helpref{wxObject::IsRefTo}{wxobjectisrefto} function. +but rather the \helpref{wxObject::IsSameAs}{wxobjectissameas} function. \subsection{Object destruction}\label{refcountdestruct} diff --git a/include/wx/mac/carbon/pen.h b/include/wx/mac/carbon/pen.h index 4c07343d22..511d9a456c 100644 --- a/include/wx/mac/carbon/pen.h +++ b/include/wx/mac/carbon/pen.h @@ -36,7 +36,7 @@ public: m_join == data.m_join && m_cap == data.m_cap && m_colour == data.m_colour && - (m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) && + (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) && (m_style != wxUSER_DASH || (m_nbDash == data.m_nbDash && memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); diff --git a/include/wx/msw/pen.h b/include/wx/msw/pen.h index d35cd47a2d..470d92c6dc 100644 --- a/include/wx/msw/pen.h +++ b/include/wx/msw/pen.h @@ -36,7 +36,7 @@ public: m_join == data.m_join && m_cap == data.m_cap && m_colour == data.m_colour && - (m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) && + (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) && (m_style != wxUSER_DASH || (m_nbDash == data.m_nbDash && memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); diff --git a/include/wx/object.h b/include/wx/object.h index b7de67c0fe..f9d9f2be9b 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -476,9 +476,8 @@ public: // Make sure this object has only one reference void UnShare() { AllocExclusive(); } - // Do a shallow comparison of our referenced data with the given object's - // refdata - bool IsRefTo(const wxObject *p) const { return m_refData == p->m_refData; } + // check if this object references the same data as the other one + bool IsSameAs(const wxObject& o) const { return m_refData == o.m_refData; } protected: // ensure that our data is not shared with anybody else: if we have no diff --git a/include/wx/os2/pen.h b/include/wx/os2/pen.h index d192842d2c..1656eec288 100644 --- a/include/wx/os2/pen.h +++ b/include/wx/os2/pen.h @@ -35,7 +35,7 @@ public: m_nJoin == data.m_nJoin && m_nCap == data.m_nCap && m_vColour == data.m_vColour && - (m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) && + (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) && (m_style != wxUSER_DASH || (m_dash == data.m_dash && memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); diff --git a/include/wx/palmos/pen.h b/include/wx/palmos/pen.h index 7ad901706c..4edd52052f 100644 --- a/include/wx/palmos/pen.h +++ b/include/wx/palmos/pen.h @@ -36,7 +36,7 @@ public: m_join == data.m_join && m_cap == data.m_cap && m_colour == data.m_colour && - (m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) && + (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) && (m_style != wxUSER_DASH || (m_nbDash == data.m_nbDash && memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); diff --git a/include/wx/variant.h b/include/wx/variant.h index d5483080e8..5d971dbba7 100644 --- a/include/wx/variant.h +++ b/include/wx/variant.h @@ -397,7 +397,7 @@ bool classname##VariantData::Eq(wxVariantData& data) const \ // implements a wxVariantData-derived class using for the Eq() method a shallow -// comparison (through wxObject::IsRefTo function) +// comparison (through wxObject::IsSameAs function) #define IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(classname,expdecl) \ IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \ \ @@ -407,7 +407,7 @@ bool classname##VariantData::Eq(wxVariantData& data) const \ \ classname##VariantData & otherData = (classname##VariantData &) data;\ \ - return (otherData.m_value.IsRefTo(&m_value));\ + return (otherData.m_value.IsSameAs(m_value));\ }\ diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index d03c8cb878..3dc6813f7b 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1023,7 +1023,7 @@ bool wxWindowBase::SetCursor(const wxCursor& cursor) { // setting an invalid cursor is ok, it means that we don't have any special // cursor - if ( m_cursor.IsRefTo(&cursor) ) + if ( m_cursor.IsSameAs(cursor) ) { // no change return false; diff --git a/src/generic/wizard.cpp b/src/generic/wizard.cpp index 138f1c6680..385a10d8b8 100644 --- a/src/generic/wizard.cpp +++ b/src/generic/wizard.cpp @@ -631,7 +631,7 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward) if ( !bmpPrev.Ok() ) bmpPrev = m_bitmap; - if ( !bmp.IsRefTo(&bmpPrev) ) + if ( !bmp.IsSameAs(bmpPrev) ) m_statbmp->SetBitmap(bmp); } #endif // wxUSE_STATBMP diff --git a/src/gtk/brush.cpp b/src/gtk/brush.cpp index 1cc7e69e1f..4c54c10897 100644 --- a/src/gtk/brush.cpp +++ b/src/gtk/brush.cpp @@ -40,7 +40,7 @@ public: bool operator == (const wxBrushRefData& data) const { return (m_style == data.m_style && - m_stipple.IsRefTo(&data.m_stipple) && + m_stipple.IsSameAs(data.m_stipple) && m_colour == data.m_colour); } diff --git a/src/gtk1/brush.cpp b/src/gtk1/brush.cpp index 25536d5518..3b9330bb1a 100644 --- a/src/gtk1/brush.cpp +++ b/src/gtk1/brush.cpp @@ -41,7 +41,7 @@ public: bool operator == (const wxBrushRefData& data) const { return (m_style == data.m_style && - m_stipple.IsRefTo(&data.m_stipple) && + m_stipple.IsSameAs(data.m_stipple) && m_colour == data.m_colour); } diff --git a/src/mac/carbon/brush.cpp b/src/mac/carbon/brush.cpp index b0fa74aa0a..95bb600893 100644 --- a/src/mac/carbon/brush.cpp +++ b/src/mac/carbon/brush.cpp @@ -33,7 +33,7 @@ public: bool operator == ( const wxBrushRefData& brush ) const { return m_style == brush.m_style && - m_stipple.IsRefTo(&brush.m_stipple) && + m_stipple.IsSameAs(brush.m_stipple) && m_colour == brush.m_colour && m_macBrushKind == brush.m_macBrushKind && m_macThemeBrush == brush.m_macThemeBrush && diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 719f9376d0..5cb844f3c0 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -1661,7 +1661,7 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const bool wxWindowMac::SetCursor(const wxCursor& cursor) { - if (m_cursor.IsRefTo(&cursor)) + if (m_cursor.IsSameAs(cursor)) return false; if (!cursor.IsOk()) diff --git a/src/mgl/brush.cpp b/src/mgl/brush.cpp index d97544d123..cb542c34f8 100644 --- a/src/mgl/brush.cpp +++ b/src/mgl/brush.cpp @@ -79,7 +79,7 @@ public: bool operator == (const wxBrushRefData& data) const { return (m_style == data.m_style && - m_stipple.IsRefTo(&data.m_stipple) && + m_stipple.IsSameAs(data.m_stipple) && m_colour == data.m_colour); } diff --git a/src/mgl/pen.cpp b/src/mgl/pen.cpp index 5879052da5..45820afcac 100644 --- a/src/mgl/pen.cpp +++ b/src/mgl/pen.cpp @@ -42,7 +42,7 @@ class wxPenRefData: public wxObjectRefData m_capStyle == data.m_capStyle && m_joinStyle == data.m_joinStyle && m_colour == data.m_colour && - (m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) && + (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) && (m_style != wxUSER_DASH || (m_dash == data.m_dash && memcmp(m_dash, data.m_dash, m_countDashes*sizeof(wxDash)) == 0)); diff --git a/src/msw/brush.cpp b/src/msw/brush.cpp index eb3c21d002..8f0e645b31 100644 --- a/src/msw/brush.cpp +++ b/src/msw/brush.cpp @@ -124,7 +124,7 @@ bool wxBrushRefData::operator==(const wxBrushRefData& data) const // don't compare HBRUSHes return m_style == data.m_style && m_colour == data.m_colour && - m_stipple.IsRefTo(&data.m_stipple); + m_stipple.IsSameAs(data.m_stipple); } void wxBrushRefData::DoSetStipple(const wxBitmap& stipple) diff --git a/src/x11/brush.cpp b/src/x11/brush.cpp index 9aeb158115..d74f745827 100644 --- a/src/x11/brush.cpp +++ b/src/x11/brush.cpp @@ -42,7 +42,7 @@ public: bool operator == (const wxBrushRefData& data) const { return (m_style == data.m_style && - m_stipple.IsRefTo(&data.m_stipple) && + m_stipple.IsSameAs(&data.m_stipple) && m_colour == data.m_colour); } -- 2.45.2