1 // -*- c-basic-offset: 2 -*-
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
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.
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.
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
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef STRING_OBJECT_H_
23 #define STRING_OBJECT_H_
25 #include "function_object.h"
26 #include "JSWrapperObject.h"
32 class StringInstance
: public JSWrapperObject
{
34 StringInstance(JSObject
*proto
);
35 StringInstance(JSObject
*proto
, StringImp
*);
36 StringInstance(JSObject
*proto
, const UString
&);
38 virtual bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
39 virtual bool getOwnPropertySlot(ExecState
*, unsigned propertyName
, PropertySlot
&);
41 virtual void put(ExecState
* exec
, const Identifier
& propertyName
, JSValue
*, int attr
= None
);
42 virtual bool deleteProperty(ExecState
* exec
, const Identifier
& propertyName
);
43 virtual void getPropertyNames(ExecState
*, PropertyNameArray
&);
45 virtual const ClassInfo
*classInfo() const { return &info
; }
46 static const ClassInfo info
;
48 StringImp
* internalValue() const { return static_cast<StringImp
*>(JSWrapperObject::internalValue());}
51 bool inlineGetOwnPropertySlot(ExecState
*, unsigned, PropertySlot
&);
53 static JSValue
* lengthGetter(ExecState
*, JSObject
*, const Identifier
&, const PropertySlot
&);
54 static JSValue
* indexGetter(ExecState
*, JSObject
*, const Identifier
&, const PropertySlot
&);
57 // WebCore uses this to make style.filter undetectable
58 class StringInstanceThatMasqueradesAsUndefined
: public StringInstance
{
60 StringInstanceThatMasqueradesAsUndefined(JSObject
* proto
, const UString
& string
)
61 : StringInstance(proto
, string
) { }
62 virtual bool masqueradeAsUndefined() const { return true; }
63 virtual bool toBoolean(ExecState
*) const { return false; }
69 * The initial value of String.prototype (and thus all objects created
70 * with the String constructor
72 class StringPrototype
: public StringInstance
{
74 StringPrototype(ExecState
*exec
,
75 ObjectPrototype
*objProto
);
76 virtual bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
77 virtual const ClassInfo
*classInfo() const { return &info
; }
78 static const ClassInfo info
;
84 * Functions to implement all methods that are properties of the
85 * String.prototype object
88 JSValue
* stringProtoFuncToString(ExecState
*, JSObject
*, const List
&);
89 JSValue
* stringProtoFuncValueOf(ExecState
*, JSObject
*, const List
&);
90 JSValue
* stringProtoFuncCharAt(ExecState
*, JSObject
*, const List
&);
91 JSValue
* stringProtoFuncCharCodeAt(ExecState
*, JSObject
*, const List
&);
92 JSValue
* stringProtoFuncConcat(ExecState
*, JSObject
*, const List
&);
93 JSValue
* stringProtoFuncIndexOf(ExecState
*, JSObject
*, const List
&);
94 JSValue
* stringProtoFuncLastIndexOf(ExecState
*, JSObject
*, const List
&);
95 JSValue
* stringProtoFuncMatch(ExecState
*, JSObject
*, const List
&);
96 JSValue
* stringProtoFuncReplace(ExecState
*, JSObject
*, const List
&);
97 JSValue
* stringProtoFuncSearch(ExecState
*, JSObject
*, const List
&);
98 JSValue
* stringProtoFuncSlice(ExecState
*, JSObject
*, const List
&);
99 JSValue
* stringProtoFuncSplit(ExecState
*, JSObject
*, const List
&);
100 JSValue
* stringProtoFuncSubstr(ExecState
*, JSObject
*, const List
&);
101 JSValue
* stringProtoFuncSubstring(ExecState
*, JSObject
*, const List
&);
102 JSValue
* stringProtoFuncToLowerCase(ExecState
*, JSObject
*, const List
&);
103 JSValue
* stringProtoFuncToUpperCase(ExecState
*, JSObject
*, const List
&);
104 JSValue
* stringProtoFuncToLocaleLowerCase(ExecState
*, JSObject
*, const List
&);
105 JSValue
* stringProtoFuncToLocaleUpperCase(ExecState
*, JSObject
*, const List
&);
106 JSValue
* stringProtoFuncLocaleCompare(ExecState
*, JSObject
*, const List
&);
108 JSValue
* stringProtoFuncBig(ExecState
*, JSObject
*, const List
&);
109 JSValue
* stringProtoFuncSmall(ExecState
*, JSObject
*, const List
&);
110 JSValue
* stringProtoFuncBlink(ExecState
*, JSObject
*, const List
&);
111 JSValue
* stringProtoFuncBold(ExecState
*, JSObject
*, const List
&);
112 JSValue
* stringProtoFuncFixed(ExecState
*, JSObject
*, const List
&);
113 JSValue
* stringProtoFuncItalics(ExecState
*, JSObject
*, const List
&);
114 JSValue
* stringProtoFuncStrike(ExecState
*, JSObject
*, const List
&);
115 JSValue
* stringProtoFuncSub(ExecState
*, JSObject
*, const List
&);
116 JSValue
* stringProtoFuncSup(ExecState
*, JSObject
*, const List
&);
117 JSValue
* stringProtoFuncFontcolor(ExecState
*, JSObject
*, const List
&);
118 JSValue
* stringProtoFuncFontsize(ExecState
*, JSObject
*, const List
&);
119 JSValue
* stringProtoFuncAnchor(ExecState
*, JSObject
*, const List
&);
120 JSValue
* stringProtoFuncLink(ExecState
*, JSObject
*, const List
&);
125 * The initial value of the the global variable's "String" property
127 class StringObjectImp
: public InternalFunctionImp
{
129 StringObjectImp(ExecState
*exec
,
130 FunctionPrototype
*funcProto
,
131 StringPrototype
*stringProto
);
133 virtual bool implementsConstruct() const;
134 virtual JSObject
*construct(ExecState
*exec
, const List
&args
);
135 virtual JSValue
*callAsFunction(ExecState
*exec
, JSObject
*thisObj
, const List
&args
);
141 * Class to implement all methods that are properties of the
144 class StringObjectFuncImp
: public InternalFunctionImp
{
146 StringObjectFuncImp(ExecState
*, FunctionPrototype
*, const Identifier
&);
147 virtual JSValue
*callAsFunction(ExecState
*exec
, JSObject
*thisObj
, const List
&args
);