-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigInt-related API fixes and non-breaking changes #285
base: master
Are you sure you want to change the base?
Conversation
You can include the breaking changes here directly, I'll release 1.0 right after it's merged. |
hmm I would wait a bit before the breaking release, just in case there are more breaking changes we haven't discovered yet? either way, +1 |
The breaking changes need to land on master anyway, even if we wait before the release. You can add them here directly, it will be simpler. |
Perfect, done. This seems to be working but I'll test it some more to make sure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment but the rest seems good :)
if (value->IsBigInt()) | ||
return value.As<v8::BigInt>()->Int64Value(); | ||
return Nan::To<int32_t>(value).ToChecked(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one feels a bit weird, with the name being ToInt32
but it returns an int64_t
. Maybe it should return an int32_t
?
side-effects: - g_value_info_get_value() returns an int64, but enums are still 32 bit, so we need to cast to Number
turns out ToBigInt() and ToNumber() doesn't perform conversion but only 'implicit' conversion which is not useful. create helpers to extract the numbers from V8 and use them everywhere (except in enum, flags, unichar)
355ca92
to
515d6a8
Compare
BigInt-related API fixes and (for now, only) non-breaking changes.
input conversions for BigInt:
all integer types (8, 16, 32, 64) now accept bigint and number
64-bit integer types ([u]long, [u]int64, gtype) now convert the value to BigInt and then call
[U]Int64Value()
(the other integer types still convert to Number first, which means IIRC that if an out-of-range BigInt is passed, they'll get converted to trash rather than the low bits, as the user would expect. but it's better for performance and user can just
& 0xFFFFFFFFn
)GType consistency (these are breaking, but very little used so I think a fix like this is justified):
GValueToV8
now convertsGType
to BigInt to be consistentGType
s only support conversion from BigInt nowI've also annotated the places that should be changed to completely support BigInt, but would be a breaking change.
other non-BigInt related fixes:
CanConvertV8ToGValue