Skip to content

Commit

Permalink
fix buffer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyProgrammist committed Nov 8, 2024
1 parent dacd907 commit eb1f751
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 130 deletions.
20 changes: 14 additions & 6 deletions src/generators/typescript/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
TypeParametersExpression,
TypedIdentifier,
id,
tBinaryExpression,
tCodeAsIs,
tComment,
tExpressionStatement,
Expand All @@ -76,6 +77,7 @@ import {
tIfStatement,
tImportDeclaration,
tMemberExpression,
tNumericLiteral,
tObjectExpression,
tObjectProperty,
tReturnStatement,
Expand Down Expand Up @@ -734,13 +736,19 @@ export function storeBool(bool: Bool): (builder: Builder) => void {
} else {
let isBuffer = useBuffer(fieldType);
let suffix = isBuffer ? "Buffer" : "Bits";
let argLoadExpr = convertToAST(fieldType.bits, ctx.constructor);
let argStoreExpr = convertToAST(
fieldType.bits,
ctx.constructor,
id(ctx.name)
)
if (isBuffer) {
argLoadExpr = tBinaryExpression(argLoadExpr, '/' , tNumericLiteral(8))
argStoreExpr = tBinaryExpression(argStoreExpr, '/', tNumericLiteral(8))
}
exprForParam = {
argLoadExpr: convertToAST(fieldType.bits, ctx.constructor),
argStoreExpr: convertToAST(
fieldType.bits,
ctx.constructor,
id(ctx.name)
),
argLoadExpr: argLoadExpr,
argStoreExpr: argStoreExpr,
paramType: isBuffer ? "Buffer" : "BitString",
fieldLoadSuffix: suffix,
fieldStoreSuffix: suffix,
Expand Down
Loading

0 comments on commit eb1f751

Please sign in to comment.