Refactor Casting and support arrays#30
Merged
Merged
Conversation
e4a4fab to
210068d
Compare
Refactors casting a bit. Fixes a bug where arrays were not being cast correctly. I think this won't really scale to more complex types and we should consider a dependency to handle this or code up a more runtime dependent solution. But for now i'm aiming to get it working well for the simple cases. Still have some tests to do.
Contributor
Author
|
Will merge with dylibso/xtp-bindgen-test#16 |
Contributor
Author
|
Actually will follow up with dylibso/xtp-bindgen-test#16 because i need to port to other languages. |
bhelx
commented
Oct 14, 2024
| return v === undefined || v === null | ||
| } | ||
|
|
||
| function cast(caster: (v: any) => any, v: any): any { |
Contributor
Author
There was a problem hiding this comment.
cast can apply caster to any value. If the value is an array, then it will apply caster to every value and return a new array. this saves us from having to put this logic into the codegen. However i don't think this will scale to all use cases.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors casting a bit. Fixes a bug where arrays were not being cast correctly. I think this won't really scale to more complex types and we should consider a dependency to handle this or code up a more runtime dependent solution. But for now i'm aiming to get it working well for the simple cases. Still have some tests to do.