Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestSpecialOperationsNotEnumerable.cpp
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 "V8TestSpecialOperationsNotEnumerable.h"
35
36 #include "RuntimeEnabledFeatures.h"
37 #include "bindings/v8/ExceptionState.h"
38 #include "bindings/v8/V8DOMConfiguration.h"
39 #include "bindings/v8/V8ObjectConstructor.h"
40 #include "core/dom/ContextFeatures.h"
41 #include "core/dom/Document.h"
42 #include "platform/TraceEvent.h"
43 #include "wtf/GetPtr.h"
44 #include "wtf/RefPtr.h"
45
46 namespace WebCore {
47
48 static void initializeScriptWrappableForInterface(TestSpecialOperationsNotEnumerable* object)
49 {
50     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
51         ScriptWrappable::setTypeInfoInObject(object, &V8TestSpecialOperationsNotEnumerable::wrapperTypeInfo);
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 issue 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/feedback/details/664619/the-namespace-of-local-function-declarations-in-c)
62 void webCoreInitializeScriptWrappableForInterface(WebCore::TestSpecialOperationsNotEnumerable* object)
63 {
64     WebCore::initializeScriptWrappableForInterface(object);
65 }
66
67 namespace WebCore {
68 const WrapperTypeInfo V8TestSpecialOperationsNotEnumerable::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestSpecialOperationsNotEnumerable::domTemplate, V8TestSpecialOperationsNotEnumerable::derefObject, 0, 0, 0, V8TestSpecialOperationsNotEnumerable::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false };
69
70 namespace TestSpecialOperationsNotEnumerableV8Internal {
71
72 template <typename T> void V8_USE(T) { }
73
74 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
75 {
76     TestSpecialOperationsNotEnumerable* imp = V8TestSpecialOperationsNotEnumerable::toNative(info.Holder());
77     String result = imp->anonymousIndexedGetter(index);
78     if (result.isNull())
79         return;
80     v8SetReturnValueString(info, result, info.GetIsolate());
81 }
82
83 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
84 {
85     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty");
86     TestSpecialOperationsNotEnumerableV8Internal::indexedPropertyGetter(index, info);
87     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
88 }
89
90 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
91 {
92     if (info.Holder()->HasRealNamedProperty(name))
93         return;
94     if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
95         return;
96
97     TestSpecialOperationsNotEnumerable* imp = V8TestSpecialOperationsNotEnumerable::toNative(info.Holder());
98     AtomicString propertyName = toCoreAtomicString(name);
99     String result = imp->anonymousNamedGetter(propertyName);
100     if (result.isNull())
101         return;
102     v8SetReturnValueString(info, result, info.GetIsolate());
103 }
104
105 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
106 {
107     TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty");
108     TestSpecialOperationsNotEnumerableV8Internal::namedPropertyGetter(name, info);
109     TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution");
110 }
111
112 } // namespace TestSpecialOperationsNotEnumerableV8Internal
113
114 static void configureV8TestSpecialOperationsNotEnumerableTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType)
115 {
116     functionTemplate->ReadOnlyPrototype();
117
118     v8::Local<v8::Signature> defaultSignature;
119     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestSpecialOperationsNotEnumerable", v8::Local<v8::FunctionTemplate>(), V8TestSpecialOperationsNotEnumerable::internalFieldCount,
120         0, 0,
121         0, 0,
122         0, 0,
123         isolate, currentWorldType);
124     v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate();
125     v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate();
126     functionTemplate->InstanceTemplate()->SetIndexedPropertyHandler(TestSpecialOperationsNotEnumerableV8Internal::indexedPropertyGetterCallback, 0, 0, 0, 0);
127     functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestSpecialOperationsNotEnumerableV8Internal::namedPropertyGetterCallback, 0, 0, 0, 0);
128
129     // Custom toString template
130     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::current()->toStringTemplate());
131 }
132
133 v8::Handle<v8::FunctionTemplate> V8TestSpecialOperationsNotEnumerable::domTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType)
134 {
135     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
136     V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&wrapperTypeInfo);
137     if (result != data->templateMap(currentWorldType).end())
138         return result->value.newLocal(isolate);
139
140     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
141     v8::EscapableHandleScope handleScope(isolate);
142     v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
143     configureV8TestSpecialOperationsNotEnumerableTemplate(templ, isolate, currentWorldType);
144     data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTemplate>(isolate, templ));
145     return handleScope.Escape(templ);
146 }
147
148 bool V8TestSpecialOperationsNotEnumerable::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate)
149 {
150     return V8PerIsolateData::from(isolate)->hasInstanceInMainWorld(&wrapperTypeInfo, jsValue)
151         || V8PerIsolateData::from(isolate)->hasInstanceInNonMainWorld(&wrapperTypeInfo, jsValue);
152 }
153
154 v8::Handle<v8::Object> V8TestSpecialOperationsNotEnumerable::createWrapper(PassRefPtr<TestSpecialOperationsNotEnumerable> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
155 {
156     ASSERT(impl);
157     ASSERT(!DOMDataStore::containsWrapper<V8TestSpecialOperationsNotEnumerable>(impl.get(), isolate));
158     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
159         const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get());
160         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
161         // the same object de-ref functions, though, so use that as the basis of the check.
162         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
163     }
164
165     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
166     if (UNLIKELY(wrapper.IsEmpty()))
167         return wrapper;
168
169     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
170     V8DOMWrapper::associateObjectWithWrapper<V8TestSpecialOperationsNotEnumerable>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
171     return wrapper;
172 }
173
174 void V8TestSpecialOperationsNotEnumerable::derefObject(void* object)
175 {
176     fromInternalPointer(object)->deref();
177 }
178
179 template<>
180 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsNotEnumerable* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
181 {
182     return toV8(impl, creationContext, isolate);
183 }
184
185 } // namespace WebCore