Releases: pmmp/ext-encoding
Releases · pmmp/ext-encoding
0.5.0
Warning
This extension is still under development. I don't recommend depending on it for production usage.
Also, please note that the API may still change again before the 1.0.0 release.
Changes since 0.4.1
- Introduced array-of-type encoder and decoder functions for short, int, long, double and float types (
BE
,LE
andVarint
). These functions are 2-4x faster than encoding/decoding single elements with loops. Needless to say, they're also significantly faster than legacy code usingBinaryStream
. ByteBuffer
has been split intoByteBufferReader
andByteBufferWriter
parts.ByteBufferReader
requires a string in the constructor and puts its offset at the start.ByteBufferWriter
does not require anything (but can be given a starting string) and puts its offset at the end.
- Increased test coverage to verify symmetry of all encode/decode methods
- VarInts are now tested against known binary values to ensure parity with
pocketmine/binaryutils
- Added
BE
andLE
methods forUnsignedLong
. Note that these still technically return signed longs, since PHP doesn't have an unsigned type; however, these allow code to be more self-documenting when e.g. implementing a protocol.
0.4.1
⚠️ This extension is still experimental. DO NOT use this in production.
The API is still in development and will likely change again before stable release. I'm exploring how best to design it to minimize mistakes while also maximizing readability and intuitiveness.
Changes since 0.4.0
- Fixed data loss when reading large varlongs (#17, thanks @JuraSciix)
0.4.0
⚠️ This extension is still experimental. DO NOT use this in production.
The API is still in development and will likely change again before stable release. I'm exploring how best to design it to minimize mistakes while also maximizing readability and intuitiveness.
Changes since 0.3.0
- Support for PHP 8.4
- All type read/write functions have been pulled out of
ByteBuffer
into static methods:readUnsigned*LE
,readSigned*LE
, and correspondingwrite
methods have been moved toLE::
static methods (e.g.pmmp\encoding\LE::readUnsignedInt($buffer)
)readUnsigned*BE
,readSigned*BE
, and correspondingwrite
methods have been moved toBE::
static methods (e.g.pmmp\encoding\BE::readUnsignedInt($buffer)
)readUnsignedByte
,readSignedByte
, and correspondingwrite
methods have been moved toByte::
static methods (e.g.pmmp\encoding\Byte::readUnsignedByte($buffer)
readUnsignedVarInt
,readSignedVarInt
,readUnsignedVarLong
,readSignedVarLong
and their correspondingwrite
methods have been moved toVarInt::
static methods (e.g.VarInt::readUnsignedVarInt($buffer)
)
BaseByteBuffer
removed- Restructure of internal extension code
0.3.0
⚠️ This extension is still experimental. DO NOT use this in production.
Changes since 0.2.x
API changes
ByteBuffer
now has separate offsets for read and write. This allows it to more closely mimic the behaviour ofBinaryStream
, which implicitly has separate offsets (BinaryStream->getOffset()
is only used for reading; writing just appends to the internal string)- Added
ByteBuffer->getReadOffset()
- Added
ByteBuffer->setReadOffset()
- Added
ByteBuffer->getWriteOffset()
- Added
ByteBuffer->setWriteOffset()
- Removed
ByteBuffer->getOffset()
- Removed
ByteBuffer->setOffset()
- Removed
ByteBuffer->rewind()
(usesetReadOffset(0)
orsetWriteOffset(0)
depending on your use case)
- Added
- Renamed
ByteBuffer->getReserved()
->ByteBuffer->getReservedLength()
- Added
ByteBuffer->getUsedLength()
- Added
ByteBuffer->clear()
Other changes
- Now tested on PHP 8.3
- All non-macro-generated API methods are now in an internal
BaseByteBuffer
class, to allow as much of the arginfo as possible to be generated by PHP'sgen-stub.php
.ByteBuffer
extendsBaseByteBuffer
and there is no observable change toByteBuffer
API and behaviour from this change.
0.2.3
0.2.2
0.2.1
0.2.0
⚠️ This extension is still experimental. DO NOT use this in production.
Changes since 0.1.0
- All classes have moved to the
pmmp\encoding
namespace new ByteBuffer
can now be called with no arguments- Added read/write methods for signed and unsigned int24
- Removed read/write for unsigned long - these made no sense as it's not possible to return an unsigned int64 to PHP code
- Fixed UAF after
var_dump
ing orserialize
ing aByteBuffer
- Fixed uninitialized memory being emitted in
var_dump
andserialize
d data - Removed
?int &$offset
parameters from all functions - these uses can be better filled withgetOffset
andsetOffset
- Added a whole bunch of new unit tests