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);
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; }
576 Value internalValue()
const;
577 void setInternalValue(
const Value &v);
581 Type preferredType = UnspecifiedType)
const;
592 {
return _prop.get(propertyName); }
594 void putDirect(
const Identifier &propertyName,
int value,
int attr = 0);
600 void setFunctionName(
const Identifier &propertyName);
606 ObjectImpPrivate *_od;
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); }
659 {
return Value(imp()->prototype()); }
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(); }
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_ 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...
An entry in a hash table.
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.