Bug 1194721: Add additional PDU pack and unpack functions, r=shuang

This patch adds PDU pack and unpack functions for 64-bit integer
values and floating-point values.
This commit is contained in:
Thomas Zimmermann 2016-02-04 12:35:13 +01:00
parent 57b67a5438
commit 3a35f019a6
2 changed files with 88 additions and 0 deletions

View File

@ -188,6 +188,30 @@ PackPDU(uint32_t aIn, DaemonSocketPDU& aPDU)
return aPDU.Write(aIn);
}
inline nsresult
PackPDU(int64_t aIn, DaemonSocketPDU& aPDU)
{
return aPDU.Write(aIn);
}
inline nsresult
PackPDU(uint64_t aIn, DaemonSocketPDU& aPDU)
{
return aPDU.Write(aIn);
}
inline nsresult
PackPDU(float aIn, DaemonSocketPDU& aPDU)
{
return aPDU.Write(aIn);
}
inline nsresult
PackPDU(double aIn, DaemonSocketPDU& aPDU)
{
return aPDU.Write(aIn);
}
nsresult
PackPDU(const DaemonSocketPDUHeader& aIn, DaemonSocketPDU& aPDU);
@ -646,6 +670,30 @@ UnpackPDU(DaemonSocketPDU& aPDU, uint32_t& aOut)
return aPDU.Read(aOut);
}
inline nsresult
UnpackPDU(DaemonSocketPDU& aPDU, int64_t& aOut)
{
return aPDU.Read(aOut);
}
inline nsresult
UnpackPDU(DaemonSocketPDU& aPDU, uint64_t& aOut)
{
return aPDU.Read(aOut);
}
inline nsresult
UnpackPDU(DaemonSocketPDU& aPDU, float& aOut)
{
return aPDU.Read(aOut);
}
inline nsresult
UnpackPDU(DaemonSocketPDU& aPDU, double& aOut)
{
return aPDU.Read(aOut);
}
inline nsresult
UnpackPDU(DaemonSocketPDU& aPDU, DaemonSocketPDUHeader& aOut)
{

View File

@ -73,6 +73,26 @@ public:
return Read(&aValue, sizeof(aValue));
}
nsresult Read(int64_t& aValue)
{
return Read(&aValue, sizeof(aValue));
}
nsresult Read(uint64_t& aValue)
{
return Read(&aValue, sizeof(aValue));
}
nsresult Read(float& aValue)
{
return Read(&aValue, sizeof(aValue));
}
nsresult Read(double& aValue)
{
return Read(&aValue, sizeof(aValue));
}
uint8_t* Append(size_t aLen);
nsresult Write(const void* aValue, size_t aLen);
@ -107,6 +127,26 @@ public:
return Write(&aValue, sizeof(aValue));
}
nsresult Write(int64_t aValue)
{
return Write(&aValue, sizeof(aValue));
}
nsresult Write(uint64_t aValue)
{
return Write(&aValue, sizeof(aValue));
}
nsresult Write(float aValue)
{
return Write(&aValue, sizeof(aValue));
}
nsresult Write(double aValue)
{
return Write(&aValue, sizeof(aValue));
}
protected:
UnixSocketBuffer();