[haiku-commits] BRANCH axeld-github.imap - src/kits/interface headers/os/interface

  • From: axeld-github.imap <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 4 Nov 2012 14:48:41 +0100 (CET)

added 1 changeset to branch 'refs/remotes/axeld-github/imap'
old head: 9df7055a57af52c2f7212e0a2c9a45a0a87c3b4d
new head: 8b94d3785c5d8d5ef2fe19da9106ad736d3cf876

----------------------------------------------------------------------------

8b94d37: Made the BRect::*Copy() methods const as they should have been.

                                   [ Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      8b94d3785c5d8d5ef2fe19da9106ad736d3cf876

Author:      Axel DÃrfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Sun Nov  4 13:07:46 2012 UTC

----------------------------------------------------------------------------

2 files changed, 88 insertions(+), 27 deletions(-)
headers/os/interface/Rect.h | 20 ++++-----
src/kits/interface/Rect.cpp | 95 +++++++++++++++++++++++++++++++++--------

----------------------------------------------------------------------------

diff --git a/headers/os/interface/Rect.h b/headers/os/interface/Rect.h
index f55f24f..b48499f 100644
--- a/headers/os/interface/Rect.h
+++ b/headers/os/interface/Rect.h
@@ -1,16 +1,16 @@
 /*
- * Copyright 2001-2009, Haiku, Inc. All rights reserved.
+ * Copyright 2001-2012, Haiku, Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  */
 #ifndef        _RECT_H
 #define        _RECT_H
 
 
+#include <math.h>
+
 #include <Point.h>
 #include <Size.h>
 
-#include <math.h>
-
 
 class BRect {
 public:
@@ -54,16 +54,16 @@ public:
        // Expression transformations
                        BRect&                          InsetBySelf(BPoint 
inset);
                        BRect&                          InsetBySelf(float dx, 
float dy);
-                       BRect                           InsetByCopy(BPoint 
inset);
-                       BRect                           InsetByCopy(float dx, 
float dy);
+                       BRect                           InsetByCopy(BPoint 
inset) const;
+                       BRect                           InsetByCopy(float dx, 
float dy) const;
                        BRect&                          OffsetBySelf(BPoint 
offset);
                        BRect&                          OffsetBySelf(float dx, 
float dy);
-                       BRect                           OffsetByCopy(BPoint 
offset);
-                       BRect                           OffsetByCopy(float dx, 
float dy);
+                       BRect                           OffsetByCopy(BPoint 
offset) const;
+                       BRect                           OffsetByCopy(float dx, 
float dy) const;
                        BRect&                          OffsetToSelf(BPoint 
offset);
                        BRect&                          OffsetToSelf(float dx, 
float dy);
-                       BRect                           OffsetToCopy(BPoint 
offset);
-                       BRect                           OffsetToCopy(float dx, 
float dy);
+                       BRect                           OffsetToCopy(BPoint 
offset) const;
+                       BRect                           OffsetToCopy(float dx, 
float dy) const;
 
        // Comparison
                        bool                            operator==(BRect r) 
const;
@@ -120,7 +120,7 @@ inline
 BRect::BRect()
        :
        left(0),
-       top(0), 
+       top(0),
        right(-1),
        bottom(-1)
 {
diff --git a/src/kits/interface/Rect.cpp b/src/kits/interface/Rect.cpp
index c56d51d..20b5130 100644
--- a/src/kits/interface/Rect.cpp
+++ b/src/kits/interface/Rect.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
+ * Copyright 2001-2012, Haiku, Inc. All Rights Reserved.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -80,7 +80,7 @@ BRect::InsetBySelf(float dx, float dy)
 
 
 BRect
-BRect::InsetByCopy(BPoint point)
+BRect::InsetByCopy(BPoint point) const
 {
        BRect copy(*this);
        copy.InsetBy(point);
@@ -89,7 +89,7 @@ BRect::InsetByCopy(BPoint point)
 
 
 BRect
-BRect::InsetByCopy(float dx, float dy)
+BRect::InsetByCopy(float dx, float dy) const
 {
        BRect copy(*this);
        copy.InsetBy(dx, dy);
@@ -134,7 +134,7 @@ BRect::OffsetBySelf(float dx, float dy)
 
 
 BRect
-BRect::OffsetByCopy(BPoint point)
+BRect::OffsetByCopy(BPoint point) const
 {
        BRect copy(*this);
        copy.OffsetBy(point);
@@ -143,7 +143,7 @@ BRect::OffsetByCopy(BPoint point)
 
 
 BRect
-BRect::OffsetByCopy(float dx, float dy)
+BRect::OffsetByCopy(float dx, float dy) const
 {
        BRect copy(*this);
        copy.OffsetBy(dx, dy);
@@ -188,7 +188,7 @@ BRect::OffsetToSelf(float dx, float dy)
 
 
 BRect
-BRect::OffsetToCopy(BPoint point)
+BRect::OffsetToCopy(BPoint point) const
 {
        BRect copy(*this);
        copy.OffsetTo(point);
@@ -197,7 +197,7 @@ BRect::OffsetToCopy(BPoint point)
 
 
 BRect
-BRect::OffsetToCopy(float dx, float dy)
+BRect::OffsetToCopy(float dx, float dy) const
 {
        BRect copy(*this);
        copy.OffsetTo(dx, dy);
@@ -215,31 +215,31 @@ BRect::PrintToStream() const
 bool
 BRect::operator==(BRect rect) const
 {
-        return left == rect.left && right == rect.right &&
-                       top == rect.top && bottom == rect.bottom;
+       return left == rect.left && right == rect.right &&
+               top == rect.top && bottom == rect.bottom;
 }
 
 
 bool
 BRect::operator!=(BRect rect) const
 {
-        return !(*this == rect);
+       return !(*this == rect);
 }
 
 
 BRect
 BRect::operator&(BRect rect) const
 {
-        return BRect(max_c(left, rect.left), max_c(top, rect.top),
-                                 min_c(right, rect.right), min_c(bottom, 
rect.bottom));
+       return BRect(max_c(left, rect.left), max_c(top, rect.top),
+               min_c(right, rect.right), min_c(bottom, rect.bottom));
 }
 
 
 BRect
 BRect::operator|(BRect rect) const
 {
-        return BRect(min_c(left, rect.left), min_c(top, rect.top),
-                                 max_c(right, rect.right), max_c(bottom, 
rect.bottom));
+       return BRect(min_c(left, rect.left), min_c(top, rect.top),
+               max_c(right, rect.right), max_c(bottom, rect.bottom));
 }
 
 
@@ -250,7 +250,7 @@ BRect::Intersects(BRect rect) const
                return false;
 
        return !(rect.left > right || rect.right < left
-                       || rect.top > bottom || rect.bottom < top);     
+               || rect.top > bottom || rect.bottom < top);
 }
 
 
@@ -258,7 +258,7 @@ bool
 BRect::Contains(BPoint point) const
 {
        return point.x >= left && point.x <= right
-                       && point.y >= top && point.y <= bottom;
+               && point.y >= top && point.y <= bottom;
 }
 
 
@@ -266,5 +266,66 @@ bool
 BRect::Contains(BRect rect) const
 {
        return rect.left >= left && rect.right <= right
-                       && rect.top >= top && rect.bottom <= bottom;
+               && rect.top >= top && rect.bottom <= bottom;
 }
+
+
+// #pragma mark - BeOS compatibility only
+#if __GNUC__ == 2
+
+
+extern "C" BRect
+InsetByCopy__5BRectG6BPoint(BRect* self, BPoint point)
+{
+       BRect copy(*self);
+       copy.InsetBy(point);
+       return copy;
+}
+
+
+extern "C" BRect
+InsetByCopy__5BRectff(BRect* self, float dx, float dy)
+{
+       BRect copy(*self);
+       copy.InsetBy(dx, dy);
+       return copy;
+}
+
+
+extern "C" BRect
+OffsetByCopy__5BRectG6BPoint(BRect* self, BPoint point)
+{
+       BRect copy(*self);
+       copy.OffsetBy(point);
+       return copy;
+}
+
+
+extern "C" BRect
+OffsetByCopy__5BRectff(BRect* self, float dx, float dy)
+{
+       BRect copy(*self);
+       copy.OffsetBy(dx, dy);
+       return copy;
+}
+
+
+extern "C" BRect
+OffsetToCopy__5BRectG6BPoint(BRect* self, BPoint point)
+{
+       BRect copy(*self);
+       copy.OffsetTo(point);
+       return copy;
+}
+
+
+extern "C" BRect
+OffsetToCopy__5BRectff(BRect* self, float dx, float dy)
+{
+       BRect copy(*self);
+       copy.OffsetTo(dx, dy);
+       return copy;
+}
+
+
+#endif // __GNUC__ == 2


Other related posts:

  • » [haiku-commits] BRANCH axeld-github.imap - src/kits/interface headers/os/interface - axeld-github . imap