Add JS_ToBigUint64

Fixes: https://github.com/quickjs-ng/quickjs/issues/376
This commit is contained in:
Saúl Ibarra Corretgé 2024-05-27 10:10:30 +02:00
parent c7bd41197a
commit e5673a8e68
2 changed files with 6 additions and 0 deletions

View file

@ -12026,6 +12026,11 @@ int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValue val)
return JS_ToBigInt64Free(ctx, pres, js_dup(val)); return JS_ToBigInt64Free(ctx, pres, js_dup(val));
} }
int JS_ToBigUint64(JSContext *ctx, uint64_t *pres, JSValue val)
{
return JS_ToBigInt64Free(ctx, (int64_t *)pres, js_dup(val));
}
static JSValue JS_NewBigInt(JSContext *ctx) static JSValue JS_NewBigInt(JSContext *ctx)
{ {
JSBigInt *p; JSBigInt *p;

View file

@ -638,6 +638,7 @@ JS_EXTERN int JS_ToIndex(JSContext *ctx, uint64_t *plen, JSValue val);
JS_EXTERN int JS_ToFloat64(JSContext *ctx, double *pres, JSValue val); JS_EXTERN int JS_ToFloat64(JSContext *ctx, double *pres, JSValue val);
/* return an exception if 'val' is a Number */ /* return an exception if 'val' is a Number */
JS_EXTERN int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValue val); JS_EXTERN int JS_ToBigInt64(JSContext *ctx, int64_t *pres, JSValue val);
JS_EXTERN int JS_ToBigUint64(JSContext *ctx, uint64_t *pres, JSValue val);
/* same as JS_ToInt64() but allow BigInt */ /* same as JS_ToInt64() but allow BigInt */
JS_EXTERN int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValue val); JS_EXTERN int JS_ToInt64Ext(JSContext *ctx, int64_t *pres, JSValue val);