boa icon indicating copy to clipboard operation
boa copied to clipboard

IntoJsValue and TryFromJsValue

Open lastmjs opened this issue 2 years ago • 1 comments

I'd love to get feedback on this, especially how I should handle errors and any other idiomatic Rust improvements you'd like me to make (I'm still kind of new to Rust).

This pull request also depends on making the Array builtin public, and in my opinion all of the builtins should be made public. I can open another pull request to make all of those public if I get the go-ahead.

This pull request also depends on implementing my opinion that i128, u128, i64 and u64 should always be converted into a JS bigint since it's the only native JS number type that will not lose precision. More discussion here: https://github.com/boa-dev/boa/issues/1991

This Pull Request fixes/closes #1975.

It changes the following:

  • Adds IntoJsValue trait with many implementations
  • Add TryFromJsValue trait with many implementations

lastmjs avatar Mar 31 '22 13:03 lastmjs

Codecov Report

Merging #1995 (c2f8824) into main (80e804c) will decrease coverage by 0.11%. The diff coverage is 4.22%.

@@            Coverage Diff             @@
##             main    #1995      +/-   ##
==========================================
- Coverage   43.50%   43.38%   -0.12%     
==========================================
  Files         220      222       +2     
  Lines       19962    20014      +52     
==========================================
  Hits         8684     8684              
- Misses      11278    11330      +52     
Impacted Files Coverage Δ
boa_engine/src/bigint.rs 37.22% <0.00%> (-1.12%) :arrow_down:
boa_engine/src/value/into_js_value.rs 0.00% <0.00%> (ø)
boa_engine/src/value/mod.rs 51.40% <0.00%> (-0.74%) :arrow_down:
boa_engine/src/value/try_from_js_value.rs 0.00% <0.00%> (ø)
boa_engine/src/value/conversions.rs 18.51% <12.50%> (-1.49%) :arrow_down:
boa_engine/src/syntax/ast/node/spread/mod.rs 57.14% <0.00%> (-14.29%) :arrow_down:
...ntax/parser/expression/left_hand_side/arguments.rs 35.00% <0.00%> (-2.50%) :arrow_down:
boa_engine/src/builtins/regexp/mod.rs 67.61% <0.00%> (-0.18%) :arrow_down:
...a_engine/src/syntax/parser/statement/switch/mod.rs 39.53% <0.00%> (+1.16%) :arrow_up:
...a_engine/src/syntax/ast/node/statement_list/mod.rs 78.12% <0.00%> (+3.12%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 80e804c...c2f8824. Read the comment docs.

codecov[bot] avatar Apr 03 '22 00:04 codecov[bot]

Closing in favour of #2276.

jedel1043 avatar Mar 09 '23 17:03 jedel1043