Skip to content

Commit

Permalink
initialise number args to zero
Browse files Browse the repository at this point in the history
  • Loading branch information
vixalien committed Jan 17, 2024
1 parent e1388cd commit 4370870
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/types/argument.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ export function initArgument(type) {
g.base_info.unref(info);
return result;
}
case GITypeTag.UINT8:
case GITypeTag.INT8:
case GITypeTag.UINT16:
case GITypeTag.INT16:
case GITypeTag.UINT32:
case GITypeTag.INT32:
case GITypeTag.FLOAT:
case GITypeTag.UINT64:
case GITypeTag.INT64:
case GITypeTag.DOUBLE:
return 0n;
default: {
return cast_ptr_u64(cast_buf_ptr(new Uint8Array(1)));
}
Expand All @@ -36,8 +47,7 @@ export function initArgument(type) {
* @param {number?} length
* @returns
*/
export function unboxArgument(type, value, length) {
const dataView = new ExtendedDataView(value);
export function unboxArgument(type, pointer, length) {
const tag = g.type_info.get_tag(type);

switch (tag) {
Expand All @@ -59,12 +69,12 @@ export function unboxArgument(type, value, length) {
case GITypeTag.INT32:
case GITypeTag.FLOAT:
return Number(pointer);

case GITypeTag.UINT64:
case GITypeTag.INT64:
case GITypeTag.DOUBLE:
return BigInt(pointer);

case GITypeTag.UTF8:
case GITypeTag.FILENAME: {
if (!pointer) {
Expand All @@ -77,7 +87,7 @@ export function unboxArgument(type, value, length) {
/* non-basic types */

case GITypeTag.ARRAY: {
return unboxArray(type, value, length);
return unboxArray(type, pointer, length);
}

case GITypeTag.GLIST:
Expand Down

0 comments on commit 4370870

Please sign in to comment.