| 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 #include "V8TestObjectPython.h" |
| 23 |
| 24 #include "RuntimeEnabledFeatures.h" |
| 25 #include "bindings/v8/ScriptController.h" |
| 26 #include "bindings/v8/V8Binding.h" |
| 27 #include "bindings/v8/V8DOMConfiguration.h" |
| 28 #include "bindings/v8/V8DOMWrapper.h" |
| 29 #include "core/dom/ContextFeatures.h" |
| 30 #include "core/dom/Document.h" |
| 31 #include "core/platform/chromium/TraceEvent.h" |
| 32 #include "wtf/UnusedParam.h" |
| 33 |
| 34 namespace WebCore { |
| 35 |
| 36 static void initializeScriptWrappableForInterface(TestObjectPython* object) |
| 37 { |
| 38 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
| 39 ScriptWrappable::setTypeInfoInObject(object, &V8TestObjectPython::info); |
| 40 else |
| 41 ASSERT_NOT_REACHED(); |
| 42 } |
| 43 |
| 44 } // namespace WebCore |
| 45 |
| 46 // In ScriptWrappable::init, the use of a local function declaration has an issu
e on Windows: |
| 47 // the local declaration does not pick up the surrounding namespace. Therefore,
we provide this function |
| 48 // in the global namespace. |
| 49 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe
edback/details/664619/the-namespace-of-local-function-declarations-in-c) |
| 50 void webCoreInitializeScriptWrappableForInterface(WebCore::TestObjectPython* obj
ect) |
| 51 { |
| 52 WebCore::initializeScriptWrappableForInterface(object); |
| 53 } |
| 54 |
| 55 namespace WebCore { |
| 56 WrapperTypeInfo V8TestObjectPython::info = { V8TestObjectPython::GetTemplate, V8
TestObjectPython::derefObject, 0, 0, 0, V8TestObjectPython::installPerContextPro
totypeProperties, 0, WrapperTypeObjectPrototype }; |
| 57 |
| 58 namespace TestObjectPythonV8Internal { |
| 59 |
| 60 template <typename T> void V8_USE(T) { } |
| 61 |
| 62 static void readOnlyDateAttributeAttributeGetter(v8::Local<v8::String> name, con
st v8::PropertyCallbackInfo<v8::Value>& info) |
| 63 { |
| 64 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 65 v8SetReturnValue(info, v8DateOrNull(imp->readOnlyDateAttribute(), info.GetIs
olate())); |
| 66 return; |
| 67 } |
| 68 |
| 69 static void readOnlyDateAttributeAttributeGetterCallback(v8::Local<v8::String> n
ame, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 70 { |
| 71 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 72 TestObjectPythonV8Internal::readOnlyDateAttributeAttributeGetter(name, info)
; |
| 73 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 74 } |
| 75 |
| 76 static void readOnlyBooleanAttributeAttributeGetter(v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) |
| 77 { |
| 78 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 79 v8SetReturnValueBool(info, imp->readOnlyBooleanAttribute()); |
| 80 return; |
| 81 } |
| 82 |
| 83 static void readOnlyBooleanAttributeAttributeGetterCallback(v8::Local<v8::String
> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 84 { |
| 85 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 86 TestObjectPythonV8Internal::readOnlyBooleanAttributeAttributeGetter(name, in
fo); |
| 87 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 88 } |
| 89 |
| 90 static void readOnlyByteAttributeAttributeGetter(v8::Local<v8::String> name, con
st v8::PropertyCallbackInfo<v8::Value>& info) |
| 91 { |
| 92 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 93 v8SetReturnValueInt(info, imp->readOnlyByteAttribute()); |
| 94 return; |
| 95 } |
| 96 |
| 97 static void readOnlyByteAttributeAttributeGetterCallback(v8::Local<v8::String> n
ame, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 98 { |
| 99 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 100 TestObjectPythonV8Internal::readOnlyByteAttributeAttributeGetter(name, info)
; |
| 101 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 102 } |
| 103 |
| 104 static void readOnlyDoubleAttributeAttributeGetter(v8::Local<v8::String> name, c
onst v8::PropertyCallbackInfo<v8::Value>& info) |
| 105 { |
| 106 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 107 v8SetReturnValue(info, imp->readOnlyDoubleAttribute()); |
| 108 return; |
| 109 } |
| 110 |
| 111 static void readOnlyDoubleAttributeAttributeGetterCallback(v8::Local<v8::String>
name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 112 { |
| 113 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 114 TestObjectPythonV8Internal::readOnlyDoubleAttributeAttributeGetter(name, inf
o); |
| 115 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 116 } |
| 117 |
| 118 static void readOnlyFloatAttributeAttributeGetter(v8::Local<v8::String> name, co
nst v8::PropertyCallbackInfo<v8::Value>& info) |
| 119 { |
| 120 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 121 v8SetReturnValue(info, imp->readOnlyFloatAttribute()); |
| 122 return; |
| 123 } |
| 124 |
| 125 static void readOnlyFloatAttributeAttributeGetterCallback(v8::Local<v8::String>
name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 126 { |
| 127 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 128 TestObjectPythonV8Internal::readOnlyFloatAttributeAttributeGetter(name, info
); |
| 129 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 130 } |
| 131 |
| 132 static void readOnlyLongAttributeAttributeGetter(v8::Local<v8::String> name, con
st v8::PropertyCallbackInfo<v8::Value>& info) |
| 133 { |
| 134 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 135 v8SetReturnValueInt(info, imp->readOnlyLongAttribute()); |
| 136 return; |
| 137 } |
| 138 |
| 139 static void readOnlyLongAttributeAttributeGetterCallback(v8::Local<v8::String> n
ame, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 140 { |
| 141 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 142 TestObjectPythonV8Internal::readOnlyLongAttributeAttributeGetter(name, info)
; |
| 143 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 144 } |
| 145 |
| 146 static void readOnlyLongLongAttributeAttributeGetter(v8::Local<v8::String> name,
const v8::PropertyCallbackInfo<v8::Value>& info) |
| 147 { |
| 148 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 149 v8SetReturnValue(info, static_cast<double>(imp->readOnlyLongLongAttribute())
); |
| 150 return; |
| 151 } |
| 152 |
| 153 static void readOnlyLongLongAttributeAttributeGetterCallback(v8::Local<v8::Strin
g> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 154 { |
| 155 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 156 TestObjectPythonV8Internal::readOnlyLongLongAttributeAttributeGetter(name, i
nfo); |
| 157 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 158 } |
| 159 |
| 160 static void readOnlyOctetAttributeAttributeGetter(v8::Local<v8::String> name, co
nst v8::PropertyCallbackInfo<v8::Value>& info) |
| 161 { |
| 162 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 163 v8SetReturnValueUnsigned(info, imp->readOnlyOctetAttribute()); |
| 164 return; |
| 165 } |
| 166 |
| 167 static void readOnlyOctetAttributeAttributeGetterCallback(v8::Local<v8::String>
name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 168 { |
| 169 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 170 TestObjectPythonV8Internal::readOnlyOctetAttributeAttributeGetter(name, info
); |
| 171 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 172 } |
| 173 |
| 174 static void readOnlyShortAttributeAttributeGetter(v8::Local<v8::String> name, co
nst v8::PropertyCallbackInfo<v8::Value>& info) |
| 175 { |
| 176 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 177 v8SetReturnValueInt(info, imp->readOnlyShortAttribute()); |
| 178 return; |
| 179 } |
| 180 |
| 181 static void readOnlyShortAttributeAttributeGetterCallback(v8::Local<v8::String>
name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 182 { |
| 183 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 184 TestObjectPythonV8Internal::readOnlyShortAttributeAttributeGetter(name, info
); |
| 185 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 186 } |
| 187 |
| 188 static void readOnlyUnsignedLongAttributeAttributeGetter(v8::Local<v8::String> n
ame, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 189 { |
| 190 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 191 v8SetReturnValueUnsigned(info, imp->readOnlyUnsignedLongAttribute()); |
| 192 return; |
| 193 } |
| 194 |
| 195 static void readOnlyUnsignedLongAttributeAttributeGetterCallback(v8::Local<v8::S
tring> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 196 { |
| 197 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 198 TestObjectPythonV8Internal::readOnlyUnsignedLongAttributeAttributeGetter(nam
e, info); |
| 199 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 200 } |
| 201 |
| 202 static void readOnlyUnsignedLongLongAttributeAttributeGetter(v8::Local<v8::Strin
g> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 203 { |
| 204 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 205 v8SetReturnValue(info, static_cast<double>(imp->readOnlyUnsignedLongLongAttr
ibute())); |
| 206 return; |
| 207 } |
| 208 |
| 209 static void readOnlyUnsignedLongLongAttributeAttributeGetterCallback(v8::Local<v
8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 210 { |
| 211 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 212 TestObjectPythonV8Internal::readOnlyUnsignedLongLongAttributeAttributeGetter
(name, info); |
| 213 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 214 } |
| 215 |
| 216 static void readOnlyUnsignedShortAttributeAttributeGetter(v8::Local<v8::String>
name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 217 { |
| 218 TestObjectPython* imp = V8TestObjectPython::toNative(info.Holder()); |
| 219 v8SetReturnValueUnsigned(info, imp->readOnlyUnsignedShortAttribute()); |
| 220 return; |
| 221 } |
| 222 |
| 223 static void readOnlyUnsignedShortAttributeAttributeGetterCallback(v8::Local<v8::
String> name, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 224 { |
| 225 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 226 TestObjectPythonV8Internal::readOnlyUnsignedShortAttributeAttributeGetter(na
me, info); |
| 227 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 228 } |
| 229 |
| 230 } // namespace TestObjectPythonV8Internal |
| 231 |
| 232 static const V8DOMConfiguration::AttributeConfiguration V8TestObjectPythonAttrib
utes[] = { |
| 233 {"readOnlyDateAttribute", TestObjectPythonV8Internal::readOnlyDateAttributeA
ttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT),
static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 234 {"readOnlyBooleanAttribute", TestObjectPythonV8Internal::readOnlyBooleanAttr
ibuteAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEF
AULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 235 {"readOnlyByteAttribute", TestObjectPythonV8Internal::readOnlyByteAttributeA
ttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT),
static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 236 {"readOnlyDoubleAttribute", TestObjectPythonV8Internal::readOnlyDoubleAttrib
uteAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAU
LT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 237 {"readOnlyFloatAttribute", TestObjectPythonV8Internal::readOnlyFloatAttribut
eAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT
), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 238 {"readOnlyLongAttribute", TestObjectPythonV8Internal::readOnlyLongAttributeA
ttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT),
static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 239 {"readOnlyLongLongAttribute", TestObjectPythonV8Internal::readOnlyLongLongAt
tributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::D
EFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 240 {"readOnlyOctetAttribute", TestObjectPythonV8Internal::readOnlyOctetAttribut
eAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT
), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 241 {"readOnlyShortAttribute", TestObjectPythonV8Internal::readOnlyShortAttribut
eAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT
), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, |
| 242 {"readOnlyUnsignedLongAttribute", TestObjectPythonV8Internal::readOnlyUnsign
edLongAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessContro
l>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance
*/}, |
| 243 {"readOnlyUnsignedLongLongAttribute", TestObjectPythonV8Internal::readOnlyUn
signedLongLongAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::Acce
ssControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on i
nstance */}, |
| 244 {"readOnlyUnsignedShortAttribute", TestObjectPythonV8Internal::readOnlyUnsig
nedShortAttributeAttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessCont
rol>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instanc
e */}, |
| 245 }; |
| 246 |
| 247 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestObjectPythonTemplate(v8::
Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType curren
tWorldType) |
| 248 { |
| 249 desc->ReadOnlyPrototype(); |
| 250 |
| 251 v8::Local<v8::Signature> defaultSignature; |
| 252 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, "TestOb
jectPython", v8::Local<v8::FunctionTemplate>(), V8TestObjectPython::internalFiel
dCount, |
| 253 V8TestObjectPythonAttributes, WTF_ARRAY_LENGTH(V8TestObjectPythonAttribu
tes), |
| 254 0, 0, isolate, currentWorldType); |
| 255 UNUSED_PARAM(defaultSignature); |
| 256 |
| 257 // Custom toString template |
| 258 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to
StringTemplate()); |
| 259 return desc; |
| 260 } |
| 261 |
| 262 v8::Handle<v8::FunctionTemplate> V8TestObjectPython::GetTemplate(v8::Isolate* is
olate, WrapperWorldType currentWorldType) |
| 263 { |
| 264 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 265 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo
rldType).find(&info); |
| 266 if (result != data->templateMap(currentWorldType).end()) |
| 267 return result->value.newLocal(isolate); |
| 268 |
| 269 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); |
| 270 v8::HandleScope handleScope(isolate); |
| 271 v8::Handle<v8::FunctionTemplate> templ = |
| 272 ConfigureV8TestObjectPythonTemplate(data->rawTemplate(&info, currentWorl
dType), isolate, currentWorldType); |
| 273 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::Function
Template>(isolate, templ)); |
| 274 return handleScope.Close(templ); |
| 275 } |
| 276 |
| 277 bool V8TestObjectPython::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* i
solate, WrapperWorldType currentWorldType) |
| 278 { |
| 279 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWor
ldType); |
| 280 } |
| 281 |
| 282 bool V8TestObjectPython::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::
Isolate* isolate) |
| 283 { |
| 284 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) |
| 285 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWo
rld) |
| 286 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorl
d); |
| 287 } |
| 288 |
| 289 v8::Handle<v8::Object> V8TestObjectPython::createWrapper(PassRefPtr<TestObjectPy
thon> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
| 290 { |
| 291 ASSERT(impl.get()); |
| 292 ASSERT(!DOMDataStore::containsWrapper<V8TestObjectPython>(impl.get(), isolat
e)); |
| 293 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { |
| 294 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje
ct(impl.get()); |
| 295 // Might be a XXXConstructor::info instead of an XXX::info. These will b
oth have |
| 296 // the same object de-ref functions, though, so use that as the basis of
the check. |
| 297 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction
== info.derefObjectFunction); |
| 298 } |
| 299 |
| 300 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext
, &info, toInternalPointer(impl.get()), isolate); |
| 301 if (UNLIKELY(wrapper.IsEmpty())) |
| 302 return wrapper; |
| 303 |
| 304 installPerContextProperties(wrapper, impl.get(), isolate); |
| 305 V8DOMWrapper::associateObjectWithWrapper<V8TestObjectPython>(impl, &info, wr
apper, isolate, WrapperConfiguration::Independent); |
| 306 return wrapper; |
| 307 } |
| 308 |
| 309 void V8TestObjectPython::derefObject(void* object) |
| 310 { |
| 311 fromInternalPointer(object)->deref(); |
| 312 } |
| 313 |
| 314 } // namespace WebCore |
| OLD | NEW |