-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[embind] Add iterable protocol support for bound classes #25993
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
base: main
Are you sure you want to change the base?
Conversation
| const makeIterator = (size, getValue) => { | ||
| const useBigInt = typeof size === 'bigint'; | ||
| const one = useBigInt ? 1n : 1; | ||
| let index = useBigInt ? 0n : 0; |
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.
Could we simply dictate that interables using size_t i.e. bigint on wasm64 and number on wasm32?
I don't image we will ever see 64-bit iterators on wasm32, right?
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.
I tried doing this, but register_vector seems to use unsigned int on purpose, so I presume forcing Bigint on wasm64 is undesirable?
Add `class_<T>::iterable()` to implement `Symbol.iterator`. Use this in `register_vector` so bound vectors have better ergonomics, such as working with `for...of` and `Array.from()`. This is tangentially related to emscripten-core#11070.
Add
class_<T>::iterable()to implementSymbol.iterator. Use this inregister_vectorso bound vectors have better ergonomics, such as working withfor...ofandArray.from().This is tangentially related to #11070 in that it's intended to make vector bindings nicer to use, but unlike what is suggested there it doesn't copy the vector to JS memory.