adapt wc/r24255/#14395/ by Mitz Pettel <mitz@webkit.org>
[kdelibs.git] / kjs / string_object.h
blobb377a49198a10390a5642139614b49493657c0ef
1 // -*- c-basic-offset: 2 -*-
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"
28 namespace KJS {
30 class StringInstance : public JSWrapperObject {
31 public:
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;
42 private:
43 static JSValue *lengthGetter(ExecState *exec, JSObject *, const Identifier&, const PropertySlot &slot);
44 static JSValue *indexGetter(ExecState *exec, JSObject *, const Identifier&, const PropertySlot &slot);
47 /**
48 * @internal
50 * The initial value of String.prototype (and thus all objects created
51 * with the String constructor
53 class StringPrototype : public StringInstance {
54 public:
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;
62 /**
63 * @internal
65 * Class to implement all methods that are properties of the
66 * String.prototype object
68 class StringProtoFunc : public InternalFunctionImp {
69 public:
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
78 #ifndef KJS_PURE_ECMA
79 , Big, Small, Blink, Bold, Fixed, Italics, Strike, Sub, Sup,
80 Fontcolor, Fontsize, Anchor, Link
81 #endif
84 static void setToLowerFunction(UnicodeSupport::StringConversionFunction f);
85 static void setToUpperFunction(UnicodeSupport::StringConversionFunction f);
86 private:
87 int id;
90 /**
91 * @internal
93 * The initial value of the the global variable's "String" property
95 class StringObjectImp : public InternalFunctionImp {
96 public:
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);
107 * @internal
109 * Class to implement all methods that are properties of the
110 * String object
112 class StringObjectFuncImp : public InternalFunctionImp {
113 public:
114 StringObjectFuncImp(ExecState*, FunctionPrototype*, const Identifier&);
115 virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List &args);
118 } // namespace
120 #endif