Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: Source/bindings/tests/results/V8TestSpecialOperations.cpp

Issue 148083004: IDL compiler: anonymous indexed property getters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! 31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
32 32
33 #include "config.h" 33 #include "config.h"
34 #include "V8TestInterfaceDocument.h" 34 #include "V8TestSpecialOperations.h"
35 35
36 #include "RuntimeEnabledFeatures.h" 36 #include "RuntimeEnabledFeatures.h"
37 #include "bindings/v8/ExceptionState.h" 37 #include "bindings/v8/ExceptionState.h"
38 #include "bindings/v8/ScriptController.h"
39 #include "bindings/v8/V8DOMConfiguration.h" 38 #include "bindings/v8/V8DOMConfiguration.h"
40 #include "bindings/v8/V8ObjectConstructor.h" 39 #include "bindings/v8/V8ObjectConstructor.h"
41 #include "bindings/v8/V8WindowShell.h"
42 #include "core/dom/ContextFeatures.h" 40 #include "core/dom/ContextFeatures.h"
43 #include "core/dom/Document.h" 41 #include "core/dom/Document.h"
44 #include "core/frame/Frame.h"
45 #include "platform/TraceEvent.h" 42 #include "platform/TraceEvent.h"
46 43
47 namespace WebCore { 44 namespace WebCore {
48 45
49 static void initializeScriptWrappableForInterface(TestInterfaceDocument* object) 46 static void initializeScriptWrappableForInterface(TestSpecialOperations* object)
50 { 47 {
51 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 48 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
52 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfaceDocument::w rapperTypeInfo); 49 ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperations::w rapperTypeInfo);
53 else 50 else
54 ASSERT_NOT_REACHED(); 51 ASSERT_NOT_REACHED();
55 } 52 }
56 53
57 } // namespace WebCore 54 } // namespace WebCore
58 55
59 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows: 56 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
60 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function 57 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
61 // in the global namespace. 58 // in the global namespace.
62 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c) 59 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
63 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceDocument * object) 60 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSpecialOperations * object)
64 { 61 {
65 WebCore::initializeScriptWrappableForInterface(object); 62 WebCore::initializeScriptWrappableForInterface(object);
66 } 63 }
67 64
68 namespace WebCore { 65 namespace WebCore {
69 const WrapperTypeInfo V8TestInterfaceDocument::wrapperTypeInfo = { gin::kEmbedde rBlink, V8TestInterfaceDocument::domTemplate, V8TestInterfaceDocument::derefObje ct, 0, V8TestInterfaceDocument::toEventTarget, 0, V8TestInterfaceDocument::insta llPerContextEnabledMethods, &V8Document::wrapperTypeInfo, WrapperTypeObjectProto type }; 66 const WrapperTypeInfo V8TestSpecialOperations::wrapperTypeInfo = { gin::kEmbedde rBlink, V8TestSpecialOperations::domTemplate, V8TestSpecialOperations::derefObje ct, 0, 0, 0, V8TestSpecialOperations::installPerContextEnabledMethods, 0, Wrappe rTypeObjectPrototype };
70 67
71 namespace TestInterfaceDocumentV8Internal { 68 namespace TestSpecialOperationsV8Internal {
72 69
73 template <typename T> void V8_USE(T) { } 70 template <typename T> void V8_USE(T) { }
74 71
75 } // namespace TestInterfaceDocumentV8Internal 72 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info)
73 {
74 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
75 TestSpecialOperations* collection = V8TestSpecialOperations::toNative(info.H older());
76 String element = collection->anonymousIndexedGetter(index);
77 if (element.isNull())
78 return;
79 v8SetReturnValueString(info, element, info.GetIsolate());
80 }
76 81
77 static void configureV8TestInterfaceDocumentTemplate(v8::Handle<v8::FunctionTemp late> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) 82 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall backInfo<v8::Value>& info)
83 {
84 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
85 TestSpecialOperationsV8Internal::indexedPropertyGetter(index, info);
86 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
87 }
88
89 } // namespace TestSpecialOperationsV8Internal
90
91 static void configureV8TestSpecialOperationsTemplate(v8::Handle<v8::FunctionTemp late> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
78 { 92 {
79 functionTemplate->ReadOnlyPrototype(); 93 functionTemplate->ReadOnlyPrototype();
80 94
81 v8::Local<v8::Signature> defaultSignature; 95 v8::Local<v8::Signature> defaultSignature;
82 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfaceDocument", V8Document::domTemplate(isolate, currentWorldType) , V8TestInterfaceDocument::internalFieldCount, 96 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestSpecialOperations", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOp erations::internalFieldCount,
83 0, 0, 97 0, 0,
84 0, 0, 98 0, 0,
85 0, 0, 99 0, 0,
86 isolate, currentWorldType); 100 isolate, currentWorldType);
87 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate(); 101 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate();
88 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate(); 102 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate();
103 functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestSpecialO perationsV8Internal::indexedPropertyGetterCallback, 0, 0, 0, indexedPropertyEnum erator<TestSpecialOperations>);
89 104
90 // Custom toString template 105 // Custom toString template
91 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :current()->toStringTemplate()); 106 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :current()->toStringTemplate());
92 } 107 }
93 108
94 v8::Handle<v8::FunctionTemplate> V8TestInterfaceDocument::domTemplate(v8::Isolat e* isolate, WrapperWorldType currentWorldType) 109 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperations::domTemplate(v8::Isolat e* isolate, WrapperWorldType currentWorldType)
95 { 110 {
96 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 111 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
97 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo); 112 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
98 if (result != data->templateMap(currentWorldType).end()) 113 if (result != data->templateMap(currentWorldType).end())
99 return result->value.newLocal(isolate); 114 return result->value.newLocal(isolate);
100 115
101 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 116 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
102 v8::EscapableHandleScope handleScope(isolate); 117 v8::EscapableHandleScope handleScope(isolate);
103 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V 8ObjectConstructor::isValidConstructorMode); 118 v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V 8ObjectConstructor::isValidConstructorMode);
104 configureV8TestInterfaceDocumentTemplate(templ, isolate, currentWorldType); 119 configureV8TestSpecialOperationsTemplate(templ, isolate, currentWorldType);
105 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 120 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
106 return handleScope.Escape(templ); 121 return handleScope.Escape(templ);
107 } 122 }
108 123
109 bool V8TestInterfaceDocument::hasInstance(v8::Handle<v8::Value> jsValue, v8::Iso late* isolate) 124 bool V8TestSpecialOperations::hasInstance(v8::Handle<v8::Value> jsValue, v8::Iso late* isolate)
110 { 125 {
111 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue) 126 return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeI nfo, jsValue)
112 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue); 127 || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTy peInfo, jsValue);
113 } 128 }
114 129
115 EventTarget* V8TestInterfaceDocument::toEventTarget(v8::Handle<v8::Object> objec t) 130 v8::Handle<v8::Object> V8TestSpecialOperations::createWrapper(PassRefPtr<TestSpe cialOperations> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isola te)
116 {
117 return toNative(object);
118 }
119
120 v8::Handle<v8::Object> wrap(TestInterfaceDocument* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
121 { 131 {
122 ASSERT(impl); 132 ASSERT(impl);
123 v8::Handle<v8::Object> wrapper = V8TestInterfaceDocument::createWrapper(impl , creationContext, isolate); 133 ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperations>(impl.get(), i solate));
124 if (wrapper.IsEmpty())
125 return wrapper;
126 if (!isolatedWorldForEnteredContext(isolate)) {
127 if (Frame* frame = impl->frame())
128 frame->script().windowShell(mainThreadNormalWorld())->updateDocument Wrapper(wrapper);
129 }
130 return wrapper;
131 }
132
133 v8::Handle<v8::Object> V8TestInterfaceDocument::createWrapper(PassRefPtr<TestInt erfaceDocument> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isola te)
134 {
135 ASSERT(impl);
136 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceDocument>(impl.get(), i solate));
137 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 134 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
138 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 135 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
139 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 136 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
140 // the same object de-ref functions, though, so use that as the basis of the check. 137 // the same object de-ref functions, though, so use that as the basis of the check.
141 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 138 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
142 } 139 }
143 140
144 if (Frame* frame = impl->frame()) {
145 if (frame->script().initializeMainWorld()) {
146 // initializeMainWorld may have created a wrapper for the object, re try from the start.
147 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapper<V8TestInte rfaceDocument>(impl.get(), isolate);
148 if (!wrapper.IsEmpty())
149 return wrapper;
150 }
151 }
152 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 141 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
153 if (UNLIKELY(wrapper.IsEmpty())) 142 if (UNLIKELY(wrapper.IsEmpty()))
154 return wrapper; 143 return wrapper;
155 144
156 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 145 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
157 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceDocument>(impl, &wra pperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent); 146 V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperations>(impl, &wra pperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
158 return wrapper; 147 return wrapper;
159 } 148 }
160 149
161 void V8TestInterfaceDocument::derefObject(void* object) 150 void V8TestSpecialOperations::derefObject(void* object)
162 { 151 {
163 fromInternalPointer(object)->deref(); 152 fromInternalPointer(object)->deref();
164 } 153 }
165 154
166 template<> 155 template<>
167 v8::Handle<v8::Value> toV8NoInline(TestInterfaceDocument* impl, v8::Handle<v8::O bject> creationContext, v8::Isolate* isolate) 156 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperations* impl, v8::Handle<v8::O bject> creationContext, v8::Isolate* isolate)
168 { 157 {
169 return toV8(impl, creationContext, isolate); 158 return toV8(impl, creationContext, isolate);
170 } 159 }
171 160
172 } // namespace WebCore 161 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698