|
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 "JSText.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "ExceptionCode.h" |
|
28 #include "JSText.h" |
|
29 #include "Text.h" |
|
30 |
|
31 using namespace KJS; |
|
32 |
|
33 namespace WebCore { |
|
34 |
|
35 /* Hash table */ |
|
36 |
|
37 static const HashEntry JSTextTableEntries[] = |
|
38 { |
|
39 { "constructor", JSText::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 } |
|
40 }; |
|
41 |
|
42 static const HashTable JSTextTable = |
|
43 { |
|
44 2, 1, JSTextTableEntries, 1 |
|
45 }; |
|
46 |
|
47 /* Hash table for constructor */ |
|
48 |
|
49 static const HashEntry JSTextConstructorTableEntries[] = |
|
50 { |
|
51 { 0, 0, 0, 0, 0 } |
|
52 }; |
|
53 |
|
54 static const HashTable JSTextConstructorTable = |
|
55 { |
|
56 2, 1, JSTextConstructorTableEntries, 1 |
|
57 }; |
|
58 |
|
59 class JSTextConstructor : public DOMObject { |
|
60 public: |
|
61 JSTextConstructor(ExecState* exec) |
|
62 { |
|
63 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
64 putDirect(exec->propertyNames().prototype, JSTextPrototype::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 }; |
|
73 |
|
74 const ClassInfo JSTextConstructor::info = { "TextConstructor", 0, &JSTextConstructorTable, 0 }; |
|
75 |
|
76 bool JSTextConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
77 { |
|
78 return getStaticValueSlot<JSTextConstructor, DOMObject>(exec, &JSTextConstructorTable, this, propertyName, slot); |
|
79 } |
|
80 |
|
81 JSValue* JSTextConstructor::getValueProperty(ExecState*, int token) const |
|
82 { |
|
83 // The token is the numeric value of its associated constant |
|
84 return jsNumber(token); |
|
85 } |
|
86 |
|
87 /* Hash table for prototype */ |
|
88 |
|
89 static const HashEntry JSTextPrototypeTableEntries[] = |
|
90 { |
|
91 { "splitText", JSText::SplitTextFuncNum, DontDelete|Function, 1, 0 } |
|
92 }; |
|
93 |
|
94 static const HashTable JSTextPrototypeTable = |
|
95 { |
|
96 2, 1, JSTextPrototypeTableEntries, 1 |
|
97 }; |
|
98 |
|
99 const ClassInfo JSTextPrototype::info = { "TextPrototype", 0, &JSTextPrototypeTable, 0 }; |
|
100 |
|
101 JSObject* JSTextPrototype::self(ExecState* exec) |
|
102 { |
|
103 return KJS::cacheGlobalObject<JSTextPrototype>(exec, "[[JSText.prototype]]"); |
|
104 } |
|
105 |
|
106 bool JSTextPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
107 { |
|
108 return getStaticFunctionSlot<JSTextPrototypeFunction, JSObject>(exec, &JSTextPrototypeTable, this, propertyName, slot); |
|
109 } |
|
110 |
|
111 const ClassInfo JSText::info = { "Text", &JSCharacterData::info, &JSTextTable, 0 }; |
|
112 |
|
113 JSText::JSText(ExecState* exec, Text* impl) |
|
114 : JSCharacterData(exec, impl) |
|
115 { |
|
116 setPrototype(JSTextPrototype::self(exec)); |
|
117 } |
|
118 |
|
119 bool JSText::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
120 { |
|
121 return getStaticValueSlot<JSText, JSCharacterData>(exec, &JSTextTable, this, propertyName, slot); |
|
122 } |
|
123 |
|
124 JSValue* JSText::getValueProperty(ExecState* exec, int token) const |
|
125 { |
|
126 switch (token) { |
|
127 case ConstructorAttrNum: |
|
128 return getConstructor(exec); |
|
129 } |
|
130 return 0; |
|
131 } |
|
132 |
|
133 JSValue* JSText::getConstructor(ExecState* exec) |
|
134 { |
|
135 return KJS::cacheGlobalObject<JSTextConstructor>(exec, "[[Text.constructor]]"); |
|
136 } |
|
137 JSValue* JSTextPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
138 { |
|
139 if (!thisObj->inherits(&JSText::info)) |
|
140 return throwError(exec, TypeError); |
|
141 |
|
142 Text* imp = static_cast<Text*>(static_cast<JSText*>(thisObj)->impl()); |
|
143 |
|
144 switch (id) { |
|
145 case JSText::SplitTextFuncNum: { |
|
146 ExceptionCode ec = 0; |
|
147 bool offsetOk; |
|
148 int offset = args[0]->toInt32(exec, offsetOk); |
|
149 if (!offsetOk) { |
|
150 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
151 return jsUndefined(); |
|
152 } |
|
153 if (offset < 0) { |
|
154 setDOMException(exec, INDEX_SIZE_ERR); |
|
155 return jsUndefined(); |
|
156 } |
|
157 |
|
158 |
|
159 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->splitText(offset, ec))); |
|
160 setDOMException(exec, ec); |
|
161 return result; |
|
162 } |
|
163 } |
|
164 return 0; |
|
165 } |
|
166 |
|
167 } |