OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! | |
32 | |
33 #include "config.h" | |
34 #include "V8TestConstants.h" | |
35 | |
36 #include "RuntimeEnabledFeatures.h" | |
37 #include "bindings/v8/ScriptController.h" | |
38 #include "bindings/v8/V8Binding.h" | |
39 #include "bindings/v8/V8DOMConfiguration.h" | |
40 #include "bindings/v8/V8DOMWrapper.h" | |
41 #include "core/dom/ContextFeatures.h" | |
42 #include "core/dom/Document.h" | |
43 #include "platform/TraceEvent.h" | |
44 #include "wtf/UnusedParam.h" | |
45 | |
46 namespace WebCore { | |
47 | |
48 static void initializeScriptWrappableForInterface(TestConstants* object) | |
49 { | |
50 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | |
51 ScriptWrappable::setTypeInfoInObject(object, &V8TestConstants::wrapperTy
peInfo); | |
52 else | |
53 ASSERT_NOT_REACHED(); | |
54 } | |
55 | |
56 } // namespace WebCore | |
57 | |
58 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: | |
59 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function | |
60 // in the global namespace. | |
61 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) | |
62 void webCoreInitializeScriptWrappableForInterface(WebCore::TestConstants* object
) | |
63 { | |
64 WebCore::initializeScriptWrappableForInterface(object); | |
65 } | |
66 | |
67 namespace WebCore { | |
68 const WrapperTypeInfo V8TestConstants::wrapperTypeInfo = { gin::kEmbedderBlink,
V8TestConstants::GetTemplate, V8TestConstants::derefObject, 0, 0, 0, V8TestConst
ants::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype }; | |
69 | |
70 namespace TestConstantsV8Internal { | |
71 | |
72 template <typename T> void V8_USE(T) { } | |
73 | |
74 } // namespace TestConstantsV8Internal | |
75 | |
76 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestConstantsTemplate(v8::Han
dle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldTy
pe currentWorldType) | |
77 { | |
78 functionTemplate->ReadOnlyPrototype(); | |
79 | |
80 v8::Local<v8::Signature> defaultSignature; | |
81 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestConstants", v8::Local<v8::FunctionTemplate>(), V8TestConstants::intern
alFieldCount, | |
82 0, 0, | |
83 0, 0, | |
84 0, 0, | |
85 isolate, currentWorldType); | |
86 UNUSED_PARAM(defaultSignature); | |
87 v8::Local<v8::ObjectTemplate> instanceTemplate = functionTemplate->InstanceT
emplate(); | |
88 v8::Local<v8::ObjectTemplate> prototypeTemplate = functionTemplate->Prototyp
eTemplate(); | |
89 UNUSED_PARAM(instanceTemplate); | |
90 UNUSED_PARAM(prototypeTemplate); | |
91 static const V8DOMConfiguration::ConstantConfiguration V8TestConstantsConsta
nts[] = { | |
92 {"CONST_VALUE_0", 0}, | |
93 {"CONST_VALUE_1", 1}, | |
94 {"CONST_VALUE_2", 2}, | |
95 {"CONST_VALUE_4", 4}, | |
96 {"CONST_VALUE_8", 8}, | |
97 {"CONST_VALUE_9", -1}, | |
98 {"CONST_VALUE_10", "my constant string"}, | |
99 {"CONST_VALUE_11", 0xffffffff}, | |
100 {"CONST_VALUE_12", 0x01}, | |
101 {"CONST_VALUE_13", 0X20}, | |
102 {"CONST_VALUE_14", 0x1abc}, | |
103 {"CONST_VALUE_15", 010}, | |
104 {"CONST_VALUE_16", -010}, | |
105 {"CONST_VALUE_16", -0x1A}, | |
106 {"CONST_VALUE_17", -0X1a}, | |
107 {"DEPRECATED_CONSTANT", 1}, | |
108 {"CONST_JAVASCRIPT", 1}, | |
109 }; | |
110 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8
TestConstantsConstants, WTF_ARRAY_LENGTH(V8TestConstantsConstants), isolate); | |
111 if (RuntimeEnabledFeatures::featureNameEnabled()) { | |
112 static const V8DOMConfiguration::ConstantConfiguration constantConfigura
tion = {"FEATURE_ENABLED_CONST", static_cast<signed int>(1)}; | |
113 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate
, &constantConfiguration, 1, isolate); | |
114 } | |
115 COMPILE_ASSERT(0 == TestConstants::CONST_VALUE_0, TheValueOfTestConstants_CO
NST_VALUE_0DoesntMatchWithImplementation); | |
116 COMPILE_ASSERT(1 == TestConstants::CONST_VALUE_1, TheValueOfTestConstants_CO
NST_VALUE_1DoesntMatchWithImplementation); | |
117 COMPILE_ASSERT(2 == TestConstants::CONST_VALUE_2, TheValueOfTestConstants_CO
NST_VALUE_2DoesntMatchWithImplementation); | |
118 COMPILE_ASSERT(4 == TestConstants::CONST_VALUE_4, TheValueOfTestConstants_CO
NST_VALUE_4DoesntMatchWithImplementation); | |
119 COMPILE_ASSERT(8 == TestConstants::CONST_VALUE_8, TheValueOfTestConstants_CO
NST_VALUE_8DoesntMatchWithImplementation); | |
120 COMPILE_ASSERT(-1 == TestConstants::CONST_VALUE_9, TheValueOfTestConstants_C
ONST_VALUE_9DoesntMatchWithImplementation); | |
121 COMPILE_ASSERT("my constant string" == TestConstants::CONST_VALUE_10, TheVal
ueOfTestConstants_CONST_VALUE_10DoesntMatchWithImplementation); | |
122 COMPILE_ASSERT(0xffffffff == TestConstants::CONST_VALUE_11, TheValueOfTestCo
nstants_CONST_VALUE_11DoesntMatchWithImplementation); | |
123 COMPILE_ASSERT(0x01 == TestConstants::CONST_VALUE_12, TheValueOfTestConstant
s_CONST_VALUE_12DoesntMatchWithImplementation); | |
124 COMPILE_ASSERT(0X20 == TestConstants::CONST_VALUE_13, TheValueOfTestConstant
s_CONST_VALUE_13DoesntMatchWithImplementation); | |
125 COMPILE_ASSERT(0x1abc == TestConstants::CONST_VALUE_14, TheValueOfTestConsta
nts_CONST_VALUE_14DoesntMatchWithImplementation); | |
126 COMPILE_ASSERT(010 == TestConstants::CONST_VALUE_15, TheValueOfTestConstants
_CONST_VALUE_15DoesntMatchWithImplementation); | |
127 COMPILE_ASSERT(-010 == TestConstants::CONST_VALUE_16, TheValueOfTestConstant
s_CONST_VALUE_16DoesntMatchWithImplementation); | |
128 COMPILE_ASSERT(-0x1A == TestConstants::CONST_VALUE_16, TheValueOfTestConstan
ts_CONST_VALUE_16DoesntMatchWithImplementation); | |
129 COMPILE_ASSERT(-0X1a == TestConstants::CONST_VALUE_17, TheValueOfTestConstan
ts_CONST_VALUE_17DoesntMatchWithImplementation); | |
130 COMPILE_ASSERT(1 == TestConstants::DEPRECATED_CONSTANT, TheValueOfTestConsta
nts_DEPRECATED_CONSTANTDoesntMatchWithImplementation); | |
131 COMPILE_ASSERT(1 == TestConstants::FEATURE_ENABLED_CONST, TheValueOfTestCons
tants_FEATURE_ENABLED_CONSTDoesntMatchWithImplementation); | |
132 COMPILE_ASSERT(1 == TestConstants::CONST_IMPL, TheValueOfTestConstants_CONST
_IMPLDoesntMatchWithImplementation); | |
133 | |
134 // Custom toString template | |
135 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin
g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); | |
136 return functionTemplate; | |
137 } | |
138 | |
139 v8::Handle<v8::FunctionTemplate> V8TestConstants::GetTemplate(v8::Isolate* isola
te, WrapperWorldType currentWorldType) | |
140 { | |
141 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | |
142 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&wrapperTypeInfo); | |
143 if (result != data->templateMap(currentWorldType).end()) | |
144 return result->value.newLocal(isolate); | |
145 | |
146 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); | |
147 v8::EscapableHandleScope handleScope(isolate); | |
148 v8::Local<v8::FunctionTemplate> templ = | |
149 ConfigureV8TestConstantsTemplate(data->rawTemplate(&wrapperTypeInfo, cur
rentWorldType), isolate, currentWorldType); | |
150 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v
8::FunctionTemplate>(isolate, templ)); | |
151 return handleScope.Escape(templ); | |
152 } | |
153 | |
154 bool V8TestConstants::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* is
olate, WrapperWorldType currentWorldType) | |
155 { | |
156 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, currentWorldType); | |
157 } | |
158 | |
159 bool V8TestConstants::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::I
solate* isolate) | |
160 { | |
161 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, MainWorld) | |
162 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, IsolatedWorld) | |
163 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu
e, WorkerWorld); | |
164 } | |
165 | |
166 v8::Handle<v8::Object> V8TestConstants::createWrapper(PassRefPtr<TestConstants>
impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | |
167 { | |
168 ASSERT(impl); | |
169 ASSERT(!DOMDataStore::containsWrapper<V8TestConstants>(impl.get(), isolate))
; | |
170 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { | |
171 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); | |
172 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper
TypeInfo. These will both have | |
173 // the same object de-ref functions, though, so use that as the basis of
the check. | |
174 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== wrapperTypeInfo.derefObjectFunction); | |
175 } | |
176 | |
177 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); | |
178 if (UNLIKELY(wrapper.IsEmpty())) | |
179 return wrapper; | |
180 | |
181 installPerContextEnabledProperties(wrapper, impl.get(), isolate); | |
182 V8DOMWrapper::associateObjectWithWrapper<V8TestConstants>(impl, &wrapperType
Info, wrapper, isolate, WrapperConfiguration::Independent); | |
183 return wrapper; | |
184 } | |
185 | |
186 void V8TestConstants::derefObject(void* object) | |
187 { | |
188 fromInternalPointer(object)->deref(); | |
189 } | |
190 | |
191 template<> | |
192 v8::Handle<v8::Value> toV8NoInline(TestConstants* impl, v8::Handle<v8::Object> c
reationContext, v8::Isolate* isolate) | |
193 { | |
194 return toV8(impl, creationContext, isolate); | |
195 } | |
196 | |
197 } // namespace WebCore | |
OLD | NEW |