WebCore/generated/JSText.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 "JSText.h"
       
    23 
       
    24 #include "ExceptionCode.h"
       
    25 #include "JSText.h"
       
    26 #include "KURL.h"
       
    27 #include "Text.h"
       
    28 #include <runtime/Error.h>
       
    29 #include <runtime/JSString.h>
       
    30 #include <wtf/GetPtr.h>
       
    31 
       
    32 using namespace JSC;
       
    33 
       
    34 namespace WebCore {
       
    35 
       
    36 ASSERT_CLASS_FITS_IN_CELL(JSText);
       
    37 
       
    38 /* Hash table */
       
    39 #if ENABLE(JIT)
       
    40 #define THUNK_GENERATOR(generator) , generator
       
    41 #else
       
    42 #define THUNK_GENERATOR(generator)
       
    43 #endif
       
    44 
       
    45 static const HashTableValue JSTextTableValues[3] =
       
    46 {
       
    47     { "wholeText", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextWholeText), (intptr_t)0 THUNK_GENERATOR(0) },
       
    48     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
       
    49     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    50 };
       
    51 
       
    52 #undef THUNK_GENERATOR
       
    53 static JSC_CONST_HASHTABLE HashTable JSTextTable = { 5, 3, JSTextTableValues, 0 };
       
    54 /* Hash table for constructor */
       
    55 #if ENABLE(JIT)
       
    56 #define THUNK_GENERATOR(generator) , generator
       
    57 #else
       
    58 #define THUNK_GENERATOR(generator)
       
    59 #endif
       
    60 
       
    61 static const HashTableValue JSTextConstructorTableValues[1] =
       
    62 {
       
    63     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
    64 };
       
    65 
       
    66 #undef THUNK_GENERATOR
       
    67 static JSC_CONST_HASHTABLE HashTable JSTextConstructorTable = { 1, 0, JSTextConstructorTableValues, 0 };
       
    68 class JSTextConstructor : public DOMConstructorObject {
       
    69 public:
       
    70     JSTextConstructor(JSC::ExecState*, JSDOMGlobalObject*);
       
    71 
       
    72     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
       
    73     virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
       
    74     virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
       
    75     static const JSC::ClassInfo s_info;
       
    76     static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
       
    77     {
       
    78         return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
       
    79     }
       
    80 protected:
       
    81     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
       
    82 };
       
    83 
       
    84 const ClassInfo JSTextConstructor::s_info = { "TextConstructor", 0, &JSTextConstructorTable, 0 };
       
    85 
       
    86 JSTextConstructor::JSTextConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
       
    87     : DOMConstructorObject(JSTextConstructor::createStructure(globalObject->objectPrototype()), globalObject)
       
    88 {
       
    89     putDirect(exec->propertyNames().prototype, JSTextPrototype::self(exec, globalObject), DontDelete | ReadOnly);
       
    90 }
       
    91 
       
    92 bool JSTextConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    93 {
       
    94     return getStaticValueSlot<JSTextConstructor, DOMObject>(exec, &JSTextConstructorTable, this, propertyName, slot);
       
    95 }
       
    96 
       
    97 bool JSTextConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
    98 {
       
    99     return getStaticValueDescriptor<JSTextConstructor, DOMObject>(exec, &JSTextConstructorTable, this, propertyName, descriptor);
       
   100 }
       
   101 
       
   102 /* Hash table for prototype */
       
   103 #if ENABLE(JIT)
       
   104 #define THUNK_GENERATOR(generator) , generator
       
   105 #else
       
   106 #define THUNK_GENERATOR(generator)
       
   107 #endif
       
   108 
       
   109 static const HashTableValue JSTextPrototypeTableValues[3] =
       
   110 {
       
   111     { "splitText", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTextPrototypeFunctionSplitText), (intptr_t)1 THUNK_GENERATOR(0) },
       
   112     { "replaceWholeText", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTextPrototypeFunctionReplaceWholeText), (intptr_t)1 THUNK_GENERATOR(0) },
       
   113     { 0, 0, 0, 0 THUNK_GENERATOR(0) }
       
   114 };
       
   115 
       
   116 #undef THUNK_GENERATOR
       
   117 static JSC_CONST_HASHTABLE HashTable JSTextPrototypeTable = { 4, 3, JSTextPrototypeTableValues, 0 };
       
   118 const ClassInfo JSTextPrototype::s_info = { "TextPrototype", 0, &JSTextPrototypeTable, 0 };
       
   119 
       
   120 JSObject* JSTextPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
       
   121 {
       
   122     return getDOMPrototype<JSText>(exec, globalObject);
       
   123 }
       
   124 
       
   125 bool JSTextPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   126 {
       
   127     return getStaticFunctionSlot<JSObject>(exec, &JSTextPrototypeTable, this, propertyName, slot);
       
   128 }
       
   129 
       
   130 bool JSTextPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   131 {
       
   132     return getStaticFunctionDescriptor<JSObject>(exec, &JSTextPrototypeTable, this, propertyName, descriptor);
       
   133 }
       
   134 
       
   135 const ClassInfo JSText::s_info = { "Text", &JSCharacterData::s_info, &JSTextTable, 0 };
       
   136 
       
   137 JSText::JSText(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<Text> impl)
       
   138     : JSCharacterData(structure, globalObject, impl)
       
   139 {
       
   140 }
       
   141 
       
   142 JSObject* JSText::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
       
   143 {
       
   144     return new (exec) JSTextPrototype(globalObject, JSTextPrototype::createStructure(JSCharacterDataPrototype::self(exec, globalObject)));
       
   145 }
       
   146 
       
   147 bool JSText::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   148 {
       
   149     return getStaticValueSlot<JSText, Base>(exec, &JSTextTable, this, propertyName, slot);
       
   150 }
       
   151 
       
   152 bool JSText::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
       
   153 {
       
   154     return getStaticValueDescriptor<JSText, Base>(exec, &JSTextTable, this, propertyName, descriptor);
       
   155 }
       
   156 
       
   157 JSValue jsTextWholeText(ExecState* exec, JSValue slotBase, const Identifier&)
       
   158 {
       
   159     JSText* castedThis = static_cast<JSText*>(asObject(slotBase));
       
   160     UNUSED_PARAM(exec);
       
   161     Text* imp = static_cast<Text*>(castedThis->impl());
       
   162     JSValue result = jsString(exec, imp->wholeText());
       
   163     return result;
       
   164 }
       
   165 
       
   166 JSValue jsTextConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
       
   167 {
       
   168     JSText* domObject = static_cast<JSText*>(asObject(slotBase));
       
   169     return JSText::getConstructor(exec, domObject->globalObject());
       
   170 }
       
   171 JSValue JSText::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
       
   172 {
       
   173     return getDOMConstructor<JSTextConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
       
   174 }
       
   175 
       
   176 EncodedJSValue JSC_HOST_CALL jsTextPrototypeFunctionSplitText(ExecState* exec)
       
   177 {
       
   178     JSValue thisValue = exec->hostThisValue();
       
   179     if (!thisValue.inherits(&JSText::s_info))
       
   180         return throwVMTypeError(exec);
       
   181     JSText* castedThis = static_cast<JSText*>(asObject(thisValue));
       
   182     Text* imp = static_cast<Text*>(castedThis->impl());
       
   183     ExceptionCode ec = 0;
       
   184     int offset = exec->argument(0).toInt32(exec);
       
   185     if (offset < 0) {
       
   186         setDOMException(exec, INDEX_SIZE_ERR);
       
   187         return JSValue::encode(jsUndefined());
       
   188     }
       
   189 
       
   190 
       
   191     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->splitText(offset, ec)));
       
   192     setDOMException(exec, ec);
       
   193     return JSValue::encode(result);
       
   194 }
       
   195 
       
   196 EncodedJSValue JSC_HOST_CALL jsTextPrototypeFunctionReplaceWholeText(ExecState* exec)
       
   197 {
       
   198     JSValue thisValue = exec->hostThisValue();
       
   199     if (!thisValue.inherits(&JSText::s_info))
       
   200         return throwVMTypeError(exec);
       
   201     JSText* castedThis = static_cast<JSText*>(asObject(thisValue));
       
   202     Text* imp = static_cast<Text*>(castedThis->impl());
       
   203     ExceptionCode ec = 0;
       
   204     const String& content = ustringToString(exec->argument(0).toString(exec));
       
   205 
       
   206 
       
   207     JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->replaceWholeText(content, ec)));
       
   208     setDOMException(exec, ec);
       
   209     return JSValue::encode(result);
       
   210 }
       
   211 
       
   212 
       
   213 }