Skip to content
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

Indexed access #124

Open
ayles opened this issue Aug 29, 2019 · 3 comments
Open

Indexed access #124

ayles opened this issue Aug 29, 2019 · 3 comments

Comments

@ayles
Copy link

ayles commented Aug 29, 2019

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 like set_indexed_accessor(accessor<Getter, Setter>)? (Like property_ for set)
So I need some recommendations and I'll try to do it.

@pmed
Copy link
Owner

pmed commented Aug 29, 2019

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 😃

@ayles
Copy link
Author

ayles commented Aug 30, 2019

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 =)

@pmed
Copy link
Owner

pmed commented Sep 1, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants