Skip to content

Commit 33840f0

Browse files
committed
small fixes
1 parent 2d0f92f commit 33840f0

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

assembly/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export namespace JSON {
336336
}
337337
}
338338

339-
function __serialize<T>(src: T, staticSize: bool = false): void {
339+
export function __serialize<T>(src: T, staticSize: bool = false): void {
340340
if (isBoolean<T>()) {
341341
serializeBool(src as bool, staticSize);
342342
} else if (isInteger<T>()) {

assembly/serialize/simple/string.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { SERIALIZE_ESCAPE_TABLE } from "../../globals/tables";
3535
store<u32>(bs.offset, escaped, 8);
3636
bs.offset += 12;
3737
} else {
38-
if (!staticSize) bs.ensureSize(4);
38+
if (!staticSize) bs.ensureSize(2);
3939
store<u32>(bs.offset, escaped, 0);
4040
bs.offset += 4;
4141
}

assembly/test.ts

+6-29
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,8 @@
1-
import { JSON } from ".";
2-
import { bytes } from "./util/bytes";
3-
import { deserializeObject_NEW } from "./deserialize/simple/object";
4-
5-
61
@json
72
class Vec3 {
8-
x: i8 = 1;
9-
y: i8 = 2;
10-
z: i8 = 3;
11-
xyx: i8 = 0;
12-
}
13-
14-
const vec: Vec3 = {
15-
x: 1,
16-
y: 2,
17-
z: 3,
18-
};
19-
// const serialized = JSON.stringify<Vec3>(vec);
20-
// const ss = '{ "x":1,"y":2,"z":3}'
21-
// const s = changetype<usize>(ss);
22-
// console.log("Serialized: " + serialized);
23-
// const deserialized = deserializeObject_NEW<Vec3>(s, s + bytes(ss))
24-
// console.log("Deserialized: " + JSON.stringify(deserialized));
25-
26-
// function str(start: usize, end: usize): string {
27-
// const size = end - start;
28-
// const out = __new(size, idof<string>());
29-
// memory.copy(out, start, size);
30-
// return changetype<string>(out);
31-
// }
3+
a: i16 = 1
4+
ab: i16 = 2;
5+
abc: i16 = 3;
6+
abcd: i16 = 4;
7+
abcde: i16 = 5;
8+
}

0 commit comments

Comments
 (0)