Fix templates for PortMessage & PortLink.
Update BApplication for changes to PortLink git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3959 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -420,8 +420,8 @@ void BApplication::SetCursor(const BCursor* cursor, bool sync)
|
|||||||
// TODO: add sync support - working on updating FlushWithReply --DW
|
// TODO: add sync support - working on updating FlushWithReply --DW
|
||||||
PortLink *link=new PortLink(fServerTo);
|
PortLink *link=new PortLink(fServerTo);
|
||||||
link->SetOpCode(AS_SET_CURSOR_BCURSOR);
|
link->SetOpCode(AS_SET_CURSOR_BCURSOR);
|
||||||
link->Attach(sync);
|
link->Attach<bool>(sync);
|
||||||
link->Attach(cursor->m_serverToken);
|
link->Attach<int32>(cursor->m_serverToken);
|
||||||
link->Flush();
|
link->Flush();
|
||||||
delete link;
|
delete link;
|
||||||
}
|
}
|
||||||
@@ -757,8 +757,8 @@ void BApplication::InitData(const char* signature, status_t* error)
|
|||||||
|
|
||||||
PortLink *link=new PortLink(fServerFrom);
|
PortLink *link=new PortLink(fServerFrom);
|
||||||
link->SetOpCode(AS_CREATE_APP);
|
link->SetOpCode(AS_CREATE_APP);
|
||||||
link->Attach((int32)fServerTo);
|
link->Attach<int32>((int32)fServerTo);
|
||||||
link->Attach(_get_object_token_(this));
|
link->Attach<int32>(_get_object_token_(this));
|
||||||
link->Attach((char*)signature,strlen(signature)+1);
|
link->Attach((char*)signature,strlen(signature)+1);
|
||||||
status_t replyerr=link->FlushWithReply(&replydata);
|
status_t replyerr=link->FlushWithReply(&replydata);
|
||||||
if(replyerr==B_OK)
|
if(replyerr==B_OK)
|
||||||
@@ -801,8 +801,8 @@ void BApplication::BeginRectTracking(BRect r, bool trackWhole)
|
|||||||
{
|
{
|
||||||
PortLink *link=new PortLink(fServerTo);
|
PortLink *link=new PortLink(fServerTo);
|
||||||
link->SetOpCode(AS_BEGIN_RECT_TRACKING);
|
link->SetOpCode(AS_BEGIN_RECT_TRACKING);
|
||||||
link->Attach(r);
|
link->Attach<BRect>(r);
|
||||||
link->Attach(trackWhole);
|
link->Attach<int32>(trackWhole);
|
||||||
link->Flush();
|
link->Flush();
|
||||||
delete link;
|
delete link;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,23 +43,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*!
|
|
||||||
\class PortLinkData PortLink.cpp
|
|
||||||
\brief Internal data storage class
|
|
||||||
|
|
||||||
PortLinkData objects serve to hold attached data whilst it is waiting to be Flattened()
|
|
||||||
and then Flushed(). There is no need for this to be used outside the PortLink class.
|
|
||||||
*/
|
|
||||||
class PortLinkData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PortLinkData(void);
|
|
||||||
~PortLinkData(void);
|
|
||||||
status_t Set(const void *data, size_t size);
|
|
||||||
char *buffer;
|
|
||||||
size_t buffersize;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
\param port A valid target port_id
|
\param port A valid target port_id
|
||||||
@@ -536,30 +519,6 @@ printf("\tAttach(): Couldn't assign data to PortLinkData object\n");
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type> status_t PortLink::Attach(Type data)
|
|
||||||
{
|
|
||||||
int32 size=sizeof(Type);
|
|
||||||
|
|
||||||
#ifdef CAPACITY_CHECKING
|
|
||||||
if(bufferlength+size>capacity)
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// create a new storage object and stash the data
|
|
||||||
PortLinkData *pld=new PortLinkData;
|
|
||||||
if(pld->Set(&data,size)==B_OK)
|
|
||||||
{
|
|
||||||
attachlist->AddItem(pld);
|
|
||||||
bufferlength+=size;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete pld;
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PortLink::FlattenData(int8 **buffer,int32 *size)
|
void PortLink::FlattenData(int8 **buffer,int32 *size)
|
||||||
{
|
{
|
||||||
// This function is where all the magic happens, but it is strictly internal.
|
// This function is where all the magic happens, but it is strictly internal.
|
||||||
|
|||||||
@@ -128,24 +128,6 @@ void PortMessage::SetBuffer(const void *buffer, const ssize_t &size, const bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Type> status_t PortMessage::Read(Type *data)
|
|
||||||
{
|
|
||||||
int32 size = sizeof(Type);
|
|
||||||
|
|
||||||
if(!data)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
if( !_buffer ||
|
|
||||||
(_buffersize < size) ||
|
|
||||||
(_index+size > _buffer+_buffersize) )
|
|
||||||
return B_NO_MEMORY;
|
|
||||||
|
|
||||||
*data=*((Type*)_index);
|
|
||||||
_index+=size;
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t PortMessage::Read(void *data, ssize_t size)
|
status_t PortMessage::Read(void *data, ssize_t size)
|
||||||
{
|
{
|
||||||
if(!data || size<1)
|
if(!data || size<1)
|
||||||
|
|||||||
Reference in New Issue
Block a user