feat(value): add conversion and UTF-16 bindings#749
Conversation
buke
commented
May 22, 2026
- add native quickjs-ng wrappers for number, index, bigint, property-key, and UTF-16 conversion APIs
- add Context.NewStringUTF16 and focused regression coverage for success and error paths
- keep full package coverage at 100.0%
- add native quickjs-ng wrappers for number, index, bigint, property-key, and UTF-16 conversion APIs - add Context.NewStringUTF16 and focused regression coverage for success and error paths - keep full package coverage at 100.0%
There was a problem hiding this comment.
Code Review
This pull request adds the NewStringUTF16 function to the Context type and introduces several conversion methods to the Value type, including ToNumber, ToIndex, ToBigInt64, ToBigUint64, ToInt64Ext, ToPropertyKey, and ToStringUTF16. The review feedback recommends using unsafe.SliceData for more idiomatic pointer acquisition and suggests optimizing exception handling in the ToNumber and ToPropertyKey methods to avoid unnecessary heap allocations when operations fail.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #749 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 3766 3831 +65
=========================================
+ Hits 3766 3831 +65
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several new conversion methods to the Value and Context types, including NewStringUTF16, ToNumber, ToIndex, and various BigInt/Int64 conversions, along with comprehensive unit tests. The review feedback highlights a critical issue in the error handling logic across all these new methods: if a JavaScript exception is thrown that is not an Error object (e.g., a primitive), v.ctx.Exception() returns nil, causing the Go functions to return a nil error despite the failure. It is recommended to implement a fallback error to ensure robust error reporting.
- add a centralized fallback error when QuickJS throws a non-Error exception value - cover primitive throw paths in Context.Exception and the PR 3 conversion APIs - keep full package coverage at 100.0%
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several new features and improvements to the QuickJS wrapper, including a NewStringUTF16 method for creating strings from UTF-16 code units and a suite of conversion methods for the Value type, such as ToNumber, ToIndex, ToBigInt64, and ToStringUTF16. Additionally, exception handling in the Context has been refactored to include a private exceptionError helper. The review feedback suggests enhancing the error message for non-Error JavaScript exceptions by including the actual thrown value to aid debugging, along with corresponding updates to the test expectations in context_test.go and value_test.go.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several new conversion methods to the Value type, including ToNumber, ToIndex, and ToStringUTF16, along with a new NewStringUTF16 method for the Context type. It also refactors exception handling to better capture JavaScript errors. Feedback suggests using unsafe.SliceData for more idiomatic slice pointer handling and improving error messages by using the string representation of thrown values instead of a generic fallback string.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several new conversion methods to the Value type—including ToNumber, ToIndex, and ToStringUTF16—and adds NewStringUTF16 to the Context type. Review feedback focuses on strengthening error handling to ensure that failures in the underlying C API always return an error, even if a specific JavaScript exception cannot be retrieved. Additionally, the reviewer suggested enhancing the exceptionError helper by including the string representation of thrown primitive values in error messages to improve debuggability.