| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 This file is part of the WebKit open source project. | |
| 3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! | |
| 4 | |
| 5 This library is free software; you can redistribute it and/or | |
| 6 modify it under the terms of the GNU Library General Public | |
| 7 License as published by the Free Software Foundation; either | |
| 8 version 2 of the License, or (at your option) any later version. | |
| 9 | |
| 10 This library is distributed in the hope that it will be useful, | |
| 11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 Library General Public License for more details. | |
| 14 | |
| 15 You should have received a copy of the GNU Library General Public License | |
| 16 along with this library; see the file COPYING.LIB. If not, write to | |
| 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 18 Boston, MA 02111-1307, USA. | |
| 19 */ | |
| 20 | |
| 21 #include "config.h" | |
| 22 #include "V8TestException.h" | |
| 23 | |
| 24 #include "BindingState.h" | |
| 25 #include "ContextFeatures.h" | |
| 26 #include "Frame.h" | |
| 27 #include "RuntimeEnabledFeatures.h" | |
| 28 #include "V8Binding.h" | |
| 29 #include "V8DOMWrapper.h" | |
| 30 #include <wtf/UnusedParam.h> | |
| 31 | |
| 32 #if ENABLE(BINDING_INTEGRITY) | |
| 33 #if defined(OS_WIN) | |
| 34 #pragma warning(disable: 4483) | |
| 35 extern "C" { extern void (*const __identifier("??_7TestException@WebCore@@6B@")[
])(); } | |
| 36 #else | |
| 37 extern "C" { extern void* _ZTVN7WebCore13TestExceptionE[]; } | |
| 38 #endif | |
| 39 #endif // ENABLE(BINDING_INTEGRITY) | |
| 40 | |
| 41 namespace WebCore { | |
| 42 | |
| 43 #if ENABLE(BINDING_INTEGRITY) | |
| 44 // This checks if a DOM object that is about to be wrapped is valid. | |
| 45 // Specifically, it checks that a vtable of the DOM object is equal to | |
| 46 // a vtable of an expected class. | |
| 47 // Due to a dangling pointer, the DOM object you are wrapping might be | |
| 48 // already freed or realloced. If freed, the check will fail because | |
| 49 // a free list pointer should be stored at the head of the DOM object. | |
| 50 // If realloced, the check will fail because the vtable of the DOM object | |
| 51 // differs from the expected vtable (unless the same class of DOM object | |
| 52 // is realloced on the slot). | |
| 53 inline void checkTypeOrDieTrying(TestException* object) | |
| 54 { | |
| 55 void* actualVTablePointer = *(reinterpret_cast<void**>(object)); | |
| 56 #if defined(OS_WIN) | |
| 57 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7Test
Exception@WebCore@@6B@")); | |
| 58 #else | |
| 59 void* expectedVTablePointer = &_ZTVN7WebCore13TestExceptionE[2]; | |
| 60 #endif | |
| 61 if (actualVTablePointer != expectedVTablePointer) | |
| 62 CRASH(); | |
| 63 } | |
| 64 #endif // ENABLE(BINDING_INTEGRITY) | |
| 65 | |
| 66 WrapperTypeInfo V8TestException::info = { V8TestException::GetTemplate, V8TestEx
ception::derefObject, 0, 0, 0, V8TestException::installPerContextPrototypeProper
ties, 0, WrapperTypeErrorPrototype }; | |
| 67 | |
| 68 namespace TestExceptionV8Internal { | |
| 69 | |
| 70 template <typename T> void V8_USE(T) { } | |
| 71 | |
| 72 static v8::Handle<v8::Value> nameAttrGetter(v8::Local<v8::String> name, const v8
::AccessorInfo& info) | |
| 73 { | |
| 74 TestException* imp = V8TestException::toNative(info.Holder()); | |
| 75 return v8String(imp->name(), info.GetIsolate(), ReturnUnsafeHandle); | |
| 76 } | |
| 77 | |
| 78 static v8::Handle<v8::Value> nameAttrGetterCallback(v8::Local<v8::String> name,
const v8::AccessorInfo& info) | |
| 79 { | |
| 80 return TestExceptionV8Internal::nameAttrGetter(name, info); | |
| 81 } | |
| 82 | |
| 83 } // namespace TestExceptionV8Internal | |
| 84 | |
| 85 static const V8DOMConfiguration::BatchedAttribute V8TestExceptionAttrs[] = { | |
| 86 // Attribute 'name' (Type: 'readonly attribute' ExtAttr: '') | |
| 87 {"name", TestExceptionV8Internal::nameAttrGetterCallback, 0, 0, 0, 0 /* no d
ata */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAtt
ribute>(v8::None), 0 /* on instance */}, | |
| 88 }; | |
| 89 | |
| 90 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestExceptionTemplate(v8:
:Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType c
urrentWorldType) | |
| 91 { | |
| 92 desc->ReadOnlyPrototype(); | |
| 93 | |
| 94 v8::Local<v8::Signature> defaultSignature; | |
| 95 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestExceptio
n", v8::Persistent<v8::FunctionTemplate>(), V8TestException::internalFieldCount, | |
| 96 V8TestExceptionAttrs, WTF_ARRAY_LENGTH(V8TestExceptionAttrs), | |
| 97 0, 0, isolate, currentWorldType); | |
| 98 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | |
| 99 | |
| 100 | |
| 101 // Custom toString template | |
| 102 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); | |
| 103 return desc; | |
| 104 } | |
| 105 | |
| 106 v8::Persistent<v8::FunctionTemplate> V8TestException::GetTemplate(v8::Isolate* i
solate, WrapperWorldType currentWorldType) | |
| 107 { | |
| 108 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 109 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); | |
| 110 if (result != data->templateMap(currentWorldType).end()) | |
| 111 return result->value; | |
| 112 | |
| 113 v8::HandleScope handleScope; | |
| 114 v8::Persistent<v8::FunctionTemplate> templ = | |
| 115 ConfigureV8TestExceptionTemplate(data->rawTemplate(&info, currentWorldTy
pe), isolate, currentWorldType); | |
| 116 data->templateMap(currentWorldType).add(&info, templ); | |
| 117 return templ; | |
| 118 } | |
| 119 | |
| 120 bool V8TestException::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isol
ate, WrapperWorldType currentWorldType) | |
| 121 { | |
| 122 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor
ldType); | |
| 123 } | |
| 124 | |
| 125 bool V8TestException::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Iso
late* isolate) | |
| 126 { | |
| 127 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | |
| 128 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
rld) | |
| 129 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
d); | |
| 130 } | |
| 131 | |
| 132 | |
| 133 v8::Handle<v8::Object> V8TestException::createWrapper(PassRefPtr<TestException>
impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
| 134 { | |
| 135 ASSERT(impl.get()); | |
| 136 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); | |
| 137 | |
| 138 #if ENABLE(BINDING_INTEGRITY) | |
| 139 checkTypeOrDieTrying(impl.get()); | |
| 140 #endif | |
| 141 | |
| 142 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, impl.get(), isolate); | |
| 143 if (UNLIKELY(wrapper.IsEmpty())) | |
| 144 return wrapper; | |
| 145 | |
| 146 installPerContextProperties(wrapper, impl.get(), isolate); | |
| 147 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD
ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep
endent); | |
| 148 return wrapper; | |
| 149 } | |
| 150 void V8TestException::derefObject(void* object) | |
| 151 { | |
| 152 static_cast<TestException*>(object)->deref(); | |
| 153 } | |
| 154 | |
| 155 } // namespace WebCore | |
| OLD | NEW |