Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5755b2863f | ||
|
|
26b65b8008 |
No files matched your search
@@ -75,7 +75,7 @@ const varint = (value: number): Buffer => {
|
||||
const encodeValue = (
|
||||
value: number | string | boolean | null | { ref: number },
|
||||
): Buffer => {
|
||||
if (typeof value === "boolean") return Buffer.from([value ? 4 : 5]);
|
||||
if (typeof value === "boolean") return Buffer.from([value ? 5 : 4]);
|
||||
if (value === null) return Buffer.from([9]);
|
||||
if (typeof value === "number") {
|
||||
const bytes = Buffer.alloc(5);
|
||||
|
||||
@@ -77,6 +77,24 @@ describe("NIBArchive decoder", () => {
|
||||
expect(decoded.coder_version).toBe(10);
|
||||
});
|
||||
|
||||
it("decodes boolean value type 4 as false and 5 as true", () => {
|
||||
const archive = encodeArchive({
|
||||
classes: ["NSButton"],
|
||||
objects: [{ classIndex: 0, values: { NSControlContinuous: null } }],
|
||||
});
|
||||
// The only value record is key varint 0x80 then one-byte type 9 (nil);
|
||||
// overwrite that type byte to pin the format's own boolean encoding.
|
||||
const typeOffset = archive.readUInt32LE(38) + 1;
|
||||
expect(archive[typeOffset]).toBe(9);
|
||||
const decodeType = (type: number) => {
|
||||
const bytes = Buffer.from(archive);
|
||||
bytes[typeOffset] = type;
|
||||
return decodeNibArchive(bytes).objects[0]?.values.NSControlContinuous;
|
||||
};
|
||||
expect(decodeType(4)).toBe(false);
|
||||
expect(decodeType(5)).toBe(true);
|
||||
});
|
||||
|
||||
it("counts AppKit outlet, action, and binding connector objects", () => {
|
||||
const archive = encodeArchive({
|
||||
classes: [
|
||||
|
||||
@@ -374,10 +374,12 @@ const readValue = (
|
||||
? Number(value)
|
||||
: value.toString();
|
||||
}
|
||||
// NIBArchive value type 4 is false and 5 is true, as ibtool --export
|
||||
// reports for the same compiled fields.
|
||||
case 4:
|
||||
return true;
|
||||
case 5:
|
||||
return false;
|
||||
case 5:
|
||||
return true;
|
||||
case 6:
|
||||
ensureRange(cursor.offset, 4, end, `value ${index}`);
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user