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