mirror of
https://github.com/danog/PHPStruct.git
synced 2024-11-26 19:54:38 +01:00
Fix n and N formats, update tests.
This commit is contained in:
parent
43cd56d019
commit
1ce94d47bf
@ -11,6 +11,6 @@ var_dump(\danog\PHP\Struct::unpack("2cxbxBx?xhxHxixIxlxLxqxQxnxNxfxdx2sx5pP",
|
||||
|
||||
)
|
||||
));
|
||||
var_dump(\danog\PHP\Struct::unpack("<2s", danog\PHP\Struct::pack(">2s", "df")));
|
||||
var_dump(\danog\PHP\Struct::calcsize("n"));
|
||||
// 2c x b x B x ? x h x H x i x I x l x L x q x Q x n x N x f x d x 2s x
|
||||
//print(struct.unpack("2cxbxBx?xhxHxixIxlxLxqxQxnxNxfxdx2sx", struct.pack("2cxbxBx?xhxHxixIxlxLxqxQxnxNxfxdx2sx", "nv", 100, 100, False, 333, 444, 232423, 234342, 234234234234, 234234234234, 234234234234, 234234234234, 34434, 344434, 2.2343, 3.03424, "dd")));
|
||||
|
@ -49,8 +49,8 @@ class Struct {
|
||||
$this->NATIVE_FORMATS = array_merge([
|
||||
// These formats need to be modified after/before encoding/decoding.
|
||||
"P" => $this->IS64BIT ? "Q" : "L", // integer or long integer, depending on the size needed to hold a pointer when it has been cast to an integer type. A NULL pointer will always be returned as the Python integer 0. When packing pointer-sized values, Python integer or long integer objects may be used. For example, the Alpha and Merced processors use 64-bit pointer values, meaning a Python long integer will be used to hold the pointer; other platforms use 32-bit pointers and will use a Python integer.
|
||||
"n" => "i",
|
||||
"N" => "I",
|
||||
"n" => $this->IS64BIT ? "q" : "l",
|
||||
"N" => $this->IS64BIT ? "Q" : "L",
|
||||
], $this->FORMATS);
|
||||
$this->SIZE = [
|
||||
"p" => 1,
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user