Skip to content

Commit

Permalink
fix: use bracket instead of brace to terminate array
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jan 20, 2025
1 parent d9bbb26 commit 8f748c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions assembly/deserialize/simple/array/float.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { isSpace } from "../../../util";
import { COMMA, BRACE_RIGHT } from "../../../custom/chars";
import { COMMA, BRACE_RIGHT, BRACKET_RIGHT } from "../../../custom/chars";
import { JSON } from "../../..";

export function deserializeFloatArray<T extends number[]>(srcStart: usize, srcEnd: usize, dst: usize): T {
const out = changetype<T>(dst);
const out = changetype<T>(dst || __new(offsetof<T>(), idof<T>()));
let lastIndex: usize = 0;
while (srcStart < srcEnd) {
const code = load<u16>(srcStart);
Expand All @@ -12,7 +12,7 @@ export function deserializeFloatArray<T extends number[]>(srcStart: usize, srcEn
srcStart += 2;
while (srcStart < srcEnd) {
const code = load<u16>(srcStart);
if (code == COMMA || code == BRACE_RIGHT || isSpace(code)) {
if (code == COMMA || code == BRACKET_RIGHT || isSpace(code)) {
out.push(JSON.__deserialize<valueof<T>>(lastIndex, srcStart));
// while (isSpace(load<u16>((srcStart += 2)))) {
// /* empty */
Expand Down
10 changes: 6 additions & 4 deletions assembly/deserialize/simple/array/integer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { isSpace } from "../../../util";
import { COMMA, BRACE_RIGHT } from "../../../custom/chars";
import { COMMA, BRACE_RIGHT, BRACKET_RIGHT } from "../../../custom/chars";
import { JSON } from "../../..";
import { ptrToStr } from "../../../util/ptrToStr";

export function deserializeIntegerArray<T extends number[]>(srcStart: usize, srcEnd: usize, dst: usize): T {
const out = changetype<T>(dst);
const out = changetype<T>(dst || __new(offsetof<T>(), idof<T>()));
let lastIndex: usize = 0;
while (srcStart < srcEnd) {
const code = load<u16>(srcStart);
Expand All @@ -12,8 +13,9 @@ export function deserializeIntegerArray<T extends number[]>(srcStart: usize, src
srcStart += 2;
while (srcStart < srcEnd) {
const code = load<u16>(srcStart);
if (code == COMMA || code == BRACE_RIGHT || isSpace(code)) {
out.push(JSON.__deserialize<valueof<T>>(lastIndex, srcStart));
if (code == COMMA || code == BRACKET_RIGHT || isSpace(code)) {
console.log("element: " + ptrToStr(lastIndex, srcStart))
// out.push(JSON.__deserialize<valueof<T>>(lastIndex, srcStart));
// while (isSpace(load<u16>((srcStart += 2)))) {
// /* empty */
// }
Expand Down

0 comments on commit 8f748c8

Please sign in to comment.