[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-commits
Subject: [haiku-commits] r42789 - haiku/trunk/src/kits/app
From: axeld () pinc-software ! de
Date: 2011-09-30 0:02:22
Message-ID: 20110930000222.D60D769A0F () vmsvn ! haiku-os ! org
[Download RAW message or body]
Author: axeld
Date: 2011-09-30 02:02:22 +0200 (Fri, 30 Sep 2011)
New Revision: 42789
Changeset: https://dev.haiku-os.org/changeset/42789
Modified:
haiku/trunk/src/kits/app/LinkReceiver.cpp
haiku/trunk/src/kits/app/ServerLink.cpp
Log:
* Coding style cleanup.
* The Read() method remembers the last error, so you don't have to check each
read when you do several in a row.
Modified: haiku/trunk/src/kits/app/LinkReceiver.cpp
===================================================================
--- haiku/trunk/src/kits/app/LinkReceiver.cpp 2011-09-30 00:00:56 UTC (rev 42788)
+++ haiku/trunk/src/kits/app/LinkReceiver.cpp 2011-09-30 00:02:22 UTC (rev 42789)
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2008, Haiku.
+ * Copyright 2001-2011, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -9,8 +9,10 @@
* Artur Wyszynski <harakash@gmail.com>
*/
-/** Class for low-overhead port-based messaging */
+/*! Class for low-overhead port-based messaging */
+
+
#include <LinkReceiver.h>
#include <stdlib.h>
@@ -47,6 +49,7 @@
namespace BPrivate {
+
LinkReceiver::LinkReceiver(port_id port)
:
fReceivePort(port), fRecvBuffer(NULL), fRecvPosition(0), fRecvStart(0),
@@ -233,7 +236,7 @@
} while (bytesRead == B_INTERRUPTED);
} else {
do {
- bytesRead = read_port(fReceivePort, &code, fRecvBuffer,
+ bytesRead = read_port(fReceivePort, &code, fRecvBuffer,
fRecvBufferSize);
} while (bytesRead == B_INTERRUPTED);
}
@@ -297,7 +300,7 @@
if (fReadError >= B_OK) {
void* areaAddress = areaInfo.address;
-
+
if (areaAddress && sourceArea >= B_OK) {
memcpy(data, areaAddress, passedSize);
delete_area(sourceArea);
@@ -345,7 +348,7 @@
if (_length)
*_length = length;
-
+
*_string = string;
return B_OK;
@@ -482,103 +485,106 @@
LinkReceiver::ReadGradient(BGradient** _gradient)
{
GTRACE(("LinkReceiver::ReadGradient\n"));
+
BGradient::Type gradientType;
int32 colorsCount;
- status_t ret;
- if ((ret = Read(&gradientType, sizeof(BGradient::Type))) != B_OK)
- return ret;
- if ((ret = Read(&colorsCount, sizeof(int32))) != B_OK)
- return ret;
+ Read(&gradientType, sizeof(BGradient::Type));
+ status_t status = Read(&colorsCount, sizeof(int32));
+ if (status != B_OK)
+ return status;
+
BGradient* gradient = gradient_for_type(gradientType);
if (!gradient)
return B_NO_MEMORY;
*_gradient = gradient;
-
+
if (colorsCount > 0) {
BGradient::ColorStop stop;
for (int i = 0; i < colorsCount; i++) {
- if ((ret = Read(&stop, sizeof(BGradient::ColorStop))) != B_OK)
- return ret;
+ if ((status = Read(&stop, sizeof(BGradient::ColorStop))) != B_OK)
+ return status;
if (!gradient->AddColorStop(stop, i))
return B_NO_MEMORY;
}
}
- switch(gradientType) {
- case BGradient::TYPE_LINEAR: {
+ switch (gradientType) {
+ case BGradient::TYPE_LINEAR:
+ {
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_LINEAR\n"));
BGradientLinear* linear = (BGradientLinear*)gradient;
BPoint start;
BPoint end;
- if ((ret = Read(&start, sizeof(BPoint))) != B_OK)
- return ret;
- if ((ret = Read(&end, sizeof(BPoint))) != B_OK)
- return ret;
+ Read(&start, sizeof(BPoint));
+ if ((status = Read(&end, sizeof(BPoint))) != B_OK)
+ return status;
linear->SetStart(start);
linear->SetEnd(end);
return B_OK;
}
- case BGradient::TYPE_RADIAL: {
+ case BGradient::TYPE_RADIAL:
+ {
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_RADIAL\n"));
BGradientRadial* radial = (BGradientRadial*)gradient;
BPoint center;
float radius;
- if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
- return ret;
- if ((ret = Read(&radius, sizeof(float))) != B_OK)
- return ret;
+ Read(¢er, sizeof(BPoint));
+ if ((status = Read(&radius, sizeof(float))) != B_OK)
+ return status;
radial->SetCenter(center);
radial->SetRadius(radius);
return B_OK;
}
- case BGradient::TYPE_RADIAL_FOCUS: {
+ case BGradient::TYPE_RADIAL_FOCUS:
+ {
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_RADIAL_FOCUS\n"));
BGradientRadialFocus* radialFocus =
(BGradientRadialFocus*)gradient;
BPoint center;
BPoint focal;
float radius;
- if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
- return ret;
- if ((ret = Read(&focal, sizeof(BPoint))) != B_OK)
- return ret;
- if ((ret = Read(&radius, sizeof(float))) != B_OK)
- return ret;
+ Read(¢er, sizeof(BPoint));
+ Read(&focal, sizeof(BPoint));
+ if ((status = Read(&radius, sizeof(float))) != B_OK)
+ return status;
radialFocus->SetCenter(center);
radialFocus->SetFocal(focal);
radialFocus->SetRadius(radius);
return B_OK;
}
- case BGradient::TYPE_DIAMOND: {
+ case BGradient::TYPE_DIAMOND:
+ {
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_DIAMOND\n"));
BGradientDiamond* diamond = (BGradientDiamond*)gradient;
BPoint center;
- if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
- return ret;
+ if ((status = Read(¢er, sizeof(BPoint))) != B_OK)
+ return status;
diamond->SetCenter(center);
return B_OK;
}
- case BGradient::TYPE_CONIC: {
+ case BGradient::TYPE_CONIC:
+ {
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_CONIC\n"));
BGradientConic* conic = (BGradientConic*)gradient;
BPoint center;
float angle;
- if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
- return ret;
- if ((ret = Read(&angle, sizeof(float))) != B_OK)
- return ret;
+ Read(¢er, sizeof(BPoint));
+ if ((status = Read(&angle, sizeof(float))) != B_OK)
+ return status;
conic->SetCenter(center);
conic->SetAngle(angle);
return B_OK;
}
- case BGradient::TYPE_NONE: {
+ case BGradient::TYPE_NONE:
+ {
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_NONE\n"));
break;
}
}
-
+
return B_ERROR;
}
+
} // namespace BPrivate
Modified: haiku/trunk/src/kits/app/ServerLink.cpp
===================================================================
--- haiku/trunk/src/kits/app/ServerLink.cpp 2011-09-30 00:00:56 UTC (rev 42788)
+++ haiku/trunk/src/kits/app/ServerLink.cpp 2011-09-30 00:02:22 UTC (rev 42789)
@@ -70,7 +70,7 @@
return fReceiver->Read(region->fData,
region->fCount * sizeof(clipping_rect));
}
-
+
return fReceiver->Read(®ion->fBounds, sizeof(clipping_rect));
}
@@ -84,7 +84,7 @@
return fSender->Attach(region.fData,
region.fCount * sizeof(clipping_rect));
}
-
+
return fSender->Attach(®ion.fBounds, sizeof(clipping_rect));
}
@@ -95,15 +95,15 @@
int32 opCount, ptCount;
fReceiver->Read(&opCount, sizeof(int32));
fReceiver->Read(&ptCount, sizeof(int32));
-
+
uint32 opList[opCount];
if (opCount > 0)
fReceiver->Read(opList, opCount * sizeof(uint32));
-
+
BPoint ptList[ptCount];
if (ptCount > 0)
fReceiver->Read(ptList, ptCount * sizeof(BPoint));
-
+
shape->SetData(opCount, ptCount, opList, ptList);
return B_OK;
}
@@ -115,9 +115,9 @@
int32 opCount, ptCount;
uint32* opList;
BPoint* ptList;
-
+
shape.GetData(&opCount, &ptCount, &opList, &ptList);
-
+
fSender->Attach(&opCount, sizeof(int32));
fSender->Attach(&ptCount, sizeof(int32));
if (opCount > 0)
@@ -135,7 +135,7 @@
return fReceiver->ReadGradient(_gradient);
}
-
+
status_t
ServerLink::AttachGradient(const BGradient& gradient)
{
@@ -152,30 +152,31 @@
sizeof(BGradient::ColorStop));
}
}
-
- switch(gradientType) {
- case BGradient::TYPE_LINEAR: {
+
+ switch (gradientType) {
+ case BGradient::TYPE_LINEAR:
+ {
GTRACE(("ServerLink::AttachGradient> type == TYPE_LINEAR\n"));
- const BGradientLinear* linear = (BGradientLinear*) &gradient;
- BPoint start = linear->Start();
- BPoint end = linear->End();
- fSender->Attach(&start, sizeof(BPoint));
- fSender->Attach(&end, sizeof(BPoint));
+ const BGradientLinear* linear = (BGradientLinear*)&gradient;
+ fSender->Attach(linear->Start());
+ fSender->Attach(linear->End());
break;
}
- case BGradient::TYPE_RADIAL: {
+ case BGradient::TYPE_RADIAL:
+ {
GTRACE(("ServerLink::AttachGradient> type == TYPE_RADIAL\n"));
- const BGradientRadial* radial = (BGradientRadial*) &gradient;
+ const BGradientRadial* radial = (BGradientRadial*)&gradient;
BPoint center = radial->Center();
float radius = radial->Radius();
fSender->Attach(¢er, sizeof(BPoint));
fSender->Attach(&radius, sizeof(float));
break;
}
- case BGradient::TYPE_RADIAL_FOCUS: {
+ case BGradient::TYPE_RADIAL_FOCUS:
+ {
GTRACE(("ServerLink::AttachGradient> type == TYPE_RADIAL_FOCUS\n"));
- const BGradientRadialFocus* radialFocus =
- (BGradientRadialFocus*) &gradient;
+ const BGradientRadialFocus* radialFocus
+ = (BGradientRadialFocus*)&gradient;
BPoint center = radialFocus->Center();
BPoint focal = radialFocus->Focal();
float radius = radialFocus->Radius();
@@ -184,23 +185,26 @@
fSender->Attach(&radius, sizeof(float));
break;
}
- case BGradient::TYPE_DIAMOND: {
+ case BGradient::TYPE_DIAMOND:
+ {
GTRACE(("ServerLink::AttachGradient> type == TYPE_DIAMOND\n"));
- const BGradientDiamond* diamond = (BGradientDiamond*) &gradient;
+ const BGradientDiamond* diamond = (BGradientDiamond*)&gradient;
BPoint center = diamond->Center();
fSender->Attach(¢er, sizeof(BPoint));
break;
}
- case BGradient::TYPE_CONIC: {
+ case BGradient::TYPE_CONIC:
+ {
GTRACE(("ServerLink::AttachGradient> type == TYPE_CONIC\n"));
- const BGradientConic* conic = (BGradientConic*) &gradient;
+ const BGradientConic* conic = (BGradientConic*)&gradient;
BPoint center = conic->Center();
float angle = conic->Angle();
fSender->Attach(¢er, sizeof(BPoint));
fSender->Attach(&angle, sizeof(float));
break;
}
- case BGradient::TYPE_NONE: {
+ case BGradient::TYPE_NONE:
+ {
GTRACE(("ServerLink::AttachGradient> type == TYPE_NONE\n"));
break;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic