point_object_template->SetHandler(
v8::NamedPropertyHandlerConfiguration(AccessorGetterCallbackFunction,0, NamedPropertyQueryCallbackFunction));
void AccessorGetterCallbackFunction(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value>& info)
{
auto pointPtr = UnwrapPoint(info.Holder());
bool bIsString = property->IsString();
std::string accessed_property;
auto value = v8::Local<v8::String>::Cast(property);
v8::String::Utf8Value utf8_value(v8::Local<v8::String>::Cast(property));
accessed_property = *utf8_value;
if (accessed_property == "x")
info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), pointPtr->x_));
else if (accessed_property == "y")
info.GetReturnValue().Set(v8::Integer::New(info.GetIsolate(), pointPtr->y_));
}
void IndexedPropertyEnumeratorCallbackFunction(
const v8::PropertyCallbackInfo<v8::Array>& p_callbackInfo)
{
v8::Local<v8::Array> IndexArray = v8::Array::New(p_callbackInfo.GetIsolate(), 2);
IndexArray->Set(
v8::Integer::New(p_callbackInfo.GetIsolate(), 0),
v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"x"));
IndexArray->Set(
v8::Integer::New(p_callbackInfo.GetIsolate(), 1),
v8::String::NewFromUtf8(p_callbackInfo.GetIsolate(), u8"y"));
p_callbackInfo.GetReturnValue().Set(IndexArray);
}
indexed property interceptors - called when accessing indexed properties. An example of this, in a browser environment, is document.forms.elements[0].
void (*IndexedPropertyEnumeratorCallback)( const PropertyCallbackInfo<Array>& info);
Instead of v8::IndexedPropertyHandlerConfiguration, you may
want to use v8::NamedPropertyHandlerConfiguration.
it seems to be overriding the callbacks NamedPropertyHandlerConfiguration and IndexedPropertyHandlerConfiguration (with respect to how it is displayed only).
Is there any way to override this behaviour?
I tried tracking where it is getting populated as function, but ended up in CALL_GENERATED_CODE called in Invoke() in execution.cc
Each function template has an associated object template. This is used to configure objects created with this function as their constructor.
/**
* Set the class name of the FunctionTemplate. This is used for
* printing objects created with the function created from the
* FunctionTemplate as its constructor.
*/
void SetClassName(Local<String> name);