WebCore/generated/JSDOMPlugin.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 "JSDOMPlugin.h"
       
    23 
       
    24 #include "AtomicString.h"
       
    25 #include "DOMMimeType.h"
       
    26 #include "DOMPlugin.h"
       
    27 #include "JSDOMMimeType.h"
       
    28 #include "KURL.h"
       
    29 #include <runtime/Error.h>
       
    30 #include <runtime/JSNumberCell.h>
       
    31 #include <runtime/JSString.h>
       
    32 #include <runtime/PropertyNameArray.h>
       
    33 #include <wtf/GetPtr.h>
       
    34 
       
    35 using namespace JSC;
       
    36 
       
    37 namespace WebCore {
       
    38 
       
    39 ASSERT_CLASS_FITS_IN_CELL(JSDOMPlugin);
       
    40 
       
    41 /* Hash table */
       
    42 #if ENABLE(JIT)
       
    43 #define THUNK_GENERATOR(generator) , generator
       
    44 #else
       
    45 #define THUNK_GENERATOR(generator)
       
    46 #endif
       
    47 
       
    48 static const HashTableValue JSDOMPluginTableValues[6] =
       
    49 {
       
    50     { "name", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginName), (intptr_t)0 THUNK_GENERATOR(0) },
       
    51     { "filename", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginFilename), (intptr_t)0 THUNK_GENERATOR(0) },
       
    52     { "description", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginDescription), (intptr_t)0 THUNK_GENERATOR(0) },
       
    53     { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginLength), (intptr_t)0 THUNK_GENERATOR(0) },
       
    54     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMPluginConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    55     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    56 };
       
    57 
       
    58 #undef THUNK_GENERATOR
       
    59 static JSC_CONST_HASHTABLE HashTable JSDOMPluginTable = { 17, 15, JSDOMPluginTableValues, 0 };
       
    60 /* Hash table for constructor */
       
    61 #if ENABLE(JIT)
       
    62 #define THUNK_GENERATOR(generator) , generator
       
    63 #else
       
    64 #define THUNK_GENERATOR(generator)
       
    65 #endif
       
    66 
       
    67 static const HashTableValue JSDOMPluginConstructorTableValues[1] =
       
    68 {
       
    69     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    70 };
       
    71 
       
    72 #undef THUNK_GENERATOR
       
    73 static JSC_CONST_HASHTABLE HashTable JSDOMPluginConstructorTable = { 1, 0, JSDOMPluginConstructorTableValues, 0 };
       
    74 class JSDOMPluginConstructor : public DOMConstructorObject {
       
    75 public:
       
    76     JSDOMPluginConstructor(JSC::ExecState*, JSDOMGlobalObject*);
       
    77 
       
    78     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
       
    79     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
       
    80     virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
       
    81     static const JSC::ClassInfo s_info;
       
    82     static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
       
    83     {
       
    84         return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
       
    85     }
       
    86 protected:
       
    87     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
       
    88 };
       
    89 
       
    90 const ClassInfo JSDOMPluginConstructor::s_info = { "PluginConstructor", 0, &JSDOMPluginConstructorTable, 0 };
       
    91 
       
    92 JSDOMPluginConstructor::JSDOMPluginConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
    93     : DOMConstructorObject(JSDOMPluginConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
    94 {
       
    95     putDirect(exec->propertyNames().prototype, JSDOMPluginPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
    96 }
       
    97 
       
    98 bool JSDOMPluginConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    99 {
       
   100     return getStaticValueSlot<JSDOMPluginConstructor, DOMObject>(exec, &JSDOMPluginConstructorTable, this, propertyName, slot);
       
   101 }
       
   102 
       
   103 bool JSDOMPluginConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   104 {
       
   105     return getStaticValueDescriptor<JSDOMPluginConstructor, DOMObject>(exec, &JSDOMPluginConstructorTable, this, propertyName, descriptor);
       
   106 }
       
   107 
       
   108 /* Hash table for prototype */
       
   109 #if ENABLE(JIT)
       
   110 #define THUNK_GENERATOR(generator) , generator
       
   111 #else
       
   112 #define THUNK_GENERATOR(generator)
       
   113 #endif
       
   114 
       
   115 static const HashTableValue JSDOMPluginPrototypeTableValues[3] =
       
   116 {
       
   117     { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMPluginPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) },
       
   118     { "namedItem", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsDOMPluginPrototypeFunctionNamedItem), (intptr_t)1 THUNK_GENERATOR(0) },
       
   119     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   120 };
       
   121 
       
   122 #undef THUNK_GENERATOR
       
   123 static JSC_CONST_HASHTABLE HashTable JSDOMPluginPrototypeTable = { 5, 3, JSDOMPluginPrototypeTableValues, 0 };
       
   124 const ClassInfo JSDOMPluginPrototype::s_info = { "PluginPrototype", 0, &JSDOMPluginPrototypeTable, 0 };
       
   125 
       
   126 JSObject* JSDOMPluginPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   127 {
       
   128     return getDOMPrototype<JSDOMPlugin>(exec, globalObject);
       
   129 }
       
   130 
       
   131 bool JSDOMPluginPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   132 {
       
   133     return getStaticFunctionSlot<JSObject>(exec, &JSDOMPluginPrototypeTable, this, propertyName, slot);
       
   134 }
       
   135 
       
   136 bool JSDOMPluginPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   137 {
       
   138     return getStaticFunctionDescriptor<JSObject>(exec, &JSDOMPluginPrototypeTable, this, propertyName, descriptor);
       
   139 }
       
   140 
       
   141 const ClassInfo JSDOMPlugin::s_info = { "Plugin", 0, &JSDOMPluginTable, 0 };
       
   142 
       
   143 JSDOMPlugin::JSDOMPlugin(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<DOMPlugin> impl)
       
   144     : DOMObjectWithGlobalPointer(structure, globalObject)
       
   145     , m_impl(impl)
       
   146 {
       
   147 }
       
   148 
       
   149 JSDOMPlugin::~JSDOMPlugin()
       
   150 {
       
   151     forgetDOMObject(this, impl());
       
   152 }
       
   153 
       
   154 JSObject* JSDOMPlugin::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   155 {
       
   156     return new (exec) JSDOMPluginPrototype(globalObject, JSDOMPluginPrototype::createStructure(globalObject->objectPrototype()));
       
   157 }
       
   158 
       
   159 bool JSDOMPlugin::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   160 {
       
   161     const HashEntry* entry = JSDOMPluginTable.entry(exec, propertyName);
       
   162     if (entry) {
       
   163         slot.setCustom(this, entry->propertyGetter());
       
   164         return true;
       
   165     }
       
   166     bool ok;
       
   167     unsigned index = propertyName.toUInt32(&ok, false);
       
   168     if (ok && index < static_cast<DOMPlugin*>(impl())->length()) {
       
   169         slot.setCustomIndex(this, index, indexGetter);
       
   170         return true;
       
   171     }
       
   172     if (canGetItemsForName(exec, static_cast<DOMPlugin*>(impl()), propertyName)) {
       
   173         slot.setCustom(this, nameGetter);
       
   174         return true;
       
   175     }
       
   176     return getStaticValueSlot<JSDOMPlugin, Base>(exec, &JSDOMPluginTable, this, propertyName, slot);
       
   177 }
       
   178 
       
   179 bool JSDOMPlugin::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   180 {
       
   181     const HashEntry* entry = JSDOMPluginTable.entry(exec, propertyName);
       
   182     if (entry) {
       
   183         PropertySlot slot;
       
   184         slot.setCustom(this, entry->propertyGetter());
       
   185         descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
       
   186         return true;
       
   187     }
       
   188     bool ok;
       
   189     unsigned index = propertyName.toUInt32(&ok, false);
       
   190     if (ok && index < static_cast<DOMPlugin*>(impl())->length()) {
       
   191         PropertySlot slot;
       
   192         slot.setCustomIndex(this, index, indexGetter);
       
   193         descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
       
   194         return true;
       
   195     }
       
   196     if (canGetItemsForName(exec, static_cast<DOMPlugin*>(impl()), propertyName)) {
       
   197         PropertySlot slot;
       
   198         slot.setCustom(this, nameGetter);
       
   199         descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
       
   200         return true;
       
   201     }
       
   202     return getStaticValueDescriptor<JSDOMPlugin, Base>(exec, &JSDOMPluginTable, this, propertyName, descriptor);
       
   203 }
       
   204 
       
   205 bool JSDOMPlugin::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
       
   206 {
       
   207     if (propertyName < static_cast<DOMPlugin*>(impl())->length()) {
       
   208         slot.setCustomIndex(this, propertyName, indexGetter);
       
   209         return true;
       
   210     }
       
   211     return getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
       
   212 }
       
   213 
       
   214 JSValue jsDOMPluginName(ExecState* exec, JSValue slotBase, const Identifier&)
       
   215 {
       
   216     JSDOMPlugin* castedThis = static_cast<JSDOMPlugin*>(asObject(slotBase));
       
   217     UNUSED_PARAM(exec);
       
   218     DOMPlugin* imp = static_cast<DOMPlugin*>(castedThis->impl());
       
   219     JSValue result = jsString(exec, imp->name());
       
   220     return result;
       
   221 }
       
   222 
       
   223 JSValue jsDOMPluginFilename(ExecState* exec, JSValue slotBase, const Identifier&)
       
   224 {
       
   225     JSDOMPlugin* castedThis = static_cast<JSDOMPlugin*>(asObject(slotBase));
       
   226     UNUSED_PARAM(exec);
       
   227     DOMPlugin* imp = static_cast<DOMPlugin*>(castedThis->impl());
       
   228     JSValue result = jsString(exec, imp->filename());
       
   229     return result;
       
   230 }
       
   231 
       
   232 JSValue jsDOMPluginDescription(ExecState* exec, JSValue slotBase, const Identifier&)
       
   233 {
       
   234     JSDOMPlugin* castedThis = static_cast<JSDOMPlugin*>(asObject(slotBase));
       
   235     UNUSED_PARAM(exec);
       
   236     DOMPlugin* imp = static_cast<DOMPlugin*>(castedThis->impl());
       
   237     JSValue result = jsString(exec, imp->description());
       
   238     return result;
       
   239 }
       
   240 
       
   241 JSValue jsDOMPluginLength(ExecState* exec, JSValue slotBase, const Identifier&)
       
   242 {
       
   243     JSDOMPlugin* castedThis = static_cast<JSDOMPlugin*>(asObject(slotBase));
       
   244     UNUSED_PARAM(exec);
       
   245     DOMPlugin* imp = static_cast<DOMPlugin*>(castedThis->impl());
       
   246     JSValue result = jsNumber(exec, imp->length());
       
   247     return result;
       
   248 }
       
   249 
       
   250 JSValue jsDOMPluginConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   251 {
       
   252     JSDOMPlugin* domObject = static_cast<JSDOMPlugin*>(asObject(slotBase));
       
   253     return JSDOMPlugin::getConstructor(exec, domObject->globalObject());
       
   254 }
       
   255 void JSDOMPlugin::getOwnPropertyNames(ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
       
   256 {
       
   257     for (unsigned i = 0; i < static_cast<DOMPlugin*>(impl())->length(); ++i)
       
   258         propertyNames.add(Identifier::from(exec, i));
       
   259      Base::getOwnPropertyNames(exec, propertyNames, mode);
       
   260 }
       
   261 
       
   262 JSValue JSDOMPlugin::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   263 {
       
   264     return getDOMConstructor<JSDOMPluginConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   265 }
       
   266 
       
   267 EncodedJSValue JSC_HOST_CALL jsDOMPluginPrototypeFunctionItem(ExecState* exec)
       
   268 {
       
   269     JSValue thisValue = exec->hostThisValue();
       
   270     if (!thisValue.inherits(&JSDOMPlugin::s_info))
       
   271         return throwVMTypeError(exec);
       
   272     JSDOMPlugin* castedThis = static_cast<JSDOMPlugin*>(asObject(thisValue));
       
   273     DOMPlugin* imp = static_cast<DOMPlugin*>(castedThis->impl());
       
   274     unsigned index = exec->argument(0).toInt32(exec);
       
   275 
       
   276 
       
   277     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->item(index)));
       
   278     return JSValue::encode(result);
       
   279 }
       
   280 
       
   281 EncodedJSValue JSC_HOST_CALL jsDOMPluginPrototypeFunctionNamedItem(ExecState* exec)
       
   282 {
       
   283     JSValue thisValue = exec->hostThisValue();
       
   284     if (!thisValue.inherits(&JSDOMPlugin::s_info))
       
   285         return throwVMTypeError(exec);
       
   286     JSDOMPlugin* castedThis = static_cast<JSDOMPlugin*>(asObject(thisValue));
       
   287     DOMPlugin* imp = static_cast<DOMPlugin*>(castedThis->impl());
       
   288     const String& name = ustringToString(exec->argument(0).toString(exec));
       
   289 
       
   290 
       
   291     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->namedItem(name)));
       
   292     return JSValue::encode(result);
       
   293 }
       
   294 
       
   295 
       
   296 JSValue JSDOMPlugin::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
       
   297 {
       
   298     JSDOMPlugin* thisObj = static_cast<JSDOMPlugin*>(asObject(slotBase));
       
   299     return toJS(exec, thisObj->globalObject(), static_cast<DOMPlugin*>(thisObj->impl())->item(index));
       
   300 }
       
   301 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMPlugin* object)
       
   302 {
       
   303     return getDOMObjectWrapper<JSDOMPlugin>(exec, globalObject, object);
       
   304 }
       
   305 DOMPlugin* toDOMPlugin(JSC::JSValue value)
       
   306 {
       
   307     return value.inherits(&JSDOMPlugin::s_info) ? static_cast<JSDOMPlugin*>(asObject(value))->impl() : 0;
       
   308 }
       
   309 
       
   310 }