| 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 "V8TestCustomNamedGetter.h" | |
| 23 | |
| 24 #include "BindingState.h" | |
| 25 #include "ContextFeatures.h" | |
| 26 #include "ExceptionCode.h" | |
| 27 #include "Frame.h" | |
| 28 #include "RuntimeEnabledFeatures.h" | |
| 29 #include "V8Binding.h" | |
| 30 #include "V8DOMWrapper.h" | |
| 31 #include <wtf/UnusedParam.h> | |
| 32 | |
| 33 #if ENABLE(BINDING_INTEGRITY) | |
| 34 #if defined(OS_WIN) | |
| 35 #pragma warning(disable: 4483) | |
| 36 extern "C" { extern void (*const __identifier("??_7TestCustomNamedGetter@WebCore
@@6B@")[])(); } | |
| 37 #else | |
| 38 extern "C" { extern void* _ZTVN7WebCore21TestCustomNamedGetterE[]; } | |
| 39 #endif | |
| 40 #endif // ENABLE(BINDING_INTEGRITY) | |
| 41 | |
| 42 namespace WebCore { | |
| 43 | |
| 44 #if ENABLE(BINDING_INTEGRITY) | |
| 45 // This checks if a DOM object that is about to be wrapped is valid. | |
| 46 // Specifically, it checks that a vtable of the DOM object is equal to | |
| 47 // a vtable of an expected class. | |
| 48 // Due to a dangling pointer, the DOM object you are wrapping might be | |
| 49 // already freed or realloced. If freed, the check will fail because | |
| 50 // a free list pointer should be stored at the head of the DOM object. | |
| 51 // If realloced, the check will fail because the vtable of the DOM object | |
| 52 // differs from the expected vtable (unless the same class of DOM object | |
| 53 // is realloced on the slot). | |
| 54 inline void checkTypeOrDieTrying(TestCustomNamedGetter* object) | |
| 55 { | |
| 56 void* actualVTablePointer = *(reinterpret_cast<void**>(object)); | |
| 57 #if defined(OS_WIN) | |
| 58 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7Test
CustomNamedGetter@WebCore@@6B@")); | |
| 59 #else | |
| 60 void* expectedVTablePointer = &_ZTVN7WebCore21TestCustomNamedGetterE[2]; | |
| 61 #endif | |
| 62 if (actualVTablePointer != expectedVTablePointer) | |
| 63 CRASH(); | |
| 64 } | |
| 65 #endif // ENABLE(BINDING_INTEGRITY) | |
| 66 | |
| 67 WrapperTypeInfo V8TestCustomNamedGetter::info = { V8TestCustomNamedGetter::GetTe
mplate, V8TestCustomNamedGetter::derefObject, 0, 0, 0, V8TestCustomNamedGetter::
installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype }; | |
| 68 | |
| 69 namespace TestCustomNamedGetterV8Internal { | |
| 70 | |
| 71 template <typename T> void V8_USE(T) { } | |
| 72 | |
| 73 static v8::Handle<v8::Value> anotherFunctionMethod(const v8::Arguments& args) | |
| 74 { | |
| 75 if (args.Length() < 1) | |
| 76 return throwNotEnoughArgumentsError(args.GetIsolate()); | |
| 77 TestCustomNamedGetter* imp = V8TestCustomNamedGetter::toNative(args.Holder()
); | |
| 78 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, str, args[0]); | |
| 79 imp->anotherFunction(str); | |
| 80 return v8Undefined(); | |
| 81 } | |
| 82 | |
| 83 static v8::Handle<v8::Value> anotherFunctionMethodCallback(const v8::Arguments&
args) | |
| 84 { | |
| 85 return TestCustomNamedGetterV8Internal::anotherFunctionMethod(args); | |
| 86 } | |
| 87 | |
| 88 } // namespace TestCustomNamedGetterV8Internal | |
| 89 | |
| 90 static const V8DOMConfiguration::BatchedMethod V8TestCustomNamedGetterMethods[]
= { | |
| 91 {"anotherFunction", TestCustomNamedGetterV8Internal::anotherFunctionMethodCa
llback, 0}, | |
| 92 }; | |
| 93 | |
| 94 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestCustomNamedGetterTemp
late(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWor
ldType currentWorldType) | |
| 95 { | |
| 96 desc->ReadOnlyPrototype(); | |
| 97 | |
| 98 v8::Local<v8::Signature> defaultSignature; | |
| 99 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestCustomNa
medGetter", v8::Persistent<v8::FunctionTemplate>(), V8TestCustomNamedGetter::int
ernalFieldCount, | |
| 100 0, 0, | |
| 101 V8TestCustomNamedGetterMethods, WTF_ARRAY_LENGTH(V8TestCustomNamedGetter
Methods), isolate, currentWorldType); | |
| 102 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | |
| 103 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); | |
| 104 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); | |
| 105 UNUSED_PARAM(instance); // In some cases, it will not be used. | |
| 106 UNUSED_PARAM(proto); // In some cases, it will not be used. | |
| 107 | |
| 108 desc->InstanceTemplate()->SetNamedPropertyHandler(V8TestCustomNamedGetter::n
amedPropertyGetter, 0, 0, 0, 0); | |
| 109 | |
| 110 // Custom toString template | |
| 111 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); | |
| 112 return desc; | |
| 113 } | |
| 114 | |
| 115 v8::Persistent<v8::FunctionTemplate> V8TestCustomNamedGetter::GetTemplate(v8::Is
olate* isolate, WrapperWorldType currentWorldType) | |
| 116 { | |
| 117 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
| 118 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); | |
| 119 if (result != data->templateMap(currentWorldType).end()) | |
| 120 return result->value; | |
| 121 | |
| 122 v8::HandleScope handleScope; | |
| 123 v8::Persistent<v8::FunctionTemplate> templ = | |
| 124 ConfigureV8TestCustomNamedGetterTemplate(data->rawTemplate(&info, curren
tWorldType), isolate, currentWorldType); | |
| 125 data->templateMap(currentWorldType).add(&info, templ); | |
| 126 return templ; | |
| 127 } | |
| 128 | |
| 129 bool V8TestCustomNamedGetter::HasInstance(v8::Handle<v8::Value> value, v8::Isola
te* isolate, WrapperWorldType currentWorldType) | |
| 130 { | |
| 131 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor
ldType); | |
| 132 } | |
| 133 | |
| 134 bool V8TestCustomNamedGetter::HasInstanceInAnyWorld(v8::Handle<v8::Value> value,
v8::Isolate* isolate) | |
| 135 { | |
| 136 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | |
| 137 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
rld) | |
| 138 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
d); | |
| 139 } | |
| 140 | |
| 141 | |
| 142 v8::Handle<v8::Object> V8TestCustomNamedGetter::createWrapper(PassRefPtr<TestCus
tomNamedGetter> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isola
te) | |
| 143 { | |
| 144 ASSERT(impl.get()); | |
| 145 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty()); | |
| 146 | |
| 147 #if ENABLE(BINDING_INTEGRITY) | |
| 148 checkTypeOrDieTrying(impl.get()); | |
| 149 #endif | |
| 150 | |
| 151 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, impl.get(), isolate); | |
| 152 if (UNLIKELY(wrapper.IsEmpty())) | |
| 153 return wrapper; | |
| 154 | |
| 155 installPerContextProperties(wrapper, impl.get(), isolate); | |
| 156 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD
ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep
endent); | |
| 157 return wrapper; | |
| 158 } | |
| 159 void V8TestCustomNamedGetter::derefObject(void* object) | |
| 160 { | |
| 161 static_cast<TestCustomNamedGetter*>(object)->deref(); | |
| 162 } | |
| 163 | |
| 164 } // namespace WebCore | |
| OLD | NEW |