webengine/osswebengine/DerivedSources/WebCore/JSCharacterData.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 "JSCharacterData.h"
       
    24 
       
    25 #include <wtf/GetPtr.h>
       
    26 
       
    27 #include "CharacterData.h"
       
    28 #include "ExceptionCode.h"
       
    29 #include "PlatformString.h"
       
    30 
       
    31 using namespace KJS;
       
    32 
       
    33 namespace WebCore {
       
    34 
       
    35 /* Hash table */
       
    36 
       
    37 static const HashEntry JSCharacterDataTableEntries[] =
       
    38 {
       
    39     { "data", JSCharacterData::DataAttrNum, DontDelete, 0, &JSCharacterDataTableEntries[3] },
       
    40     { "length", JSCharacterData::LengthAttrNum, DontDelete|ReadOnly, 0, 0 },
       
    41     { 0, 0, 0, 0, 0 },
       
    42     { "constructor", JSCharacterData::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 }
       
    43 };
       
    44 
       
    45 static const HashTable JSCharacterDataTable = 
       
    46 {
       
    47     2, 4, JSCharacterDataTableEntries, 3
       
    48 };
       
    49 
       
    50 /* Hash table for constructor */
       
    51 
       
    52 static const HashEntry JSCharacterDataConstructorTableEntries[] =
       
    53 {
       
    54     { 0, 0, 0, 0, 0 }
       
    55 };
       
    56 
       
    57 static const HashTable JSCharacterDataConstructorTable = 
       
    58 {
       
    59     2, 1, JSCharacterDataConstructorTableEntries, 1
       
    60 };
       
    61 
       
    62 class JSCharacterDataConstructor : public DOMObject {
       
    63 public:
       
    64     JSCharacterDataConstructor(ExecState* exec)
       
    65     {
       
    66         setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
       
    67         putDirect(exec->propertyNames().prototype, JSCharacterDataPrototype::self(exec), None);
       
    68     }
       
    69     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
       
    70     JSValue* getValueProperty(ExecState*, int token) const;
       
    71     virtual const ClassInfo* classInfo() const { return &info; }
       
    72     static const ClassInfo info;
       
    73 
       
    74     virtual bool implementsHasInstance() const { return true; }
       
    75 };
       
    76 
       
    77 const ClassInfo JSCharacterDataConstructor::info = { "CharacterDataConstructor", 0, &JSCharacterDataConstructorTable, 0 };
       
    78 
       
    79 bool JSCharacterDataConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
    80 {
       
    81     return getStaticValueSlot<JSCharacterDataConstructor, DOMObject>(exec, &JSCharacterDataConstructorTable, this, propertyName, slot);
       
    82 }
       
    83 
       
    84 JSValue* JSCharacterDataConstructor::getValueProperty(ExecState*, int token) const
       
    85 {
       
    86     // The token is the numeric value of its associated constant
       
    87     return jsNumber(token);
       
    88 }
       
    89 
       
    90 /* Hash table for prototype */
       
    91 
       
    92 static const HashEntry JSCharacterDataPrototypeTableEntries[] =
       
    93 {
       
    94     { "appendData", JSCharacterData::AppendDataFuncNum, DontDelete|Function, 1, &JSCharacterDataPrototypeTableEntries[5] },
       
    95     { "insertData", JSCharacterData::InsertDataFuncNum, DontDelete|Function, 2, 0 },
       
    96     { 0, 0, 0, 0, 0 },
       
    97     { "substringData", JSCharacterData::SubstringDataFuncNum, DontDelete|Function, 2, 0 },
       
    98     { "deleteData", JSCharacterData::DeleteDataFuncNum, DontDelete|Function, 2, 0 },
       
    99     { "replaceData", JSCharacterData::ReplaceDataFuncNum, DontDelete|Function, 3, 0 }
       
   100 };
       
   101 
       
   102 static const HashTable JSCharacterDataPrototypeTable = 
       
   103 {
       
   104     2, 6, JSCharacterDataPrototypeTableEntries, 5
       
   105 };
       
   106 
       
   107 const ClassInfo JSCharacterDataPrototype::info = { "CharacterDataPrototype", 0, &JSCharacterDataPrototypeTable, 0 };
       
   108 
       
   109 JSObject* JSCharacterDataPrototype::self(ExecState* exec)
       
   110 {
       
   111     return KJS::cacheGlobalObject<JSCharacterDataPrototype>(exec, "[[JSCharacterData.prototype]]");
       
   112 }
       
   113 
       
   114 bool JSCharacterDataPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   115 {
       
   116     return getStaticFunctionSlot<JSCharacterDataPrototypeFunction, JSObject>(exec, &JSCharacterDataPrototypeTable, this, propertyName, slot);
       
   117 }
       
   118 
       
   119 const ClassInfo JSCharacterData::info = { "CharacterData", &JSEventTargetNode::info, &JSCharacterDataTable, 0 };
       
   120 
       
   121 JSCharacterData::JSCharacterData(ExecState* exec, CharacterData* impl)
       
   122     : JSEventTargetNode(exec, impl)
       
   123 {
       
   124     setPrototype(JSCharacterDataPrototype::self(exec));
       
   125 }
       
   126 
       
   127 bool JSCharacterData::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
       
   128 {
       
   129     return getStaticValueSlot<JSCharacterData, JSEventTargetNode>(exec, &JSCharacterDataTable, this, propertyName, slot);
       
   130 }
       
   131 
       
   132 JSValue* JSCharacterData::getValueProperty(ExecState* exec, int token) const
       
   133 {
       
   134     switch (token) {
       
   135     case DataAttrNum: {
       
   136         CharacterData* imp = static_cast<CharacterData*>(impl());
       
   137 
       
   138         return jsString(imp->data());
       
   139     }
       
   140     case LengthAttrNum: {
       
   141         CharacterData* imp = static_cast<CharacterData*>(impl());
       
   142 
       
   143         return jsNumber(imp->length());
       
   144     }
       
   145     case ConstructorAttrNum:
       
   146         return getConstructor(exec);
       
   147     }
       
   148     return 0;
       
   149 }
       
   150 
       
   151 void JSCharacterData::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
       
   152 {
       
   153     lookupPut<JSCharacterData, JSEventTargetNode>(exec, propertyName, value, attr, &JSCharacterDataTable, this);
       
   154 }
       
   155 
       
   156 void JSCharacterData::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
       
   157 {
       
   158     switch (token) {
       
   159     case DataAttrNum: {
       
   160         CharacterData* imp = static_cast<CharacterData*>(impl());
       
   161 
       
   162         ExceptionCode ec = 0;
       
   163         imp->setData(valueToStringWithNullCheck(exec, value), ec);
       
   164         setDOMException(exec, ec);
       
   165         break;
       
   166     }
       
   167     }
       
   168 }
       
   169 
       
   170 JSValue* JSCharacterData::getConstructor(ExecState* exec)
       
   171 {
       
   172     return KJS::cacheGlobalObject<JSCharacterDataConstructor>(exec, "[[CharacterData.constructor]]");
       
   173 }
       
   174 JSValue* JSCharacterDataPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
       
   175 {
       
   176     if (!thisObj->inherits(&JSCharacterData::info))
       
   177       return throwError(exec, TypeError);
       
   178 
       
   179     CharacterData* imp = static_cast<CharacterData*>(static_cast<JSCharacterData*>(thisObj)->impl());
       
   180 
       
   181     switch (id) {
       
   182     case JSCharacterData::SubstringDataFuncNum: {
       
   183         ExceptionCode ec = 0;
       
   184         bool offsetOk;
       
   185         int offset = args[0]->toInt32(exec, offsetOk);
       
   186         if (!offsetOk) {
       
   187             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   188             return jsUndefined();
       
   189         }
       
   190         if (offset < 0) {
       
   191             setDOMException(exec, INDEX_SIZE_ERR);
       
   192             return jsUndefined();
       
   193         }
       
   194         bool lengthOk;
       
   195         int length = args[1]->toInt32(exec, lengthOk);
       
   196         if (!lengthOk) {
       
   197             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   198             return jsUndefined();
       
   199         }
       
   200         if (length < 0) {
       
   201             setDOMException(exec, INDEX_SIZE_ERR);
       
   202             return jsUndefined();
       
   203         }
       
   204 
       
   205 
       
   206         KJS::JSValue* result = jsStringOrNull(imp->substringData(offset, length, ec));
       
   207         setDOMException(exec, ec);
       
   208         return result;
       
   209     }
       
   210     case JSCharacterData::AppendDataFuncNum: {
       
   211         ExceptionCode ec = 0;
       
   212         String data = args[0]->toString(exec);
       
   213 
       
   214         imp->appendData(data, ec);
       
   215         setDOMException(exec, ec);
       
   216         return jsUndefined();
       
   217     }
       
   218     case JSCharacterData::InsertDataFuncNum: {
       
   219         ExceptionCode ec = 0;
       
   220         bool offsetOk;
       
   221         int offset = args[0]->toInt32(exec, offsetOk);
       
   222         if (!offsetOk) {
       
   223             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   224             return jsUndefined();
       
   225         }
       
   226         if (offset < 0) {
       
   227             setDOMException(exec, INDEX_SIZE_ERR);
       
   228             return jsUndefined();
       
   229         }
       
   230         String data = args[1]->toString(exec);
       
   231 
       
   232         imp->insertData(offset, data, ec);
       
   233         setDOMException(exec, ec);
       
   234         return jsUndefined();
       
   235     }
       
   236     case JSCharacterData::DeleteDataFuncNum: {
       
   237         ExceptionCode ec = 0;
       
   238         bool offsetOk;
       
   239         int offset = args[0]->toInt32(exec, offsetOk);
       
   240         if (!offsetOk) {
       
   241             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   242             return jsUndefined();
       
   243         }
       
   244         if (offset < 0) {
       
   245             setDOMException(exec, INDEX_SIZE_ERR);
       
   246             return jsUndefined();
       
   247         }
       
   248         bool lengthOk;
       
   249         int length = args[1]->toInt32(exec, lengthOk);
       
   250         if (!lengthOk) {
       
   251             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   252             return jsUndefined();
       
   253         }
       
   254         if (length < 0) {
       
   255             setDOMException(exec, INDEX_SIZE_ERR);
       
   256             return jsUndefined();
       
   257         }
       
   258 
       
   259         imp->deleteData(offset, length, ec);
       
   260         setDOMException(exec, ec);
       
   261         return jsUndefined();
       
   262     }
       
   263     case JSCharacterData::ReplaceDataFuncNum: {
       
   264         ExceptionCode ec = 0;
       
   265         bool offsetOk;
       
   266         int offset = args[0]->toInt32(exec, offsetOk);
       
   267         if (!offsetOk) {
       
   268             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   269             return jsUndefined();
       
   270         }
       
   271         if (offset < 0) {
       
   272             setDOMException(exec, INDEX_SIZE_ERR);
       
   273             return jsUndefined();
       
   274         }
       
   275         bool lengthOk;
       
   276         int length = args[1]->toInt32(exec, lengthOk);
       
   277         if (!lengthOk) {
       
   278             setDOMException(exec, TYPE_MISMATCH_ERR);
       
   279             return jsUndefined();
       
   280         }
       
   281         if (length < 0) {
       
   282             setDOMException(exec, INDEX_SIZE_ERR);
       
   283             return jsUndefined();
       
   284         }
       
   285         String data = args[2]->toString(exec);
       
   286 
       
   287         imp->replaceData(offset, length, data, ec);
       
   288         setDOMException(exec, ec);
       
   289         return jsUndefined();
       
   290     }
       
   291     }
       
   292     return 0;
       
   293 }
       
   294 
       
   295 }