kjs Library API Documentation

KJS::ObjectImp Class Reference

Inheritance diagram for KJS::ObjectImp:

Inheritance graph
[legend]
Collaboration diagram for KJS::ObjectImp:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ObjectImp (const Object &proto)
 ObjectImp (ObjectImp *proto)
 ObjectImp ()
virtual ~ObjectImp ()
virtual void mark ()
Type type () const
virtual const ClassInfoclassInfo () const
bool inherits (const ClassInfo *cinfo) const
Value prototype () const
void setPrototype (const Value &proto)
virtual UString className () const
virtual Value get (ExecState *exec, const Identifier &propertyName) const
virtual Value getPropertyByIndex (ExecState *exec, unsigned propertyName) const
virtual void put (ExecState *exec, const Identifier &propertyName, const Value &value, int attr=None)
virtual void putPropertyByIndex (ExecState *exec, unsigned propertyName, const Value &value, int attr=None)
virtual bool canPut (ExecState *exec, const Identifier &propertyName) const
virtual bool hasProperty (ExecState *exec, const Identifier &propertyName) const
virtual bool hasPropertyByIndex (ExecState *exec, unsigned propertyName) const
virtual bool deleteProperty (ExecState *exec, const Identifier &propertyName)
virtual bool deletePropertyByIndex (ExecState *exec, unsigned propertyName)
void deleteAllProperties (ExecState *)
virtual Value defaultValue (ExecState *exec, Type hint) const
virtual bool implementsConstruct () const
virtual Object construct (ExecState *exec, const List &args)
virtual bool implementsCall () const
virtual Value call (ExecState *exec, Object &thisObj, const List &args)
virtual bool implementsHasInstance () const
virtual Boolean hasInstance (ExecState *exec, const Value &value)
const ScopeChainscope () const
void setScope (const ScopeChain &s)
virtual ReferenceList propList (ExecState *exec, bool recursive=true)
Value internalValue () const
void setInternalValue (const Value &v)
void setInternalValue (ValueImp *v)
Value toPrimitive (ExecState *exec, Type preferredType=UnspecifiedType) const
bool toBoolean (ExecState *exec) const
double toNumber (ExecState *exec) const
UString toString (ExecState *exec) const
Object toObject (ExecState *exec) const
ValueImpgetDirect (const Identifier &propertyName) const
void putDirect (const Identifier &propertyName, ValueImp *value, int attr=0)
void putDirect (const Identifier &propertyName, int value, int attr=0)
void setFunctionName (const Identifier &propertyName)

Protected Attributes

PropertyMap _prop

Friends

class ObjectProtoFuncImp

Detailed Description

Definition at line 359 of file object.h.


Constructor & Destructor Documentation

ObjectImp::ObjectImp const Object proto  ) 
 

Creates a new ObjectImp with the specified prototype.

Parameters:
proto The prototype

Definition at line 81 of file object.cpp.

ObjectImp::ObjectImp  ) 
 

Creates a new ObjectImp with a prototype of Null() (that is, the ECMAScript "null" value, not a null Object).

Definition at line 92 of file object.cpp.

References KJS::NullImp::staticNull.

Referenced by KJS::ObjectObjectImp::construct(), KJS::FunctionObjectImp::construct(), and KJS::DeclaredFunctionImp::construct().


Member Function Documentation

const ClassInfo * ObjectImp::classInfo  )  const [virtual]
 

A pointer to a ClassInfo struct for this class.

This provides a basic facility for run-time type information, and can be used to check an object's class an inheritance (see inherits()). This should always return a statically declared pointer, or 0 to indicate that there is no class information.

This is primarily useful if you have application-defined classes that you wish to check against for casting purposes.

For example, to specify the class info for classes FooImp and BarImp, where FooImp inherits from BarImp, you would add the following in your class declarations:

   class BarImp : public ObjectImp {
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
     // ...
   };

   class FooImp : public ObjectImp {
     virtual const ClassInfo *classInfo() const { return &info; }
     static const ClassInfo info;
     // ...
   };

And in your source file:

   const ClassInfo BarImp::info = {0, 0, 0}; // no parent class
   const ClassInfo FooImp::info = {&BarImp::info, 0, 0};

See also:
inherits()

Reimplemented in KJS::ArrayInstanceImp, KJS::ArrayPrototypeImp, KJS::BooleanInstanceImp, KJS::DateInstanceImp, KJS::DatePrototypeImp, KJS::ErrorInstanceImp, KJS::NativeErrorImp, KJS::InternalFunctionImp, KJS::FunctionImp, KJS::DeclaredFunctionImp, KJS::ArgumentsImp, KJS::ActivationImp, KJS::MathObjectImp, KJS::NumberInstanceImp, KJS::NumberObjectImp, KJS::RegExpImp, KJS::StringInstanceImp, and KJS::StringPrototypeImp.

Definition at line 120 of file object.cpp.

Referenced by KJS::ArrayProtoFuncImp::call(), KJS::Object::classInfo(), className(), inherits(), and propList().

bool ObjectImp::inherits const ClassInfo cinfo  )  const
 

Checks whether this object inherits from the class with the specified classInfo() pointer.

This requires that both this class and the other class return a non-NULL pointer for their classInfo() methods (otherwise it will return false).

For example, for two ObjectImp pointers obj1 and obj2, you can check if obj1's class inherits from obj2's class using the following:

if (obj1->inherits(obj2->classInfo())) { // ... }

If you have a handle to a statically declared ClassInfo, such as in the classInfo() example, you can check for inheritance without needing an instance of the other class:

if (obj1->inherits(FooImp::info)) { // ... }

Parameters:
cinfo The ClassInfo pointer for the class you want to check inheritance against.
Returns:
true if this object's class inherits from class with the ClassInfo pointer specified in cinfo

Definition at line 125 of file object.cpp.

References classInfo(), and KJS::ClassInfo::parentClass.

Referenced by KJS::ContextImp::ContextImp(), KJS::Object::inherits(), and setFunctionName().

Value ObjectImp::prototype  )  const
 

Implementation of the [[Prototype]] internal property (implemented by all Objects).

See also:
Object::prototype()

Definition at line 145 of file object.cpp.

References KJS::ValueImp::Value.

Referenced by KJS::ObjectProtoFuncImp::call(), KJS::FunctionObjectImp::construct(), get(), and hasProperty().

UString ObjectImp::className  )  const [virtual]
 

Implementation of the [[Class]] internal property (implemented by all Objects).

The default implementation uses classInfo(). You should either implement classInfo(), or if you simply need a classname, you can reimplement className() instead.

See also:
Object::className()

Definition at line 155 of file object.cpp.

References classInfo(), and KJS::ClassInfo::className.

Referenced by KJS::Object::className().

Value ObjectImp::get ExecState exec,
const Identifier propertyName
const [virtual]
 

Implementation of the [[Get]] internal property (implemented by all Objects).

See also:
Object::get()

Reimplemented in KJS::ArrayInstanceImp, KJS::ArrayPrototypeImp, KJS::DatePrototypeImp, KJS::FunctionImp, KJS::ArgumentsImp, KJS::ActivationImp, KJS::MathObjectImp, KJS::NumberObjectImp, KJS::RegExpObjectImp, KJS::StringInstanceImp, and KJS::StringPrototypeImp.

Definition at line 163 of file object.cpp.

References KJS::Object::dynamicCast(), KJS::Object::get(), getDirect(), KJS::Value::isNull(), KJS::Value::isValid(), prototype(), KJS::specialPrototypePropertyName, and KJS::ValueImp::Value.

Referenced by KJS::StringProtoFuncImp::call(), defaultValue(), KJS::StringInstanceImp::get(), KJS::RegExpObjectImp::get(), KJS::Object::get(), KJS::ActivationImp::get(), KJS::ArgumentsImp::get(), KJS::FunctionImp::get(), KJS::ArrayInstanceImp::get(), getPropertyByIndex(), KJS::ArrayInstanceImp::getPropertyByIndex(), KJS::Reference::getValue(), KJS::InternalFunctionImp::hasInstance(), and KJS::ArgumentsImp::put().

void ObjectImp::put ExecState exec,
const Identifier propertyName,
const Value value,
int  attr = None
[virtual]
 

Implementation of the [[Put]] internal property (implemented by all Objects).

See also:
Object::put()

Reimplemented in KJS::ArrayInstanceImp, KJS::FunctionImp, KJS::ArgumentsImp, and KJS::StringInstanceImp.

Definition at line 192 of file object.cpp.

References _prop, KJS::Identifier::ascii(), canPut(), KJS::Value::imp(), KJS::Value::isNull(), KJS::PropertyMap::put(), setPrototype(), and KJS::specialPrototypePropertyName.

Referenced by KJS::ArgumentsImp::ArgumentsImp(), KJS::ArrayObjectImp::ArrayObjectImp(), KJS::ArrayProtoFuncImp::ArrayProtoFuncImp(), KJS::StringProtoFuncImp::call(), KJS::ErrorPrototypeImp::ErrorPrototypeImp(), KJS::InterpreterImp::initGlobalObject(), KJS::ObjectPrototypeImp::ObjectPrototypeImp(), KJS::StringInstanceImp::put(), KJS::Object::put(), KJS::ArgumentsImp::put(), KJS::FunctionImp::put(), KJS::ArrayInstanceImp::put(), putPropertyByIndex(), KJS::ArrayInstanceImp::putPropertyByIndex(), and KJS::Reference::putValue().

bool ObjectImp::canPut ExecState exec,
const Identifier propertyName
const [virtual]
 

Implementation of the [[CanPut]] internal property (implemented by all Objects).

See also:
Object::canPut()

Definition at line 226 of file object.cpp.

References _prop, KJS::HashEntry::attr, and KJS::PropertyMap::get().

Referenced by KJS::Object::canPut(), and put().

bool ObjectImp::hasProperty ExecState exec,
const Identifier propertyName
const [virtual]
 

Implementation of the [[HasProperty]] internal property (implemented by all Objects).

See also:
Object::hasProperty()

Reimplemented in KJS::ArrayInstanceImp, KJS::FunctionImp, KJS::ActivationImp, and KJS::StringInstanceImp.

Definition at line 244 of file object.cpp.

References _prop, KJS::Object::dynamicCast(), KJS::PropertyMap::get(), KJS::Object::hasProperty(), KJS::Value::isNull(), prototype(), and KJS::specialPrototypePropertyName.

Referenced by KJS::ResolveNode::evaluateReference(), KJS::StringInstanceImp::hasProperty(), KJS::Object::hasProperty(), KJS::ActivationImp::hasProperty(), KJS::FunctionImp::hasProperty(), KJS::ArrayInstanceImp::hasProperty(), hasPropertyByIndex(), KJS::ArrayInstanceImp::hasPropertyByIndex(), KJS::StringInstanceImp::propList(), and KJS::ArrayInstanceImp::propList().

bool ObjectImp::deleteProperty ExecState exec,
const Identifier propertyName
[virtual]
 

Implementation of the [[Delete]] internal property (implemented by all Objects).

See also:
Object::deleteProperty()

Reimplemented in KJS::ArrayInstanceImp, KJS::FunctionImp, KJS::ActivationImp, and KJS::StringInstanceImp.

Definition at line 268 of file object.cpp.

References _prop, KJS::HashEntry::attr, KJS::PropertyMap::get(), and KJS::PropertyMap::remove().

Referenced by KJS::StringInstanceImp::deleteProperty(), KJS::Object::deleteProperty(), KJS::ActivationImp::deleteProperty(), KJS::FunctionImp::deleteProperty(), KJS::ArrayInstanceImp::deleteProperty(), deletePropertyByIndex(), KJS::ArrayInstanceImp::deletePropertyByIndex(), and KJS::Reference::deleteValue().

void ObjectImp::deleteAllProperties ExecState  ) 
 

Remove all properties from this object.

This doesn't take DontDelete into account, and isn't in the ECMA spec. It's simply a quick way to remove everything before destroying.

Definition at line 291 of file object.cpp.

References _prop, and KJS::PropertyMap::clear().

Value ObjectImp::defaultValue ExecState exec,
Type  hint
const [virtual]
 

Implementation of the [[DefaultValue]] internal property (implemented by all Objects).

See also:
Object::defaultValue()

Definition at line 297 of file object.cpp.

References KJS::Interpreter::builtinDatePrototype(), KJS::Object::call(), KJS::Error::create(), KJS::List::empty(), get(), KJS::Value::imp(), KJS::Object::imp(), KJS::Object::implementsCall(), KJS::ExecState::interpreter(), KJS::ExecState::setException(), KJS::toStringPropertyName, KJS::Value::type(), and KJS::valueOfPropertyName.

Referenced by KJS::Object::defaultValue(), and toPrimitive().

Object ObjectImp::construct ExecState exec,
const List args
[virtual]
 

Implementation of the [[Construct]] internal property.

See also:
Object::construct()

Reimplemented in KJS::ArrayObjectImp, KJS::BooleanObjectImp, KJS::DateObjectImp, KJS::ErrorObjectImp, KJS::NativeErrorImp, KJS::FunctionObjectImp, KJS::DeclaredFunctionImp, KJS::NumberObjectImp, KJS::ObjectObjectImp, KJS::RegExpObjectImp, and KJS::StringObjectImp.

Definition at line 370 of file object.cpp.

Referenced by KJS::Object::construct().

Value ObjectImp::call ExecState exec,
Object thisObj,
const List args
[virtual]
 

Implementation of the [[Call]] internal property.

See also:
Object::call()

Reimplemented in KJS::ArrayProtoFuncImp, KJS::ArrayObjectImp, KJS::BooleanProtoFuncImp, KJS::BooleanObjectImp, KJS::DateProtoFuncImp, KJS::DateObjectImp, KJS::DateObjectFuncImp, KJS::ErrorProtoFuncImp, KJS::ErrorObjectImp, KJS::NativeErrorImp, KJS::FunctionPrototypeImp, KJS::FunctionProtoFuncImp, KJS::FunctionObjectImp, KJS::FunctionImp, KJS::GlobalFuncImp, KJS::MathFuncImp, KJS::NumberProtoFuncImp, KJS::NumberObjectImp, KJS::ObjectProtoFuncImp, KJS::ObjectObjectImp, KJS::RegExpProtoFuncImp, KJS::RegExpObjectImp, KJS::StringProtoFuncImp, KJS::StringObjectImp, and KJS::StringObjectFuncImp.

Definition at line 381 of file object.cpp.

Boolean ObjectImp::hasInstance ExecState exec,
const Value value
[virtual]
 

Implementation of the [[HasInstance]] internal property.

See also:
Object::hasInstance()

Reimplemented in KJS::InternalFunctionImp.

Definition at line 392 of file object.cpp.

Referenced by KJS::Object::hasInstance().

const ScopeChain& KJS::ObjectImp::scope  )  const [inline]
 

Implementation of the [[Scope]] internal property.

See also:
Object::scope()

Definition at line 569 of file object.h.

Referenced by KJS::ContextImp::ContextImp(), and KJS::Object::scope().

ReferenceList ObjectImp::propList ExecState exec,
bool  recursive = true
[virtual]
 

######### check for duplicates with the propertymap

Reimplemented in KJS::ArrayInstanceImp, and KJS::StringInstanceImp.

Definition at line 398 of file object.cpp.

References _prop, KJS::PropertyMap::addEnumerablesToReferenceList(), KJS::ReferenceList::append(), KJS::HashEntry::attr, classInfo(), KJS::ValueImp::dispatchType(), KJS::HashTable::entries, KJS::ClassInfo::parentClass, KJS::ClassInfo::propHashTable, KJS::HashTable::sbase, KJS::HashTable::size, and KJS::HashEntry::soffset.

Referenced by KJS::StringInstanceImp::propList(), KJS::Object::propList(), and KJS::ArrayInstanceImp::propList().

void ObjectImp::setFunctionName const Identifier propertyName  ) 
 

Sets the name of the function, if this is an InternalFunctionImp object.

(calling InternalFunctionImp::setName)

Definition at line 481 of file object.cpp.

References KJS::InternalFunctionImp::info, and inherits().

Referenced by KJS::lookupOrCreateFunction().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kjs Library Version 3.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Jul 20 13:54:28 2006 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003