2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
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.
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.
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.
22 #include "V8TestEventConstructor.h"
24 #include "Dictionary.h"
25 #include "RuntimeEnabledFeatures.h"
26 #include "V8Binding.h"
27 #include "V8BindingMacros.h"
28 #include "V8BindingState.h"
29 #include "V8DOMWrapper.h"
30 #include "V8IsolatedContext.h"
32 #include <wtf/UnusedParam.h>
36 WrapperTypeInfo V8TestEventConstructor::info = { V8TestEventConstructor::GetTemplate, V8TestEventConstructor::derefObject, 0, 0 };
38 namespace TestEventConstructorInternal {
40 template <typename T> void V8_USE(T) { }
42 static v8::Handle<v8::Value> attr1AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
44 INC_STATS("DOM.TestEventConstructor.attr1._get");
45 TestEventConstructor* imp = V8TestEventConstructor::toNative(info.Holder());
46 return v8String(imp->attr1());
49 static v8::Handle<v8::Value> attr2AttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
51 INC_STATS("DOM.TestEventConstructor.attr2._get");
52 TestEventConstructor* imp = V8TestEventConstructor::toNative(info.Holder());
53 return v8String(imp->attr2());
56 } // namespace TestEventConstructorInternal
58 static const BatchedAttribute TestEventConstructorAttrs[] = {
59 // Attribute 'attr1' (Type: 'readonly attribute' ExtAttr: '')
60 {"attr1", TestEventConstructorInternal::attr1AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
61 // Attribute 'attr2' (Type: 'readonly attribute' ExtAttr: 'InitializedByEventConstructor')
62 {"attr2", TestEventConstructorInternal::attr2AttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
65 v8::Handle<v8::Value> V8TestEventConstructor::constructorCallback(const v8::Arguments& args)
67 INC_STATS("DOM.TestEventConstructor.Constructor");
69 if (!args.IsConstructCall())
70 return throwError("DOM object constructor cannot be called as a function.", V8Proxy::TypeError);
72 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
75 if (args.Length() < 1)
76 return throwError("Not enough arguments", V8Proxy::TypeError);
78 STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, args[0]);
79 TestEventConstructorInit eventInit;
80 if (args.Length() >= 2) {
81 EXCEPTION_BLOCK(Dictionary, options, args[1]);
82 if (!fillTestEventConstructorInit(eventInit, options))
83 return v8::Undefined();
86 RefPtr<TestEventConstructor> event = TestEventConstructor::create(type, eventInit);
88 V8DOMWrapper::setDOMWrapper(args.Holder(), &info, event.get());
89 return toV8(event.release(), args.Holder());
92 bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, const Dictionary& options)
94 options.get("attr2", eventInit.attr2);
98 static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestEventConstructorTemplate(v8::Persistent<v8::FunctionTemplate> desc)
100 desc->ReadOnlyPrototype();
102 v8::Local<v8::Signature> defaultSignature;
103 defaultSignature = configureTemplate(desc, "TestEventConstructor", v8::Persistent<v8::FunctionTemplate>(), V8TestEventConstructor::internalFieldCount,
104 TestEventConstructorAttrs, WTF_ARRAY_LENGTH(TestEventConstructorAttrs),
106 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
107 desc->SetCallHandler(V8TestEventConstructor::constructorCallback);
110 // Custom toString template
111 desc->Set(getToStringName(), getToStringTemplate());
115 v8::Persistent<v8::FunctionTemplate> V8TestEventConstructor::GetRawTemplate()
117 V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
118 V8BindingPerIsolateData::TemplateMap::iterator result = data->rawTemplateMap().find(&info);
119 if (result != data->rawTemplateMap().end())
120 return result->second;
122 v8::HandleScope handleScope;
123 v8::Persistent<v8::FunctionTemplate> templ = createRawTemplate();
124 data->rawTemplateMap().add(&info, templ);
128 v8::Persistent<v8::FunctionTemplate> V8TestEventConstructor::GetTemplate()
130 V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
131 V8BindingPerIsolateData::TemplateMap::iterator result = data->templateMap().find(&info);
132 if (result != data->templateMap().end())
133 return result->second;
135 v8::HandleScope handleScope;
136 v8::Persistent<v8::FunctionTemplate> templ =
137 ConfigureV8TestEventConstructorTemplate(GetRawTemplate());
138 data->templateMap().add(&info, templ);
142 bool V8TestEventConstructor::HasInstance(v8::Handle<v8::Value> value)
144 return GetRawTemplate()->HasInstance(value);
148 v8::Handle<v8::Object> V8TestEventConstructor::wrapSlow(TestEventConstructor* impl)
150 v8::Handle<v8::Object> wrapper;
152 wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
153 if (UNLIKELY(wrapper.IsEmpty()))
157 v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
159 if (!hasDependentLifetime)
160 wrapperHandle.MarkIndependent();
161 getDOMObjectMap().set(impl, wrapperHandle);
165 void V8TestEventConstructor::derefObject(void* object)
167 static_cast<TestEventConstructor*>(object)->deref();
170 } // namespace WebCore