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

Side by Side Diff: Source/WebCore/bindings/scripts/test/V8/V8Float64Array.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 "V8Float64Array.h"
23
24 #include "BindingState.h"
25 #include "ContextFeatures.h"
26 #include "ExceptionCode.h"
27 #include "Frame.h"
28 #include "RuntimeEnabledFeatures.h"
29 #include "V8ArrayBufferView.h"
30 #include "V8ArrayBufferViewCustom.h"
31 #include "V8Binding.h"
32 #include "V8DOMWrapper.h"
33 #include "V8Float32Array.h"
34 #include "V8Int32Array.h"
35 #include <wtf/Float32Array.h>
36 #include <wtf/Float64Array.h>
37 #include <wtf/GetPtr.h>
38 #include <wtf/Int32Array.h>
39 #include <wtf/RefCounted.h>
40 #include <wtf/RefPtr.h>
41 #include <wtf/UnusedParam.h>
42
43 #if ENABLE(BINDING_INTEGRITY)
44 #if defined(OS_WIN)
45 #pragma warning(disable: 4483)
46 extern "C" { extern void (*const __identifier("??_7Float64Array@WebCore@@6B@")[] )(); }
47 #else
48 extern "C" { extern void* _ZTVN7WebCore12Float64ArrayE[]; }
49 #endif
50 #endif // ENABLE(BINDING_INTEGRITY)
51
52 namespace WebCore {
53
54 #if ENABLE(BINDING_INTEGRITY)
55 // This checks if a DOM object that is about to be wrapped is valid.
56 // Specifically, it checks that a vtable of the DOM object is equal to
57 // a vtable of an expected class.
58 // Due to a dangling pointer, the DOM object you are wrapping might be
59 // already freed or realloced. If freed, the check will fail because
60 // a free list pointer should be stored at the head of the DOM object.
61 // If realloced, the check will fail because the vtable of the DOM object
62 // differs from the expected vtable (unless the same class of DOM object
63 // is realloced on the slot).
64 inline void checkTypeOrDieTrying(Float64Array* object)
65 {
66 void* actualVTablePointer = *(reinterpret_cast<void**>(object));
67 #if defined(OS_WIN)
68 void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7Floa t64Array@WebCore@@6B@"));
69 #else
70 void* expectedVTablePointer = &_ZTVN7WebCore12Float64ArrayE[2];
71 #endif
72 if (actualVTablePointer != expectedVTablePointer)
73 CRASH();
74 }
75 #endif // ENABLE(BINDING_INTEGRITY)
76
77 WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64A rray::derefObject, 0, 0, 0, V8Float64Array::installPerContextPrototypeProperties , &V8ArrayBufferView::info, WrapperTypeObjectPrototype };
78
79 namespace Float64ArrayV8Internal {
80
81 template <typename T> void V8_USE(T) { }
82
83 static v8::Handle<v8::Value> fooMethod(const v8::Arguments& args)
84 {
85 if (args.Length() < 1)
86 return throwNotEnoughArgumentsError(args.GetIsolate());
87 Float64Array* imp = V8Float64Array::toNative(args.Holder());
88 V8TRYCATCH(Float32Array*, array, V8Float32Array::HasInstance(args[0], args.G etIsolate(), worldType(args.GetIsolate())) ? V8Float32Array::toNative(v8::Handle <v8::Object>::Cast(args[0])) : 0);
89 return toV8(imp->foo(array), args.Holder(), args.GetIsolate());
90 }
91
92 static v8::Handle<v8::Value> fooMethodCallback(const v8::Arguments& args)
93 {
94 return Float64ArrayV8Internal::fooMethod(args);
95 }
96
97 static v8::Handle<v8::Value> setMethod(const v8::Arguments& args)
98 {
99 return setWebGLArrayHelper<Float64Array, V8Float64Array>(args);
100 }
101
102 static v8::Handle<v8::Value> setMethodCallback(const v8::Arguments& args)
103 {
104 return Float64ArrayV8Internal::setMethod(args);
105 }
106
107 static v8::Handle<v8::Value> constructor(const v8::Arguments& args)
108 {
109 return constructWebGLArray<Float64Array, V8Float64Array, double>(args, &V8Fl oat64Array::info, v8::kExternalDoubleArray);
110 }
111
112 } // namespace Float64ArrayV8Internal
113
114 v8::Handle<v8::Object> wrap(Float64Array* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
115 {
116 ASSERT(impl);
117 v8::Handle<v8::Object> wrapper = V8Float64Array::createWrapper(impl, creatio nContext, isolate);
118 if (!wrapper.IsEmpty())
119 wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8 ::kExternalDoubleArray, impl->length());
120 return wrapper;
121 }
122
123 static const V8DOMConfiguration::BatchedMethod V8Float64ArrayMethods[] = {
124 {"set", Float64ArrayV8Internal::setMethodCallback, 0},
125 };
126
127 v8::Handle<v8::Value> V8Float64Array::constructorCallback(const v8::Arguments& a rgs)
128 {
129 if (!args.IsConstructCall())
130 return throwTypeError("DOM object constructor cannot be called as a func tion.", args.GetIsolate());
131
132 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
133 return args.Holder();
134
135 return Float64ArrayV8Internal::constructor(args);
136 }
137
138 static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float64ArrayTemplate(v8:: Persistent<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType cu rrentWorldType)
139 {
140 desc->ReadOnlyPrototype();
141
142 v8::Local<v8::Signature> defaultSignature;
143 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "Float64Array ", V8ArrayBufferView::GetTemplate(isolate, currentWorldType), V8Float64Array::in ternalFieldCount,
144 0, 0,
145 V8Float64ArrayMethods, WTF_ARRAY_LENGTH(V8Float64ArrayMethods), isolate, currentWorldType);
146 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
147 desc->SetCallHandler(V8Float64Array::constructorCallback);
148 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
149 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
150 UNUSED_PARAM(instance); // In some cases, it will not be used.
151 UNUSED_PARAM(proto); // In some cases, it will not be used.
152
153
154 // Custom Signature 'foo'
155 const int fooArgc = 1;
156 v8::Handle<v8::FunctionTemplate> fooArgv[fooArgc] = { V8PerIsolateData::from (isolate)->rawTemplate(&V8Float32Array::info, currentWorldType) };
157 v8::Handle<v8::Signature> fooSignature = v8::Signature::New(desc, fooArgc, f ooArgv);
158 proto->Set(v8::String::NewSymbol("foo"), v8::FunctionTemplate::New(Float64Ar rayV8Internal::fooMethodCallback, v8Undefined(), fooSignature));
159
160 // Custom toString template
161 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate());
162 return desc;
163 }
164
165 v8::Persistent<v8::FunctionTemplate> V8Float64Array::GetTemplate(v8::Isolate* is olate, WrapperWorldType currentWorldType)
166 {
167 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
168 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info);
169 if (result != data->templateMap(currentWorldType).end())
170 return result->value;
171
172 v8::HandleScope handleScope;
173 v8::Persistent<v8::FunctionTemplate> templ =
174 ConfigureV8Float64ArrayTemplate(data->rawTemplate(&info, currentWorldTyp e), isolate, currentWorldType);
175 data->templateMap(currentWorldType).add(&info, templ);
176 return templ;
177 }
178
179 bool V8Float64Array::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isola te, WrapperWorldType currentWorldType)
180 {
181 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor ldType);
182 }
183
184 bool V8Float64Array::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isol ate* isolate)
185 {
186 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld)
187 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo rld)
188 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl d);
189 }
190
191
192 v8::Handle<v8::Object> V8Float64Array::createWrapper(PassRefPtr<Float64Array> im pl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
193 {
194 ASSERT(impl.get());
195 ASSERT(DOMDataStore::getWrapper(impl.get(), isolate).IsEmpty());
196
197 #if ENABLE(BINDING_INTEGRITY)
198 checkTypeOrDieTrying(impl.get());
199 #endif
200 ASSERT(static_cast<void*>(static_cast<ArrayBufferView*>(impl.get())) == stat ic_cast<void*>(impl.get()));
201
202 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &info, impl.get(), isolate);
203 if (UNLIKELY(wrapper.IsEmpty()))
204 return wrapper;
205
206 installPerContextProperties(wrapper, impl.get(), isolate);
207 V8DOMWrapper::associateObjectWithWrapper(impl, &info, wrapper, isolate, hasD ependentLifetime ? WrapperConfiguration::Dependent : WrapperConfiguration::Indep endent);
208 return wrapper;
209 }
210 void V8Float64Array::derefObject(void* object)
211 {
212 static_cast<Float64Array*>(object)->deref();
213 }
214
215 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698