25 #ifndef _KJS_OBJECT_H_
26 #define _KJS_OBJECT_H_
32 #include "reference_list.h"
33 #include "identifier.h"
34 #include "property_map.h"
35 #include "scope_chain.h"
39 class ObjectImpPrivate;
48 enum Attribute { None = 0,
84 explicit Object(ObjectImp *v);
86 ObjectImp *imp()
const;
89 bool inherits(
const ClassInfo *cinfo)
const;
110 Value prototype()
const;
147 const Value &value,
int attr = None);
148 void put(
ExecState *exec,
unsigned propertyName,
149 const Value &value,
int attr = None);
174 bool hasProperty(
ExecState *exec,
unsigned propertyName)
const;
188 bool deleteProperty(
ExecState *exec,
unsigned propertyName);
212 bool implementsConstruct()
const;
249 bool implementsCall()
const;
279 bool implementsHasInstance()
const;
346 Value internalValue()
const;
355 void setInternalValue(
const Value &v);
360 class KJS_EXPORT ObjectImp :
public ValueImp {
361 friend class ObjectProtoFuncImp;
368 ObjectImp(
const Object &proto);
369 ObjectImp(ObjectImp *proto);
378 virtual ~ObjectImp();
421 virtual const ClassInfo *classInfo()
const;
449 bool inherits(
const ClassInfo *cinfo)
const;
459 Value prototype()
const;
460 void setPrototype(
const Value &proto);
473 virtual UString className()
const;
484 unsigned propertyName)
const;
493 const Value &value,
int attr = None);
494 virtual void putPropertyByIndex(
ExecState *exec,
unsigned propertyName,
495 const Value &value,
int attr = None);
511 virtual bool hasProperty(
ExecState *exec,
513 virtual bool hasPropertyByIndex(
ExecState *exec,
unsigned propertyName)
const;
521 virtual bool deleteProperty(
ExecState *exec,
523 virtual bool deletePropertyByIndex(
ExecState *exec,
unsigned propertyName);
540 virtual bool implementsConstruct()
const;
548 virtual bool implementsCall()
const;
557 virtual bool implementsHasInstance()
const;
570 const ScopeChain &scope()
const {
return _scope; }
571 void setScope(
const ScopeChain &s) { _scope = s; }
573 virtual ReferenceList propList(ExecState *exec,
bool recursive =
true);
575 Value internalValue()
const;
576 void setInternalValue(
const Value &v);
577 void setInternalValue(ValueImp *v);
579 Value toPrimitive(ExecState *exec,
580 Type preferredType = UnspecifiedType)
const;
581 bool toBoolean(ExecState *exec)
const;
582 double toNumber(ExecState *exec)
const;
583 UString toString(ExecState *exec)
const;
584 Object toObject(ExecState *exec)
const;
590 ValueImp *getDirect(
const Identifier& propertyName)
const
591 {
return _prop.get(propertyName); }
592 void putDirect(
const Identifier &propertyName, ValueImp *value,
int attr = 0);
593 void putDirect(
const Identifier &propertyName,
int value,
int attr = 0);
599 void setFunctionName(
const Identifier &propertyName);
604 const HashEntry* findPropertyHashEntry(
const Identifier& propertyName )
const;
605 ObjectImpPrivate *_od;
607 ValueImp *_internalValue;
615 enum ErrorType { GeneralError = 0,
637 static Object create(
ExecState *exec, ErrorType errtype = GeneralError,
638 const char *message = 0,
int lineno = -1,
647 inline Object::Object(ObjectImp *v) :
Value(v) { }
649 inline ObjectImp *Object::imp()
const {
return static_cast<ObjectImp*
>(rep); }
651 inline const ClassInfo *Object::classInfo()
const
652 {
return imp()->classInfo(); }
654 inline bool Object::inherits(
const ClassInfo *cinfo)
const
655 {
return imp()->inherits(cinfo); }
661 {
return imp()->className(); }
664 {
return imp()->get(exec,propertyName); }
667 {
return imp()->getPropertyByIndex(exec, propertyName); }
670 { imp()->put(exec,propertyName,value,attr); }
673 { imp()->putPropertyByIndex(exec, propertyName, value, attr); }
676 {
return imp()->canPut(exec,propertyName); }
679 {
return imp()->hasProperty(exec, propertyName); }
682 {
return imp()->hasPropertyByIndex(exec, propertyName); }
685 {
return imp()->deleteProperty(exec,propertyName); }
688 {
return imp()->deletePropertyByIndex(exec, propertyName); }
691 {
return imp()->defaultValue(exec,hint); }
694 {
return imp()->implementsConstruct(); }
697 {
return imp()->construct(exec,args); }
700 {
return imp()->implementsCall(); }
703 {
return imp()->implementsHasInstance(); }
706 {
return imp()->hasInstance(exec,value); }
709 {
return imp()->scope(); }
711 inline void Object::setScope(
const ScopeChain &s)
712 { imp()->setScope(s); }
715 {
return imp()->propList(exec,recursive); }
718 {
return imp()->internalValue(); }
721 { imp()->setInternalValue(v); }
725 #endif // _KJS_OBJECT_H_