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
Before this fix, `uint64_t` would be returned as a signed integer from
Embind (e.g. if you return `UINT64_MAX`, it gets returned as `-1`).
I fixed that behaviour so that unsigned integers are correctly "fixed
up" like they already are for `uint32_t`, and added tests for 64-bit
integer limits to `test_i64_binding`.
In the process I had to also delete the invalid test
`other.test_embind_long_long` - it had incorrect expectations (see
commit message for more details) and is now superseded by the correct
test mentioned above.
- Fixes#20354.
Closes#20353.
- Fixes#13902.
thrownewTypeError(`Passing a number "${embindRepr(value)}" from JS side to C/C++ side to an argument of type "${typeName}", which is outside the valid range [${minRange}, ${maxRange}]!`);
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}]!`);
// `size_t` ends up here, but it's transferred in the ABI as a plain number instead of a bigint.
394
+
if(typeofvalue=='number'){
395
+
returnvalue>>>0;
396
+
}
397
+
#endif
398
+
returnBigInt.asUintN(bitSize,value);
399
+
}
400
+
maxRange=fromWireType(maxRange);
392
401
}
393
402
394
403
registerType(primitiveType,{
395
404
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
-
}
405
+
'fromWireType': fromWireType,
406
+
'toWireType': (destructors,value)=>{
401
407
if(typeofvalue=="number"){
402
408
value=BigInt(value);
403
409
}
404
410
#if ASSERTIONS
405
-
if(value<minRange||value>maxRange){
406
-
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}]!`);
411
+
elseif(typeofvalue!="bigint"){
412
+
thrownewTypeError(`Cannot convert "${embindRepr(value)}" to ${this.name}`);
0 commit comments