OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 WebCore::initializeScriptWrappableForInterface(object); | 64 WebCore::initializeScriptWrappableForInterface(object); |
65 } | 65 } |
66 | 66 |
67 namespace WebCore { | 67 namespace WebCore { |
68 const WrapperTypeInfo V8TestInterfaceNamedConstructor::wrapperTypeInfo = { gin::
kEmbedderBlink, V8TestInterfaceNamedConstructor::domTemplate, V8TestInterfaceNam
edConstructor::derefObject, V8TestInterfaceNamedConstructor::toActiveDOMObject,
0, 0, V8TestInterfaceNamedConstructor::installPerContextEnabledMethods, 0, Wrapp
erTypeObjectPrototype, false }; | 68 const WrapperTypeInfo V8TestInterfaceNamedConstructor::wrapperTypeInfo = { gin::
kEmbedderBlink, V8TestInterfaceNamedConstructor::domTemplate, V8TestInterfaceNam
edConstructor::derefObject, V8TestInterfaceNamedConstructor::toActiveDOMObject,
0, 0, V8TestInterfaceNamedConstructor::installPerContextEnabledMethods, 0, Wrapp
erTypeObjectPrototype, false }; |
69 | 69 |
70 namespace TestInterfaceNamedConstructorV8Internal { | 70 namespace TestInterfaceNamedConstructorV8Internal { |
71 | 71 |
72 template <typename T> void V8_USE(T) { } | 72 template <typename T> void V8_USE(T) { } |
73 | 73 |
| 74 static void TestInterfaceNamedConstructorConstructorGetter(v8::Local<v8::String>
, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 75 { |
| 76 v8::Handle<v8::Value> data = info.Data(); |
| 77 ASSERT(data->IsExternal()); |
| 78 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
| 79 if (!perContextData) |
| 80 return; |
| 81 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); |
| 82 } |
| 83 |
| 84 static void TestInterfaceNamedConstructorReplaceableAttributeSetter(v8::Local<v8
::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<voi
d>& info) |
| 85 { |
| 86 info.This()->ForceSet(name, jsValue); |
| 87 } |
| 88 |
| 89 static void TestInterfaceNamedConstructorReplaceableAttributeSetterCallback(v8::
Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallback
Info<void>& info) |
| 90 { |
| 91 TestInterfaceNamedConstructorV8Internal::TestInterfaceNamedConstructorReplac
eableAttributeSetter(name, jsValue, info); |
| 92 } |
| 93 |
74 } // namespace TestInterfaceNamedConstructorV8Internal | 94 } // namespace TestInterfaceNamedConstructorV8Internal |
75 | 95 |
| 96 static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceNamedCons
tructorAttributes[] = { |
| 97 {"testNamedConstructorConstructorAttribute", TestInterfaceNamedConstructorV8
Internal::TestInterfaceNamedConstructorConstructorGetter, TestInterfaceNamedCons
tructorV8Internal::TestInterfaceNamedConstructorReplaceableAttributeSetterCallba
ck, 0, 0, const_cast<WrapperTypeInfo*>(&V8TestNamedConstructor::wrapperTypeInfo)
, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute
>(v8::DontEnum), 0 /* on instance */}, |
| 98 }; |
| 99 |
76 const WrapperTypeInfo V8TestInterfaceNamedConstructorConstructor::wrapperTypeInf
o = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructorConstructor::domTempla
te, V8TestInterfaceNamedConstructor::derefObject, V8TestInterfaceNamedConstructo
r::toActiveDOMObject, 0, 0, V8TestInterfaceNamedConstructor::installPerContextEn
abledMethods, 0, WrapperTypeObjectPrototype, false }; | 100 const WrapperTypeInfo V8TestInterfaceNamedConstructorConstructor::wrapperTypeInf
o = { gin::kEmbedderBlink, V8TestInterfaceNamedConstructorConstructor::domTempla
te, V8TestInterfaceNamedConstructor::derefObject, V8TestInterfaceNamedConstructo
r::toActiveDOMObject, 0, 0, V8TestInterfaceNamedConstructor::installPerContextEn
abledMethods, 0, WrapperTypeObjectPrototype, false }; |
77 | 101 |
78 static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::Functio
nCallbackInfo<v8::Value>& info) | 102 static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::Functio
nCallbackInfo<v8::Value>& info) |
79 { | 103 { |
80 if (!info.IsConstructCall()) { | 104 if (!info.IsConstructCall()) { |
81 throwTypeError(ExceptionMessages::failedToConstruct("Audio", "Please use
the 'new' operator, this DOM object constructor cannot be called as a function.
"), info.GetIsolate()); | 105 throwTypeError(ExceptionMessages::failedToConstruct("Audio", "Please use
the 'new' operator, this DOM object constructor cannot be called as a function.
"), info.GetIsolate()); |
82 return; | 106 return; |
83 } | 107 } |
84 | 108 |
85 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { | 109 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 159 |
136 return scope.Escape(result); | 160 return scope.Escape(result); |
137 } | 161 } |
138 | 162 |
139 static void configureV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::Func
tionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWo
rldType) | 163 static void configureV8TestInterfaceNamedConstructorTemplate(v8::Handle<v8::Func
tionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWo
rldType) |
140 { | 164 { |
141 functionTemplate->ReadOnlyPrototype(); | 165 functionTemplate->ReadOnlyPrototype(); |
142 | 166 |
143 v8::Local<v8::Signature> defaultSignature; | 167 v8::Local<v8::Signature> defaultSignature; |
144 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceNamedConstructor::internalFieldCount, | 168 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceNamedConstructor", v8::Local<v8::FunctionTemplate>(), V8TestI
nterfaceNamedConstructor::internalFieldCount, |
145 0, 0, | 169 V8TestInterfaceNamedConstructorAttributes, WTF_ARRAY_LENGTH(V8TestInterf
aceNamedConstructorAttributes), |
146 0, 0, | 170 0, 0, |
147 0, 0, | 171 0, 0, |
148 isolate, currentWorldType); | 172 isolate, currentWorldType); |
149 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); | 173 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla
te->InstanceTemplate(); |
150 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); | 174 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl
ate->PrototypeTemplate(); |
151 | 175 |
152 // Custom toString template | 176 // Custom toString template |
153 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); | 177 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:current()->toStringTemplate()); |
154 } | 178 } |
155 | 179 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 fromInternalPointer(object)->deref(); | 228 fromInternalPointer(object)->deref(); |
205 } | 229 } |
206 | 230 |
207 template<> | 231 template<> |
208 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) | 232 v8::Handle<v8::Value> toV8NoInline(TestInterfaceNamedConstructor* impl, v8::Hand
le<v8::Object> creationContext, v8::Isolate* isolate) |
209 { | 233 { |
210 return toV8(impl, creationContext, isolate); | 234 return toV8(impl, creationContext, isolate); |
211 } | 235 } |
212 | 236 |
213 } // namespace WebCore | 237 } // namespace WebCore |
OLD | NEW |