* made the dano and r5 message more similar to use (naming).

* coding style changes to structure naming.
* but no bug fixes yet...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15055 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-20 22:24:03 +00:00
parent 5232a619c1
commit e489029756
7 changed files with 397 additions and 367 deletions
+38 -43
View File
@@ -5,7 +5,6 @@
* Authors:
* Michael Lotz <[email protected]>
*/
#ifndef _MESSAGE_H
#define _MESSAGE_H
@@ -23,13 +22,10 @@
#include <AppDefs.h> /* For convenience */
#include <TypeConstants.h> /* For convenience */
class BBlockCache;
class BMessenger;
class BHandler;
class BString;
struct message_header_s;
struct field_header_s;
class BBlockCache;
class BMessenger;
class BHandler;
class BString;
// Private or reserved ---------------------------------------------------------
extern "C" void _msg_cache_cleanup_();
@@ -37,7 +33,6 @@ extern "C" int _init_message_();
extern "C" int _delete_message_();
//------------------------------------------------------------------------------
// Name lengths and Scripting specifiers ---------------------------------------
#define B_FIELD_NAME_LENGTH 255
#define B_PROPERTY_NAME_LENGTH 255
@@ -55,18 +50,15 @@ enum {
B_SPECIFIERS_END = 128
// app-defined specifiers start at B_SPECIFIERS_END + 1
};
//------------------------------------------------------------------------------
class BMessage {
public:
public:
uint32 what;
BMessage();
BMessage(uint32 what);
BMessage(const BMessage &other);
virtual ~BMessage();
virtual ~BMessage();
BMessage &operator=(const BMessage &other);
@@ -265,11 +257,13 @@ virtual ~BMessage();
float FindFloat(const char *, int32 n = 0) const;
double FindDouble(const char *, int32 n = 0) const;
class Private;
class Private;
struct message_header;
struct field_header;
private:
friend class Private;
friend class BMessageQueue;
private:
friend class Private;
friend class BMessageQueue;
status_t _InitCommon();
status_t _InitHeader();
@@ -277,54 +271,55 @@ friend class BMessageQueue;
status_t _ResizeData(int32 offset, int32 change);
uint32 _HashName(const char *name) const;
status_t _FindField(const char *name, type_code type,
field_header_s **result) const;
status_t _AddField(const char *name, type_code type,
bool isFixedSize, field_header_s **result);
status_t _RemoveField(field_header_s *field);
uint32 _HashName(const char* name) const;
status_t _FindField(const char* name, type_code type,
field_header** _result) const;
status_t _AddField(const char* name, type_code type,
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;
message_header_s*fHeader;
field_header_s *fFields;
uint8 *fData;
private:
message_header* fHeader;
field_header* fFields;
uint8* fData;
mutable BMessage *fOriginal;
mutable BMessage* fOriginal;
// fQueueLink is used by BMessageQueue to build a linked list
BMessage *fQueueLink;
BMessage* fQueueLink;
// fQueueLink is used by BMessageQueue to build a linked list
uint32 fReserved[11];
// deprecated
BMessage(BMessage *a_message);
BMessage(BMessage *message);
virtual void _ReservedMessage1();
virtual void _ReservedMessage2();
virtual void _ReservedMessage3();
virtual void _ReservedMessage1();
virtual void _ReservedMessage2();
virtual void _ReservedMessage3();
status_t _SendMessage(port_id port, int32 token, bigtime_t timeout,
bool replyRequired, BMessenger &replyTo) const;
status_t _SendMessage(port_id port, team_id portOwner,
int32 token, BMessage *reply, bigtime_t sendTimeout,
bigtime_t replyTimeout) const;
static status_t _SendFlattenedMessage(void *data, int32 size,
static status_t _SendFlattenedMessage(void *data, int32 size,
port_id port, int32 token, bigtime_t timeout);
static void _StaticInit();
static void _StaticCleanup();
static void _StaticCacheCleanup();
static int32 _StaticGetCachedReplyPort();
static void _StaticInit();
static void _StaticCleanup();
static void _StaticCacheCleanup();
static int32 _StaticGetCachedReplyPort();
enum { sNumReplyPorts = 3 };
static port_id sReplyPorts[sNumReplyPorts];
static long sReplyPortInUse[sNumReplyPorts];
static int32 sGetCachedReplyPort();
static port_id sReplyPorts[sNumReplyPorts];
static long sReplyPortInUse[sNumReplyPorts];
static int32 sGetCachedReplyPort();
static BBlockCache *sMsgCache;
static BBlockCache* sMsgCache;
};
#endif // _MESSAGE_H
+23 -23
View File
@@ -37,40 +37,40 @@ enum {
};
typedef struct field_header_s {
struct BMessage::field_header {
uint32 flags;
type_code type;
int32 nameLength;
int32 name_length;
int32 count;
ssize_t dataSize;
ssize_t data_size;
ssize_t allocated;
int32 offset;
int32 nextField;
} FieldHeader;
int32 next_field;
};
typedef struct message_header_s {
struct BMessage::message_header {
uint32 format;
uint32 what;
uint32 flags;
ssize_t fieldsSize;
ssize_t dataSize;
ssize_t fieldsAvailable;
ssize_t dataAvailable;
ssize_t fields_size;
ssize_t data_size;
ssize_t fields_available;
ssize_t data_available;
int32 target;
int32 currentSpecifier;
int32 current_specifier;
// reply info
port_id replyPort;
int32 replyTarget;
team_id replyTeam;
port_id reply_port;
int32 reply_target;
team_id reply_team;
// body info
int32 fieldCount;
int32 hashTableSize;
int32 hashTable[MESSAGE_BODY_HASH_TABLE_SIZE];
int32 field_count;
int32 hash_table_size;
int32 hash_table[MESSAGE_BODY_HASH_TABLE_SIZE];
/* The hash table does contain indexes into the field list and
not direct offsets to the fields. This has the advantage
@@ -78,7 +78,7 @@ typedef struct message_header_s {
The hash table must be reevaluated when we remove a field
though.
*/
} MessageHeader;
};
class BMessage::Private {
@@ -103,9 +103,9 @@ class BMessage::Private {
SetReply(BMessenger messenger)
{
BMessenger::Private messengerPrivate(messenger);
fMessage->fHeader->replyPort = messengerPrivate.Port();
fMessage->fHeader->replyTarget = messengerPrivate.Token();
fMessage->fHeader->replyTeam = messengerPrivate.Team();
fMessage->fHeader->reply_port = messengerPrivate.Port();
fMessage->fHeader->reply_target = messengerPrivate.Token();
fMessage->fHeader->reply_team = messengerPrivate.Team();
}
int32
@@ -132,13 +132,13 @@ class BMessage::Private {
return fMessage->_InitHeader();
}
MessageHeader*
BMessage::message_header*
GetMessageHeader()
{
return fMessage->fHeader;
}
FieldHeader*
BMessage::field_header*
GetMessageFields()
{
return fMessage->fFields;