MCPcopy Create free account
hub / github.com/nodejs/nan / SetIndexedPropertyHandler

Function SetIndexedPropertyHandler

nan.h:2975–3043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2973}
2974
2975inline void SetIndexedPropertyHandler(
2976 v8::Local<v8::ObjectTemplate> tpl
2977 , IndexGetterCallback getter
2978 , IndexSetterCallback setter = 0
2979 , IndexQueryCallback query = 0
2980 , IndexDeleterCallback deleter = 0
2981 , IndexEnumeratorCallback enumerator = 0
2982 , v8::Local<v8::Value> data = v8::Local<v8::Value>()) {
2983 HandleScope scope;
2984
2985 imp::NativeIndexGetter getter_ =
2986 imp::IndexGetterCallbackWrapper;
2987 imp::NativeIndexSetter setter_ =
2988 setter ? imp::IndexSetterCallbackWrapper : 0;
2989 imp::NativeIndexQuery query_ =
2990 query ? imp::IndexQueryCallbackWrapper : 0;
2991 imp::NativeIndexDeleter deleter_ =
2992 deleter ? imp::IndexDeleterCallbackWrapper : 0;
2993 imp::NativeIndexEnumerator enumerator_ =
2994 enumerator ? imp::IndexEnumeratorCallbackWrapper : 0;
2995
2996 v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>();
2997 otpl->SetInternalFieldCount(imp::kIndexPropertyFieldCount);
2998 v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked();
2999 obj->SetInternalField(
3000 imp::kIndexPropertyGetterIndex
3001 , New<v8::External>(reinterpret_cast<void *>(getter)));
3002
3003 if (setter) {
3004 obj->SetInternalField(
3005 imp::kIndexPropertySetterIndex
3006 , New<v8::External>(reinterpret_cast<void *>(setter)));
3007 }
3008
3009 if (query) {
3010 obj->SetInternalField(
3011 imp::kIndexPropertyQueryIndex
3012 , New<v8::External>(reinterpret_cast<void *>(query)));
3013 }
3014
3015 if (deleter) {
3016 obj->SetInternalField(
3017 imp::kIndexPropertyDeleterIndex
3018 , New<v8::External>(reinterpret_cast<void *>(deleter)));
3019 }
3020
3021 if (enumerator) {
3022 obj->SetInternalField(
3023 imp::kIndexPropertyEnumeratorIndex
3024 , New<v8::External>(reinterpret_cast<void *>(enumerator)));
3025 }
3026
3027 if (!data.IsEmpty()) {
3028 obj->SetInternalField(imp::kDataIndex, data);
3029 }
3030
3031#if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION
3032 tpl->SetHandler(v8::IndexedPropertyHandlerConfiguration(

Callers 1

NAN_MODULE_INITFunction · 0.85

Calls 3

ToLocalCheckedMethod · 0.80
NewInstanceFunction · 0.70
IsEmptyMethod · 0.45

Tested by

no test coverage detected