Add helper functions to maplike/setlike to allow iterating contents from C++
Categories
(Core :: DOM: Bindings (WebIDL), enhancement)
Tracking
()
People
(Reporter: jjaschke, Unassigned)
References
(Blocks 2 open bugs)
Details
For proper implementation of the WebIDL part of the Highlight API (Bug 1703961) iterator access to the contents of a maplike/setlike from C++ is needed.
Currently, helper functions are provided to add()
, delete()
, clear()
or has()/get()
on the setlike/maplike, but it is not possible to iterate / get the contents, e.g. by using begin()..end()
or keys()
.
Comment 1•2 years ago
|
||
(Same comment as bug 1311198, unless this is terribly trivial we should probably just fix bug 1311198 instead, then you'd basically just have a C++ collection you iterate over)
Comment 2•2 years ago
|
||
I dig into this a bit, it seems a bit tricky to have a helper method to get all keys as JSAPI only provides JS::MapKeys
and JS::SetKeys
which returns a javascript iterator, not sure if we have any utility that could easy to iterate over it or maybe we need to try to iterate it by ourself. jandem, would you mind shielding some light here?
Comment 3•2 years ago
|
||
But yes, it would be nice if we could use spec new model, but I haven't have a chance looking into it, it seems we could reuse the current mechanism for iterable interface for set/map iterators, but what is the data structure we should use for maplike might be a tricky part.
Comment 4•2 years ago
|
||
It should just be an Index map (so a hashmap that preserves insertion order).
Comment 5•2 years ago
|
||
Just to be sure I understand.. We want a C++ iterator class for iterating over a JS Map
or Set
object's keys/values?
We do have JS::ForOfIterator
, maybe you could make it work with that for now? It's not the fastest thing though.
Comment 6•2 years ago
|
||
FYI, I've started looking into doing bug 1311198. It's going to take some time, so yes, if there's a trivial fix we can do to unblock this in the meantime that's ok too.
Updated•5 months ago
|
Description
•