Open Yangff opened 7 years ago
I can't help you with your code, @Yangff, but I'd like to +1 this proposal and take it a step further: I'd like a way to intercept all property accesses that aren't handled by other v8pp properties. Use case is simple: I want all other properties to return null to JS and throw a JS exception on set.
Some time ago I started working on generalized indexed/named property accessor handler in v8pp::class_
. Both of these handlers have 5 functions to get/set/query/delete/enumerate items or properties. Unfortunately, currently I have no spare time to complete that implementation.
At the present moment the only way is to set accessor handler with v8pp::class_::class_function_template()->InstanceTemplate()->SetHandler(your_accessor_handler_configuration)
. The accessor handler configuration could be created similar to example above by @Yangff
To achieve this, I added some code to
class.hpp
, so I can callklass.index<Type>()
to make this class array-like. However I don't think it's an elegant way (my code)...Is there any better method to do this?