webengine/osswebengine/DerivedSources/WebCore/JSDOMParser.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 
       
    23 #include "JSDOMParser.h"
       
    24 
       
    25 #include <wtf/GetPtr.h>
       
    26 
       
    27 #include "DOMParser.h"
       
    28 #include "Document.h"
       
    29 #include "JSDocument.h"
       
    30 
       
    31 using namespace KJS;
       
    32 
       
    33 namespace WebCore {
       
    34 
       
    35 /* Hash table */
       
    36 
       
    37 static const HashEntry JSDOMParserTableEntries[] =
       
    38 {
       
    39     { "constructor", JSDOMParser::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }
       
    40 };
       
    41 
       
    42 static const HashTable JSDOMParserTable = 
       
    43 {
       
    44     2, 1, JSDOMParserTableEntries, 1
       
    45 };
       
    46 
       
    47 /* Hash table for constructor */
       
    48 
       
    49 static const HashEntry JSDOMParserConstructorTableEntries[] =
       
    50 {
       
    51     { 0, 0, 0, 0, 0 }
       
    52 };
       
    53 
       
    54 static const HashTable JSDOMParserConstructorTable = 
       
    55 {
       
    56     2, 1, JSDOMParserConstructorTableEntries, 1
       
    57 };
       
    58 
       
    59 class JSDOMParserConstructor : public DOMObject {
       
    60 public:
       
    61     JSDOMParserConstructor(ExecState* exec)
       
    62     {
       
    63         setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
       
    64         putDirect(exec->propertyNames().prototype, JSDOMParserPrototype::self(exec), None);
       
    65     }
       
    66     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
       
    67     JSValue* getValueProperty(ExecState*, int token) const;
       
    68     virtual const ClassInfo* classInfo() const { return &info; }
       
    69     static const ClassInfo info;
       
    70 
       
    71     virtual bool implementsHasInstance() const { return true; }
       
    72     virtual bool implementsConstruct() const { return true; }
       
    73     virtual JSObject* construct(ExecState* exec, const List& args) { return static_cast<JSObject*>(toJS(exec, new DOMParser)); }
       
    74 };
       
    75 
       
    76 const ClassInfo JSDOMParserConstructor::info = { "DOMParserConstructor", 0, &JSDOMParserConstructorTable, 0 };
       
    77 
       
    78 bool JSDOMParserConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    79 {
       
    80     return getStaticValueSlot<JSDOMParserConstructor, DOMObject>(exec, &JSDOMParserConstructorTable, this, propertyName, slot);
       
    81 }
       
    82 
       
    83 JSValue* JSDOMParserConstructor::getValueProperty(ExecState*, int token) const
       
    84 {
       
    85     // The token is the numeric value of its associated constant
       
    86     return jsNumber(token);
       
    87 }
       
    88 
       
    89 /* Hash table for prototype */
       
    90 
       
    91 static const HashEntry JSDOMParserPrototypeTableEntries[] =
       
    92 {
       
    93     { "parseFromString", JSDOMParser::ParseFromStringFuncNum, DontDelete|Function, 2, 0 }
       
    94 };
       
    95 
       
    96 static const HashTable JSDOMParserPrototypeTable = 
       
    97 {
       
    98     2, 1, JSDOMParserPrototypeTableEntries, 1
       
    99 };
       
   100 
       
   101 const ClassInfo JSDOMParserPrototype::info = { "DOMParserPrototype", 0, &JSDOMParserPrototypeTable, 0 };
       
   102 
       
   103 JSObject* JSDOMParserPrototype::self(ExecState* exec)
       
   104 {
       
   105     return KJS::cacheGlobalObject<JSDOMParserPrototype>(exec, "[[JSDOMParser.prototype]]");
       
   106 }
       
   107 
       
   108 bool JSDOMParserPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   109 {
       
   110     return getStaticFunctionSlot<JSDOMParserPrototypeFunction, JSObject>(exec, &JSDOMParserPrototypeTable, this, propertyName, slot);
       
   111 }
       
   112 
       
   113 const ClassInfo JSDOMParser::info = { "DOMParser", 0, &JSDOMParserTable, 0 };
       
   114 
       
   115 JSDOMParser::JSDOMParser(ExecState* exec, DOMParser* impl)
       
   116     : m_impl(impl)
       
   117 {
       
   118     setPrototype(JSDOMParserPrototype::self(exec));
       
   119 }
       
   120 
       
   121 JSDOMParser::~JSDOMParser()
       
   122 {
       
   123     ScriptInterpreter::forgetDOMObject(m_impl.get());
       
   124 }
       
   125 
       
   126 bool JSDOMParser::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   127 {
       
   128     return getStaticValueSlot<JSDOMParser, KJS::DOMObject>(exec, &JSDOMParserTable, this, propertyName, slot);
       
   129 }
       
   130 
       
   131 JSValue* JSDOMParser::getValueProperty(ExecState* exec, int token) const
       
   132 {
       
   133     switch (token) {
       
   134     case ConstructorAttrNum:
       
   135         return getConstructor(exec);
       
   136     }
       
   137     return 0;
       
   138 }
       
   139 
       
   140 JSValue* JSDOMParser::getConstructor(ExecState* exec)
       
   141 {
       
   142     return KJS::cacheGlobalObject<JSDOMParserConstructor>(exec, "[[DOMParser.constructor]]");
       
   143 }
       
   144 JSValue* JSDOMParserPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
       
   145 {
       
   146     if (!thisObj->inherits(&JSDOMParser::info))
       
   147       return throwError(exec, TypeError);
       
   148 
       
   149     DOMParser* imp = static_cast<DOMParser*>(static_cast<JSDOMParser*>(thisObj)->impl());
       
   150 
       
   151     switch (id) {
       
   152     case JSDOMParser::ParseFromStringFuncNum: {
       
   153         String str = args[0]->toString(exec);
       
   154         String contentType = args[1]->toString(exec);
       
   155 
       
   156 
       
   157         KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->parseFromString(str, contentType)));
       
   158         return result;
       
   159     }
       
   160     }
       
   161     return 0;
       
   162 }
       
   163 KJS::JSValue* toJS(KJS::ExecState* exec, DOMParser* obj)
       
   164 {
       
   165     return KJS::cacheDOMObject<DOMParser, JSDOMParser>(exec, obj);
       
   166 }
       
   167 DOMParser* toDOMParser(KJS::JSValue* val)
       
   168 {
       
   169     return val->isObject(&JSDOMParser::info) ? static_cast<JSDOMParser*>(val)->impl() : 0;
       
   170 }
       
   171 
       
   172 }