WebCore/generated/JSHTMLCollection.cpp
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 "JSHTMLCollection.h"
       
    23 
       
    24 #include "AtomicString.h"
       
    25 #include "HTMLCollection.h"
       
    26 #include "JSNode.h"
       
    27 #include "Node.h"
       
    28 #include <runtime/Error.h>
       
    29 #include <runtime/JSNumberCell.h>
       
    30 #include <runtime/PropertyNameArray.h>
       
    31 #include <wtf/GetPtr.h>
       
    32 
       
    33 using namespace JSC;
       
    34 
       
    35 namespace WebCore {
       
    36 
       
    37 ASSERT_CLASS_FITS_IN_CELL(JSHTMLCollection);
       
    38 
       
    39 /* Hash table */
       
    40 #if ENABLE(JIT)
       
    41 #define THUNK_GENERATOR(generator) , generator
       
    42 #else
       
    43 #define THUNK_GENERATOR(generator)
       
    44 #endif
       
    45 
       
    46 static const HashTableValue JSHTMLCollectionTableValues[3] =
       
    47 {
       
    48     { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCollectionLength), (intptr_t)0 THUNK_GENERATOR(0) },
       
    49     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLCollectionConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    50     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    51 };
       
    52 
       
    53 #undef THUNK_GENERATOR
       
    54 static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionTable = { 5, 3, JSHTMLCollectionTableValues, 0 };
       
    55 /* Hash table for constructor */
       
    56 #if ENABLE(JIT)
       
    57 #define THUNK_GENERATOR(generator) , generator
       
    58 #else
       
    59 #define THUNK_GENERATOR(generator)
       
    60 #endif
       
    61 
       
    62 static const HashTableValue JSHTMLCollectionConstructorTableValues[1] =
       
    63 {
       
    64     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    65 };
       
    66 
       
    67 #undef THUNK_GENERATOR
       
    68 static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionConstructorTable = { 1, 0, JSHTMLCollectionConstructorTableValues, 0 };
       
    69 class JSHTMLCollectionConstructor : public DOMConstructorObject {
       
    70 public:
       
    71     JSHTMLCollectionConstructor(JSC::ExecState*, JSDOMGlobalObject*);
       
    72 
       
    73     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
       
    74     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
       
    75     virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
       
    76     static const JSC::ClassInfo s_info;
       
    77     static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
       
    78     {
       
    79         return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
       
    80     }
       
    81 protected:
       
    82     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
       
    83 };
       
    84 
       
    85 const ClassInfo JSHTMLCollectionConstructor::s_info = { "HTMLCollectionConstructor", 0, &JSHTMLCollectionConstructorTable, 0 };
       
    86 
       
    87 JSHTMLCollectionConstructor::JSHTMLCollectionConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
    88     : DOMConstructorObject(JSHTMLCollectionConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
    89 {
       
    90     putDirect(exec->propertyNames().prototype, JSHTMLCollectionPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
    91 }
       
    92 
       
    93 bool JSHTMLCollectionConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    94 {
       
    95     return getStaticValueSlot<JSHTMLCollectionConstructor, DOMObject>(exec, &JSHTMLCollectionConstructorTable, this, propertyName, slot);
       
    96 }
       
    97 
       
    98 bool JSHTMLCollectionConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
    99 {
       
   100     return getStaticValueDescriptor<JSHTMLCollectionConstructor, DOMObject>(exec, &JSHTMLCollectionConstructorTable, this, propertyName, descriptor);
       
   101 }
       
   102 
       
   103 /* Hash table for prototype */
       
   104 #if ENABLE(JIT)
       
   105 #define THUNK_GENERATOR(generator) , generator
       
   106 #else
       
   107 #define THUNK_GENERATOR(generator)
       
   108 #endif
       
   109 
       
   110 static const HashTableValue JSHTMLCollectionPrototypeTableValues[3] =
       
   111 {
       
   112     { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsHTMLCollectionPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) },
       
   113     { "namedItem", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsHTMLCollectionPrototypeFunctionNamedItem), (intptr_t)1 THUNK_GENERATOR(0) },
       
   114     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   115 };
       
   116 
       
   117 #undef THUNK_GENERATOR
       
   118 static JSC_CONST_HASHTABLE HashTable JSHTMLCollectionPrototypeTable = { 5, 3, JSHTMLCollectionPrototypeTableValues, 0 };
       
   119 const ClassInfo JSHTMLCollectionPrototype::s_info = { "HTMLCollectionPrototype", 0, &JSHTMLCollectionPrototypeTable, 0 };
       
   120 
       
   121 JSObject* JSHTMLCollectionPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   122 {
       
   123     return getDOMPrototype<JSHTMLCollection>(exec, globalObject);
       
   124 }
       
   125 
       
   126 bool JSHTMLCollectionPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   127 {
       
   128     return getStaticFunctionSlot<JSObject>(exec, &JSHTMLCollectionPrototypeTable, this, propertyName, slot);
       
   129 }
       
   130 
       
   131 bool JSHTMLCollectionPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   132 {
       
   133     return getStaticFunctionDescriptor<JSObject>(exec, &JSHTMLCollectionPrototypeTable, this, propertyName, descriptor);
       
   134 }
       
   135 
       
   136 const ClassInfo JSHTMLCollection::s_info = { "HTMLCollection", 0, &JSHTMLCollectionTable, 0 };
       
   137 
       
   138 JSHTMLCollection::JSHTMLCollection(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<HTMLCollection> impl)
       
   139     : DOMObjectWithGlobalPointer(structure, globalObject)
       
   140     , m_impl(impl)
       
   141 {
       
   142 }
       
   143 
       
   144 JSHTMLCollection::~JSHTMLCollection()
       
   145 {
       
   146     forgetDOMObject(this, impl());
       
   147 }
       
   148 
       
   149 JSObject* JSHTMLCollection::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   150 {
       
   151     return new (exec) JSHTMLCollectionPrototype(globalObject, JSHTMLCollectionPrototype::createStructure(globalObject->objectPrototype()));
       
   152 }
       
   153 
       
   154 bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   155 {
       
   156     JSValue proto = prototype();
       
   157     if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
       
   158         return false;
       
   159 
       
   160     const HashEntry* entry = JSHTMLCollectionTable.entry(exec, propertyName);
       
   161     if (entry) {
       
   162         slot.setCustom(this, entry->propertyGetter());
       
   163         return true;
       
   164     }
       
   165     bool ok;
       
   166     unsigned index = propertyName.toUInt32(&ok, false);
       
   167     if (ok && index < static_cast<HTMLCollection*>(impl())->length()) {
       
   168         slot.setCustomIndex(this, index, indexGetter);
       
   169         return true;
       
   170     }
       
   171     if (canGetItemsForName(exec, static_cast<HTMLCollection*>(impl()), propertyName)) {
       
   172         slot.setCustom(this, nameGetter);
       
   173         return true;
       
   174     }
       
   175     return getStaticValueSlot<JSHTMLCollection, Base>(exec, &JSHTMLCollectionTable, this, propertyName, slot);
       
   176 }
       
   177 
       
   178 bool JSHTMLCollection::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   179 {
       
   180     JSValue proto = prototype();
       
   181     if (proto.isObject() && static_cast<JSObject*>(asObject(proto))->hasProperty(exec, propertyName))
       
   182         return false;
       
   183 
       
   184     const HashEntry* entry = JSHTMLCollectionTable.entry(exec, propertyName);
       
   185     if (entry) {
       
   186         PropertySlot slot;
       
   187         slot.setCustom(this, entry->propertyGetter());
       
   188         descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
       
   189         return true;
       
   190     }
       
   191     bool ok;
       
   192     unsigned index = propertyName.toUInt32(&ok, false);
       
   193     if (ok && index < static_cast<HTMLCollection*>(impl())->length()) {
       
   194         PropertySlot slot;
       
   195         slot.setCustomIndex(this, index, indexGetter);
       
   196         descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
       
   197         return true;
       
   198     }
       
   199     if (canGetItemsForName(exec, static_cast<HTMLCollection*>(impl()), propertyName)) {
       
   200         PropertySlot slot;
       
   201         slot.setCustom(this, nameGetter);
       
   202         descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
       
   203         return true;
       
   204     }
       
   205     return getStaticValueDescriptor<JSHTMLCollection, Base>(exec, &JSHTMLCollectionTable, this, propertyName, descriptor);
       
   206 }
       
   207 
       
   208 bool JSHTMLCollection::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
       
   209 {
       
   210     if (propertyName < static_cast<HTMLCollection*>(impl())->length()) {
       
   211         slot.setCustomIndex(this, propertyName, indexGetter);
       
   212         return true;
       
   213     }
       
   214     return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
       
   215 }
       
   216 
       
   217 JSValue jsHTMLCollectionLength(ExecState* exec, JSValue slotBase, const Identifier&)
       
   218 {
       
   219     JSHTMLCollection* castedThis = static_cast<JSHTMLCollection*>(asObject(slotBase));
       
   220     UNUSED_PARAM(exec);
       
   221     HTMLCollection* imp = static_cast<HTMLCollection*>(castedThis->impl());
       
   222     JSValue result = jsNumber(exec, imp->length());
       
   223     return result;
       
   224 }
       
   225 
       
   226 JSValue jsHTMLCollectionConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   227 {
       
   228     JSHTMLCollection* domObject = static_cast<JSHTMLCollection*>(asObject(slotBase));
       
   229     return JSHTMLCollection::getConstructor(exec, domObject->globalObject());
       
   230 }
       
   231 void JSHTMLCollection::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
       
   232 {
       
   233     for (unsigned i = 0; i < static_cast<HTMLCollection*>(impl())->length(); ++i)
       
   234         propertyNames.add(Identifier::from(exec, i));
       
   235      Base::getOwnPropertyNames(exec, propertyNames, mode);
       
   236 }
       
   237 
       
   238 JSValue JSHTMLCollection::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   239 {
       
   240     return getDOMConstructor<JSHTMLCollectionConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   241 }
       
   242 
       
   243 EncodedJSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionItem(ExecState* exec)
       
   244 {
       
   245     JSValue thisValue = exec->hostThisValue();
       
   246     if (!thisValue.inherits(&JSHTMLCollection::s_info))
       
   247         return throwVMTypeError(exec);
       
   248     JSHTMLCollection* castedThis = static_cast<JSHTMLCollection*>(asObject(thisValue));
       
   249     return JSValue::encode(castedThis->item(exec));
       
   250 }
       
   251 
       
   252 EncodedJSValue JSC_HOST_CALL jsHTMLCollectionPrototypeFunctionNamedItem(ExecState* exec)
       
   253 {
       
   254     JSValue thisValue = exec->hostThisValue();
       
   255     if (!thisValue.inherits(&JSHTMLCollection::s_info))
       
   256         return throwVMTypeError(exec);
       
   257     JSHTMLCollection* castedThis = static_cast<JSHTMLCollection*>(asObject(thisValue));
       
   258     return JSValue::encode(castedThis->namedItem(exec));
       
   259 }
       
   260 
       
   261 
       
   262 JSValue JSHTMLCollection::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
       
   263 {
       
   264     JSHTMLCollection* thisObj = static_cast<JSHTMLCollection*>(asObject(slotBase));
       
   265     return toJS(exec, thisObj->globalObject(), static_cast<HTMLCollection*>(thisObj->impl())->item(index));
       
   266 }
       
   267 HTMLCollection* toHTMLCollection(JSC::JSValue value)
       
   268 {
       
   269     return value.inherits(&JSHTMLCollection::s_info) ? static_cast<JSHTMLCollection*>(asObject(value))->impl() : 0;
       
   270 }
       
   271 
       
   272 }