tizen beta release
[framework/web/webkit-efl.git] / Source / WebCore / bindings / scripts / test / V8 / V8Float64Array.cpp
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 "ExceptionCode.h"
25 #include "RuntimeEnabledFeatures.h"
26 #include "V8ArrayBufferView.h"
27 #include "V8Binding.h"
28 #include "V8BindingMacros.h"
29 #include "V8BindingState.h"
30 #include "V8DOMWrapper.h"
31 #include "V8Float32Array.h"
32 #include "V8Int32Array.h"
33 #include "V8IsolatedContext.h"
34 #include "V8Proxy.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 namespace WebCore {
44
45 WrapperTypeInfo V8Float64Array::info = { V8Float64Array::GetTemplate, V8Float64Array::derefObject, 0, &V8ArrayBufferView::info };
46
47 namespace Float64ArrayInternal {
48
49 template <typename T> void V8_USE(T) { }
50
51 static v8::Handle<v8::Value> fooCallback(const v8::Arguments& args)
52 {
53     INC_STATS("DOM.Float64Array.foo");
54     if (args.Length() < 1)
55         return throwError("Not enough arguments", V8Proxy::TypeError);
56     Float64Array* imp = V8Float64Array::toNative(args.Holder());
57     EXCEPTION_BLOCK(Float32Array*, array, V8Float32Array::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8Float32Array::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
58     return toV8(imp->foo(array));
59 }
60
61 } // namespace Float64ArrayInternal
62
63 static v8::Persistent<v8::FunctionTemplate> ConfigureV8Float64ArrayTemplate(v8::Persistent<v8::FunctionTemplate> desc)
64 {
65     desc->ReadOnlyPrototype();
66
67     v8::Local<v8::Signature> defaultSignature;
68     defaultSignature = configureTemplate(desc, "Float64Array", V8ArrayBufferView::GetTemplate(), V8Float64Array::internalFieldCount,
69         0, 0,
70         0, 0);
71     UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
72     desc->SetCallHandler(V8Float64Array::constructorCallback);
73     v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
74     v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
75     UNUSED_PARAM(instance); // In some cases, it will not be used.
76     UNUSED_PARAM(proto); // In some cases, it will not be used.
77     
78
79     // Custom Signature 'foo'
80     const int fooArgc = 1;
81     v8::Handle<v8::FunctionTemplate> fooArgv[fooArgc] = { V8Float32Array::GetRawTemplate() };
82     v8::Handle<v8::Signature> fooSignature = v8::Signature::New(desc, fooArgc, fooArgv);
83     proto->Set(v8::String::New("foo"), v8::FunctionTemplate::New(Float64ArrayInternal::fooCallback, v8::Handle<v8::Value>(), fooSignature));
84
85     // Custom toString template
86     desc->Set(getToStringName(), getToStringTemplate());
87     return desc;
88 }
89
90 v8::Persistent<v8::FunctionTemplate> V8Float64Array::GetRawTemplate()
91 {
92     V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
93     V8BindingPerIsolateData::TemplateMap::iterator result = data->rawTemplateMap().find(&info);
94     if (result != data->rawTemplateMap().end())
95         return result->second;
96
97     v8::HandleScope handleScope;
98     v8::Persistent<v8::FunctionTemplate> templ = createRawTemplate();
99     data->rawTemplateMap().add(&info, templ);
100     return templ;
101 }
102
103 v8::Persistent<v8::FunctionTemplate> V8Float64Array::GetTemplate()
104 {
105     V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
106     V8BindingPerIsolateData::TemplateMap::iterator result = data->templateMap().find(&info);
107     if (result != data->templateMap().end())
108         return result->second;
109
110     v8::HandleScope handleScope;
111     v8::Persistent<v8::FunctionTemplate> templ =
112         ConfigureV8Float64ArrayTemplate(GetRawTemplate());
113     data->templateMap().add(&info, templ);
114     return templ;
115 }
116
117 bool V8Float64Array::HasInstance(v8::Handle<v8::Value> value)
118 {
119     return GetRawTemplate()->HasInstance(value);
120 }
121
122
123 v8::Handle<v8::Object> V8Float64Array::wrapSlow(Float64Array* impl)
124 {
125     v8::Handle<v8::Object> wrapper;
126     V8Proxy* proxy = 0;
127     wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
128     if (wrapper.IsEmpty())
129         return wrapper;
130
131     impl->ref();
132     v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
133
134     if (!hasDependentLifetime)
135         wrapperHandle.MarkIndependent();
136     getDOMObjectMap().set(impl, wrapperHandle);
137     return wrapper;
138 }
139
140 void V8Float64Array::derefObject(void* object)
141 {
142     static_cast<Float64Array*>(object)->deref();
143 }
144
145 } // namespace WebCore