Make rect data part of union as suggested by Ingo.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43100 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent
2011-11-02 09:19:24 +00:00
parent 38a0577422
commit 7bf8fcfab4
2 changed files with 17 additions and 15 deletions
+7 -6
View File
@@ -159,13 +159,14 @@ private:
void* fPointer; void* fPointer;
char* fString; char* fString;
BReferenceable* fReferenceable; BReferenceable* fReferenceable;
uint8 fBytes[8]; struct {
float left;
float top;
float right;
float bottom;
} fRect;
uint8 fBytes[sizeof(float) * 4];
}; };
float fLeft;
float fTop;
float fRight;
float fBottom;
}; };
+10 -9
View File
@@ -177,8 +177,9 @@ BVariant::operator==(const BVariant& other) const
return fString == other.fString; return fString == other.fString;
return strcmp(fString, other.fString) == 0; return strcmp(fString, other.fString) == 0;
case B_RECT_TYPE: case B_RECT_TYPE:
return BRect(fLeft, fTop, fRight, fBottom) == BRect( return BRect(fRect.left, fRect.top, fRect.right, fRect.bottom)
other.fLeft, other.fTop, other.fRight, other.fBottom); == BRect(other.fRect.left, other.fRect.top, other.fRect.right,
other.fRect.bottom);
default: default:
return false; return false;
} }
@@ -316,7 +317,7 @@ BVariant::ToDouble() const
BRect BRect
BVariant::ToRect() const BVariant::ToRect() const
{ {
return BRect(fLeft, fTop, fRight, fBottom); return BRect(fRect.left, fRect.top, fRect.right, fRect.bottom);
} }
@@ -405,8 +406,8 @@ BVariant::AddToMessage(BMessage& message, const char* fieldName) const
case B_STRING_TYPE: case B_STRING_TYPE:
return message.AddString(fieldName, fString); return message.AddString(fieldName, fString);
case B_RECT_TYPE: case B_RECT_TYPE:
return message.AddRect(fieldName, BRect(fLeft, fTop, fRight, return message.AddRect(fieldName, BRect(fRect.left, fRect.top,
fBottom)); fRect.right, fRect.bottom));
default: default:
return B_UNSUPPORTED; return B_UNSUPPORTED;
} }
@@ -633,10 +634,10 @@ BVariant::_SetTo(float left, float top, float right, float bottom)
{ {
fType = B_RECT_TYPE; fType = B_RECT_TYPE;
fFlags = 0; fFlags = 0;
fLeft = left; fRect.left = left;
fTop = top; fRect.top = top;
fRight = right; fRect.right = right;
fBottom = bottom; fRect.bottom = bottom;
} }