• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • KJS
  • Object
Public Member Functions | Static Public Member Functions | List of all members
KJS::Object Class Reference

#include <object.h>

Inheritance diagram for KJS::Object:
KJS::Value

Public Member Functions

 Object (ObjectImp *v)
 
ObjectImp * imp () const
 
const ClassInfo * classInfo () const
 
bool inherits (const ClassInfo *cinfo) const
 
Value prototype () const
 
UString className () const
 
Value get (ExecState *exec, const Identifier &propertyName) const
 
Value get (ExecState *exec, unsigned propertyName) const
 
void put (ExecState *exec, const Identifier &propertyName, const Value &value, int attr=None)
 
void put (ExecState *exec, unsigned propertyName, const Value &value, int attr=None)
 
bool canPut (ExecState *exec, const Identifier &propertyName) const
 
bool hasProperty (ExecState *exec, const Identifier &propertyName) const
 
bool hasProperty (ExecState *exec, unsigned propertyName) const
 
bool deleteProperty (ExecState *exec, const Identifier &propertyName)
 
bool deleteProperty (ExecState *exec, unsigned propertyName)
 
Value defaultValue (ExecState *exec, Type hint) const
 
bool implementsConstruct () const
 
Object construct (ExecState *exec, const List &args)
 
bool implementsCall () const
 
Value call (ExecState *exec, Object &thisObj, const List &args)
 
bool implementsHasInstance () const
 
Boolean hasInstance (ExecState *exec, const Value &value)
 
const ScopeChain & scope () const
 
void setScope (const ScopeChain &s)
 
ReferenceList propList (ExecState *exec, bool recursive=true)
 
Value internalValue () const
 
void setInternalValue (const Value &v)
 
- Public Member Functions inherited from KJS::Value
 Value (ValueImp *v)
 
 Value (const Value &v)
 
Value & operator= (const Value &v)
 
bool isValid () const
 
bool isNull () const
 
ValueImp * imp () const
 
Type type () const
 
bool isA (Type t) const
 
Value toPrimitive (ExecState *exec, Type preferredType=UnspecifiedType) const
 
bool toBoolean (ExecState *exec) const
 
double toNumber (ExecState *exec) const
 
int toInteger (ExecState *exec) const
 
int toInt32 (ExecState *exec) const
 
unsigned int toUInt32 (ExecState *exec) const
 
unsigned short toUInt16 (ExecState *exec) const
 
UString toString (ExecState *exec) const
 
Object toObject (ExecState *exec) const
 
bool toUInt32 (unsigned &i) const
 

Static Public Member Functions

static Object dynamicCast (const Value &v)
 

Additional Inherited Members

- Protected Attributes inherited from KJS::Value
ValueImp * rep
 

Detailed Description

Represents an Object.

This is a wrapper for ObjectImp

Definition at line 81 of file object.h.

Constructor & Destructor Documentation

◆ Object() [1/2]

KJS::Object::Object ( )
inline

Definition at line 83 of file object.h.

◆ Object() [2/2]

KJS::Object::Object ( ObjectImp *  v)
inlineexplicit

Definition at line 647 of file object.h.

Member Function Documentation

◆ call()

Value Object::call ( ExecState *  exec,
Object &  thisObj,
const List &  args 
)

Calls this object as if it is a function.

Note: This function should not be called if implementsCall() returns false, in which case it will result in an assertion failure.

See ECMA 8.6.2.3

Parameters
execThe current execution state
thisObjThe obj to be used as "this" within function execution. Note that in most cases this will be different from the C++ "this" object. For example, if the ECMAScript code "window.location.toString()" is executed, call() will be invoked on the C++ object which implements the toString method, with the thisObj being window.location
argsList of arguments to be passed to the function
Returns
The return value from the function

Definition at line 53 of file object.cpp.

◆ canPut()

bool KJS::Object::canPut ( ExecState *  exec,
const Identifier &  propertyName 
) const
inline

Used to check whether or not a particular property is allowed to be set on an object.

See ECMA 8.6.2.3

Parameters
execThe current execution state
propertyNameThe name of the property
Returns
true if the property can be set, otherwise false

Definition at line 675 of file object.h.

◆ classInfo()

const ClassInfo * KJS::Object::classInfo ( ) const
inline

Definition at line 651 of file object.h.

◆ className()

UString KJS::Object::className ( ) const
inline

Returns the class name of the object.

See ECMA 8.6.2

Returns
The object's class name

Definition at line 660 of file object.h.

◆ construct()

Object KJS::Object::construct ( ExecState *  exec,
const List &  args 
)
inline

Creates a new object based on this object.

Typically this means the following:

  1. A new object is created
  2. The prototype of the new object is set to the value of this object's "prototype" property
  3. The call() method of this object is called, with the new object passed as the this value
  4. The new object is returned

In some cases, Host objects may differ from these semantics, although this is discouraged.

If an error occurs during construction, the execution state's exception will be set. This can be tested for with ExecState::hadException(). Under some circumstances, the exception object may also be returned.

Note: This function should not be called if implementsConstruct() returns false, in which case it will result in an assertion failure.

Parameters
execThe current execution state
argsThe arguments to be passed to call() once the new object has been created
Returns
The newly created & initialized object

Definition at line 696 of file object.h.

◆ defaultValue()

Value KJS::Object::defaultValue ( ExecState *  exec,
Type  hint 
) const
inline

Converts the object into a primitive value.

The value return may differ depending on the supplied hint

See ECMA 8.6.2.6

Parameters
execThe current execution state
hintThe desired primitive type to convert to
Returns
A primitive value converted from the objetc. Note that the type of primitive value returned may not be the same as the requested hint.

Definition at line 690 of file object.h.

◆ deleteProperty() [1/2]

bool KJS::Object::deleteProperty ( ExecState *  exec,
const Identifier &  propertyName 
)
inline

Removes the specified property from the object.

See ECMA 8.6.2.5

Parameters
execThe current execution state
propertyNameThe name of the property to delete
Returns
true if the property was successfully deleted or did not exist on the object. false if deleting the specified property is not allowed.

Definition at line 684 of file object.h.

◆ deleteProperty() [2/2]

bool KJS::Object::deleteProperty ( ExecState *  exec,
unsigned  propertyName 
)
inline

Definition at line 687 of file object.h.

◆ dynamicCast()

Object Object::dynamicCast ( const Value &  v)
static

Converts a Value into an Object.

If the value's type is not ObjectType, a null object will be returned (i.e. one with it's internal pointer set to 0). If you do not know for sure whether the value is of type ObjectType, you should check the isValid() methods afterwards before calling any methods on the Object.

Returns
The value converted to an object

Definition at line 45 of file object.cpp.

◆ get() [1/2]

Value KJS::Object::get ( ExecState *  exec,
const Identifier &  propertyName 
) const
inline

Retrieves the specified property from the object.

If neither the object or any other object in it's prototype chain have the property, this function will return Undefined.

See ECMA 8.6.2.1

Parameters
execThe current execution state
propertyNameThe name of the property to retrieve
Returns
The specified property, or Undefined

Definition at line 663 of file object.h.

◆ get() [2/2]

Value KJS::Object::get ( ExecState *  exec,
unsigned  propertyName 
) const
inline

Definition at line 666 of file object.h.

◆ hasInstance()

Boolean KJS::Object::hasInstance ( ExecState *  exec,
const Value &  value 
)
inline

Checks whether value delegates behavior to this object.

Used by the instanceof operator.

Parameters
execThe current execution state
valueThe value to check
Returns
true if value delegates behavior to this object, otherwise false

Definition at line 705 of file object.h.

◆ hasProperty() [1/2]

bool KJS::Object::hasProperty ( ExecState *  exec,
const Identifier &  propertyName 
) const
inline

Checks to see whether the object (or any object in it's prototype chain) has a property with the specified name.

See ECMA 8.6.2.4

Parameters
execThe current execution state
propertyNameThe name of the property to check for
Returns
true if the object has the property, otherwise false

Definition at line 678 of file object.h.

◆ hasProperty() [2/2]

bool KJS::Object::hasProperty ( ExecState *  exec,
unsigned  propertyName 
) const
inline

Definition at line 681 of file object.h.

◆ imp()

ObjectImp * KJS::Object::imp ( ) const
inline

Definition at line 649 of file object.h.

◆ implementsCall()

bool KJS::Object::implementsCall ( ) const
inline

Whether or not the object implements the call() method.

If this returns false you should not call the call() method on this object (typically, an assertion will fail to indicate this).

Returns
true if this object implements the call() method, otherwise false

Definition at line 699 of file object.h.

◆ implementsConstruct()

bool KJS::Object::implementsConstruct ( ) const
inline

Whether or not the object implements the construct() method.

If this returns false you should not call the construct() method on this object (typically, an assertion will fail to indicate this).

Returns
true if this object implements the construct() method, otherwise false

Definition at line 693 of file object.h.

◆ implementsHasInstance()

bool KJS::Object::implementsHasInstance ( ) const
inline

Whether or not the object implements the hasInstance() method.

If this returns false you should not call the hasInstance() method on this object (typically, an assertion will fail to indicate this).

Returns
true if this object implements the hasInstance() method, otherwise false

Definition at line 702 of file object.h.

◆ inherits()

bool KJS::Object::inherits ( const ClassInfo *  cinfo) const
inline

Definition at line 654 of file object.h.

◆ internalValue()

Value KJS::Object::internalValue ( ) const
inline

Returns the internal value of the object.

This is used for objects such as String and Boolean which are wrappers for native types. The interal value is the actual value represented by the wrapper objects.

See also
ECMA 8.6.2
Returns
The internal value of the object

Definition at line 717 of file object.h.

◆ propList()

ReferenceList KJS::Object::propList ( ExecState *  exec,
bool  recursive = true 
)
inline

Returns a List of References to all the properties of the object.

Used in "for x in y" statements. The list is created new, so it can be freely modified without affecting the object's properties. It should be deleted by the caller.

Subclasses can override this method in ObjectImpl to provide the appearance of having extra properties other than those set specifically with put().

Parameters
execThe current execution state
recursiveWhether or not properties in the object's prototype chain should be included in the list.
Returns
A List of References to properties of the object.

Definition at line 714 of file object.h.

◆ prototype()

Value KJS::Object::prototype ( ) const
inline

Returns the prototype of this object.

Note that this is not the same as the "prototype" property.

See ECMA 8.6.2

Returns
The object's prototype

Definition at line 657 of file object.h.

◆ put() [1/2]

void KJS::Object::put ( ExecState *  exec,
const Identifier &  propertyName,
const Value &  value,
int  attr = None 
)
inline

Sets the specified property.

See ECMA 8.6.2.2

Parameters
execThe current execution state
propertyNameThe name of the property to set
valueThe value to set
attrThe Attribute value for the property

Definition at line 669 of file object.h.

◆ put() [2/2]

void KJS::Object::put ( ExecState *  exec,
unsigned  propertyName,
const Value &  value,
int  attr = None 
)
inline

Definition at line 672 of file object.h.

◆ scope()

const ScopeChain & KJS::Object::scope ( ) const
inline

Returns the scope of this object.

This is used when execution declared functions - the execution context for the function is initialized with extra object in it's scope. An example of this is functions declared inside other functions:

function f() {
function b() {
return prototype;
}
var x = 4;
// do some stuff
}
f.prototype = new String();
KJS::Object::prototype
Value prototype() const
Returns the prototype of this object.
Definition: object.h:657

When the function f.b is executed, its scope will include properties of f. So in the example above the return value of f.b() would be the new String object that was assigned to f.prototype.

Returns
The function's scope

Definition at line 708 of file object.h.

◆ setInternalValue()

void KJS::Object::setInternalValue ( const Value &  v)
inline

Sets the internal value of the object.

See also
internalValue()
Parameters
vThe new internal value

Definition at line 720 of file object.h.

◆ setScope()

void KJS::Object::setScope ( const ScopeChain &  s)
inline

Definition at line 711 of file object.h.


The documentation for this class was generated from the following files:
  • object.h
  • object.cpp

kjs

Skip menu "kjs"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kjs

Skip menu "kjs"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.9.4
This website is maintained by Timothy Pearson.