00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 #ifndef _STRING_OBJECT_H_
00023 #define _STRING_OBJECT_H_
00024 
00025 #include "internal.h"
00026 #include "function_object.h"
00027 
00028 namespace KJS {
00029 
00030   class StringInstanceImp : public ObjectImp {
00031   public:
00032     StringInstanceImp(ObjectImp *proto);
00033     StringInstanceImp(ObjectImp *proto, const UString &string);
00034 
00035     virtual Value get(ExecState *exec, const Identifier &propertyName) const;
00036     virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
00037     virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
00038     virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
00039     virtual ReferenceList propList(ExecState *exec, bool recursive);
00040 
00041     virtual const ClassInfo *classInfo() const { return &info; }
00042     static const ClassInfo info;
00043  };
00044 
00051   class StringPrototypeImp : public StringInstanceImp {
00052   public:
00053     StringPrototypeImp(ExecState *exec,
00054                        ObjectPrototypeImp *objProto);
00055     Value get(ExecState *exec, const Identifier &p) const;
00056     virtual const ClassInfo *classInfo() const { return &info; }
00057     static const ClassInfo info;
00058   };
00059 
00066   class StringProtoFuncImp : public InternalFunctionImp {
00067   public:
00068     StringProtoFuncImp(ExecState *exec, int i, int len);
00069 
00070     virtual bool implementsCall() const;
00071     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
00072 
00073     enum { ToString, ValueOf, CharAt, CharCodeAt, Concat, IndexOf, LastIndexOf,
00074        Match, Replace, Search, Slice, Split,
00075        Substr, Substring, FromCharCode, ToLowerCase, ToUpperCase
00076 #ifndef KJS_PURE_ECMA
00077        , Big, Small, Blink, Bold, Fixed, Italics, Strike, Sub, Sup,
00078        Fontcolor, Fontsize, Anchor, Link
00079 #endif
00080     };
00081   private:
00082     int id;
00083   };
00084 
00090   class StringObjectImp : public InternalFunctionImp {
00091   public:
00092     StringObjectImp(ExecState *exec,
00093                     FunctionPrototypeImp *funcProto,
00094                     StringPrototypeImp *stringProto);
00095 
00096     virtual bool implementsConstruct() const;
00097     virtual Object construct(ExecState *exec, const List &args);
00098     virtual bool implementsCall() const;
00099     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
00100   };
00101 
00108   class StringObjectFuncImp : public InternalFunctionImp {
00109   public:
00110     StringObjectFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto);
00111     virtual bool implementsCall() const;
00112     virtual Value call(ExecState *exec, Object &thisObj, const List &args);
00113   };
00114 
00115 } 
00116 
00117 #endif
00118