~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of the WebKit open source project.
 
3
    This file has been generated by generate-bindings.pl. 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., 51 Franklin Street, Fifth Floor,
 
18
    Boston, MA 02110-1301, USA.
 
19
*/
 
20
 
 
21
#include "config.h"
 
22
#include "JSTestCustomNamedGetter.h"
 
23
 
 
24
#include "ExceptionCode.h"
 
25
#include "JSDOMBinding.h"
 
26
#include "TestCustomNamedGetter.h"
 
27
#include "wtf/text/AtomicString.h"
 
28
#include <runtime/Error.h>
 
29
#include <wtf/GetPtr.h>
 
30
 
 
31
using namespace JSC;
 
32
 
 
33
namespace WebCore {
 
34
 
 
35
/* Hash table */
 
36
 
 
37
static const HashTableValue JSTestCustomNamedGetterTableValues[] =
 
38
{
 
39
    { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestCustomNamedGetterConstructor), (intptr_t)0, NoIntrinsic },
 
40
    { 0, 0, 0, 0, NoIntrinsic }
 
41
};
 
42
 
 
43
static const HashTable JSTestCustomNamedGetterTable = { 2, 1, JSTestCustomNamedGetterTableValues, 0 };
 
44
/* Hash table for constructor */
 
45
 
 
46
static const HashTableValue JSTestCustomNamedGetterConstructorTableValues[] =
 
47
{
 
48
    { 0, 0, 0, 0, NoIntrinsic }
 
49
};
 
50
 
 
51
static const HashTable JSTestCustomNamedGetterConstructorTable = { 1, 0, JSTestCustomNamedGetterConstructorTableValues, 0 };
 
52
const ClassInfo JSTestCustomNamedGetterConstructor::s_info = { "TestCustomNamedGetterConstructor", &Base::s_info, &JSTestCustomNamedGetterConstructorTable, 0, CREATE_METHOD_TABLE(JSTestCustomNamedGetterConstructor) };
 
53
 
 
54
JSTestCustomNamedGetterConstructor::JSTestCustomNamedGetterConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
 
55
    : DOMConstructorObject(structure, globalObject)
 
56
{
 
57
}
 
58
 
 
59
void JSTestCustomNamedGetterConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
 
60
{
 
61
    Base::finishCreation(exec->globalData());
 
62
    ASSERT(inherits(&s_info));
 
63
    putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestCustomNamedGetterPrototype::self(exec, globalObject), DontDelete | ReadOnly);
 
64
}
 
65
 
 
66
bool JSTestCustomNamedGetterConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 
67
{
 
68
    return getStaticValueSlot<JSTestCustomNamedGetterConstructor, JSDOMWrapper>(exec, &JSTestCustomNamedGetterConstructorTable, jsCast<JSTestCustomNamedGetterConstructor*>(cell), propertyName, slot);
 
69
}
 
70
 
 
71
bool JSTestCustomNamedGetterConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
 
72
{
 
73
    return getStaticValueDescriptor<JSTestCustomNamedGetterConstructor, JSDOMWrapper>(exec, &JSTestCustomNamedGetterConstructorTable, jsCast<JSTestCustomNamedGetterConstructor*>(object), propertyName, descriptor);
 
74
}
 
75
 
 
76
/* Hash table for prototype */
 
77
 
 
78
static const HashTableValue JSTestCustomNamedGetterPrototypeTableValues[] =
 
79
{
 
80
    { "anotherFunction", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestCustomNamedGetterPrototypeFunctionAnotherFunction), (intptr_t)1, NoIntrinsic },
 
81
    { 0, 0, 0, 0, NoIntrinsic }
 
82
};
 
83
 
 
84
static const HashTable JSTestCustomNamedGetterPrototypeTable = { 2, 1, JSTestCustomNamedGetterPrototypeTableValues, 0 };
 
85
const ClassInfo JSTestCustomNamedGetterPrototype::s_info = { "TestCustomNamedGetterPrototype", &Base::s_info, &JSTestCustomNamedGetterPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestCustomNamedGetterPrototype) };
 
86
 
 
87
JSObject* JSTestCustomNamedGetterPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
 
88
{
 
89
    return getDOMPrototype<JSTestCustomNamedGetter>(exec, globalObject);
 
90
}
 
91
 
 
92
bool JSTestCustomNamedGetterPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 
93
{
 
94
    JSTestCustomNamedGetterPrototype* thisObject = jsCast<JSTestCustomNamedGetterPrototype*>(cell);
 
95
    return getStaticFunctionSlot<JSObject>(exec, &JSTestCustomNamedGetterPrototypeTable, thisObject, propertyName, slot);
 
96
}
 
97
 
 
98
bool JSTestCustomNamedGetterPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
 
99
{
 
100
    JSTestCustomNamedGetterPrototype* thisObject = jsCast<JSTestCustomNamedGetterPrototype*>(object);
 
101
    return getStaticFunctionDescriptor<JSObject>(exec, &JSTestCustomNamedGetterPrototypeTable, thisObject, propertyName, descriptor);
 
102
}
 
103
 
 
104
const ClassInfo JSTestCustomNamedGetter::s_info = { "TestCustomNamedGetter", &Base::s_info, &JSTestCustomNamedGetterTable, 0 , CREATE_METHOD_TABLE(JSTestCustomNamedGetter) };
 
105
 
 
106
JSTestCustomNamedGetter::JSTestCustomNamedGetter(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestCustomNamedGetter> impl)
 
107
    : JSDOMWrapper(structure, globalObject)
 
108
    , m_impl(impl.leakRef())
 
109
{
 
110
}
 
111
 
 
112
void JSTestCustomNamedGetter::finishCreation(JSGlobalData& globalData)
 
113
{
 
114
    Base::finishCreation(globalData);
 
115
    ASSERT(inherits(&s_info));
 
116
}
 
117
 
 
118
JSObject* JSTestCustomNamedGetter::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
 
119
{
 
120
    return JSTestCustomNamedGetterPrototype::create(exec->globalData(), globalObject, JSTestCustomNamedGetterPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
 
121
}
 
122
 
 
123
void JSTestCustomNamedGetter::destroy(JSC::JSCell* cell)
 
124
{
 
125
    JSTestCustomNamedGetter* thisObject = static_cast<JSTestCustomNamedGetter*>(cell);
 
126
    thisObject->JSTestCustomNamedGetter::~JSTestCustomNamedGetter();
 
127
}
 
128
 
 
129
JSTestCustomNamedGetter::~JSTestCustomNamedGetter()
 
130
{
 
131
    releaseImplIfNotNull();
 
132
}
 
133
 
 
134
bool JSTestCustomNamedGetter::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
 
135
{
 
136
    JSTestCustomNamedGetter* thisObject = jsCast<JSTestCustomNamedGetter*>(cell);
 
137
    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
 
138
    if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) {
 
139
        slot.setCustom(thisObject, thisObject->nameGetter);
 
140
        return true;
 
141
    }
 
142
    return getStaticValueSlot<JSTestCustomNamedGetter, Base>(exec, &JSTestCustomNamedGetterTable, thisObject, propertyName, slot);
 
143
}
 
144
 
 
145
bool JSTestCustomNamedGetter::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
 
146
{
 
147
    JSTestCustomNamedGetter* thisObject = jsCast<JSTestCustomNamedGetter*>(object);
 
148
    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
 
149
    if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) {
 
150
        PropertySlot slot;
 
151
        slot.setCustom(thisObject, nameGetter);
 
152
        descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
 
153
        return true;
 
154
    }
 
155
    return getStaticValueDescriptor<JSTestCustomNamedGetter, Base>(exec, &JSTestCustomNamedGetterTable, thisObject, propertyName, descriptor);
 
156
}
 
157
 
 
158
bool JSTestCustomNamedGetter::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned index, PropertySlot& slot)
 
159
{
 
160
    JSTestCustomNamedGetter* thisObject = jsCast<JSTestCustomNamedGetter*>(cell);
 
161
    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
 
162
    PropertyName propertyName = Identifier::from(exec, index);
 
163
    if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) {
 
164
        slot.setCustom(thisObject, thisObject->nameGetter);
 
165
        return true;
 
166
    }
 
167
    return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot);
 
168
}
 
169
 
 
170
JSValue jsTestCustomNamedGetterConstructor(ExecState* exec, JSValue slotBase, PropertyName)
 
171
{
 
172
    JSTestCustomNamedGetter* domObject = jsCast<JSTestCustomNamedGetter*>(asObject(slotBase));
 
173
    return JSTestCustomNamedGetter::getConstructor(exec, domObject->globalObject());
 
174
}
 
175
 
 
176
JSValue JSTestCustomNamedGetter::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
 
177
{
 
178
    return getDOMConstructor<JSTestCustomNamedGetterConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
 
179
}
 
180
 
 
181
EncodedJSValue JSC_HOST_CALL jsTestCustomNamedGetterPrototypeFunctionAnotherFunction(ExecState* exec)
 
182
{
 
183
    JSValue thisValue = exec->hostThisValue();
 
184
    if (!thisValue.inherits(&JSTestCustomNamedGetter::s_info))
 
185
        return throwVMTypeError(exec);
 
186
    JSTestCustomNamedGetter* castedThis = jsCast<JSTestCustomNamedGetter*>(asObject(thisValue));
 
187
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestCustomNamedGetter::s_info);
 
188
    TestCustomNamedGetter* impl = static_cast<TestCustomNamedGetter*>(castedThis->impl());
 
189
    if (exec->argumentCount() < 1)
 
190
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
 
191
    const String& str(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? String() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec));
 
192
    if (exec->hadException())
 
193
        return JSValue::encode(jsUndefined());
 
194
    impl->anotherFunction(str);
 
195
    return JSValue::encode(jsUndefined());
 
196
}
 
197
 
 
198
static inline bool isObservable(JSTestCustomNamedGetter* jsTestCustomNamedGetter)
 
199
{
 
200
    if (jsTestCustomNamedGetter->hasCustomProperties())
 
201
        return true;
 
202
    return false;
 
203
}
 
204
 
 
205
bool JSTestCustomNamedGetterOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
 
206
{
 
207
    JSTestCustomNamedGetter* jsTestCustomNamedGetter = jsCast<JSTestCustomNamedGetter*>(handle.get().asCell());
 
208
    if (!isObservable(jsTestCustomNamedGetter))
 
209
        return false;
 
210
    UNUSED_PARAM(visitor);
 
211
    return false;
 
212
}
 
213
 
 
214
void JSTestCustomNamedGetterOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
 
215
{
 
216
    JSTestCustomNamedGetter* jsTestCustomNamedGetter = jsCast<JSTestCustomNamedGetter*>(handle.get().asCell());
 
217
    DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
 
218
    uncacheWrapper(world, jsTestCustomNamedGetter->impl(), jsTestCustomNamedGetter);
 
219
    jsTestCustomNamedGetter->releaseImpl();
 
220
}
 
221
 
 
222
JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestCustomNamedGetter* impl)
 
223
{
 
224
    return wrap<JSTestCustomNamedGetter>(exec, globalObject, impl);
 
225
}
 
226
 
 
227
TestCustomNamedGetter* toTestCustomNamedGetter(JSC::JSValue value)
 
228
{
 
229
    return value.inherits(&JSTestCustomNamedGetter::s_info) ? jsCast<JSTestCustomNamedGetter*>(asObject(value))->impl() : 0;
 
230
}
 
231
 
 
232
}