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_
Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...
Factory methods for error objects.
const ClassInfo * parentClass
Pointer to the class information of the base class.
Value defaultValue(ExecState *exec, Type hint) const
Converts the object into a primitive value.
Value get(ExecState *exec, const Identifier &propertyName) const
Retrieves the specified property from the object.
Object construct(ExecState *exec, const List &args)
Creates a new object based on this object.
Boolean hasInstance(ExecState *exec, const Value &value)
Checks whether value delegates behavior to this object.
bool implementsConstruct() const
Whether or not the object implements the construct() method.
bool deleteProperty(ExecState *exec, const Identifier &propertyName)
Removes the specified property from the object.
void * dummy
Reserved for future extension.
UString className() const
Returns the class name of the object.
void setInternalValue(const Value &v)
Sets the internal value of the object.
bool hasProperty(ExecState *exec, const Identifier &propertyName) const
Checks to see whether the object (or any object in it's prototype chain) has a property with the spec...
A hash table Usually the hashtable is generated by the create_hash_table script, from a ...
bool implementsHasInstance() const
Whether or not the object implements the hasInstance() method.
const char * className
A string denoting the class name.
Object toObject(ExecState *exec) const
Performs the ToObject type conversion operation on this value (ECMA 9.9)
bool implementsCall() const
Whether or not the object implements the call() method.
bool canPut(ExecState *exec, const Identifier &propertyName) const
Used to check whether or not a particular property is allowed to be set on an object.
static const char *const *const errorNames
Array of error names corresponding to ErrorType.
ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...
Value internalValue() const
Returns the internal value of the object.
const HashTable * propHashTable
Static hash-table of properties.
ReferenceList propList(ExecState *exec, bool recursive=true)
Returns a List of References to all the properties of the object.
A list of Reference objects.
const ScopeChain & scope() const
Returns the scope of this object.
void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr=None)
Sets the specified property.
Represents an primitive Boolean value.
Value prototype() const
Returns the prototype of this object.
Represents the current state of script execution.
Represents an Identifier for a Javascript object.