Updated the messaging related build platform code with the current Haiku
version. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34259 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007, Haiku Inc. All Rights Reserved.
|
||||
* Copyright 2005-2009, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -106,9 +106,13 @@ class BMessage {
|
||||
status_t AddString(const char *name, const char *aString);
|
||||
status_t AddString(const char *name, const BString &aString);
|
||||
status_t AddInt8(const char *name, int8 value);
|
||||
status_t AddUInt8(const char *name, uint8 value);
|
||||
status_t AddInt16(const char *name, int16 value);
|
||||
status_t AddUInt16(const char *name, uint16 value);
|
||||
status_t AddInt32(const char *name, int32 value);
|
||||
status_t AddUInt32(const char *name, uint32 value);
|
||||
status_t AddInt64(const char *name, int64 value);
|
||||
status_t AddUInt64(const char *name, uint64 value);
|
||||
status_t AddBool(const char *name, bool aBoolean);
|
||||
status_t AddFloat(const char *name, float aFloat);
|
||||
status_t AddDouble(const char *name, double aDouble);
|
||||
@@ -138,12 +142,20 @@ class BMessage {
|
||||
status_t FindString(const char *name, int32 index, BString *string) const;
|
||||
status_t FindInt8(const char *name, int8 *value) const;
|
||||
status_t FindInt8(const char *name, int32 index, int8 *value) const;
|
||||
status_t FindUInt8(const char *name, uint8 *value) const;
|
||||
status_t FindUInt8(const char *name, int32 index, uint8 *value) const;
|
||||
status_t FindInt16(const char *name, int16 *value) const;
|
||||
status_t FindInt16(const char *name, int32 index, int16 *value) const;
|
||||
status_t FindUInt16(const char *name, uint16 *value) const;
|
||||
status_t FindUInt16(const char *name, int32 index, uint16 *value) const;
|
||||
status_t FindInt32(const char *name, int32 *value) const;
|
||||
status_t FindInt32(const char *name, int32 index, int32 *value) const;
|
||||
status_t FindUInt32(const char *name, uint32 *value) const;
|
||||
status_t FindUInt32(const char *name, int32 index, uint32 *value) const;
|
||||
status_t FindInt64(const char *name, int64 *value) const;
|
||||
status_t FindInt64(const char *name, int32 index, int64 *value) const;
|
||||
status_t FindUInt64(const char *name, uint64 *value) const;
|
||||
status_t FindUInt64(const char *name, int32 index, uint64 *value) const;
|
||||
status_t FindBool(const char *name, bool *value) const;
|
||||
status_t FindBool(const char *name, int32 index, bool *value) const;
|
||||
status_t FindFloat(const char *name, float *value) const;
|
||||
@@ -176,12 +188,20 @@ class BMessage {
|
||||
status_t ReplaceString(const char *name, int32 index, const BString &aString);
|
||||
status_t ReplaceInt8(const char *name, int8 value);
|
||||
status_t ReplaceInt8(const char *name, int32 index, int8 value);
|
||||
status_t ReplaceUInt8(const char *name, uint8 value);
|
||||
status_t ReplaceUInt8(const char *name, int32 index, uint8 value);
|
||||
status_t ReplaceInt16(const char *name, int16 value);
|
||||
status_t ReplaceInt16(const char *name, int32 index, int16 value);
|
||||
status_t ReplaceUInt16(const char *name, uint16 value);
|
||||
status_t ReplaceUInt16(const char *name, int32 index, uint16 value);
|
||||
status_t ReplaceInt32(const char *name, int32 value);
|
||||
status_t ReplaceInt32(const char *name, int32 index, int32 value);
|
||||
status_t ReplaceUInt32(const char *name, uint32 value);
|
||||
status_t ReplaceUInt32(const char *name, int32 index, uint32 value);
|
||||
status_t ReplaceInt64(const char *name, int64 value);
|
||||
status_t ReplaceInt64(const char *name, int32 index, int64 value);
|
||||
status_t ReplaceUInt64(const char *name, uint64 value);
|
||||
status_t ReplaceUInt64(const char *name, int32 index, uint64 value);
|
||||
status_t ReplaceBool(const char *name, bool aBoolean);
|
||||
status_t ReplaceBool(const char *name, int32 index, bool aBoolean);
|
||||
status_t ReplaceFloat(const char *name, float aFloat);
|
||||
@@ -203,6 +223,10 @@ class BMessage {
|
||||
status_t ReplaceData(const char *name, type_code type, int32 index,
|
||||
const void *data, ssize_t numBytes);
|
||||
|
||||
// Comparing data - Haiku experimental API
|
||||
bool HasSameData(const BMessage &other,
|
||||
bool ignoreFieldOrder = true, bool deep = false) const;
|
||||
|
||||
void *operator new(size_t size);
|
||||
void *operator new(size_t, void *pointer);
|
||||
void operator delete(void *pointer, size_t size);
|
||||
@@ -212,9 +236,13 @@ class BMessage {
|
||||
bool HasPoint(const char *, int32 n = 0) const;
|
||||
bool HasString(const char *, int32 n = 0) const;
|
||||
bool HasInt8(const char *, int32 n = 0) const;
|
||||
bool HasUInt8(const char *, int32 n = 0) const;
|
||||
bool HasInt16(const char *, int32 n = 0) const;
|
||||
bool HasUInt16(const char *, int32 n = 0) const;
|
||||
bool HasInt32(const char *, int32 n = 0) const;
|
||||
bool HasUInt32(const char *, int32 n = 0) const;
|
||||
bool HasInt64(const char *, int32 n = 0) const;
|
||||
bool HasUInt64(const char *, int32 n = 0) const;
|
||||
bool HasBool(const char *, int32 n = 0) const;
|
||||
bool HasFloat(const char *, int32 n = 0) const;
|
||||
bool HasDouble(const char *, int32 n = 0) const;
|
||||
@@ -244,11 +272,13 @@ class BMessage {
|
||||
friend class Private;
|
||||
friend class BMessageQueue;
|
||||
|
||||
status_t _InitCommon();
|
||||
status_t _InitCommon(bool initHeader);
|
||||
status_t _InitHeader();
|
||||
status_t _Clear();
|
||||
|
||||
status_t _ResizeData(int32 offset, int32 change);
|
||||
status_t _ValidateMessage();
|
||||
|
||||
status_t _ResizeData(uint32 offset, int32 change);
|
||||
|
||||
uint32 _HashName(const char* name) const;
|
||||
status_t _FindField(const char* name, type_code type,
|
||||
@@ -257,26 +287,29 @@ class BMessage {
|
||||
bool isFixedSize, field_header** _result);
|
||||
status_t _RemoveField(field_header* field);
|
||||
|
||||
ssize_t _NativeFlattenedSize() const;
|
||||
status_t _NativeFlatten(char *buffer, ssize_t size) const;
|
||||
status_t _NativeFlatten(BDataIO *stream, ssize_t *size = NULL) const;
|
||||
void _PrintToStream(const char* indent) const;
|
||||
|
||||
private:
|
||||
message_header* fHeader;
|
||||
field_header* fFields;
|
||||
uint8* fData;
|
||||
area_id fClonedArea;
|
||||
|
||||
uint32 fFieldsAvailable;
|
||||
size_t fDataAvailable;
|
||||
|
||||
mutable BMessage* fOriginal;
|
||||
|
||||
BMessage* fQueueLink;
|
||||
// fQueueLink is used by BMessageQueue to build a linked list
|
||||
|
||||
uint32 fReserved[9];
|
||||
|
||||
// deprecated
|
||||
BMessage(BMessage *message);
|
||||
|
||||
static void _StaticCacheCleanup();
|
||||
virtual void _ReservedMessage1();
|
||||
virtual void _ReservedMessage2();
|
||||
virtual void _ReservedMessage3();
|
||||
|
||||
static BBlockCache* sMsgCache;
|
||||
};
|
||||
|
||||
@@ -1,54 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2002, OpenBeOS
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: Messenger.h
|
||||
// Author: Ingo Weinhold ([email protected])
|
||||
// Description: BMessenger delivers messages to local or remote targets.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Ingo Weinhold ([email protected])
|
||||
*/
|
||||
#ifndef _MESSENGER_H
|
||||
#define _MESSENGER_H
|
||||
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <BeBuild.h>
|
||||
#include <OS.h>
|
||||
#include <ByteOrder.h>
|
||||
#include <Message.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
|
||||
// Globals ---------------------------------------------------------------------
|
||||
|
||||
class BHandler;
|
||||
class BLooper;
|
||||
|
||||
// BMessenger class ------------------------------------------------------------
|
||||
|
||||
class BMessenger {
|
||||
public:
|
||||
public:
|
||||
BMessenger();
|
||||
BMessenger(const BMessenger &from);
|
||||
~BMessenger();
|
||||
@@ -67,22 +37,18 @@ public:
|
||||
|
||||
private:
|
||||
friend class Private;
|
||||
|
||||
void SetTo(team_id team, port_id port, int32 token, bool preferred);
|
||||
|
||||
void _SetTo(team_id team, port_id port, int32 token);
|
||||
|
||||
private:
|
||||
port_id fPort;
|
||||
int32 fHandlerToken;
|
||||
team_id fTeam;
|
||||
int32 extra0;
|
||||
int32 extra1;
|
||||
bool fPreferredTarget;
|
||||
bool extra2;
|
||||
bool extra3;
|
||||
bool extra4;
|
||||
|
||||
int32 _reserved[3];
|
||||
};
|
||||
|
||||
_IMPEXP_BE bool operator<(const BMessenger &a, const BMessenger &b);
|
||||
_IMPEXP_BE bool operator!=(const BMessenger &a, const BMessenger &b);
|
||||
bool operator<(const BMessenger &a, const BMessenger &b);
|
||||
bool operator!=(const BMessenger &a, const BMessenger &b);
|
||||
|
||||
#endif // _MESSENGER_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2007, Haiku Inc. All rights reserved.
|
||||
* Copyright 2005-2009, Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
@@ -9,13 +9,14 @@
|
||||
#define _MESSAGE_PRIVATE_H_
|
||||
|
||||
#include <Message.h>
|
||||
#include <Messenger.h>
|
||||
#include <MessengerPrivate.h>
|
||||
#include <TokenSpace.h>
|
||||
|
||||
|
||||
#define MESSAGE_BODY_HASH_TABLE_SIZE 10
|
||||
#define MESSAGE_BODY_HASH_TABLE_SIZE 5
|
||||
#define MAX_DATA_PREALLOCATION B_PAGE_SIZE * 10
|
||||
#define MAX_FIELD_PREALLOCATION 50
|
||||
#define MAX_ITEM_PREALLOCATION B_PAGE_SIZE
|
||||
|
||||
|
||||
static const int32 kPortMessageCode = 'pjpp';
|
||||
@@ -28,8 +29,8 @@ enum {
|
||||
MESSAGE_FLAG_IS_REPLY = 0x0008,
|
||||
MESSAGE_FLAG_WAS_DELIVERED = 0x0010,
|
||||
MESSAGE_FLAG_HAS_SPECIFIERS = 0x0020,
|
||||
MESSAGE_FLAG_WAS_DROPPED = 0x0080,
|
||||
MESSAGE_FLAG_PASS_BY_AREA = 0x0100
|
||||
MESSAGE_FLAG_WAS_DROPPED = 0x0040,
|
||||
MESSAGE_FLAG_PASS_BY_AREA = 0x0080
|
||||
};
|
||||
|
||||
|
||||
@@ -40,15 +41,14 @@ enum {
|
||||
|
||||
|
||||
struct BMessage::field_header {
|
||||
uint32 flags;
|
||||
uint16 flags;
|
||||
uint16 name_length;
|
||||
type_code type;
|
||||
int32 name_length;
|
||||
int32 count;
|
||||
ssize_t data_size;
|
||||
ssize_t allocated;
|
||||
int32 offset;
|
||||
uint32 count;
|
||||
uint32 data_size;
|
||||
uint32 offset;
|
||||
int32 next_field;
|
||||
};
|
||||
} _PACKED;
|
||||
|
||||
|
||||
struct BMessage::message_header {
|
||||
@@ -56,17 +56,9 @@ struct BMessage::message_header {
|
||||
uint32 what;
|
||||
uint32 flags;
|
||||
|
||||
ssize_t fields_size;
|
||||
ssize_t data_size;
|
||||
ssize_t fields_available;
|
||||
ssize_t data_available;
|
||||
|
||||
uint32 fields_checksum;
|
||||
uint32 data_checksum;
|
||||
|
||||
int32 target;
|
||||
int32 current_specifier;
|
||||
area_id shared_area;
|
||||
area_id message_area;
|
||||
|
||||
// reply info
|
||||
port_id reply_port;
|
||||
@@ -74,8 +66,9 @@ struct BMessage::message_header {
|
||||
team_id reply_team;
|
||||
|
||||
// body info
|
||||
int32 field_count;
|
||||
int32 hash_table_size;
|
||||
uint32 data_size;
|
||||
uint32 field_count;
|
||||
uint32 hash_table_size;
|
||||
int32 hash_table[MESSAGE_BODY_HASH_TABLE_SIZE];
|
||||
|
||||
/* The hash table does contain indexes into the field list and
|
||||
@@ -84,18 +77,20 @@ struct BMessage::message_header {
|
||||
The hash table must be reevaluated when we remove a field
|
||||
though.
|
||||
*/
|
||||
};
|
||||
} _PACKED;
|
||||
|
||||
|
||||
class BMessage::Private {
|
||||
public:
|
||||
Private(BMessage *msg)
|
||||
: fMessage(msg)
|
||||
:
|
||||
fMessage(msg)
|
||||
{
|
||||
}
|
||||
|
||||
Private(BMessage &msg)
|
||||
: fMessage(&msg)
|
||||
:
|
||||
fMessage(&msg)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -105,6 +100,23 @@ class BMessage::Private {
|
||||
fMessage->fHeader->target = token;
|
||||
}
|
||||
|
||||
void
|
||||
SetReply(BMessenger messenger)
|
||||
{
|
||||
BMessenger::Private messengerPrivate(messenger);
|
||||
fMessage->fHeader->reply_port = messengerPrivate.Port();
|
||||
fMessage->fHeader->reply_target = messengerPrivate.Token();
|
||||
fMessage->fHeader->reply_team = messengerPrivate.Team();
|
||||
}
|
||||
|
||||
void
|
||||
SetReply(team_id team, port_id port, int32 target)
|
||||
{
|
||||
fMessage->fHeader->reply_port = port;
|
||||
fMessage->fHeader->reply_target = target;
|
||||
fMessage->fHeader->reply_team = team;
|
||||
}
|
||||
|
||||
int32
|
||||
GetTarget()
|
||||
{
|
||||
@@ -156,32 +168,6 @@ class BMessage::Private {
|
||||
return fMessage->fData;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
NativeFlattenedSize() const
|
||||
{
|
||||
return fMessage->_NativeFlattenedSize();
|
||||
}
|
||||
|
||||
status_t
|
||||
NativeFlatten(char *buffer, ssize_t size) const
|
||||
{
|
||||
return fMessage->_NativeFlatten(buffer, size);
|
||||
}
|
||||
|
||||
status_t
|
||||
NativeFlatten(BDataIO *stream, ssize_t *size) const
|
||||
{
|
||||
return fMessage->_NativeFlatten(stream, size);
|
||||
}
|
||||
|
||||
// static methods
|
||||
|
||||
static void
|
||||
StaticCacheCleanup()
|
||||
{
|
||||
BMessage::_StaticCacheCleanup();
|
||||
}
|
||||
|
||||
private:
|
||||
BMessage* fMessage;
|
||||
};
|
||||
|
||||
@@ -1,25 +1,31 @@
|
||||
/*
|
||||
* Copyright 2003-2005, Haiku.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef MESSENGER_PRIVATE_H
|
||||
#define MESSENGER_PRIVATE_H
|
||||
|
||||
#include <Messenger.h>
|
||||
|
||||
class BMessenger::Private
|
||||
{
|
||||
#include <Messenger.h>
|
||||
#include <TokenSpace.h>
|
||||
|
||||
|
||||
class BMessenger::Private {
|
||||
public:
|
||||
Private(BMessenger* msnger) : fMessenger(msnger) {;}
|
||||
Private(BMessenger& msnger) : fMessenger(&msnger) {;}
|
||||
Private(BMessenger* messenger) : fMessenger(messenger) {}
|
||||
Private(BMessenger& messenger) : fMessenger(&messenger) {}
|
||||
|
||||
port_id Port()
|
||||
{ return fMessenger->fPort; }
|
||||
int32 Token()
|
||||
int32 Token()
|
||||
{ return fMessenger->fHandlerToken; }
|
||||
team_id Team()
|
||||
{ return fMessenger->fTeam; }
|
||||
bool IsPreferredTarget()
|
||||
{ return fMessenger->fPreferredTarget; }
|
||||
bool IsPreferredTarget()
|
||||
{ return fMessenger->fHandlerToken == B_PREFERRED_TOKEN; }
|
||||
|
||||
void SetTo(team_id team, port_id port, int32 token, bool preferred)
|
||||
{ fMessenger->SetTo(team, port, token, preferred); }
|
||||
void SetTo(team_id team, port_id port, int32 token)
|
||||
{ fMessenger->_SetTo(team, port, token); }
|
||||
|
||||
private:
|
||||
BMessenger* fMessenger;
|
||||
|
||||
Reference in New Issue
Block a user