You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewTypeError(`Cannot convert "${embindRepr(value)}" to ${toTypeName}`);
350
-
}
351
-
if(value<minRange||value>maxRange){
352
-
thrownewTypeError(`Passing a number "${embindRepr(value)}" from JS side to C/C++ side to an argument of type "${name}", which is outside the valid range [${minRange}, ${maxRange}]!`);
thrownewTypeError(`Cannot convert "${embindRepr(value)}" to ${toTypeName}`);
349
+
}
350
+
if(value<minRange||value>maxRange){
351
+
thrownewTypeError(`Passing a number "${embindRepr(value)}" from JS side to C/C++ side to an argument of type "${name}", which is outside the valid range [${minRange}, ${maxRange}]!`);
352
+
}
353
+
#endif
365
354
// The VM will perform JS to Wasm value conversion, according to the spec:
// `size_t` ends up here, but it's transferred in the ABI as a plain number instead of a bigint.
381
+
if(typeofvalue=='number'){
382
+
returnvalue>>>0;
383
+
}
384
+
#endif
385
+
returnBigInt.asUintN(bitSize,value);
386
+
}
387
+
maxRange=fromWireType(maxRange);
392
388
}
393
389
394
390
registerType(primitiveType,{
395
391
name,
396
-
'fromWireType': (value)=>value,
397
-
'toWireType': function(destructors,value){
398
-
if(typeofvalue!="bigint"&&typeofvalue!="number"){
399
-
thrownewTypeError(`Cannot convert "${embindRepr(value)}" to ${this.name}`);
400
-
}
392
+
'fromWireType': fromWireType,
393
+
'toWireType': (destructors,value)=>{
401
394
if(typeofvalue=="number"){
402
395
value=BigInt(value);
403
396
}
404
397
#if ASSERTIONS
398
+
elseif(typeofvalue!="bigint"){
399
+
thrownewTypeError(`Cannot convert "${embindRepr(value)}" to ${this.name}`);
400
+
}
405
401
if(value<minRange||value>maxRange){
406
402
thrownewTypeError(`Passing a number "${embindRepr(value)}" from JS side to C/C++ side to an argument of type "${name}", which is outside the valid range [${minRange}, ${maxRange}]!`);
Copy file name to clipboardExpand all lines: test/embind/test_i64_binding.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
usingnamespaceemscripten;
14
14
usingnamespacestd;
15
15
16
-
#defineassert_js_eq(X, Y) run_js(string("const x = ") + X + ", y = " + Y + "; assert(x === y, `" + X + ": actual = ${x}, expected = ${y}`);")
16
+
#defineassert_js_eq(X, Y) run_js(string("const x = ") + X + ", y = " + Y + "; assert(x === y, `" + X + ": actual = ${typeof x} ${x}, expected = ${typeof y} ${y}`);")
0 commit comments