webengine/osswebengine/DerivedSources/WebCore/JSXMLSerializer.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 "JSXMLSerializer.h"
       
    24 
       
    25 #include <wtf/GetPtr.h>
       
    26 
       
    27 #include "JSNode.h"
       
    28 #include "PlatformString.h"
       
    29 #include "XMLSerializer.h"
       
    30 
       
    31 using namespace KJS;
       
    32 
       
    33 namespace WebCore {
       
    34 
       
    35 /* Hash table */
       
    36 
       
    37 static const HashEntry JSXMLSerializerTableEntries[] =
       
    38 {
       
    39     { "constructor", JSXMLSerializer::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }
       
    40 };
       
    41 
       
    42 static const HashTable JSXMLSerializerTable = 
       
    43 {
       
    44     2, 1, JSXMLSerializerTableEntries, 1
       
    45 };
       
    46 
       
    47 /* Hash table for constructor */
       
    48 
       
    49 static const HashEntry JSXMLSerializerConstructorTableEntries[] =
       
    50 {
       
    51     { 0, 0, 0, 0, 0 }
       
    52 };
       
    53 
       
    54 static const HashTable JSXMLSerializerConstructorTable = 
       
    55 {
       
    56     2, 1, JSXMLSerializerConstructorTableEntries, 1
       
    57 };
       
    58 
       
    59 class JSXMLSerializerConstructor : public DOMObject {
       
    60 public:
       
    61     JSXMLSerializerConstructor(ExecState* exec)
       
    62     {
       
    63         setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
       
    64         putDirect(exec->propertyNames().prototype, JSXMLSerializerPrototype::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 XMLSerializer)); }
       
    74 };
       
    75 
       
    76 const ClassInfo JSXMLSerializerConstructor::info = { "XMLSerializerConstructor", 0, &JSXMLSerializerConstructorTable, 0 };
       
    77 
       
    78 bool JSXMLSerializerConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    79 {
       
    80     return getStaticValueSlot<JSXMLSerializerConstructor, DOMObject>(exec, &JSXMLSerializerConstructorTable, this, propertyName, slot);
       
    81 }
       
    82 
       
    83 JSValue* JSXMLSerializerConstructor::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 JSXMLSerializerPrototypeTableEntries[] =
       
    92 {
       
    93     { "serializeToString", JSXMLSerializer::SerializeToStringFuncNum, DontDelete|Function, 1, 0 }
       
    94 };
       
    95 
       
    96 static const HashTable JSXMLSerializerPrototypeTable = 
       
    97 {
       
    98     2, 1, JSXMLSerializerPrototypeTableEntries, 1
       
    99 };
       
   100 
       
   101 const ClassInfo JSXMLSerializerPrototype::info = { "XMLSerializerPrototype", 0, &JSXMLSerializerPrototypeTable, 0 };
       
   102 
       
   103 JSObject* JSXMLSerializerPrototype::self(ExecState* exec)
       
   104 {
       
   105     return KJS::cacheGlobalObject<JSXMLSerializerPrototype>(exec, "[[JSXMLSerializer.prototype]]");
       
   106 }
       
   107 
       
   108 bool JSXMLSerializerPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   109 {
       
   110     return getStaticFunctionSlot<JSXMLSerializerPrototypeFunction, JSObject>(exec, &JSXMLSerializerPrototypeTable, this, propertyName, slot);
       
   111 }
       
   112 
       
   113 const ClassInfo JSXMLSerializer::info = { "XMLSerializer", 0, &JSXMLSerializerTable, 0 };
       
   114 
       
   115 JSXMLSerializer::JSXMLSerializer(ExecState* exec, XMLSerializer* impl)
       
   116     : m_impl(impl)
       
   117 {
       
   118     setPrototype(JSXMLSerializerPrototype::self(exec));
       
   119 }
       
   120 
       
   121 JSXMLSerializer::~JSXMLSerializer()
       
   122 {
       
   123     ScriptInterpreter::forgetDOMObject(m_impl.get());
       
   124 }
       
   125 
       
   126 bool JSXMLSerializer::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   127 {
       
   128     return getStaticValueSlot<JSXMLSerializer, KJS::DOMObject>(exec, &JSXMLSerializerTable, this, propertyName, slot);
       
   129 }
       
   130 
       
   131 JSValue* JSXMLSerializer::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* JSXMLSerializer::getConstructor(ExecState* exec)
       
   141 {
       
   142     return KJS::cacheGlobalObject<JSXMLSerializerConstructor>(exec, "[[XMLSerializer.constructor]]");
       
   143 }
       
   144 JSValue* JSXMLSerializerPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
       
   145 {
       
   146     if (!thisObj->inherits(&JSXMLSerializer::info))
       
   147       return throwError(exec, TypeError);
       
   148 
       
   149     XMLSerializer* imp = static_cast<XMLSerializer*>(static_cast<JSXMLSerializer*>(thisObj)->impl());
       
   150 
       
   151     switch (id) {
       
   152     case JSXMLSerializer::SerializeToStringFuncNum: {
       
   153         ExceptionCode ec = 0;
       
   154         Node* node = toNode(args[0]);
       
   155 
       
   156 
       
   157         KJS::JSValue* result = jsString(imp->serializeToString(node, ec));
       
   158         setDOMException(exec, ec);
       
   159         return result;
       
   160     }
       
   161     }
       
   162     return 0;
       
   163 }
       
   164 KJS::JSValue* toJS(KJS::ExecState* exec, XMLSerializer* obj)
       
   165 {
       
   166     return KJS::cacheDOMObject<XMLSerializer, JSXMLSerializer>(exec, obj);
       
   167 }
       
   168 XMLSerializer* toXMLSerializer(KJS::JSValue* val)
       
   169 {
       
   170     return val->isObject(&JSXMLSerializer::info) ? static_cast<JSXMLSerializer*>(val)->impl() : 0;
       
   171 }
       
   172 
       
   173 }