26 #ifndef _KJS_OBJECT_H_
27 #define _KJS_OBJECT_H_
33 #include "reference_list.h"
34 #include "identifier.h"
35 #include "property_map.h"
36 #include "scope_chain.h"
40 class ObjectImpPrivate;
49 enum Attribute { None = 0,
85 explicit Object(ObjectImp *v);
87 ObjectImp *imp()
const;
90 bool inherits(
const ClassInfo *cinfo)
const;
111 Value prototype()
const;
148 const Value &value,
int attr = None);
149 void put(
ExecState *exec,
unsigned propertyName,
150 const Value &value,
int attr = None);
175 bool hasProperty(
ExecState *exec,
unsigned propertyName)
const;
189 bool deleteProperty(
ExecState *exec,
unsigned propertyName);
213 bool implementsConstruct()
const;
250 bool implementsCall()
const;
280 bool implementsHasInstance()
const;
347 Value internalValue()
const;
356 void setInternalValue(
const Value &v);
361 class KJS_EXPORT ObjectImp :
public ValueImp {
362 friend class ObjectProtoFuncImp;
369 ObjectImp(
const Object &proto);
370 ObjectImp(ObjectImp *proto);
379 virtual ~ObjectImp();
422 virtual const ClassInfo *classInfo()
const;
450 bool inherits(
const ClassInfo *cinfo)
const;
460 Value prototype()
const;
461 void setPrototype(
const Value &proto);
474 virtual UString className()
const;
485 unsigned propertyName)
const;
494 const Value &value,
int attr = None);
495 virtual void putPropertyByIndex(
ExecState *exec,
unsigned propertyName,
496 const Value &value,
int attr = None);
512 virtual bool hasProperty(
ExecState *exec,
514 virtual bool hasPropertyByIndex(
ExecState *exec,
unsigned propertyName)
const;
522 virtual bool deleteProperty(
ExecState *exec,
524 virtual bool deletePropertyByIndex(
ExecState *exec,
unsigned propertyName);
541 virtual bool implementsConstruct()
const;
549 virtual bool implementsCall()
const;
558 virtual bool implementsHasInstance()
const;
571 const ScopeChain &scope()
const {
return _scope; }
572 void setScope(
const ScopeChain &s) { _scope = s; }
574 virtual ReferenceList propList(ExecState *exec,
bool recursive =
true);
576 Value internalValue()
const;
577 void setInternalValue(
const Value &v);
578 void setInternalValue(ValueImp *v);
580 Value toPrimitive(ExecState *exec,
581 Type preferredType = UnspecifiedType)
const;
582 bool toBoolean(ExecState *exec)
const;
583 double toNumber(ExecState *exec)
const;
584 UString toString(ExecState *exec)
const;
585 Object toObject(ExecState *exec)
const;
591 ValueImp *getDirect(
const Identifier& propertyName)
const
592 {
return _prop.get(propertyName); }
593 void putDirect(
const Identifier &propertyName, ValueImp *value,
int attr = 0);
594 void putDirect(
const Identifier &propertyName,
int value,
int attr = 0);
600 void setFunctionName(
const Identifier &propertyName);
605 const HashEntry* findPropertyHashEntry(
const Identifier& propertyName )
const;
606 ObjectImpPrivate *_od;
608 ValueImp *_internalValue;
616 enum ErrorType { GeneralError = 0,
638 static Object create(
ExecState *exec, ErrorType errtype = GeneralError,
639 const char *message = 0,
int lineno = -1,
648 inline Object::Object(ObjectImp *v) :
Value(v) { }
650 inline ObjectImp *Object::imp()
const {
return static_cast<ObjectImp*
>(rep); }
652 inline const ClassInfo *Object::classInfo()
const
653 {
return imp()->classInfo(); }
655 inline bool Object::inherits(
const ClassInfo *cinfo)
const
656 {
return imp()->inherits(cinfo); }
662 {
return imp()->className(); }
665 {
return imp()->get(exec,propertyName); }
668 {
return imp()->getPropertyByIndex(exec, propertyName); }
671 { imp()->put(exec,propertyName,value,attr); }
674 { imp()->putPropertyByIndex(exec, propertyName, value, attr); }
677 {
return imp()->canPut(exec,propertyName); }
680 {
return imp()->hasProperty(exec, propertyName); }
683 {
return imp()->hasPropertyByIndex(exec, propertyName); }
686 {
return imp()->deleteProperty(exec,propertyName); }
689 {
return imp()->deletePropertyByIndex(exec, propertyName); }
692 {
return imp()->defaultValue(exec,hint); }
695 {
return imp()->implementsConstruct(); }
698 {
return imp()->construct(exec,args); }
701 {
return imp()->implementsCall(); }
704 {
return imp()->implementsHasInstance(); }
707 {
return imp()->hasInstance(exec,value); }
710 {
return imp()->scope(); }
712 inline void Object::setScope(
const ScopeChain &s)
713 { imp()->setScope(s); }
716 {
return imp()->propList(exec,recursive); }
719 {
return imp()->internalValue(); }
722 { imp()->setInternalValue(v); }
726 #endif // _KJS_OBJECT_H_