object.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _KJS_OBJECT_H_
00026 #define _KJS_OBJECT_H_
00027
00028
00029
00030 #include "value.h"
00031 #include "types.h"
00032
00033 namespace KJS {
00034
00035 class ObjectImpPrivate;
00036 class PropertyMap;
00037 class HashTable;
00038 class HashEntry;
00039 class ListImp;
00040
00041
00042
00043 enum Attribute { None = 0,
00044 ReadOnly = 1 << 1,
00045 DontEnum = 1 << 2,
00046 DontDelete = 1 << 3,
00047 Internal = 1 << 4,
00048 Function = 1 << 5 };
00049
00053 struct ClassInfo {
00057 const char* className;
00062 const ClassInfo *parentClass;
00066 const HashTable *propHashTable;
00070 void *dummy;
00071 };
00072
00076 class Object : public Value {
00077 public:
00078 Object();
00079 explicit Object(ObjectImp *v);
00080 Object(const Object &v);
00081 virtual ~Object();
00082
00083 Object& operator=(const Object &v);
00084
00085 virtual const ClassInfo *classInfo() const;
00086 bool inherits(const ClassInfo *cinfo) const;
00087
00097 static Object dynamicCast(const Value &v);
00098
00107 Value prototype() const;
00108
00116 UString className() const;
00117
00130 Value get(ExecState *exec, const UString &propertyName) const;
00131
00141 void put(ExecState *exec, const UString &propertyName,
00142 const Value &value, int attr = None);
00143
00154 bool canPut(ExecState *exec, const UString &propertyName) const;
00155
00166 bool hasProperty(ExecState *exec, const UString &propertyName) const;
00167
00179 bool deleteProperty(ExecState *exec, const UString &propertyName);
00180
00193 Value defaultValue(ExecState *exec, Type hint) const;
00194
00203 bool implementsConstruct() const;
00204
00230 Object construct(ExecState *exec, const List &args);
00231
00240 bool implementsCall() const;
00241
00242
00260 Value call(ExecState *exec, Object &thisObj, const List &args);
00261
00270 bool implementsHasInstance() const;
00271
00281 Boolean hasInstance(ExecState *exec, const Value &value);
00282
00307 const List scope() const;
00308 void setScope(const List &s);
00309
00326 List propList(ExecState *exec, bool recursive = true);
00327
00336 Value internalValue() const;
00337
00345 void setInternalValue(const Value &v);
00346 };
00347
00348 class ObjectImp : public ValueImp {
00349 public:
00355 ObjectImp(const Object &proto);
00356
00362 ObjectImp();
00363
00364 virtual ~ObjectImp();
00365
00366 virtual void mark();
00367
00368 Type type() const;
00369
00403 virtual const ClassInfo *classInfo() const;
00404
00431 bool inherits(const ClassInfo *cinfo) const;
00432
00433
00434
00441 Value prototype() const;
00442 void setPrototype(const Value &proto);
00443
00455 virtual UString className() const;
00456
00463
00464 virtual Value get(ExecState *exec, const UString &propertyName) const;
00465
00472 virtual void put(ExecState *exec, const UString &propertyName,
00473 const Value &value, int attr = None);
00474
00481 virtual bool canPut(ExecState *exec, const UString &propertyName) const;
00482
00489 virtual bool hasProperty(ExecState *exec,
00490 const UString &propertyName) const;
00491
00498 virtual bool deleteProperty(ExecState *exec,
00499 const UString &propertyName);
00500
00506 void deleteAllProperties( ExecState * );
00507
00514 virtual Value defaultValue(ExecState *exec, Type hint) const;
00515
00516 virtual bool implementsConstruct() const;
00522 virtual Object construct(ExecState *exec, const List &args);
00523
00524 virtual bool implementsCall() const;
00530 virtual Value call(ExecState *exec, Object &thisObj,
00531 const List &args);
00532
00533 virtual bool implementsHasInstance() const;
00539 virtual Boolean hasInstance(ExecState *exec, const Value &value);
00540
00546 const List scope() const;
00547 void setScope(const List &s);
00548
00549 List propList(ExecState *exec, bool recursive = true);
00550
00551 Value internalValue() const;
00552 void setInternalValue(const Value &v);
00553
00554 Value toPrimitive(ExecState *exec,
00555 Type preferredType = UnspecifiedType) const;
00556 bool toBoolean(ExecState *exec) const;
00557 double toNumber(ExecState *exec) const;
00558 int toInteger(ExecState *exec) const;
00559 int toInt32(ExecState *exec) const;
00560 unsigned int toUInt32(ExecState *exec) const;
00561 unsigned short toUInt16(ExecState *exec) const;
00562 UString toString(ExecState *exec) const;
00563 Object toObject(ExecState *exec) const;
00564
00565 ValueImp* getDirect(const UString& propertyName) const;
00566 private:
00567 const HashEntry* findPropertyHashEntry( const UString& propertyName ) const;
00568 ObjectImpPrivate *_od;
00569 PropertyMap *_prop;
00570 ValueImp *_proto;
00571 ValueImp *_internalValue;
00572 ListImp *_scope;
00573 };
00574
00579 enum ErrorType { GeneralError = 0,
00580 EvalError = 1,
00581 RangeError = 2,
00582 ReferenceError = 3,
00583 SyntaxError = 4,
00584 TypeError = 5,
00585 URIError = 6};
00586
00590 class Error {
00591 public:
00601 static Object create(ExecState *exec, ErrorType errtype = GeneralError,
00602 const char *message = 0, int lineno = -1,
00603 int sourceId = -1);
00604
00608 static const char * const * const errorNames;
00609 };
00610
00611 }
00612
00613 #endif // _KJS_OBJECT_H_
This file is part of the documentation for kdelibs Version 3.1.4.