mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 1 | // -*- c-basic-offset: 2 -*- |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 2 | /* |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 3 | * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) |
darin@apple.com | a313ead | 2008-01-27 08:54:25 +0000 | [diff] [blame] | 4 | * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
mjs | cdff33b | 2006-01-23 21:41:36 +0000 | [diff] [blame] | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 19 | * |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
mjs | b64c50a | 2005-10-03 21:13:12 +0000 | [diff] [blame] | 22 | #include "config.h" |
| 23 | #include "string_object.h" |
| 24 | |
mjs | 308be5a | 2006-08-14 03:06:14 +0000 | [diff] [blame] | 25 | #include "JSWrapperObject.h" |
mrowe@apple.com | e54b76f | 2007-12-06 04:14:59 +0000 | [diff] [blame] | 26 | #include "PropertyNameArray.h" |
darin@apple.com | 5c0863d | 2008-06-16 04:17:44 +0000 | [diff] [blame] | 27 | #include "ArrayPrototype.h" |
darin | 36d1136 | 2006-04-11 16:30:21 +0000 | [diff] [blame] | 28 | #include "error_object.h" |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 29 | #include "operations.h" |
darin@apple.com | 5c0863d | 2008-06-16 04:17:44 +0000 | [diff] [blame] | 30 | #include "RegExpObject.h" |
mrowe@apple.com | 1c11eae | 2007-10-29 03:00:16 +0000 | [diff] [blame] | 31 | #include <wtf/MathExtras.h> |
ap@webkit.org | afd0318 | 2008-03-06 17:50:08 +0000 | [diff] [blame] | 32 | #include <wtf/unicode/Collator.h> |
andersca | aa39c42 | 2006-12-20 20:11:47 +0000 | [diff] [blame] | 33 | |
darin | f9e5d6c | 2007-01-09 14:54:26 +0000 | [diff] [blame] | 34 | using namespace WTF; |
| 35 | |
| 36 | namespace KJS { |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 37 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 38 | static JSValue* stringProtoFuncToString(ExecState*, JSObject*, JSValue*, const ArgList&); |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 39 | static JSValue* stringProtoFuncCharAt(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 40 | static JSValue* stringProtoFuncCharCodeAt(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 41 | static JSValue* stringProtoFuncConcat(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 42 | static JSValue* stringProtoFuncIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 43 | static JSValue* stringProtoFuncLastIndexOf(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 44 | static JSValue* stringProtoFuncMatch(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 45 | static JSValue* stringProtoFuncReplace(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 46 | static JSValue* stringProtoFuncSearch(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 47 | static JSValue* stringProtoFuncSlice(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 48 | static JSValue* stringProtoFuncSplit(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 49 | static JSValue* stringProtoFuncSubstr(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 50 | static JSValue* stringProtoFuncSubstring(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 51 | static JSValue* stringProtoFuncToLowerCase(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 52 | static JSValue* stringProtoFuncToUpperCase(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 53 | static JSValue* stringProtoFuncToLocaleLowerCase(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 54 | static JSValue* stringProtoFuncToLocaleUpperCase(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 55 | static JSValue* stringProtoFuncLocaleCompare(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 56 | |
| 57 | static JSValue* stringProtoFuncBig(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 58 | static JSValue* stringProtoFuncSmall(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 59 | static JSValue* stringProtoFuncBlink(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 60 | static JSValue* stringProtoFuncBold(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 61 | static JSValue* stringProtoFuncFixed(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 62 | static JSValue* stringProtoFuncItalics(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 63 | static JSValue* stringProtoFuncStrike(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 64 | static JSValue* stringProtoFuncSub(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 65 | static JSValue* stringProtoFuncSup(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 66 | static JSValue* stringProtoFuncFontcolor(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 67 | static JSValue* stringProtoFuncFontsize(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 68 | static JSValue* stringProtoFuncAnchor(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 69 | static JSValue* stringProtoFuncLink(ExecState*, JSObject*, JSValue*, const ArgList&); |
| 70 | |
| 71 | } |
| 72 | |
| 73 | #include "string_object.lut.h" |
| 74 | |
| 75 | namespace KJS { |
| 76 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 77 | // ------------------------------ StringObject ---------------------------- |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 78 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 79 | const ClassInfo StringObject::info = { "String", 0, 0, 0 }; |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 80 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 81 | StringObject::StringObject(ExecState* exec, JSObject* proto) |
mjs | 308be5a | 2006-08-14 03:06:14 +0000 | [diff] [blame] | 82 | : JSWrapperObject(proto) |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 83 | { |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 84 | setInternalValue(jsString(exec, "")); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 85 | } |
| 86 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 87 | StringObject::StringObject(JSObject* proto, JSString* string) |
mjs | 06ed466 | 2007-07-25 21:50:00 +0000 | [diff] [blame] | 88 | : JSWrapperObject(proto) |
| 89 | { |
| 90 | setInternalValue(string); |
| 91 | } |
| 92 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 93 | StringObject::StringObject(ExecState* exec, JSObject* proto, const UString& string) |
mjs | 308be5a | 2006-08-14 03:06:14 +0000 | [diff] [blame] | 94 | : JSWrapperObject(proto) |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 95 | { |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 96 | setInternalValue(jsString(exec, string)); |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 97 | } |
| 98 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 99 | bool StringObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 100 | { |
darin@apple.com | 68dbe31 | 2008-06-13 04:53:56 +0000 | [diff] [blame] | 101 | if (internalValue()->getStringPropertySlot(exec, propertyName, slot)) |
eseidel | 74efded | 2007-10-29 07:55:34 +0000 | [diff] [blame] | 102 | return true; |
eseidel | 74efded | 2007-10-29 07:55:34 +0000 | [diff] [blame] | 103 | return JSObject::getOwnPropertySlot(exec, propertyName, slot); |
| 104 | } |
| 105 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 106 | bool StringObject::getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) |
eseidel | 74efded | 2007-10-29 07:55:34 +0000 | [diff] [blame] | 107 | { |
darin@apple.com | 68dbe31 | 2008-06-13 04:53:56 +0000 | [diff] [blame] | 108 | if (internalValue()->getStringPropertySlot(propertyName, slot)) |
| 109 | return true; |
ap@webkit.org | 07e5bce | 2008-06-16 23:28:38 +0000 | [diff] [blame] | 110 | return JSObject::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot); |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 111 | } |
| 112 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 113 | void StringObject::put(ExecState* exec, const Identifier& propertyName, JSValue* value) |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 114 | { |
darin@apple.com | e25e04e | 2008-02-24 05:01:27 +0000 | [diff] [blame] | 115 | if (propertyName == exec->propertyNames().length) |
| 116 | return; |
| 117 | JSObject::put(exec, propertyName, value); |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 118 | } |
| 119 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 120 | bool StringObject::deleteProperty(ExecState *exec, const Identifier &propertyName) |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 121 | { |
mjs | 23fc88d | 2007-03-19 05:43:47 +0000 | [diff] [blame] | 122 | if (propertyName == exec->propertyNames().length) |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 123 | return false; |
darin | 35940e8 | 2005-12-11 02:06:17 +0000 | [diff] [blame] | 124 | return JSObject::deleteProperty(exec, propertyName); |
darin | a6cae2c | 2002-11-19 06:53:35 +0000 | [diff] [blame] | 125 | } |
| 126 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 127 | void StringObject::getPropertyNames(ExecState* exec, PropertyNameArray& propertyNames) |
ggaren | c17d984 | 2005-12-29 11:38:57 +0000 | [diff] [blame] | 128 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 129 | int size = internalValue()->value().size(); |
ggaren | d49ee98 | 2006-07-12 10:01:06 +0000 | [diff] [blame] | 130 | for (int i = 0; i < size; i++) |
ap@webkit.org | 07e5bce | 2008-06-16 23:28:38 +0000 | [diff] [blame] | 131 | propertyNames.add(Identifier(exec, UString::from(i))); |
mjs | b3598b8 | 2006-07-16 21:06:28 +0000 | [diff] [blame] | 132 | return JSObject::getPropertyNames(exec, propertyNames); |
ggaren | c17d984 | 2005-12-29 11:38:57 +0000 | [diff] [blame] | 133 | } |
| 134 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 135 | UString StringObject::toString(ExecState*) const |
| 136 | { |
| 137 | return internalValue()->value(); |
| 138 | } |
| 139 | |
| 140 | UString StringObject::toThisString(ExecState*) const |
| 141 | { |
| 142 | return internalValue()->value(); |
| 143 | } |
| 144 | |
| 145 | JSString* StringObject::toThisJSString(ExecState*) |
| 146 | { |
| 147 | return internalValue(); |
| 148 | } |
| 149 | |
darin | 35940e8 | 2005-12-11 02:06:17 +0000 | [diff] [blame] | 150 | // ------------------------------ StringPrototype --------------------------- |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 151 | const ClassInfo StringPrototype::info = { "String", &StringObject::info, 0, ExecState::stringTable }; |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 152 | /* Source for string_object.lut.h |
| 153 | @begin stringTable 26 |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 154 | toString stringProtoFuncToString DontEnum|Function 0 |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 155 | valueOf stringProtoFuncToString DontEnum|Function 0 |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 156 | charAt stringProtoFuncCharAt DontEnum|Function 1 |
| 157 | charCodeAt stringProtoFuncCharCodeAt DontEnum|Function 1 |
| 158 | concat stringProtoFuncConcat DontEnum|Function 1 |
| 159 | indexOf stringProtoFuncIndexOf DontEnum|Function 1 |
| 160 | lastIndexOf stringProtoFuncLastIndexOf DontEnum|Function 1 |
| 161 | match stringProtoFuncMatch DontEnum|Function 1 |
| 162 | replace stringProtoFuncReplace DontEnum|Function 2 |
| 163 | search stringProtoFuncSearch DontEnum|Function 1 |
| 164 | slice stringProtoFuncSlice DontEnum|Function 2 |
| 165 | split stringProtoFuncSplit DontEnum|Function 2 |
| 166 | substr stringProtoFuncSubstr DontEnum|Function 2 |
| 167 | substring stringProtoFuncSubstring DontEnum|Function 2 |
| 168 | toLowerCase stringProtoFuncToLowerCase DontEnum|Function 0 |
| 169 | toUpperCase stringProtoFuncToUpperCase DontEnum|Function 0 |
| 170 | toLocaleLowerCase stringProtoFuncToLocaleLowerCase DontEnum|Function 0 |
| 171 | toLocaleUpperCase stringProtoFuncToLocaleUpperCase DontEnum|Function 0 |
| 172 | localeCompare stringProtoFuncLocaleCompare DontEnum|Function 1 |
weinig@apple.com | 31afc95 | 2008-01-16 21:50:19 +0000 | [diff] [blame] | 173 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 174 | big stringProtoFuncBig DontEnum|Function 0 |
| 175 | small stringProtoFuncSmall DontEnum|Function 0 |
| 176 | blink stringProtoFuncBlink DontEnum|Function 0 |
| 177 | bold stringProtoFuncBold DontEnum|Function 0 |
| 178 | fixed stringProtoFuncFixed DontEnum|Function 0 |
| 179 | italics stringProtoFuncItalics DontEnum|Function 0 |
| 180 | strike stringProtoFuncStrike DontEnum|Function 0 |
| 181 | sub stringProtoFuncSub DontEnum|Function 0 |
| 182 | sup stringProtoFuncSup DontEnum|Function 0 |
| 183 | fontcolor stringProtoFuncFontcolor DontEnum|Function 1 |
| 184 | fontsize stringProtoFuncFontsize DontEnum|Function 1 |
| 185 | anchor stringProtoFuncAnchor DontEnum|Function 1 |
| 186 | link stringProtoFuncLink DontEnum|Function 1 |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 187 | @end |
| 188 | */ |
| 189 | // ECMA 15.5.4 |
mjs | 23fc88d | 2007-03-19 05:43:47 +0000 | [diff] [blame] | 190 | StringPrototype::StringPrototype(ExecState* exec, ObjectPrototype* objProto) |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 191 | : StringObject(exec, objProto) |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 192 | { |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 193 | // The constructor will be added later, after StringConstructor has been built |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 194 | putDirect(exec->propertyNames().length, jsNumber(exec, 0), DontDelete | ReadOnly | DontEnum); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 195 | } |
| 196 | |
darin | 35940e8 | 2005-12-11 02:06:17 +0000 | [diff] [blame] | 197 | bool StringPrototype::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot &slot) |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 198 | { |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 199 | return getStaticFunctionSlot<StringObject>(exec, ExecState::stringTable(exec), this, propertyName, slot); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 200 | } |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 201 | |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 202 | // ------------------------------ Functions -------------------------- |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 203 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 204 | static inline UString substituteBackreferences(const UString& replacement, const UString& source, const int* ovector, RegExp* reg) |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 205 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 206 | UString substitutedReplacement; |
| 207 | int offset = 0; |
ddkilzer | 31459a5 | 2006-06-03 04:56:56 +0000 | [diff] [blame] | 208 | int i = -1; |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 209 | while ((i = replacement.find('$', i + 1)) != -1) { |
| 210 | if (i + 1 == replacement.size()) |
ddkilzer | 31459a5 | 2006-06-03 04:56:56 +0000 | [diff] [blame] | 211 | break; |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 212 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 213 | unsigned short ref = replacement[i + 1]; |
| 214 | if (ref == '$') { |
| 215 | // "$$" -> "$" |
| 216 | ++i; |
| 217 | substitutedReplacement.append(replacement.data() + offset, i - offset); |
| 218 | offset = i + 1; |
| 219 | substitutedReplacement.append('$'); |
ddkilzer | 31459a5 | 2006-06-03 04:56:56 +0000 | [diff] [blame] | 220 | continue; |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 221 | } |
| 222 | |
| 223 | int backrefStart; |
| 224 | int backrefLength; |
| 225 | int advance = 0; |
| 226 | if (ref == '&') { |
ddkilzer | 31459a5 | 2006-06-03 04:56:56 +0000 | [diff] [blame] | 227 | backrefStart = ovector[0]; |
| 228 | backrefLength = ovector[1] - backrefStart; |
| 229 | } else if (ref == '`') { |
| 230 | backrefStart = 0; |
| 231 | backrefLength = ovector[0]; |
| 232 | } else if (ref == '\'') { |
| 233 | backrefStart = ovector[1]; |
| 234 | backrefLength = source.size() - backrefStart; |
| 235 | } else if (ref >= '0' && ref <= '9') { |
| 236 | // 1- and 2-digit back references are allowed |
| 237 | unsigned backrefIndex = ref - '0'; |
ggaren@apple.com | 8a50ec5 | 2007-11-07 17:18:39 +0000 | [diff] [blame] | 238 | if (backrefIndex > reg->numSubpatterns()) |
ggaren | b3ebb43 | 2006-06-06 05:59:43 +0000 | [diff] [blame] | 239 | continue; |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 240 | if (replacement.size() > i + 2) { |
| 241 | ref = replacement[i + 2]; |
ddkilzer | 31459a5 | 2006-06-03 04:56:56 +0000 | [diff] [blame] | 242 | if (ref >= '0' && ref <= '9') { |
| 243 | backrefIndex = 10 * backrefIndex + ref - '0'; |
ggaren@apple.com | 8a50ec5 | 2007-11-07 17:18:39 +0000 | [diff] [blame] | 244 | if (backrefIndex > reg->numSubpatterns()) |
ggaren | b3ebb43 | 2006-06-06 05:59:43 +0000 | [diff] [blame] | 245 | backrefIndex = backrefIndex / 10; // Fall back to the 1-digit reference |
| 246 | else |
| 247 | advance = 1; |
ddkilzer | 31459a5 | 2006-06-03 04:56:56 +0000 | [diff] [blame] | 248 | } |
| 249 | } |
ddkilzer | 31459a5 | 2006-06-03 04:56:56 +0000 | [diff] [blame] | 250 | backrefStart = ovector[2 * backrefIndex]; |
| 251 | backrefLength = ovector[2 * backrefIndex + 1] - backrefStart; |
| 252 | } else |
| 253 | continue; |
| 254 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 255 | if (i - offset) |
| 256 | substitutedReplacement.append(replacement.data() + offset, i - offset); |
| 257 | i += 1 + advance; |
| 258 | offset = i + 1; |
| 259 | substitutedReplacement.append(source.data() + backrefStart, backrefLength); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 260 | } |
| 261 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 262 | if (!offset) |
| 263 | return replacement; |
| 264 | |
| 265 | if (replacement.size() - offset) |
| 266 | substitutedReplacement.append(replacement.data() + offset, replacement.size() - offset); |
| 267 | |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 268 | return substitutedReplacement; |
| 269 | } |
ap@webkit.org | afd0318 | 2008-03-06 17:50:08 +0000 | [diff] [blame] | 270 | |
weinig | 9835234 | 2007-05-29 23:07:02 +0000 | [diff] [blame] | 271 | static inline int localeCompare(const UString& a, const UString& b) |
| 272 | { |
ap@webkit.org | afd0318 | 2008-03-06 17:50:08 +0000 | [diff] [blame] | 273 | return Collator::userDefault()->collate(reinterpret_cast<const ::UChar*>(a.data()), a.size(), reinterpret_cast<const ::UChar*>(b.data()), b.size()); |
weinig | 9835234 | 2007-05-29 23:07:02 +0000 | [diff] [blame] | 274 | } |
andersca | aa39c42 | 2006-12-20 20:11:47 +0000 | [diff] [blame] | 275 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 276 | JSValue* stringProtoFuncReplace(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 277 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 278 | JSString* sourceVal = thisValue->toThisJSString(exec); |
| 279 | const UString& source = sourceVal->value(); |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 280 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 281 | JSValue* pattern = args[0]; |
| 282 | |
| 283 | JSValue* replacement = args[1]; |
| 284 | UString replacementString; |
| 285 | CallData callData; |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 286 | CallType callType = replacement->getCallData(callData); |
| 287 | if (callType == CallTypeNone) |
darin | c13d2ca | 2005-08-08 04:07:46 +0000 | [diff] [blame] | 288 | replacementString = replacement->toString(exec); |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 289 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 290 | if (pattern->isObject(&RegExpObject::info)) { |
| 291 | RegExp* reg = static_cast<RegExpObject*>(pattern)->regExp(); |
ggaren@apple.com | 8a50ec5 | 2007-11-07 17:18:39 +0000 | [diff] [blame] | 292 | bool global = reg->global(); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 293 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 294 | RegExpConstructor* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 295 | |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 296 | int lastIndex = 0; |
| 297 | int startPosition = 0; |
| 298 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 299 | Vector<UString::Range, 16> sourceRanges; |
| 300 | Vector<UString, 16> replacements; |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 301 | |
| 302 | // This is either a loop (if global is set) or a one-way (if not). |
| 303 | do { |
darin | 9fa44df | 2007-10-31 14:46:41 +0000 | [diff] [blame] | 304 | int matchIndex; |
| 305 | int matchLen; |
| 306 | int* ovector; |
| 307 | regExpObj->performMatch(reg, source, startPosition, matchIndex, matchLen, &ovector); |
| 308 | if (matchIndex < 0) |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 309 | break; |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 310 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 311 | sourceRanges.append(UString::Range(lastIndex, matchIndex - lastIndex)); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 312 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 313 | if (callType != CallTypeNone) { |
ggaren | 91f0374 | 2005-10-11 20:43:49 +0000 | [diff] [blame] | 314 | int completeMatchStart = ovector[0]; |
darin@apple.com | 80d38f9 | 2008-06-16 05:28:46 +0000 | [diff] [blame] | 315 | ArgList args; |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 316 | |
ggaren@apple.com | 8a50ec5 | 2007-11-07 17:18:39 +0000 | [diff] [blame] | 317 | for (unsigned i = 0; i < reg->numSubpatterns() + 1; i++) { |
darin | 9fa44df | 2007-10-31 14:46:41 +0000 | [diff] [blame] | 318 | int matchStart = ovector[i * 2]; |
| 319 | int matchLen = ovector[i * 2 + 1] - matchStart; |
bdash | 7891c02 | 2007-06-21 00:00:12 +0000 | [diff] [blame] | 320 | |
darin | cd9cd76 | 2007-08-13 02:42:17 +0000 | [diff] [blame] | 321 | if (matchStart < 0) |
| 322 | args.append(jsUndefined()); |
| 323 | else |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 324 | args.append(jsString(exec, source.substr(matchStart, matchLen))); |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 325 | } |
| 326 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 327 | args.append(jsNumber(exec, completeMatchStart)); |
mjs | 0b00317 | 2007-08-05 05:20:35 +0000 | [diff] [blame] | 328 | args.append(sourceVal); |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 329 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 330 | replacements.append(call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec)); |
bdash | 7891c02 | 2007-06-21 00:00:12 +0000 | [diff] [blame] | 331 | } else |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 332 | replacements.append(substituteBackreferences(replacementString, source, ovector, reg)); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 333 | |
| 334 | lastIndex = matchIndex + matchLen; |
| 335 | startPosition = lastIndex; |
| 336 | |
| 337 | // special case of empty match |
| 338 | if (matchLen == 0) { |
| 339 | startPosition++; |
| 340 | if (startPosition > source.size()) |
| 341 | break; |
| 342 | } |
| 343 | } while (global); |
| 344 | |
| 345 | if (lastIndex < source.size()) |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 346 | sourceRanges.append(UString::Range(lastIndex, source.size() - lastIndex)); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 347 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 348 | UString result = source.spliceSubstringsWithSeparators(sourceRanges.data(), sourceRanges.size(), replacements.data(), replacements.size()); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 349 | |
mjs | 0b00317 | 2007-08-05 05:20:35 +0000 | [diff] [blame] | 350 | if (result == source) |
| 351 | return sourceVal; |
| 352 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 353 | return jsString(exec, result); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 354 | } |
darin | 44b175c | 2005-04-29 00:22:55 +0000 | [diff] [blame] | 355 | |
| 356 | // First arg is a string |
darin | c13d2ca | 2005-08-08 04:07:46 +0000 | [diff] [blame] | 357 | UString patternString = pattern->toString(exec); |
darin | 44b175c | 2005-04-29 00:22:55 +0000 | [diff] [blame] | 358 | int matchPos = source.find(patternString); |
| 359 | int matchLen = patternString.size(); |
| 360 | // Do the replacement |
| 361 | if (matchPos == -1) |
mjs | 0b00317 | 2007-08-05 05:20:35 +0000 | [diff] [blame] | 362 | return sourceVal; |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 363 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 364 | if (callType != CallTypeNone) { |
darin@apple.com | 80d38f9 | 2008-06-16 05:28:46 +0000 | [diff] [blame] | 365 | ArgList args; |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 366 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 367 | args.append(jsString(exec, source.substr(matchPos, matchLen))); |
| 368 | args.append(jsNumber(exec, matchPos)); |
mjs | 0b00317 | 2007-08-05 05:20:35 +0000 | [diff] [blame] | 369 | args.append(sourceVal); |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 370 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 371 | replacementString = call(exec, replacement, callType, callData, exec->globalThisValue(), args)->toString(exec); |
darin | e0dd924 | 2005-06-22 17:26:17 +0000 | [diff] [blame] | 372 | } |
| 373 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 374 | return jsString(exec, source.substr(0, matchPos) + replacementString + source.substr(matchPos + matchLen)); |
mjs | 5d90e06 | 2004-09-15 00:16:34 +0000 | [diff] [blame] | 375 | } |
| 376 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 377 | JSValue* stringProtoFuncToString(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 378 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 379 | // Also used for valueOf. |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 380 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 381 | if (thisValue->isString()) |
| 382 | return thisValue; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 383 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 384 | if (thisValue->isObject(&StringObject::info)) |
| 385 | return static_cast<StringObject*>(thisValue)->internalValue(); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 386 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 387 | return throwError(exec, TypeError); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 388 | } |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 389 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 390 | JSValue* stringProtoFuncCharAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 391 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 392 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 393 | int len = s.size(); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 394 | |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 395 | UString u; |
| 396 | JSValue* a0 = args[0]; |
| 397 | double dpos = a0->toInteger(exec); |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 398 | if (dpos >= 0 && dpos < len) |
darin | a51d07b | 2004-02-02 21:23:17 +0000 | [diff] [blame] | 399 | u = s.substr(static_cast<int>(dpos), 1); |
darin | 0dd092a | 2004-08-02 21:44:42 +0000 | [diff] [blame] | 400 | else |
| 401 | u = ""; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 402 | return jsString(exec, u); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 403 | } |
| 404 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 405 | JSValue* stringProtoFuncCharCodeAt(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 406 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 407 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 408 | int len = s.size(); |
| 409 | |
| 410 | JSValue* result = 0; |
| 411 | |
| 412 | JSValue* a0 = args[0]; |
| 413 | double dpos = a0->toInteger(exec); |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 414 | if (dpos >= 0 && dpos < len) |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 415 | result = jsNumber(exec, s[static_cast<int>(dpos)]); |
darin | f0d7326 | 2004-09-27 01:54:30 +0000 | [diff] [blame] | 416 | else |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 417 | result = jsNaN(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 418 | return result; |
| 419 | } |
| 420 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 421 | JSValue* stringProtoFuncConcat(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 422 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 423 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 424 | |
darin@apple.com | 80d38f9 | 2008-06-16 05:28:46 +0000 | [diff] [blame] | 425 | ArgList::const_iterator end = args.end(); |
| 426 | for (ArgList::const_iterator it = args.begin(); it != end; ++it) { |
ggaren | 879ab75 | 2007-11-05 21:27:15 +0000 | [diff] [blame] | 427 | s += (*it)->toString(exec); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 428 | } |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 429 | return jsString(exec, s); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 430 | } |
| 431 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 432 | JSValue* stringProtoFuncIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 433 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 434 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 435 | int len = s.size(); |
| 436 | |
| 437 | JSValue* a0 = args[0]; |
| 438 | JSValue* a1 = args[1]; |
| 439 | UString u2 = a0->toString(exec); |
| 440 | double dpos = a1->toInteger(exec); |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 441 | if (dpos < 0) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 442 | dpos = 0; |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 443 | else if (dpos > len) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 444 | dpos = len; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 445 | return jsNumber(exec, s.find(u2, static_cast<int>(dpos))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 446 | } |
| 447 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 448 | JSValue* stringProtoFuncLastIndexOf(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 449 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 450 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 451 | int len = s.size(); |
| 452 | |
| 453 | JSValue* a0 = args[0]; |
| 454 | JSValue* a1 = args[1]; |
| 455 | |
| 456 | UString u2 = a0->toString(exec); |
| 457 | double dpos = a1->toIntegerPreserveNaN(exec); |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 458 | if (dpos < 0) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 459 | dpos = 0; |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 460 | else if (!(dpos <= len)) // true for NaN |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 461 | dpos = len; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 462 | return jsNumber(exec, s.rfind(u2, static_cast<int>(dpos))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 463 | } |
| 464 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 465 | JSValue* stringProtoFuncMatch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 466 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 467 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 468 | |
| 469 | JSValue* a0 = args[0]; |
| 470 | |
| 471 | UString u = s; |
darin@apple.com | e4ba8cf | 2008-02-09 18:09:42 +0000 | [diff] [blame] | 472 | RefPtr<RegExp> reg; |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 473 | RegExpObject* imp = 0; |
| 474 | if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpObject::info)) { |
| 475 | reg = static_cast<RegExpObject *>(a0)->regExp(); |
ggaren | 91f0374 | 2005-10-11 20:43:49 +0000 | [diff] [blame] | 476 | } else { |
| 477 | /* |
darin | b70665a | 2002-04-15 23:43:21 +0000 | [diff] [blame] | 478 | * ECMA 15.5.4.12 String.prototype.search (regexp) |
| 479 | * If regexp is not an object whose [[Class]] property is "RegExp", it is |
| 480 | * replaced with the result of the expression new RegExp(regexp). |
| 481 | */ |
darin@apple.com | e4ba8cf | 2008-02-09 18:09:42 +0000 | [diff] [blame] | 482 | reg = RegExp::create(a0->toString(exec)); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 483 | } |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 484 | RegExpConstructor* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); |
darin | 9fa44df | 2007-10-31 14:46:41 +0000 | [diff] [blame] | 485 | int pos; |
| 486 | int matchLength; |
darin@apple.com | e4ba8cf | 2008-02-09 18:09:42 +0000 | [diff] [blame] | 487 | regExpObj->performMatch(reg.get(), u, 0, pos, matchLength); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 488 | JSValue* result; |
| 489 | if (!(reg->global())) { |
| 490 | // case without 'g' flag is handled like RegExp.prototype.exec |
| 491 | if (pos < 0) |
| 492 | result = jsNull(); |
| 493 | else |
| 494 | result = regExpObj->arrayOfMatches(exec); |
darin | 74f6ed6 | 2002-07-22 05:38:39 +0000 | [diff] [blame] | 495 | } else { |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 496 | // return array of matches |
darin@apple.com | 80d38f9 | 2008-06-16 05:28:46 +0000 | [diff] [blame] | 497 | ArgList list; |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 498 | int lastIndex = 0; |
| 499 | while (pos >= 0) { |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 500 | list.append(jsString(exec, u.substr(pos, matchLength))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 501 | lastIndex = pos; |
| 502 | pos += matchLength == 0 ? 1 : matchLength; |
darin@apple.com | e4ba8cf | 2008-02-09 18:09:42 +0000 | [diff] [blame] | 503 | regExpObj->performMatch(reg.get(), u, pos, pos, matchLength); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 504 | } |
| 505 | if (imp) |
darin@apple.com | 8e21ef1 | 2008-02-06 17:33:07 +0000 | [diff] [blame] | 506 | imp->setLastIndex(lastIndex); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 507 | if (list.isEmpty()) { |
| 508 | // if there are no matches at all, it's important to return |
| 509 | // Null instead of an empty array, because this matches |
| 510 | // other browsers and because Null is a false value. |
| 511 | result = jsNull(); |
darin | 74f6ed6 | 2002-07-22 05:38:39 +0000 | [diff] [blame] | 512 | } else { |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 513 | result = constructArray(exec, list); |
darin | 74f6ed6 | 2002-07-22 05:38:39 +0000 | [diff] [blame] | 514 | } |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 515 | } |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 516 | return result; |
| 517 | } |
| 518 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 519 | JSValue* stringProtoFuncSearch(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 520 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 521 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 522 | |
| 523 | JSValue* a0 = args[0]; |
| 524 | |
| 525 | UString u = s; |
darin@apple.com | e4ba8cf | 2008-02-09 18:09:42 +0000 | [diff] [blame] | 526 | RefPtr<RegExp> reg; |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 527 | if (a0->isObject() && static_cast<JSObject*>(a0)->inherits(&RegExpObject::info)) { |
| 528 | reg = static_cast<RegExpObject*>(a0)->regExp(); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 529 | } else { |
| 530 | /* |
| 531 | * ECMA 15.5.4.12 String.prototype.search (regexp) |
| 532 | * If regexp is not an object whose [[Class]] property is "RegExp", it is |
| 533 | * replaced with the result of the expression new RegExp(regexp). |
| 534 | */ |
darin@apple.com | e4ba8cf | 2008-02-09 18:09:42 +0000 | [diff] [blame] | 535 | reg = RegExp::create(a0->toString(exec)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 536 | } |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 537 | RegExpConstructor* regExpObj = exec->lexicalGlobalObject()->regExpConstructor(); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 538 | int pos; |
| 539 | int matchLength; |
darin@apple.com | e4ba8cf | 2008-02-09 18:09:42 +0000 | [diff] [blame] | 540 | regExpObj->performMatch(reg.get(), u, 0, pos, matchLength); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 541 | return jsNumber(exec, pos); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 542 | } |
| 543 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 544 | JSValue* stringProtoFuncSlice(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 545 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 546 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 547 | int len = s.size(); |
| 548 | |
| 549 | JSValue* a0 = args[0]; |
| 550 | JSValue* a1 = args[1]; |
| 551 | |
| 552 | // The arg processing is very much like ArrayProtoFunc::Slice |
| 553 | double start = a0->toInteger(exec); |
| 554 | double end = a1->isUndefined() ? len : a1->toInteger(exec); |
| 555 | double from = start < 0 ? len + start : start; |
| 556 | double to = end < 0 ? len + end : end; |
| 557 | if (to > from && to > 0 && from < len) { |
ggaren | bace8b6 | 2005-11-06 05:48:45 +0000 | [diff] [blame] | 558 | if (from < 0) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 559 | from = 0; |
ggaren | bace8b6 | 2005-11-06 05:48:45 +0000 | [diff] [blame] | 560 | if (to > len) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 561 | to = len; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 562 | return jsString(exec, s.substr(static_cast<int>(from), static_cast<int>(to - from))); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 563 | } |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 564 | |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 565 | return jsString(exec, ""); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 566 | } |
| 567 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 568 | JSValue* stringProtoFuncSplit(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 569 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 570 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 571 | |
| 572 | JSValue* a0 = args[0]; |
| 573 | JSValue* a1 = args[1]; |
| 574 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 575 | JSObject* res = constructEmptyArray(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 576 | JSValue* result = res; |
| 577 | UString u = s; |
| 578 | int pos; |
| 579 | int i = 0; |
| 580 | int p0 = 0; |
darin | c13d2ca | 2005-08-08 04:07:46 +0000 | [diff] [blame] | 581 | uint32_t limit = a1->isUndefined() ? 0xFFFFFFFFU : a1->toUInt32(exec); |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 582 | if (a0->isObject() && static_cast<JSObject *>(a0)->inherits(&RegExpObject::info)) { |
| 583 | RegExp *reg = static_cast<RegExpObject *>(a0)->regExp(); |
darin | 9fa44df | 2007-10-31 14:46:41 +0000 | [diff] [blame] | 584 | if (u.isEmpty() && reg->match(u, 0) >= 0) { |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 585 | // empty string matched by regexp -> empty array |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 586 | res->put(exec, exec->propertyNames().length, jsNumber(exec, 0)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 587 | return result; |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 588 | } |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 589 | pos = 0; |
darin | e3385e9 | 2004-08-10 18:43:51 +0000 | [diff] [blame] | 590 | while (static_cast<uint32_t>(i) != limit && pos < u.size()) { |
darin | 9fa44df | 2007-10-31 14:46:41 +0000 | [diff] [blame] | 591 | OwnArrayPtr<int> ovector; |
| 592 | int mpos = reg->match(u, pos, &ovector); |
| 593 | if (mpos < 0) |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 594 | break; |
darin | 9fa44df | 2007-10-31 14:46:41 +0000 | [diff] [blame] | 595 | int mlen = ovector[1] - ovector[0]; |
| 596 | pos = mpos + (mlen == 0 ? 1 : mlen); |
| 597 | if (mpos != p0 || mlen) { |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 598 | res->put(exec,i, jsString(exec, u.substr(p0, mpos-p0))); |
darin | 9fa44df | 2007-10-31 14:46:41 +0000 | [diff] [blame] | 599 | p0 = mpos + mlen; |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 600 | i++; |
| 601 | } |
ggaren@apple.com | 8a50ec5 | 2007-11-07 17:18:39 +0000 | [diff] [blame] | 602 | for (unsigned si = 1; si <= reg->numSubpatterns(); ++si) { |
darin | cd9cd76 | 2007-08-13 02:42:17 +0000 | [diff] [blame] | 603 | int spos = ovector[si * 2]; |
| 604 | if (spos < 0) |
| 605 | res->put(exec, i++, jsUndefined()); |
| 606 | else |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 607 | res->put(exec, i++, jsString(exec, u.substr(spos, ovector[si * 2 + 1] - spos))); |
darin | cd9cd76 | 2007-08-13 02:42:17 +0000 | [diff] [blame] | 608 | } |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 609 | } |
darin | e3385e9 | 2004-08-10 18:43:51 +0000 | [diff] [blame] | 610 | } else { |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 611 | UString u2 = a0->toString(exec); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 612 | if (u2.isEmpty()) { |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 613 | if (u.isEmpty()) { |
| 614 | // empty separator matches empty string -> empty array |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 615 | res->put(exec, exec->propertyNames().length, jsNumber(exec, 0)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 616 | return result; |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 617 | } else { |
| 618 | while (static_cast<uint32_t>(i) != limit && i < u.size()-1) |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 619 | res->put(exec, i++, jsString(exec, u.substr(p0++, 1))); |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 620 | } |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 621 | } else { |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 622 | while (static_cast<uint32_t>(i) != limit && (pos = u.find(u2, p0)) >= 0) { |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 623 | res->put(exec, i, jsString(exec, u.substr(p0, pos - p0))); |
darin | ae58eff | 2006-07-30 00:04:22 +0000 | [diff] [blame] | 624 | p0 = pos + u2.size(); |
| 625 | i++; |
| 626 | } |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 627 | } |
| 628 | } |
| 629 | // add remaining string, if any |
darin | e3385e9 | 2004-08-10 18:43:51 +0000 | [diff] [blame] | 630 | if (static_cast<uint32_t>(i) != limit) |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 631 | res->put(exec, i++, jsString(exec, u.substr(p0))); |
| 632 | res->put(exec, exec->propertyNames().length, jsNumber(exec, i)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 633 | return result; |
| 634 | } |
| 635 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 636 | JSValue* stringProtoFuncSubstr(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 637 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 638 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 639 | int len = s.size(); |
| 640 | |
| 641 | JSValue* a0 = args[0]; |
| 642 | JSValue* a1 = args[1]; |
| 643 | |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 644 | double start = a0->toInteger(exec); |
| 645 | double length = a1->isUndefined() ? len : a1->toInteger(exec); |
| 646 | if (start >= len) |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 647 | return jsString(exec, ""); |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 648 | if (length < 0) |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 649 | return jsString(exec, ""); |
darin | 1622f9e | 2007-10-26 07:51:25 +0000 | [diff] [blame] | 650 | if (start < 0) { |
| 651 | start += len; |
| 652 | if (start < 0) |
| 653 | start = 0; |
darin | a51d07b | 2004-02-02 21:23:17 +0000 | [diff] [blame] | 654 | } |
weinig@apple.com | 9583503 | 2008-01-16 01:22:25 +0000 | [diff] [blame] | 655 | if (length > len) |
| 656 | length = len; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 657 | return jsString(exec, s.substr(static_cast<int>(start), static_cast<int>(length))); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 658 | } |
| 659 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 660 | JSValue* stringProtoFuncSubstring(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 661 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 662 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 663 | int len = s.size(); |
| 664 | |
| 665 | JSValue* a0 = args[0]; |
| 666 | JSValue* a1 = args[1]; |
| 667 | |
darin | c13d2ca | 2005-08-08 04:07:46 +0000 | [diff] [blame] | 668 | double start = a0->toNumber(exec); |
| 669 | double end = a1->toNumber(exec); |
mrowe@apple.com | 915de55 | 2007-10-29 02:52:04 +0000 | [diff] [blame] | 670 | if (isnan(start)) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 671 | start = 0; |
mrowe@apple.com | 915de55 | 2007-10-29 02:52:04 +0000 | [diff] [blame] | 672 | if (isnan(end)) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 673 | end = 0; |
| 674 | if (start < 0) |
| 675 | start = 0; |
| 676 | if (end < 0) |
| 677 | end = 0; |
| 678 | if (start > len) |
| 679 | start = len; |
| 680 | if (end > len) |
| 681 | end = len; |
darin | c13d2ca | 2005-08-08 04:07:46 +0000 | [diff] [blame] | 682 | if (a1->isUndefined()) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 683 | end = len; |
| 684 | if (start > end) { |
| 685 | double temp = end; |
| 686 | end = start; |
| 687 | start = temp; |
| 688 | } |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 689 | return jsString(exec, s.substr((int)start, (int)end-(int)start)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 690 | } |
| 691 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 692 | JSValue* stringProtoFuncToLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 693 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 694 | JSString* sVal = thisValue->toThisJSString(exec); |
| 695 | const UString& s = sVal->value(); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 696 | |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 697 | int ssize = s.size(); |
| 698 | if (!ssize) |
| 699 | return sVal; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 700 | Vector<UChar> buffer(ssize); |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 701 | bool error; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 702 | int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 703 | if (error) { |
| 704 | buffer.resize(length); |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 705 | length = Unicode::toLower(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 706 | if (error) |
| 707 | return sVal; |
| 708 | } |
| 709 | if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) |
| 710 | return sVal; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 711 | return jsString(exec, UString(buffer.releaseBuffer(), length, false)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 712 | } |
| 713 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 714 | JSValue* stringProtoFuncToUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 715 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 716 | JSString* sVal = thisValue->toThisJSString(exec); |
| 717 | const UString& s = sVal->value(); |
| 718 | |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 719 | int ssize = s.size(); |
| 720 | if (!ssize) |
| 721 | return sVal; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 722 | Vector<UChar> buffer(ssize); |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 723 | bool error; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 724 | int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 725 | if (error) { |
| 726 | buffer.resize(length); |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 727 | length = Unicode::toUpper(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
darin | 0d66de7 | 2007-08-08 00:45:39 +0000 | [diff] [blame] | 728 | if (error) |
| 729 | return sVal; |
| 730 | } |
| 731 | if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) |
| 732 | return sVal; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 733 | return jsString(exec, UString(buffer.releaseBuffer(), length, false)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 734 | } |
| 735 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 736 | JSValue* stringProtoFuncToLocaleLowerCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 737 | { |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 738 | // FIXME: See http://www.unicode.org/Public/UNIDATA/SpecialCasing.txt for locale-sensitive mappings that aren't implemented. |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 739 | |
| 740 | JSString* sVal = thisValue->toThisJSString(exec); |
| 741 | const UString& s = sVal->value(); |
| 742 | |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 743 | int ssize = s.size(); |
| 744 | if (!ssize) |
| 745 | return sVal; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 746 | Vector<UChar> buffer(ssize); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 747 | bool error; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 748 | int length = Unicode::toLower(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 749 | if (error) { |
| 750 | buffer.resize(length); |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 751 | length = Unicode::toLower(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 752 | if (error) |
| 753 | return sVal; |
| 754 | } |
| 755 | if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) |
| 756 | return sVal; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 757 | return jsString(exec, UString(buffer.releaseBuffer(), length, false)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 758 | } |
| 759 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 760 | JSValue* stringProtoFuncToLocaleUpperCase(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 761 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 762 | JSString* sVal = thisValue->toThisJSString(exec); |
| 763 | const UString& s = sVal->value(); |
| 764 | |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 765 | int ssize = s.size(); |
| 766 | if (!ssize) |
| 767 | return sVal; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 768 | Vector<UChar> buffer(ssize); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 769 | bool error; |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 770 | int length = Unicode::toUpper(buffer.data(), ssize, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 771 | if (error) { |
| 772 | buffer.resize(length); |
eric@webkit.org | 87d855b | 2008-03-10 22:06:44 +0000 | [diff] [blame] | 773 | length = Unicode::toUpper(buffer.data(), length, reinterpret_cast<const UChar*>(s.data()), ssize, &error); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 774 | if (error) |
| 775 | return sVal; |
| 776 | } |
| 777 | if (length == ssize && memcmp(buffer.data(), s.data(), length * sizeof(UChar)) == 0) |
| 778 | return sVal; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 779 | return jsString(exec, UString(buffer.releaseBuffer(), length, false)); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 780 | } |
| 781 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 782 | JSValue* stringProtoFuncLocaleCompare(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 783 | { |
weinig | 55d6dd2 | 2007-05-26 21:57:28 +0000 | [diff] [blame] | 784 | if (args.size() < 1) |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 785 | return jsNumber(exec, 0); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 786 | |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 787 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 788 | JSValue* a0 = args[0]; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 789 | return jsNumber(exec, localeCompare(s, a0->toString(exec))); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 790 | } |
| 791 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 792 | JSValue* stringProtoFuncBig(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 793 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 794 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 795 | return jsString(exec, "<big>" + s + "</big>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 796 | } |
| 797 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 798 | JSValue* stringProtoFuncSmall(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 799 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 800 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 801 | return jsString(exec, "<small>" + s + "</small>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 802 | } |
| 803 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 804 | JSValue* stringProtoFuncBlink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 805 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 806 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 807 | return jsString(exec, "<blink>" + s + "</blink>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 808 | } |
| 809 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 810 | JSValue* stringProtoFuncBold(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 811 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 812 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 813 | return jsString(exec, "<b>" + s + "</b>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 814 | } |
| 815 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 816 | JSValue* stringProtoFuncFixed(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 817 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 818 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 819 | return jsString(exec, "<tt>" + s + "</tt>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 820 | } |
| 821 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 822 | JSValue* stringProtoFuncItalics(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 823 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 824 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 825 | return jsString(exec, "<i>" + s + "</i>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 826 | } |
| 827 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 828 | JSValue* stringProtoFuncStrike(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 829 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 830 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 831 | return jsString(exec, "<strike>" + s + "</strike>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 832 | } |
| 833 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 834 | JSValue* stringProtoFuncSub(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 835 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 836 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 837 | return jsString(exec, "<sub>" + s + "</sub>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 838 | } |
| 839 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 840 | JSValue* stringProtoFuncSup(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList&) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 841 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 842 | UString s = thisValue->toThisString(exec); |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 843 | return jsString(exec, "<sup>" + s + "</sup>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 844 | } |
| 845 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 846 | JSValue* stringProtoFuncFontcolor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 847 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 848 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 849 | JSValue* a0 = args[0]; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 850 | return jsString(exec, "<font color=\"" + a0->toString(exec) + "\">" + s + "</font>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 851 | } |
| 852 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 853 | JSValue* stringProtoFuncFontsize(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 854 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 855 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 856 | JSValue* a0 = args[0]; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 857 | return jsString(exec, "<font size=\"" + a0->toString(exec) + "\">" + s + "</font>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 858 | } |
| 859 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 860 | JSValue* stringProtoFuncAnchor(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 861 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 862 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 863 | JSValue* a0 = args[0]; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 864 | return jsString(exec, "<a name=\"" + a0->toString(exec) + "\">" + s + "</a>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 865 | } |
| 866 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 867 | JSValue* stringProtoFuncLink(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 868 | { |
darin@apple.com | 59c4d4e | 2008-06-27 02:53:42 +0000 | [diff] [blame^] | 869 | UString s = thisValue->toThisString(exec); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 870 | JSValue* a0 = args[0]; |
ap@webkit.org | 960c28e | 2008-06-19 17:29:29 +0000 | [diff] [blame] | 871 | return jsString(exec, "<a href=\"" + a0->toString(exec) + "\">" + s + "</a>"); |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 872 | } |
| 873 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 874 | // ------------------------------ StringConstructor ------------------------------ |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 875 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 876 | static JSValue* stringFromCharCode(ExecState* exec, JSObject*, JSValue*, const ArgList& args) |
| 877 | { |
| 878 | UString s; |
| 879 | if (args.size()) { |
| 880 | UChar* buf = static_cast<UChar*>(fastMalloc(args.size() * sizeof(UChar))); |
| 881 | UChar* p = buf; |
| 882 | ArgList::const_iterator end = args.end(); |
| 883 | for (ArgList::const_iterator it = args.begin(); it != end; ++it) |
| 884 | *p++ = static_cast<UChar>((*it)->toUInt32(exec)); |
| 885 | s = UString(buf, args.size(), false); |
| 886 | } else |
| 887 | s = ""; |
| 888 | |
| 889 | return jsString(exec, s); |
| 890 | } |
| 891 | |
darin@apple.com | 6de4edc | 2008-06-16 03:02:57 +0000 | [diff] [blame] | 892 | StringConstructor::StringConstructor(ExecState* exec, FunctionPrototype* funcProto, StringPrototype* stringProto) |
ap@webkit.org | 07e5bce | 2008-06-16 23:28:38 +0000 | [diff] [blame] | 893 | : InternalFunction(funcProto, Identifier(exec, stringProto->classInfo()->className)) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 894 | { |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 895 | // ECMA 15.5.3.1 String.prototype |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 896 | putDirect(exec->propertyNames().prototype, stringProto, ReadOnly | DontEnum | DontDelete); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 897 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 898 | // ECMA 15.5.3.2 fromCharCode() |
| 899 | putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 1, exec->propertyNames().fromCharCode, stringFromCharCode), DontEnum); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 900 | |
| 901 | // no. of arguments for constructor |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 902 | putDirect(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete); |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | // ECMA 15.5.2 |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 906 | static JSObject* constructWithStringConstructor(ExecState* exec, JSObject*, const ArgList& args) |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 907 | { |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 908 | JSObject* prototype = exec->lexicalGlobalObject()->stringPrototype(); |
| 909 | if (args.isEmpty()) |
| 910 | return new (exec) StringObject(exec, prototype); |
| 911 | return new (exec) StringObject(exec, prototype, args[0]->toString(exec)); |
| 912 | } |
| 913 | |
| 914 | ConstructType StringConstructor::getConstructData(ConstructData& constructData) |
| 915 | { |
| 916 | constructData.native.function = constructWithStringConstructor; |
| 917 | return ConstructTypeNative; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 918 | } |
| 919 | |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 920 | // ECMA 15.5.1 |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 921 | static JSValue* callStringConstructor(ExecState* exec, JSObject*, JSValue*, const ArgList& args) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 922 | { |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 923 | if (args.isEmpty()) |
| 924 | return jsString(exec, ""); |
| 925 | return jsString(exec, args[0]->toString(exec)); |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 926 | } |
| 927 | |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 928 | CallType StringConstructor::getCallData(CallData& callData) |
mjs | 6f821c8 | 2002-03-22 00:31:57 +0000 | [diff] [blame] | 929 | { |
darin@apple.com | 1edff43 | 2008-06-24 05:23:17 +0000 | [diff] [blame] | 930 | callData.native.function = callStringConstructor; |
| 931 | return CallTypeNative; |
kocienda | 66a6d36 | 2001-08-24 14:24:45 +0000 | [diff] [blame] | 932 | } |
darin | f9e5d6c | 2007-01-09 14:54:26 +0000 | [diff] [blame] | 933 | |
weinig@apple.com | a73c15f | 2007-11-08 20:31:26 +0000 | [diff] [blame] | 934 | } // namespace KJS |