blob: bbbd90f54232b05fd1217bbfc631c7b0e3ec7af7 [file] [log] [blame]
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +01001/*
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#ifndef V8TestObj_h
22#define V8TestObj_h
23
24#include "bindings/bindings/tests/idls/TestObj.h"
25#include "bindings/v8/V8Binding.h"
26#include "bindings/v8/V8DOMWrapper.h"
27#include "bindings/v8/WrapperTypeInfo.h"
Torne (Richard Coles)81a51572013-05-13 16:52:28 +010028#include "wtf/HashMap.h"
29#include "wtf/text/StringHash.h"
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010030#include <v8.h>
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010031
32namespace WebCore {
33
34class V8TestObj {
35public:
36 static const bool hasDependentLifetime = false;
37 static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldType);
38 static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*);
39 static v8::Persistent<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWorldType);
40 static TestObj* toNative(v8::Handle<v8::Object> object)
41 {
42 return reinterpret_cast<TestObj*>(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
43 }
44 static void derefObject(void*);
45 static WrapperTypeInfo info;
46 static v8::Handle<v8::Value> customMethodMethodCustom(const v8::Arguments&);
47 static v8::Handle<v8::Value> customMethodWithArgsMethodCustom(const v8::Arguments&);
48 static v8::Handle<v8::Value> classMethod2MethodCustom(const v8::Arguments&);
49 static v8::Handle<v8::Value> constructorCallback(const v8::Arguments&);
50 static v8::Handle<v8::Value> customAttrAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo&);
51 static void customAttrAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value>, const v8::AccessorInfo&);
Torne (Richard Coles)81a51572013-05-13 16:52:28 +010052 static v8::Handle<v8::Value> indexedPropertyGetter(uint32_t, const v8::AccessorInfo&);
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010053 static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0;
54 static void installPerContextProperties(v8::Handle<v8::Object>, TestObj*, v8::Isolate*);
55 static void installPerContextPrototypeProperties(v8::Handle<v8::Object>, v8::Isolate*);
56private:
57 friend v8::Handle<v8::Object> wrap(TestObj*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
58 static v8::Handle<v8::Object> createWrapper(PassRefPtr<TestObj>, v8::Handle<v8::Object> creationContext, v8::Isolate*);
59};
60
61template<>
62class WrapperTypeTraits<TestObj > {
63public:
64 static WrapperTypeInfo* info() { return &V8TestObj::info; }
65};
66
67
68inline v8::Handle<v8::Object> wrap(TestObj* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
69{
70 ASSERT(impl);
71 ASSERT(DOMDataStore::getWrapper(impl, isolate).IsEmpty());
Torne (Richard Coles)81a51572013-05-13 16:52:28 +010072 if (ScriptWrappable::wrapperCanBeStoredInObject(impl)) {
73 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl);
74 // Might be a XXXConstructor::info instead of an XXX::info. These will both have
75 // the same object de-ref functions, though, so use that as the basis of the check.
76 RELEASE_ASSERT(actualInfo->derefObjectFunction == V8TestObj::info.derefObjectFunction);
77 }
Torne (Richard Coles)53e740f2013-05-09 18:38:43 +010078 return V8TestObj::createWrapper(impl, creationContext, isolate);
79}
80
81inline v8::Handle<v8::Value> toV8(TestObj* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
82{
83 if (UNLIKELY(!impl))
84 return v8NullWithCheck(isolate);
85 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate);
86 if (!wrapper.IsEmpty())
87 return wrapper;
88 return wrap(impl, creationContext, isolate);
89}
90
91inline v8::Handle<v8::Value> toV8ForMainWorld(TestObj* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
92{
93 ASSERT(worldType(isolate) == MainWorld);
94 if (UNLIKELY(!impl))
95 return v8NullWithCheck(isolate);
96 v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapperForMainWorld(impl);
97 if (!wrapper.IsEmpty())
98 return wrapper;
99 return wrap(impl, creationContext, isolate);
100}
101
102template<class HolderContainer, class Wrappable>
103inline v8::Handle<v8::Value> toV8Fast(TestObj* impl, const HolderContainer& container, Wrappable* wrappable)
104{
105 if (UNLIKELY(!impl))
106 return v8Null(container.GetIsolate());
107 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperFast(impl, container, wrappable);
108 if (!wrapper.IsEmpty())
109 return wrapper;
110 return wrap(impl, container.Holder(), container.GetIsolate());
111}
112
113template<class HolderContainer, class Wrappable>
114inline v8::Handle<v8::Value> toV8FastForMainWorld(TestObj* impl, const HolderContainer& container, Wrappable* wrappable)
115{
116 ASSERT(worldType(container.GetIsolate()) == MainWorld);
117 if (UNLIKELY(!impl))
118 return v8Null(container.GetIsolate());
119 v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld(impl);
120 if (!wrapper.IsEmpty())
121 return wrapper;
122 return wrap(impl, container.Holder(), container.GetIsolate());
123}
124
125template<class HolderContainer, class Wrappable>
126inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< TestObj > impl, const HolderContainer& container, Wrappable* wrappable)
127{
128 return toV8FastForMainWorld(impl.get(), container, wrappable);
129}
130
131
132template<class HolderContainer, class Wrappable>
133inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< TestObj > impl, const HolderContainer& container, Wrappable* wrappable)
134{
135 return toV8Fast(impl.get(), container, wrappable);
136}
137
138inline v8::Handle<v8::Value> toV8(PassRefPtr< TestObj > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
139{
140 return toV8(impl.get(), creationContext, isolate);
141}
142
143}
144
145#endif // V8TestObj_h