| 2903 | } |
| 2904 | #endif |
| 2905 | inline void SetNamedPropertyHandler( |
| 2906 | v8::Local<v8::ObjectTemplate> tpl |
| 2907 | , PropertyGetterCallback getter |
| 2908 | , PropertySetterCallback setter = 0 |
| 2909 | , PropertyQueryCallback query = 0 |
| 2910 | , PropertyDeleterCallback deleter = 0 |
| 2911 | , PropertyEnumeratorCallback enumerator = 0 |
| 2912 | , v8::Local<v8::Value> data = v8::Local<v8::Value>()) { |
| 2913 | HandleScope scope; |
| 2914 | |
| 2915 | imp::NativePropertyGetter getter_ = |
| 2916 | imp::PropertyGetterCallbackWrapper; |
| 2917 | imp::NativePropertySetter setter_ = |
| 2918 | setter ? imp::PropertySetterCallbackWrapper : 0; |
| 2919 | imp::NativePropertyQuery query_ = |
| 2920 | query ? imp::PropertyQueryCallbackWrapper : 0; |
| 2921 | imp::NativePropertyDeleter *deleter_ = |
| 2922 | deleter ? imp::PropertyDeleterCallbackWrapper : 0; |
| 2923 | imp::NativePropertyEnumerator enumerator_ = |
| 2924 | enumerator ? imp::PropertyEnumeratorCallbackWrapper : 0; |
| 2925 | |
| 2926 | v8::Local<v8::ObjectTemplate> otpl = New<v8::ObjectTemplate>(); |
| 2927 | otpl->SetInternalFieldCount(imp::kPropertyFieldCount); |
| 2928 | v8::Local<v8::Object> obj = NewInstance(otpl).ToLocalChecked(); |
| 2929 | obj->SetInternalField( |
| 2930 | imp::kPropertyGetterIndex |
| 2931 | , New<v8::External>(reinterpret_cast<void *>(getter))); |
| 2932 | |
| 2933 | if (setter) { |
| 2934 | obj->SetInternalField( |
| 2935 | imp::kPropertySetterIndex |
| 2936 | , New<v8::External>(reinterpret_cast<void *>(setter))); |
| 2937 | } |
| 2938 | |
| 2939 | if (query) { |
| 2940 | obj->SetInternalField( |
| 2941 | imp::kPropertyQueryIndex |
| 2942 | , New<v8::External>(reinterpret_cast<void *>(query))); |
| 2943 | } |
| 2944 | |
| 2945 | if (deleter) { |
| 2946 | obj->SetInternalField( |
| 2947 | imp::kPropertyDeleterIndex |
| 2948 | , New<v8::External>(reinterpret_cast<void *>(deleter))); |
| 2949 | } |
| 2950 | |
| 2951 | if (enumerator) { |
| 2952 | obj->SetInternalField( |
| 2953 | imp::kPropertyEnumeratorIndex |
| 2954 | , New<v8::External>(reinterpret_cast<void *>(enumerator))); |
| 2955 | } |
| 2956 | |
| 2957 | if (!data.IsEmpty()) { |
| 2958 | obj->SetInternalField(imp::kDataIndex, data); |
| 2959 | } |
| 2960 | |
| 2961 | #if NODE_MODULE_VERSION > NODE_0_12_MODULE_VERSION |
| 2962 | tpl->SetHandler(v8::NamedPropertyHandlerConfiguration( |
no test coverage detected