BPicture: Style fixes related to documentation.

Mostly pointer style adjustments
This commit is contained in:
John Scipione
2014-05-19 20:13:38 -04:00
parent 87d5f67840
commit df48d3f9a8
2 changed files with 110 additions and 97 deletions
+5 -6
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2009, Haiku, Inc. All rights reserved.
* Copyright 2001-2014 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _PICTURE_H
@@ -20,13 +20,12 @@ class BPicture : public BArchivable {
public:
BPicture();
BPicture(const BPicture& other);
BPicture(BMessage* archive);
BPicture(BMessage* data);
virtual ~BPicture();
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive,
bool deep = true) const;
virtual status_t Perform(perform_code d, void* arg);
static BArchivable* Instantiate(BMessage* data);
virtual status_t Archive(BMessage* data, bool deep = true) const;
virtual status_t Perform(perform_code code, void* arg);
status_t Play(void** callBackTable,
int32 tableEntries,
+50 -36
View File
@@ -1,12 +1,13 @@
/*
* Copyright 2001-2007, Haiku Inc.
* Copyright 2001-2014 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Marc Flerackers ([email protected])
* Marc Flerackers, [email protected]
*/
//! BPicture records a series of drawing instructions that can be "replayed" later.
// Records a series of drawing instructions that can be "replayed" later.
#include <Picture.h>
@@ -88,7 +89,6 @@ struct _BPictureExtent_ {
int32 CountPictures() const
{ return fPictures.CountItems(); }
private:
void* fNewData;
int32 fNewSize;
@@ -129,25 +129,27 @@ BPicture::BPicture(const BPicture &otherPicture)
link.Attach<int32>(otherPicture.fToken);
status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK
&& status == B_OK)
if (link.FlushWithReply(status) == B_OK && status == B_OK)
link.Read<int32>(&fToken);
if (status < B_OK)
return;
}
if (otherPicture.fExtent->Size() > 0) {
fExtent->ImportData(otherPicture.fExtent->Data(), otherPicture.fExtent->Size());
fExtent->ImportData(otherPicture.fExtent->Data(),
otherPicture.fExtent->Size());
for (int32 i = 0; i < otherPicture.fExtent->CountPictures(); i++) {
BPicture *picture = new BPicture(*otherPicture.fExtent->PictureAt(i));
BPicture* picture
= new BPicture(*otherPicture.fExtent->PictureAt(i));
fExtent->AddPicture(picture);
}
}
}
BPicture::BPicture(BMessage *archive)
BPicture::BPicture(BMessage* data)
:
fToken(-1),
fExtent(NULL),
@@ -156,24 +158,26 @@ BPicture::BPicture(BMessage *archive)
_InitData();
int32 version;
if (archive->FindInt32("_ver", &version) != B_OK)
if (data->FindInt32("_ver", &version) != B_OK)
version = 0;
int8 endian;
if (archive->FindInt8("_endian", &endian) != B_OK)
if (data->FindInt8("_endian", &endian) != B_OK)
endian = 0;
const void *data;
const void* pictureData;
int32 size;
if (archive->FindData("_data", B_RAW_TYPE, &data, (ssize_t*)&size) != B_OK)
if (data->FindData("_data", B_RAW_TYPE, &pictureData, (ssize_t*)&size)
!= B_OK) {
return;
}
// Load sub pictures
BMessage picMsg;
BMessage pictureMessage;
int32 i = 0;
while (archive->FindMessage("piclib", i++, &picMsg) == B_OK) {
BPicture *pic = new BPicture(&picMsg);
fExtent->AddPicture(pic);
while (data->FindMessage("piclib", i++, &pictureMessage) == B_OK) {
BPicture* picture = new BPicture(&pictureMessage);
fExtent->AddPicture(picture);
}
if (version == 0) {
@@ -245,45 +249,45 @@ BPicture::_DisposeData()
BArchivable*
BPicture::Instantiate(BMessage *archive)
BPicture::Instantiate(BMessage* data)
{
if (validate_instantiation(archive, "BPicture"))
return new BPicture(archive);
if (validate_instantiation(data, "BPicture"))
return new BPicture(data);
return NULL;
}
status_t
BPicture::Archive(BMessage *archive, bool deep) const
BPicture::Archive(BMessage* data, bool deep) const
{
if (!const_cast<BPicture*>(this)->_AssertLocalCopy())
return B_ERROR;
status_t err = BArchivable::Archive(archive, deep);
status_t err = BArchivable::Archive(data, deep);
if (err != B_OK)
return err;
err = archive->AddInt32("_ver", 1);
err = data->AddInt32("_ver", 1);
if (err != B_OK)
return err;
err = archive->AddInt8("_endian", B_HOST_IS_BENDIAN);
err = data->AddInt8("_endian", B_HOST_IS_BENDIAN);
if (err != B_OK)
return err;
err = archive->AddData("_data", B_RAW_TYPE, fExtent->Data(), fExtent->Size());
err = data->AddData("_data", B_RAW_TYPE, fExtent->Data(), fExtent->Size());
if (err != B_OK)
return err;
for (int32 i = 0; i < fExtent->CountPictures(); i++) {
BMessage picMsg;
BMessage pictureMessage;
err = fExtent->PictureAt(i)->Archive(&picMsg, deep);
err = fExtent->PictureAt(i)->Archive(&pictureMessage, deep);
if (err != B_OK)
break;
err = archive->AddMessage("piclib", &picMsg);
err = data->AddMessage("piclib", &pictureMessage);
if (err != B_OK)
break;
}
@@ -293,9 +297,9 @@ BPicture::Archive(BMessage *archive, bool deep) const
status_t
BPicture::Perform(perform_code d, void *arg)
BPicture::Perform(perform_code code, void* arg)
{
return BArchivable::Perform(d, arg);
return BArchivable::Perform(code, arg);
}
@@ -305,7 +309,8 @@ BPicture::Play(void **callBackTable, int32 tableEntries, void *user)
if (!_AssertLocalCopy())
return B_ERROR;
BPrivate::PicturePlayer player(fExtent->Data(), fExtent->Size(), fExtent->Pictures());
BPrivate::PicturePlayer player(fExtent->Data(), fExtent->Size(),
fExtent->Pictures());
return player.Play(callBackTable, tableEntries, user);
}
@@ -323,6 +328,7 @@ BPicture::Flatten(BDataIO *stream)
ssize_t bytesWritten = stream->Write(&header, sizeof(header));
if (bytesWritten < B_OK)
return bytesWritten;
if (bytesWritten != (ssize_t)sizeof(header))
return B_IO_ERROR;
@@ -339,6 +345,7 @@ BPicture::Unflatten(BDataIO *stream)
ssize_t bytesRead = stream->Read(&header, sizeof(header));
if (bytesRead < B_OK)
return bytesRead;
if (bytesRead != (ssize_t)sizeof(header)
|| header.magic1 != 2 || header.magic2 != 0)
return B_BAD_TYPE;
@@ -434,7 +441,7 @@ BPicture::_Upload()
for (int32 i = 0; i < fExtent->CountPictures(); i++) {
BPicture* picture = fExtent->PictureAt(i);
if (picture)
if (picture != NULL)
link.Attach<int32>(picture->fToken);
else
link.Attach<int32>(-1);
@@ -444,8 +451,9 @@ BPicture::_Upload()
status_t status = B_ERROR;
if (link.FlushWithReply(status) == B_OK
&& status == B_OK)
&& status == B_OK) {
link.Read<int32>(&fToken);
}
return status;
}
@@ -469,9 +477,9 @@ BPicture::_Download()
// Read sub picture tokens
for (int32 i = 0; i < count; i++) {
BPicture *pic = new BPicture;
link.Read<int32>(&pic->fToken);
fExtent->AddPicture(pic);
BPicture* picture = new BPicture;
link.Read<int32>(&picture->fToken);
fExtent->AddPicture(picture);
}
int32 size;
@@ -603,6 +611,7 @@ _BPictureExtent_::Unflatten(BDataIO *stream)
bytesRead = stream->Read(&size, sizeof(size));
if (bytesRead < B_OK)
return bytesRead;
if (bytesRead != (ssize_t)sizeof(size))
return B_IO_ERROR;
@@ -616,6 +625,7 @@ _BPictureExtent_::Unflatten(BDataIO *stream)
bytesRead = stream->Read(fNewData, size);
if (bytesRead < B_OK)
return bytesRead;
if (bytesRead != (ssize_t)size)
return B_IO_ERROR;
@@ -630,6 +640,7 @@ _BPictureExtent_::Flatten(BDataIO *stream)
ssize_t bytesWritten = stream->Write(&count, sizeof(count));
if (bytesWritten < B_OK)
return bytesWritten;
if (bytesWritten != (ssize_t)sizeof(count))
return B_IO_ERROR;
@@ -642,12 +653,14 @@ _BPictureExtent_::Flatten(BDataIO *stream)
bytesWritten = stream->Write(&fNewSize, sizeof(fNewSize));
if (bytesWritten < B_OK)
return bytesWritten;
if (bytesWritten != (ssize_t)sizeof(fNewSize))
return B_IO_ERROR;
bytesWritten = stream->Write(fNewData, fNewSize);
if (bytesWritten < B_OK)
return bytesWritten;
if (bytesWritten != fNewSize)
return B_IO_ERROR;
@@ -671,6 +684,7 @@ _BPictureExtent_::SetSize(const int32 &size)
void* data = realloc(fNewData, size);
if (data == NULL)
return B_NO_MEMORY;
fNewData = data;
}