Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(943)

Side by Side Diff: Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp

Issue 13937004: Move bindings-tests to bindings/tests (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 "V8TestEventConstructor.h"
23
24 #include "BindingState.h"
25 #include "ContextFeatures.h"
26 #include "Dictionary.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("??_7TestEventConstructor@WebCore@ @6B@")[])(); }
37 #else
38 extern "C" { extern void* _ZTVN7WebCore20TestEventConstructorE[]; }
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(TestEventConstructor* object)
55 {
56 void* actualVTablePointer = *(reinterpret_cast<void**>(object));
57 #if defined(OS_WIN)
58 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7Test EventConstructor@WebCore@@6B@"));
59 #else
60 void* expectedVTablePointer = &_ZTVN7WebCore20TestEventConstructorE[2];
61 #endif
62 if (actualVTablePointer != expectedVTablePointer)
63 CRASH();
64 }
65 #endif // ENABLE(BINDING_INTEGRITY)
66
67 WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemp late, V8TestEventConstructor::derefObject, 0, 0, 0, V8TestEventConstructor::inst allPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype };
68
69 namespace TestEventConstructorV8Internal {
70
71 template <typename T> void V8_USE(T) { }
72
73 static v8::Handle<v8::Value> attr1AttrGetter(v8::Local<v8::String> name, const v 8::AccessorInfo& info)
74 {
75 TestEventConstructor* imp = V8TestEventConstructor::toNative(info.Holder());
76 return v8String(imp->attr1(), info.GetIsolate(), ReturnUnsafeHandle);
77 }
78
79 static v8::Handle<v8::Value> attr1AttrGetterCallback(v8::Local<v8::String> name, const v8::AccessorInfo& info)
80 {
81 return TestEventConstructorV8Internal::attr1AttrGetter(name, info);
82 }
83
84 static v8::Handle<v8::Value> attr2AttrGetter(v8::Local<v8::String> name, const v 8::AccessorInfo& info)
85 {
86 TestEventConstructor* imp = V8TestEventConstructor::toNative(info.Holder());
87 return v8String(imp->attr2(), info.GetIsolate(), ReturnUnsafeHandle);
88 }
89
90 static v8::Handle<v8::Value> attr2AttrGetterCallback(v8::Local<v8::String> name, const v8::AccessorInfo& info)
91 {
92 return TestEventConstructorV8Internal::attr2AttrGetter(name, info);
93 }
94
95 static v8::Handle<v8::Value> constructor(const v8::Arguments& args)
96 {
97 if (args.Length() < 1)
98 return throwNotEnoughArgumentsError(args.GetIsolate());
99
100 V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, args[0]);
101 TestEventConstructorInit eventInit;
102 if (args.Length() >= 2) {
103 V8TRYCATCH(Dictionary, options, Dictionary(args[1], args.GetIsolate()));
104 if (!fillTestEventConstructorInit(eventInit, options))
105 return v8Undefined();
106 }
107
108 RefPtr<TestEventConstructor> event = TestEventConstructor::create(type, even tInit);
109
110 v8::Handle<v8::Object> wrapper = args.Holder();
111 V8DOMWrapper::associateObjectWithWrapper(event.release(), &V8TestEventConstr uctor::info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent);
112 return wrapper;
113 }
114 } // namespace TestEventConstructorV8Internal
115
116 static const V8DOMConfiguration::BatchedAttribute V8TestEventConstructorAttrs[] = {
117 // Attribute 'attr1' (Type: 'readonly attribute' ExtAttr: '')
118 {"attr1", TestEventConstructorV8Internal::attr1AttrGetterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::Pr opertyAttribute>(v8::None), 0 /* on instance */},
119 // Attribute 'attr2' (Type: 'readonly attribute' ExtAttr: 'InitializedByEven tConstructor')
120 {"attr2", TestEventConstructorV8Internal::attr2AttrGetterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::Pr opertyAttribute>(v8::None), 0 /* on instance */},
121 };
122
123 bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, const Dic tionary& options)
124 {
125 options.get("attr2", eventInit.attr2);
126 return true;
127 }
128
129 v8::Handle<v8::Value> V8TestEventConstructor::constructorCallback(const v8::Argu ments& args)
130 {
131 if (!args.IsConstructCall())
132 return throwTypeError("DOM object constructor cannot be called as a func tion.", args.GetIsolate());
133
134 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
135 return args.Holder();
136
137 return TestEventConstructorV8Internal::constructor(args);
138 }
139
140 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestEventConstructorTempl ate(v8::Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorl dType currentWorldType)
141 {
142 desc->ReadOnlyPrototype();
143
144 v8::Local<v8::Signature> defaultSignature;
145 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestEventCon structor", v8::Persistent<v8::FunctionTemplate>(), V8TestEventConstructor::inter nalFieldCount,
146 V8TestEventConstructorAttrs, WTF_ARRAY_LENGTH(V8TestEventConstructorAttr s),
147 0, 0, isolate, currentWorldType);
148 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
149 desc->SetCallHandler(V8TestEventConstructor::constructorCallback);
150
151
152 // Custom toString template
153 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate());
154 return desc;
155 }
156
157 v8::Persistent<v8::FunctionTemplate> V8TestEventConstructor::GetTemplate(v8::Iso late* isolate, WrapperWorldType currentWorldType)
158 {
159 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
160 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info);
161 if (result != data->templateMap(currentWorldType).end())
162 return result->value;
163
164 v8::HandleScope handleScope;
165 v8::Persistent<v8::FunctionTemplate> templ =
166 ConfigureV8TestEventConstructorTemplate(data->rawTemplate(&info, current WorldType), isolate, currentWorldType);
167 data->templateMap(currentWorldType).add(&info, templ);
168 return templ;
169 }
170
171 bool V8TestEventConstructor::HasInstance(v8::Handle<v8::Value> value, v8::Isolat e* isolate, WrapperWorldType currentWorldType)
172 {
173 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType);
174 }
175
176 bool V8TestEventConstructor::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate* isolate)
177 {
178 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
179 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld)
180 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d);
181 }
182
183
184 v8::Handle<v8::Object> V8TestEventConstructor::createWrapper(PassRefPtr<TestEven tConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate )
185 {
186 ASSERT(impl.get());
187 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty());
188
189 #if ENABLE(BINDING_INTEGRITY)
190 checkTypeOrDieTrying(impl.get());
191 #endif
192
193 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, impl.get(), isolate);
194 if (UNLIKELY(wrapper.IsEmpty()))
195 return wrapper;
196
197 installPerContextProperties(wrapper, impl.get(), isolate);
198 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep endent);
199 return wrapper;
200 }
201 void V8TestEventConstructor::derefObject(void* object)
202 {
203 static_cast<TestEventConstructor*>(object)->deref();
204 }
205
206 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698