Open ayles opened 4 years ago
Hi,
I like the idea and some time ago there was a request for this feature in #47. Unfortunately, I've never used indexed accessors, so they are still not implemented.
A possible implementation could be generalized both for indexed and named property accessors, and it would be good to support also lambdas, similar to the current property accessor implementation.
The next version (in c++17
branch) has no set_
prefixed bind functions, so it could be named as indexer(getter, setter)
.
Anyway, a pull request is greatly welcomed 😃
Hmmmm.
I implemented indexer in c++17
as indexer(getter, setter)
, but there is one problem... Idk should I add support for (...query, deleter, enumerator)
. If should, it will be implementation separated from property
, so I'm here with this question =)
As I understand from comments to v8::IndexedPropertyHandlerConfiguration
only getter is required, so other callbacks are optional. But as a generic solution, it would be nice to support them in the v8pp.
The property
has a specialisation for read-only case with only a pointer to getter function. This allows to have sizeof(property) == sizeof(void*)
with no extra memory management for v8::External
data storage.
Similar way may be used for a new indexed_property
implementation.
What about setting indexed accessor on
class_
? (Simulating array behaviour, for examle). I tried to write it myself but I have no complete idea how to do it right. Maybe something likeset_indexed_accessor(accessor<Getter, Setter>)
? (Likeproperty_
forset
) So I need some recommendations and I'll try to do it.