• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Chromium Authors. All rights reserved.
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 "config.h"
6 #include "bindings/v8/V8HiddenValue.h"
7 
8 #include "bindings/v8/ScriptWrappable.h"
9 #include "bindings/v8/V8Binding.h"
10 
11 namespace WebCore {
12 
13 #define V8_DEFINE_METHOD(name) \
14 v8::Handle<v8::String> V8HiddenValue::name(v8::Isolate* isolate)    \
15 { \
16     V8HiddenValue* hiddenValue = V8PerIsolateData::from(isolate)->hiddenValue(); \
17     if (hiddenValue->m_##name.isEmpty()) { \
18         hiddenValue->m_##name.set(isolate, v8AtomicString(isolate, #name)); \
19     } \
20     return hiddenValue->m_##name.newLocal(isolate); \
21 }
22 
23 V8_HIDDEN_VALUES(V8_DEFINE_METHOD);
24 
getHiddenValue(v8::Isolate * isolate,v8::Handle<v8::Object> object,v8::Handle<v8::String> key)25 v8::Local<v8::Value> V8HiddenValue::getHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key)
26 {
27     return object->GetHiddenValue(key);
28 }
29 
setHiddenValue(v8::Isolate * isolate,v8::Handle<v8::Object> object,v8::Handle<v8::String> key,v8::Handle<v8::Value> value)30 bool V8HiddenValue::setHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key, v8::Handle<v8::Value> value)
31 {
32     return object->SetHiddenValue(key, value);
33 }
34 
deleteHiddenValue(v8::Isolate * isolate,v8::Handle<v8::Object> object,v8::Handle<v8::String> key)35 bool V8HiddenValue::deleteHiddenValue(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::String> key)
36 {
37     return object->DeleteHiddenValue(key);
38 }
39 
getHiddenValueFromMainWorldWrapper(v8::Isolate * isolate,ScriptWrappable * wrappable,v8::Handle<v8::String> key)40 v8::Local<v8::Value> V8HiddenValue::getHiddenValueFromMainWorldWrapper(v8::Isolate* isolate, ScriptWrappable* wrappable, v8::Handle<v8::String> key)
41 {
42     v8::Local<v8::Object> wrapper = wrappable->newLocalWrapper(isolate);
43     return wrapper.IsEmpty() ? v8::Local<v8::Value>() : getHiddenValue(isolate, wrapper, key);
44 }
45 
46 } // namespace WebCore
47