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"
30 class StringInstance
: public JSWrapperObject
{
32 StringInstance(JSObject
*proto
);
33 StringInstance(JSObject
*proto
, const UString
&string
);
35 virtual bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
36 virtual void put(ExecState
* exec
, const Identifier
& propertyName
, JSValue
* value
, int attr
= None
);
37 virtual bool deleteProperty(ExecState
* exec
, const Identifier
& propertyName
);
38 virtual void getPropertyNames(ExecState
*, PropertyNameArray
&);
40 virtual const ClassInfo
*classInfo() const { return &info
; }
41 static const ClassInfo info
;
43 static JSValue
*lengthGetter(ExecState
*exec
, JSObject
*, const Identifier
&, const PropertySlot
&slot
);
44 static JSValue
*indexGetter(ExecState
*exec
, JSObject
*, const Identifier
&, const PropertySlot
&slot
);
50 * The initial value of String.prototype (and thus all objects created
51 * with the String constructor
53 class StringPrototype
: public StringInstance
{
55 StringPrototype(ExecState
*exec
,
56 ObjectPrototype
*objProto
);
57 virtual bool getOwnPropertySlot(ExecState
*, const Identifier
&, PropertySlot
&);
58 virtual const ClassInfo
*classInfo() const { return &info
; }
59 static const ClassInfo info
;
65 * Class to implement all methods that are properties of the
66 * String.prototype object
68 class StringProtoFunc
: public InternalFunctionImp
{
70 StringProtoFunc(ExecState
*exec
, int i
, int len
, const Identifier
&);
72 virtual JSValue
*callAsFunction(ExecState
*exec
, JSObject
*thisObj
, const List
&args
);
74 enum { ToString
, ValueOf
, CharAt
, CharCodeAt
, Concat
, IndexOf
, LastIndexOf
,
75 Match
, Replace
, Search
, Slice
, Split
,
76 Substr
, Substring
, FromCharCode
, ToLowerCase
, ToUpperCase
,
77 ToLocaleLowerCase
, ToLocaleUpperCase
, LocaleCompare
79 , Big
, Small
, Blink
, Bold
, Fixed
, Italics
, Strike
, Sub
, Sup
,
80 Fontcolor
, Fontsize
, Anchor
, Link
84 static void setToLowerFunction(UnicodeSupport::StringConversionFunction f
);
85 static void setToUpperFunction(UnicodeSupport::StringConversionFunction f
);
93 * The initial value of the the global variable's "String" property
95 class StringObjectImp
: public InternalFunctionImp
{
97 StringObjectImp(ExecState
*exec
,
98 FunctionPrototype
*funcProto
,
99 StringPrototype
*stringProto
);
101 virtual bool implementsConstruct() const;
102 virtual JSObject
*construct(ExecState
*exec
, const List
&args
);
103 virtual JSValue
*callAsFunction(ExecState
*exec
, JSObject
*thisObj
, const List
&args
);
109 * Class to implement all methods that are properties of the
112 class StringObjectFuncImp
: public InternalFunctionImp
{
114 StringObjectFuncImp(ExecState
*, FunctionPrototype
*, const Identifier
&);
115 virtual JSValue
*callAsFunction(ExecState
*exec
, JSObject
*thisObj
, const List
&args
);