Avi Drissman | 468e51b6 | 2022-09-13 20:47:01 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "gin/interceptor.h" |
| 6 | |
avi | 90e658dd | 2015-12-21 07:16:19 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 9 | #include <map> |
| 10 | |
| 11 | #include "gin/per_isolate_data.h" |
| 12 | |
| 13 | namespace gin { |
| 14 | |
| 15 | NamedPropertyInterceptor::NamedPropertyInterceptor(v8::Isolate* isolate, |
| 16 | WrappableBase* base) |
| 17 | : isolate_(isolate), base_(base) { |
| 18 | PerIsolateData::From(isolate_)->SetNamedPropertyInterceptor(base_, this); |
| 19 | } |
| 20 | |
| 21 | NamedPropertyInterceptor::~NamedPropertyInterceptor() { |
| 22 | PerIsolateData::From(isolate_)->ClearNamedPropertyInterceptor(base_, this); |
| 23 | } |
| 24 | |
| 25 | v8::Local<v8::Value> NamedPropertyInterceptor::GetNamedProperty( |
| 26 | v8::Isolate* isolate, |
| 27 | const std::string& property) { |
| 28 | return v8::Local<v8::Value>(); |
| 29 | } |
| 30 | |
jochen@chromium.org | d656f87 | 2014-08-13 17:12:55 | [diff] [blame] | 31 | bool NamedPropertyInterceptor::SetNamedProperty(v8::Isolate* isolate, |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 32 | const std::string& property, |
jochen@chromium.org | d656f87 | 2014-08-13 17:12:55 | [diff] [blame] | 33 | v8::Local<v8::Value> value) { |
| 34 | return false; |
| 35 | } |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 36 | |
| 37 | std::vector<std::string> NamedPropertyInterceptor::EnumerateNamedProperties( |
| 38 | v8::Isolate* isolate) { |
| 39 | return std::vector<std::string>(); |
| 40 | } |
| 41 | |
Hyowon Kim | 0e7a84f | 2023-11-24 00:32:01 | [diff] [blame] | 42 | void NamedPropertyInterceptor::ClearForTesting() { |
| 43 | PerIsolateData::From(isolate_)->ClearNamedPropertyInterceptor(base_, this); |
| 44 | isolate_ = nullptr; |
| 45 | } |
| 46 | |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 47 | IndexedPropertyInterceptor::IndexedPropertyInterceptor(v8::Isolate* isolate, |
| 48 | WrappableBase* base) |
| 49 | : isolate_(isolate), base_(base) { |
| 50 | PerIsolateData::From(isolate_)->SetIndexedPropertyInterceptor(base_, this); |
| 51 | } |
| 52 | |
| 53 | IndexedPropertyInterceptor::~IndexedPropertyInterceptor() { |
| 54 | PerIsolateData::From(isolate_)->ClearIndexedPropertyInterceptor(base_, this); |
| 55 | } |
| 56 | |
| 57 | v8::Local<v8::Value> IndexedPropertyInterceptor::GetIndexedProperty( |
| 58 | v8::Isolate* isolate, |
| 59 | uint32_t index) { |
| 60 | return v8::Local<v8::Value>(); |
| 61 | } |
| 62 | |
jochen@chromium.org | d656f87 | 2014-08-13 17:12:55 | [diff] [blame] | 63 | bool IndexedPropertyInterceptor::SetIndexedProperty( |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 64 | v8::Isolate* isolate, |
| 65 | uint32_t index, |
jochen@chromium.org | d656f87 | 2014-08-13 17:12:55 | [diff] [blame] | 66 | v8::Local<v8::Value> value) { |
| 67 | return false; |
| 68 | } |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 69 | |
| 70 | std::vector<uint32_t> IndexedPropertyInterceptor::EnumerateIndexedProperties( |
| 71 | v8::Isolate* isolate) { |
| 72 | return std::vector<uint32_t>(); |
| 73 | } |
| 74 | |
Hyowon Kim | 0e7a84f | 2023-11-24 00:32:01 | [diff] [blame] | 75 | void IndexedPropertyInterceptor::ClearForTesting() { |
| 76 | PerIsolateData::From(isolate_)->ClearIndexedPropertyInterceptor(base_, this); |
| 77 | isolate_ = nullptr; |
| 78 | } |
| 79 | |
jochen@chromium.org | 5c969b8 | 2014-03-12 04:59:05 | [diff] [blame] | 80 | } // namespace gin |