diff --git a/headers/os/app/Message.h b/headers/os/app/Message.h index 2e2c3d62cb..1cf0b4091f 100644 --- a/headers/os/app/Message.h +++ b/headers/os/app/Message.h @@ -301,8 +301,6 @@ friend class BMessenger; friend class BApplication; friend class Private; -friend void _msg_cache_cleanup_(); -friend BMessage *_reconstruct_msg_(uint32,uint32,uint32); friend inline void _set_message_target_(BMessage *, int32, bool); friend inline void _set_message_reply_(BMessage *, BMessenger); friend inline int32 _get_message_target_(BMessage *); @@ -362,13 +360,15 @@ static status_t _SendFlattenedMessage(void *data, int32 size, port_id port, int32 token, bool preferred, bigtime_t timeout); +static void _StaticInit(); +static void _StaticCleanup(); +static void _StaticCacheCleanup(); + enum { sNumReplyPorts = 3 }; static port_id sReplyPorts[sNumReplyPorts]; static long sReplyPortInUse[sNumReplyPorts]; static int32 sGetCachedReplyPort(); -friend int _init_message_(); -friend int _delete_message_(); static BBlockCache *sMsgCache; struct dyn_array { diff --git a/headers/private/app/MessagePrivate.h b/headers/private/app/MessagePrivate.h index 8c17ff4db9..73dae37b2c 100644 --- a/headers/private/app/MessagePrivate.h +++ b/headers/private/app/MessagePrivate.h @@ -6,25 +6,10 @@ #ifndef MESSAGEPRIVATE_H #define MESSAGEPRIVATE_H -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- #include #include #include -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - -extern "C" void _msg_cache_cleanup_(); -extern "C" int _init_message_(); -extern "C" int _delete_message_(); - class BMessage::Private { public: @@ -36,6 +21,7 @@ class BMessage::Private fMessage->fTarget = token; fMessage->fPreferred = preferred; } + inline void SetReply(BMessenger messenger) { BMessenger::Private mp(messenger); @@ -44,10 +30,12 @@ class BMessage::Private fMessage->fReplyTo.team = mp.Team(); fMessage->fReplyTo.preferred = mp.IsPreferredTarget(); } + inline int32 GetTarget() { return fMessage->fTarget; } + inline bool UsePreferredTarget() { return fMessage->fPreferred; @@ -60,6 +48,21 @@ class BMessage::Private preferred, timeout); } + static inline void StaticInit() + { + BMessage::_StaticInit(); + } + + static inline void StaticCleanup() + { + BMessage::_StaticCleanup(); + } + + static inline void StaticCacheCleanup() + { + BMessage::_StaticCacheCleanup(); + } + private: BMessage* fMessage; }; diff --git a/src/kits/app/InitTerminateLibBe.cpp b/src/kits/app/InitTerminateLibBe.cpp index 90f2c8282a..f114ec8a51 100644 --- a/src/kits/app/InitTerminateLibBe.cpp +++ b/src/kits/app/InitTerminateLibBe.cpp @@ -41,7 +41,7 @@ initialize_before() { DBG(OUT("initialize_before()\n")); - _init_message_(); + BMessage::Private::StaticInit(); BRoster::Private::InitBeRoster(); BPrivate::init_clipboard(); @@ -56,8 +56,8 @@ terminate_after() DBG(OUT("terminate_after()\n")); BRoster::Private::DeleteBeRoster(); - _delete_message_(); - _msg_cache_cleanup_(); + BMessage::Private::StaticCleanup(); + BMessage::Private::StaticCacheCleanup(); DBG(OUT("terminate_after() done\n")); } diff --git a/src/kits/app/Message.cpp b/src/kits/app/Message.cpp index 1ac5a9bf8c..af27494f3d 100644 --- a/src/kits/app/Message.cpp +++ b/src/kits/app/Message.cpp @@ -101,44 +101,6 @@ static status_t handle_reply(port_id reply_port, static status_t convert_message(const KMessage *fromMessage, BMessage *toMessage); -//------------------------------------------------------------------------------ -extern "C" { -void _msg_cache_cleanup_() -{ - delete BMessage::sMsgCache; - BMessage::sMsgCache = NULL; -} -//------------------------------------------------------------------------------ -int _init_message_() -{ - BMessage::sReplyPorts[0] = create_port(1, "tmp_rport0"); - BMessage::sReplyPorts[1] = create_port(1, "tmp_rport1"); - BMessage::sReplyPorts[2] = create_port(1, "tmp_rport2"); - - BMessage::sReplyPortInUse[0] = 0; - BMessage::sReplyPortInUse[1] = 0; - BMessage::sReplyPortInUse[2] = 0; - return 0; -} -//------------------------------------------------------------------------------ -int _delete_message_() -{ - delete_port(BMessage::sReplyPorts[0]); - BMessage::sReplyPorts[0] = -1; - delete_port(BMessage::sReplyPorts[1]); - BMessage::sReplyPorts[1] = -1; - delete_port(BMessage::sReplyPorts[2]); - BMessage::sReplyPorts[2] = -1; - return 0; -} -} // extern "C" -//------------------------------------------------------------------------------ -BMessage *_reconstruct_msg_(uint32,uint32,uint32) -{ - return NULL; -} -//------------------------------------------------------------------------------ - void BMessage::_ReservedMessage1() {} void BMessage::_ReservedMessage2() {} void BMessage::_ReservedMessage3() {} @@ -1976,6 +1938,39 @@ BMessage::_SendFlattenedMessage(void *data, int32 size, port_id port, } +void +BMessage::_StaticCacheCleanup() +{ + delete sMsgCache; + sMsgCache = NULL; +} + + +void +BMessage::_StaticInit() +{ + sReplyPorts[0] = create_port(1, "tmp_rport0"); + sReplyPorts[1] = create_port(1, "tmp_rport1"); + sReplyPorts[2] = create_port(1, "tmp_rport2"); + + sReplyPortInUse[0] = 0; + sReplyPortInUse[1] = 0; + sReplyPortInUse[2] = 0; +} + + +void +BMessage::_StaticCleanup() +{ + delete_port(sReplyPorts[0]); + sReplyPorts[0] = -1; + delete_port(sReplyPorts[1]); + sReplyPorts[1] = -1; + delete_port(sReplyPorts[2]); + sReplyPorts[2] = -1; +} + + int32 BMessage::sGetCachedReplyPort() {