Applied patch by Vasilis:
* Fixed warnings in Message.cpp and Messenger.cpp when building with GCC 4. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24643 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,19 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2005-2007, Haiku Inc. All rights reserved.
|
* Copyright 2005-2008, Haiku Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Michael Lotz <[email protected]>
|
* Michael Lotz <[email protected]>
|
||||||
*/
|
*/
|
||||||
#include <Message.h>
|
|
||||||
#include <MessageAdapter.h>
|
|
||||||
#include <MessagePrivate.h>
|
|
||||||
#include <MessageUtils.h>
|
|
||||||
|
|
||||||
#include <TokenSpace.h>
|
#include <Message.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <AppMisc.h>
|
|
||||||
#include <BlockCache.h>
|
#include <BlockCache.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <MessageQueue.h>
|
#include <MessageQueue.h>
|
||||||
@@ -23,11 +24,11 @@
|
|||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <AppMisc.h>
|
||||||
#include <ctype.h>
|
#include <MessageAdapter.h>
|
||||||
#include <stdio.h>
|
#include <MessagePrivate.h>
|
||||||
#include <stdlib.h>
|
#include <MessageUtils.h>
|
||||||
#include <string.h>
|
#include <TokenSpace.h>
|
||||||
|
|
||||||
|
|
||||||
const char *B_SPECIFIER_ENTRY = "specifiers";
|
const char *B_SPECIFIER_ENTRY = "specifiers";
|
||||||
@@ -384,7 +385,8 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
case B_STRING_TYPE: {
|
case B_STRING_TYPE: {
|
||||||
ssize_t size = *(ssize_t *)pointer;
|
ssize_t size = *(ssize_t *)pointer;
|
||||||
pointer += sizeof(ssize_t);
|
pointer += sizeof(ssize_t);
|
||||||
printf("string(\"%s\", %ld bytes)\n", (char *)pointer, size);
|
printf("string(\"%s\", %ld bytes)\n", (char *)pointer,
|
||||||
|
(long)size);
|
||||||
pointer += size;
|
pointer += size;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -425,7 +427,7 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
BPrivate::entry_ref_unflatten(&ref, (char *)pointer, size);
|
BPrivate::entry_ref_unflatten(&ref, (char *)pointer, size);
|
||||||
|
|
||||||
printf("entry_ref(device=%ld, directory=%lld, name=\"%s\", ",
|
printf("entry_ref(device=%ld, directory=%lld, name=\"%s\", ",
|
||||||
ref.device, ref.directory, ref.name);
|
(long)ref.device, ref.directory, ref.name);
|
||||||
|
|
||||||
BPath path(&ref);
|
BPath path(&ref);
|
||||||
printf("path=\"%s\")\n", path.Path());
|
printf("path=\"%s\")\n", path.Path());
|
||||||
@@ -441,7 +443,7 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
BMessage message;
|
BMessage message;
|
||||||
const ssize_t size = *(const ssize_t *)pointer;
|
const ssize_t size = *(const ssize_t *)pointer;
|
||||||
pointer += sizeof(ssize_t);
|
pointer += sizeof(ssize_t);
|
||||||
if (message.Unflatten((const char *)pointer)!=B_OK) {
|
if (message.Unflatten((const char *)pointer) != B_OK) {
|
||||||
fprintf(stderr, "couldn't unflatten item %ld\n", i);
|
fprintf(stderr, "couldn't unflatten item %ld\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -451,9 +453,10 @@ BMessage::_PrintToStream(const char* indent) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default:
|
||||||
printf("(type = '%.4s')(size = %ld)\n", (char *)&value, size);
|
printf("(type = '%.4s')(size = %ld)\n", (char *)&value,
|
||||||
}
|
(long)size);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,99 +1,76 @@
|
|||||||
//------------------------------------------------------------------------------
|
/*
|
||||||
// Copyright (c) 2001-2005, Haiku
|
* Copyright 2001-2008, Haiku Inc. All rights reserved.
|
||||||
//
|
* Distributed under the terms of the MIT License.
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
*
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
* Authors:
|
||||||
// to deal in the Software without restriction, including without limitation
|
* Ingo Weinhold, [email protected]
|
||||||
// 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.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// debugging
|
/*!
|
||||||
//#define DBG(x) x
|
\class BMessenger
|
||||||
#define DBG(x)
|
Delivers messages to local or remote targets.
|
||||||
#define OUT printf
|
*/
|
||||||
|
|
||||||
|
#include <Messenger.h>
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
// System Includes -------------------------------------------------------------
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <AppMisc.h>
|
||||||
#include <Handler.h>
|
#include <Handler.h>
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
#include <LooperList.h>
|
#include <LooperList.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <Messenger.h>
|
#include <MessageUtils.h>
|
||||||
#include <MessengerPrivate.h>
|
#include <MessengerPrivate.h>
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <TokenSpace.h>
|
#include <TokenSpace.h>
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
#include <ObjectLocker.h>
|
||||||
#include <AppMisc.h>
|
//#include "TokenSpace.h"
|
||||||
#include <MessageUtils.h>
|
|
||||||
#include "ObjectLocker.h"
|
|
||||||
#include "TokenSpace.h"
|
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
#define DBG(x)
|
||||||
|
#define OUT printf
|
||||||
// Local Defines ---------------------------------------------------------------
|
|
||||||
|
|
||||||
// Globals ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
using BPrivate::gDefaultTokens;
|
using BPrivate::gDefaultTokens;
|
||||||
using BPrivate::gLooperList;
|
using BPrivate::gLooperList;
|
||||||
using BPrivate::BLooperList;
|
using BPrivate::BLooperList;
|
||||||
using BPrivate::BObjectLocker;
|
using BPrivate::BObjectLocker;
|
||||||
|
|
||||||
enum {
|
|
||||||
NOT_IMPLEMENTED = B_ERROR,
|
// #pragma mark -
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
|
||||||
/*! \brief Creates an unitialized BMessenger.
|
/*! \brief Creates an unitialized BMessenger.
|
||||||
*/
|
*/
|
||||||
BMessenger::BMessenger()
|
BMessenger::BMessenger()
|
||||||
: fPort(-1),
|
:
|
||||||
|
fPort(-1),
|
||||||
fHandlerToken(B_NULL_TOKEN),
|
fHandlerToken(B_NULL_TOKEN),
|
||||||
fTeam(-1),
|
fTeam(-1),
|
||||||
fPreferredTarget(false)
|
fPreferredTarget(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy constructor
|
|
||||||
/*! \brief Creates a BMessenger and initializes it to have the same target
|
/*! \brief Creates a BMessenger and initializes it to have the same target
|
||||||
as the supplied messemger.
|
as the supplied messemger.
|
||||||
|
|
||||||
\param from The messenger to be copied.
|
\param from The messenger to be copied.
|
||||||
*/
|
*/
|
||||||
BMessenger::BMessenger(const BMessenger &from)
|
BMessenger::BMessenger(const BMessenger &from)
|
||||||
: fPort(from.fPort),
|
:
|
||||||
|
fPort(from.fPort),
|
||||||
fHandlerToken(from.fHandlerToken),
|
fHandlerToken(from.fHandlerToken),
|
||||||
fTeam(from.fTeam),
|
fTeam(from.fTeam),
|
||||||
fPreferredTarget(from.fPreferredTarget)
|
fPreferredTarget(from.fPreferredTarget)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// destructor
|
|
||||||
/*! \brief Frees all resources associated with this object.
|
/*! \brief Frees all resources associated with this object.
|
||||||
*/
|
*/
|
||||||
BMessenger::~BMessenger()
|
BMessenger::~BMessenger()
|
||||||
@@ -101,9 +78,6 @@ BMessenger::~BMessenger()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Operators and misc
|
|
||||||
|
|
||||||
// =
|
|
||||||
/*! \brief Makes this BMessenger a copy of the supplied one.
|
/*! \brief Makes this BMessenger a copy of the supplied one.
|
||||||
|
|
||||||
\param from the messenger to be copied.
|
\param from the messenger to be copied.
|
||||||
@@ -121,7 +95,7 @@ BMessenger::operator=(const BMessenger &from)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==
|
|
||||||
/*! \brief Returns whether this and the supplied messenger have the same
|
/*! \brief Returns whether this and the supplied messenger have the same
|
||||||
target.
|
target.
|
||||||
|
|
||||||
@@ -133,12 +107,12 @@ bool
|
|||||||
BMessenger::operator==(const BMessenger &other) const
|
BMessenger::operator==(const BMessenger &other) const
|
||||||
{
|
{
|
||||||
// Note: The fTeam fields are not compared.
|
// Note: The fTeam fields are not compared.
|
||||||
return (fPort == other.fPort
|
return fPort == other.fPort
|
||||||
&& fHandlerToken == other.fHandlerToken
|
&& fHandlerToken == other.fHandlerToken
|
||||||
&& fPreferredTarget == other.fPreferredTarget);
|
&& fPreferredTarget == other.fPreferredTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsValid
|
|
||||||
/*! \brief Returns whether the messenger's target looper does still exist.
|
/*! \brief Returns whether the messenger's target looper does still exist.
|
||||||
|
|
||||||
It is not checked whether the target handler is also still existing.
|
It is not checked whether the target handler is also still existing.
|
||||||
@@ -149,12 +123,11 @@ BMessenger::operator==(const BMessenger &other) const
|
|||||||
bool
|
bool
|
||||||
BMessenger::IsValid() const
|
BMessenger::IsValid() const
|
||||||
{
|
{
|
||||||
port_info info;
|
return fPort >= 0;
|
||||||
// return (fPort >= 0 && get_port_info(fPort, &info) == B_OK);
|
// for the build version, we don't actually check the port
|
||||||
return (fPort >= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Team
|
|
||||||
/*! \brief Returns the ID of the team the messenger's target lives in.
|
/*! \brief Returns the ID of the team the messenger's target lives in.
|
||||||
|
|
||||||
\return The team of the messenger's target.
|
\return The team of the messenger's target.
|
||||||
@@ -166,9 +139,6 @@ BMessenger::Team() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----- Private or reserved -----------------------------------------
|
|
||||||
|
|
||||||
// SetTo
|
|
||||||
/*! \brief Sets the messenger's team, target looper port and handler token.
|
/*! \brief Sets the messenger's team, target looper port and handler token.
|
||||||
|
|
||||||
If \a preferred is \c true, \a token is ignored.
|
If \a preferred is \c true, \a token is ignored.
|
||||||
@@ -184,11 +154,11 @@ BMessenger::SetTo(team_id team, port_id port, int32 token, bool preferred)
|
|||||||
{
|
{
|
||||||
fTeam = team;
|
fTeam = team;
|
||||||
fPort = port;
|
fPort = port;
|
||||||
fHandlerToken = (preferred ? B_PREFERRED_TOKEN : token);
|
fHandlerToken = preferred ? B_PREFERRED_TOKEN : token;
|
||||||
fPreferredTarget = preferred;
|
fPreferredTarget = preferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <
|
|
||||||
/*! \brief Returns whether the first one of two BMessengers is less than the
|
/*! \brief Returns whether the first one of two BMessengers is less than the
|
||||||
second one.
|
second one.
|
||||||
|
|
||||||
@@ -205,21 +175,20 @@ operator<(const BMessenger &_a, const BMessenger &_b)
|
|||||||
BMessenger::Private a(const_cast<BMessenger&>(_a));
|
BMessenger::Private a(const_cast<BMessenger&>(_a));
|
||||||
BMessenger::Private b(const_cast<BMessenger&>(_b));
|
BMessenger::Private b(const_cast<BMessenger&>(_b));
|
||||||
|
|
||||||
|
|
||||||
// significance:
|
// significance:
|
||||||
// 1. fPort
|
// 1. fPort
|
||||||
// 2. fHandlerToken
|
// 2. fHandlerToken
|
||||||
// 3. fPreferredTarget
|
// 3. fPreferredTarget
|
||||||
// fTeam is insignificant
|
// fTeam is insignificant
|
||||||
return (a.Port() < b.Port()
|
return a.Port() < b.Port()
|
||||||
|| a.Port() == b.Port()
|
|| (a.Port() == b.Port()
|
||||||
&& (a.Token() < b.Token()
|
&& (a.Token() < b.Token()
|
||||||
|| a.Token() == b.Token()
|
|| (a.Token() == b.Token()
|
||||||
&& !a.IsPreferredTarget()
|
&& !a.IsPreferredTarget()
|
||||||
&& b.IsPreferredTarget()));
|
&& b.IsPreferredTarget())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// !=
|
|
||||||
/*! \brief Returns whether two BMessengers have not the same target.
|
/*! \brief Returns whether two BMessengers have not the same target.
|
||||||
|
|
||||||
\param a The first messenger.
|
\param a The first messenger.
|
||||||
@@ -232,4 +201,3 @@ operator!=(const BMessenger &a, const BMessenger &b)
|
|||||||
{
|
{
|
||||||
return !(a == b);
|
return !(a == b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user