OLD | NEW |
| (Empty) |
1 /* | |
2 This file is part of the Blink open source project. | |
3 This file has been auto-generated by CodeGeneratorV8.pm. 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 {% if conditional_string %} | |
23 #if {{conditional_string}} | |
24 {% endif %} | |
25 #include "{{v8_class_name}}.h" | |
26 | |
27 {% for filename in cpp_includes %} | |
28 #include "{{ filename }}" | |
29 {% endfor %} | |
30 | |
31 namespace WebCore { | |
32 | |
33 static void initializeScriptWrappableForInterface({{cpp_class_name}}* object) | |
34 { | |
35 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | |
36 ScriptWrappable::setTypeInfoInObject(object, &{{v8_class_name}}::info); | |
37 else | |
38 ASSERT_NOT_REACHED(); | |
39 } | |
40 | |
41 } // namespace WebCore | |
42 | |
43 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: | |
44 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function | |
45 // in the global namespace. | |
46 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) | |
47 void webCoreInitializeScriptWrappableForInterface(WebCore::{{cpp_class_name}}* o
bject) | |
48 { | |
49 WebCore::initializeScriptWrappableForInterface(object); | |
50 } | |
51 | |
52 namespace WebCore { | |
53 WrapperTypeInfo {{v8_class_name}}::info = { {{v8_class_name}}::GetTemplate, {{v8
_class_name}}::derefObject, 0, 0, 0, {{v8_class_name}}::installPerContextPrototy
peProperties, 0, WrapperTypeObjectPrototype }; | |
54 | |
55 namespace {{cpp_class_name}}V8Internal { | |
56 | |
57 template <typename T> void V8_USE(T) { } | |
58 | |
59 {% for attribute in attributes %} | |
60 static void {{attribute.name}}AttrGetter(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Value>& info) | |
61 { | |
62 {{cpp_class_name}}* imp = {{v8_class_name}}::toNative(info.Holder()); | |
63 {{attribute.cpp_type}} result = imp->{{attribute.cpp_method_name}}(); | |
64 v8::Handle<v8::Value> wrapper = result.get() ? v8::Handle<v8::Value>(DOMData
Store::getWrapper<{{attribute.v8_type}}>(result.get(), info.GetIsolate())) : v8U
ndefined(); | |
65 if (wrapper.IsEmpty()) { | |
66 wrapper = toV8(result.get(), info.Holder(), info.GetIsolate()); | |
67 if (!wrapper.IsEmpty()) | |
68 V8HiddenPropertyName::setNamedHiddenReference(info.Holder(), "{{attr
ibute.name}}", wrapper); | |
69 } | |
70 v8SetReturnValue(info, wrapper); | |
71 } | |
72 | |
73 static void {{attribute.name}}AttrGetterCallback(v8::Local<v8::String> name, con
st v8::PropertyCallbackInfo<v8::Value>& info) | |
74 { | |
75 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | |
76 {{cpp_class_name}}V8Internal::{{attribute.name}}AttrGetter(name, info); | |
77 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | |
78 } | |
79 | |
80 {% endfor %} | |
81 | |
82 } // namespace {{cpp_class_name}}V8Internal | |
83 | |
84 {% if attributes %} | |
85 static const V8DOMConfiguration::BatchedAttribute {{v8_class_name}}Attributes[]
= { | |
86 {% for attribute in attributes %} | |
87 {"{{attribute.name}}", {{cpp_class_name}}V8Internal::{{attribute.name}}AttrG
etterCallback, 0, 0, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFA
ULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, | |
88 {% endfor %} | |
89 }; | |
90 | |
91 {% endif %} | |
92 | |
93 | |
94 static v8::Handle<v8::FunctionTemplate> Configure{{v8_class_name}}Template(v8::H
andle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType current
WorldType) | |
95 { | |
96 desc->ReadOnlyPrototype(); | |
97 | |
98 v8::Local<v8::Signature> defaultSignature; | |
99 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "{{interface_
name}}", v8::Local<v8::FunctionTemplate>(), {{v8_class_name}}::internalFieldCoun
t, | |
100 {{attribute_templates}}, {{number_of_attributes}}, | |
101 0, 0, isolate, currentWorldType); | |
102 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | |
103 | |
104 // Custom toString template | |
105 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); | |
106 return desc; | |
107 } | |
108 | |
109 v8::Handle<v8::FunctionTemplate> {{v8_class_name}}::GetTemplate(v8::Isolate* iso
late, WrapperWorldType currentWorldType) | |
110 { | |
111 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
112 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); | |
113 if (result != data->templateMap(currentWorldType).end()) | |
114 return result->value.newLocal(isolate); | |
115 | |
116 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | |
117 v8::HandleScope handleScope(isolate); | |
118 v8::Handle<v8::FunctionTemplate> templ = | |
119 Configure{{v8_class_name}}Template(data->rawTemplate(&info, currentWorld
Type), isolate, currentWorldType); | |
120 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::Function
Template>(isolate, templ)); | |
121 return handleScope.Close(templ); | |
122 } | |
123 | |
124 bool {{v8_class_name}}::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* is
olate, WrapperWorldType currentWorldType) | |
125 { | |
126 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor
ldType); | |
127 } | |
128 | |
129 bool {{v8_class_name}}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::I
solate* isolate) | |
130 { | |
131 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) | |
132 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
rld) | |
133 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
d); | |
134 } | |
135 | |
136 v8::Handle<v8::Object> {{v8_class_name}}::createWrapper(PassRefPtr<{{cpp_class_n
ame}}> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
137 { | |
138 ASSERT(impl.get()); | |
139 ASSERT(DOMDataStore::getWrapper<{{v8_class_name}}>(impl.get(), isolate).IsEm
pty()); | |
140 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | |
141 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | |
142 // Might be a XXXConstructor::info instead of an XXX::info. These will b
oth have | |
143 // the same object de-ref functions, though, so use that as the basis of
the check. | |
144 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== info.derefObjectFunction); | |
145 } | |
146 | |
147 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, toInternalPointer(impl.get()), isolate); | |
148 if (UNLIKELY(wrapper.IsEmpty())) | |
149 return wrapper; | |
150 | |
151 installPerContextProperties(wrapper, impl.get(), isolate); | |
152 V8DOMWrapper::associateObjectWithWrapper<{{v8_class_name}}>(impl, &info, wra
pper, isolate, WrapperConfiguration::Independent); | |
153 return wrapper; | |
154 } | |
155 | |
156 void {{v8_class_name}}::derefObject(void* object) | |
157 { | |
158 fromInternalPointer(object)->deref(); | |
159 } | |
160 | |
161 } // namespace WebCore | |
162 | |
163 {% if conditional_string %} | |
164 #endif // {{conditional_string}} | |
165 {% endif %} | |
166 | |
OLD | NEW |