Unicorn XML Toolkit
Version 1.00.00

Namespace EcmaScript
Class CObject

class CObject: public CInterface {
public:
    enum {
        hintNone,
        hintString,
        hintNumber
        };
public:
    CObject();
    virtual ~CObject();
public:
    virtual XObject Prototype() = 0;
    virtual CString Class() = 0;
    virtual XValue Value() = 0;
    virtual void SetValue(const XValue &pValue) = 0;
    virtual XValue Get(
        CContext &context, 
        const CPropertyName &propertyName) = 0;
    virtual void Put(
        CContext &context,
        const CPropertyName &propertyName, 
        const XValue &pValue) = 0;
    virtual bool CanPut(
        CContext &context, 
        const CPropertyName &propertyName) = 0;
    virtual bool HasProperty(
        CContext &context, 
        const CPropertyName &propertyName) = 0;
    virtual bool Delete(
        CContext &context, 
        const CPropertyName &propertyName) = 0;
    virtual XValue DefaultValue(CContext &context, int nHint) = 0;
    virtual XValue Construct(
        CContext &context, const CList &argList) = 0;
    virtual XValue Call(
        CContext &context, 
        const XObject &pThis, 
        const CList &argList) = 0;
    virtual bool Match(
        CContext &context,
        CString &strString,
        int nIndex,
        RegExp::CResult &result) = 0;
    virtual void CreateProperty(
        const CPropertyName &propertyName,
        const XValue &pValue,
        int nAttributes,
        bool bOverride=true) = 0;
    virtual XEnumerator CreateEnumerator() = 0;
    virtual CString TypeOf() = 0;
    virtual XObject CreateObject() = 0;
    virtual bool Equals(const XObject &pObject);
    };

The abstract interface to ECMAScript objects.

Since:
1.00.00
Version:
1.00.00
Author:
Alexey Gokhberg
See Also:
CValue, CPropertyName, CContext, CEnumerator, CList, RegExp::CResult
Constructor/Destructor Summary
CObject ();
����������Constructs the object.
~CObject ();
����������Destroys the object.

Function Summary
XObject Prototype ();
����������Returns the prototype object of this object.
CString Class ();
����������Returns the class of this object.
XValue Value ();
����������Returns the value associated with this object.
void SetValue (const XValue &pValue);
����������Associates the new value with this object.
XValue Get (CContext &context, const CPropertyName &propertyName);
����������Gets the value of the given property of this object.
void Put (CContext &context, const CPropertyName &propertyName, const XValue &pValue);
����������Puts the given value of the given property of this object.
bool CanPut (CContext &context, const CPropertyName &propertyName);
����������Tests whether the put operation is allowed for the given property of this object.
bool HasProperty (CContext &context, const CPropertyName &propertyName);
����������Tests whether this object has the given property.
bool Delete (CContext &context, const CPropertyName &propertyName);
����������Deletes the given property from the property list of this object.
XValue DefaultValue (CContext &context, int nHint);
����������Returns the defaut value associated with this object.
XValue Construct (CContext &context, const CList &argList);
����������Calls this object as a constructor.
XValue Call (CContext &context, const XObject &pThis, const CList &argList);
����������Calls this object as a function.
bool Match (CContext &context, CString &strString, int nIndex, RegExp::CResult &result);
����������Matches the given string against this object.
void CreateProperty (const CPropertyName &propertyName, const XValue &pValue, int nAttributes, bool bOverride=true);
����������Creates a property with the given property name, initial value and attributes.
XEnumerator CreateEnumerator ();
����������Creates an enumerator for properties of this object.
CString TypeOf ();
����������Returns a string representing type of this object.
XObject CreateObject ();
����������Called by the ECMAScript Object constructor when this object is passed as a constructor argument.
bool Equals (const XObject &pObject);
����������Matches this object and another object for equality.

Constructor/Destructor Detail

CObject

CObject();

Constructs the object.

~CObject

virtual ~CObject();

Destroys the object.

Function Detail

Prototype

virtual XObject Prototype() = 0;

Returns the prototype object of this object.

This function corresponds to the internal [[Prototype]] property.

Returns:
the prototype object of this object; NULL if this object has no prototype

Class

virtual CString Class() = 0;

Returns the class of this object.

This function corresponds to the internal [[Class]] property.

Returns:
the class of this object

Value

virtual XValue Value() = 0;

Returns the value associated with this object.

This function corresponds to the internal [[Value]] property.

Returns:
the value associated with this object; NULL if this object has no value associated

SetValue

virtual void SetValue(const XValue &pValue) = 0;

Associates the new value with this object.

This function corresponds to the internal [[Value]] property.

Parameters:
pValue - the new value

Get

virtual XValue Get(
    CContext &context, 
    const CPropertyName &propertyName) = 0;

Gets the value of the given property of this object.

This function corresponds to the internal [[Get]] property.

Parameters:
context - the evaluation context
propertyName - the property name
Returns:
the value of the property obtained as the result of the get operation

Put

virtual void Put(
    CContext &context,
    const CPropertyName &propertyName, 
    const XValue &pValue) = 0;

Puts the given value of the given property of this object.

This function corresponds to the internal [[Put]] property.

Parameters:
context - the evaluation context
propertyName - the property name
pValue - the value to put

CanPut

virtual bool CanPut(
    CContext &context, 
    const CPropertyName &propertyName) = 0;

Tests whether the put operation is allowed for the given property of this object.

This function corresponds to the internal [[CanPut]] property.

Parameters:
context - the evaluation context
propertyName - the property name
Returns:
true if the put operation is allowed; false otherwise

HasProperty

virtual bool HasProperty(
    CContext &context, 
    const CPropertyName &propertyName) = 0;

Tests whether this object has the given property.

This function corresponds to the internal [[HasProperty]] property.

Parameters:
context - the evaluation context
propertyName - the property name
Returns:
true if this object has the property; false otherwise

Delete

virtual bool Delete(
    CContext &context, 
    const CPropertyName &propertyName) = 0;

Deletes the given property from the property list of this object.

This function corresponds to the internal [[Delete]] property.

Parameters:
context - the evaluation context
propertyName - the property name
Returns:
true if the property was deleted successfully; false otherwise

DefaultValue

virtual XValue DefaultValue(CContext &context, int nHint) = 0;

Returns the defaut value associated with this object.

The desired type of the default value must be specified using nHint parameter. Allowed values for this parameter are CValue::hintNone , CValue::hintString , and CValue::hintNumber .

This function corresponds to the internal [[DefaultValue]] property.

Parameters:
context - the evaluation context
nHint - the integer specifying the desired type of the default value
Returns:
the default value associated with this object

Construct

virtual XValue Construct(
    CContext &context, const CList &argList) = 0;

Calls this object as a constructor.

This function corresponds to the internal [[Construct]] property.

Parameters:
context - the evaluation context
argList - the list of argument values
Returns:
the value representing the newly constructed object

Call

virtual XValue Call(
    CContext &context, 
    const XObject &pThis, 
    const CList &argList) = 0;

Calls this object as a function.

This function corresponds to the internal [[Call]] property.

Parameters:
context - the evaluation context
pThis - the object to be used as value of this during the function call
argList - the list of argument values
Returns:
the value obtained as the result of the function call

Match

virtual bool Match(
    CContext &context,
    CString &strString,
    int nIndex,
    RegExp::CResult &result) = 0;

Matches the given string against this object.

This function corresponds to the internal [[Match]] property (defined in the 3rd edition of ECMA-262).

Parameters:
context - the evaluation context
strString - the string to match
nIndex - the starting index in the string
result - on return, contains the result of match
Returns:
true if match succeeded; false otherwise

CreateProperty

virtual void CreateProperty(
    const CPropertyName &propertyName,
    const XValue &pValue,
    int nAttributes,
    bool bOverride=true) = 0;

Creates a property with the given property name, initial value and attributes.

Parameters:
propertyName - the property name
pValue - the initial value of the property
nAttributes - the set of property attributes represented as the combination of bit flags declared by the CAttribute class
bOverride - indicates whether property with the given property name, if already present, must be overriden

CreateEnumerator

virtual XEnumerator CreateEnumerator() = 0;

Creates an enumerator for properties of this object.

Returns:
the newly created enumerator

TypeOf

virtual CString TypeOf() = 0;

Returns a string representing type of this object.

Returns:
the string representing type of this object

CreateObject

virtual XObject CreateObject() = 0;

Called by the ECMAScript Object constructor when this object is passed as a constructor argument.

Returns:
the object to be used as the constructor return value

Equals

virtual bool Equals(const XObject &pObject);

Matches this object and another object for equality.

This function is needed, because certain classes of host objects might be represented by several instances of CObject class; therefore the straightforward matching of instance pointers for equality may be not sufficient to determine whether these pointers refer to the same ECMAScript object.

Parameters:
pObject - the object to match
Returns:
true , if this object and the object specified refer to the same ECMAScript object

Unicorn XML Toolkit
Version 1.00.00


This document was created using Unicorn DOC++.

Copyright 1999-2001 Unicorn Enterprises SA.
All Rights Reserved.