Unicorn XML Toolkit
Version 1.00.00

Namespace EcmaScript
Class CNativeObject

class CNativeObject: virtual public CObject {
    friend class CNativeEnumerator;
public:
    CNativeObject(
        CGlobalObject *pGlobalObject,
        const XObject &pPrototype);
    ~CNativeObject();
public:
    XObject Prototype();
    CString Class();
    XValue Value();
    void SetValue(const XValue &pValue);
    XValue Get(
        CContext &context, 
        const CPropertyName &propertyName);
    void Put(
        CContext &context, 
        const CPropertyName &propertyName, 
        const XValue &pValue);
    bool CanPut(
        CContext &context, 
        const CPropertyName &propertyName);
    bool HasProperty(
        CContext &context, 
        const CPropertyName &propertyName);
    bool Delete(
        CContext &context, 
        const CPropertyName &propertyName);
    XValue DefaultValue(CContext &context, int nHint);
    XValue Construct(CContext &context, const CList &argList);
    XValue Call(
        CContext &context, 
        const XObject &pThis, 
        const CList &argList);
    bool Match(
        CContext &context,
        CString &strString,
        int nIndex,
        RegExp::CResult &result);
    void CreateProperty(
        const CPropertyName &propertyName,
        const XValue &pValue,
        int nAttributes,
        bool bOverride=true);
    XEnumerator CreateEnumerator();
    CString TypeOf();
    XObject CreateObject();
public:
    void SetPropertyMap(const XPropertyMap &pPropertyMap);
public:
    virtual XValue GetProperty(
        CContext &context,
        int nSelector);
    virtual void PutProperty(
        CContext &context,
        int nSelector,
        const XValue &pValue);
    virtual XValue FunctionCall(
        CContext &context, 
        int nSelector, 
        const XObject &pThis, 
        const CList &argList);
    };

The abstract interface to ECMAScript native objects.

Since:
1.00.00
Version:
1.00.00
Author:
Alexey Gokhberg
See Also:
CValue, CPropertyName, CContext, CEnumerator, CList, CPropertyMap, RegExp::CResult
Constructor/Destructor Summary
CNativeObject (CGlobalObject *pGlobalObject, const XObject &pPrototype);
����������Constructs the native object.
~CNativeObject ();
����������Destroys the native 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.
void SetPropertyMap (const XPropertyMap &pPropertyMap);
����������Attaches a property map to this native object.
XValue GetProperty (CContext &context, int nSelector);
����������Gets the value of the property referenced by the given selector.
void PutProperty (CContext &context, int nSelector, const XValue &pValue);
����������Puts the value of the property referenced by the given selector.
XValue FunctionCall (CContext &context, int nSelector, const XObject &pThis, const CList &argList);
����������Calls the function property referenced by the given selector.

Constructor/Destructor Detail

CNativeObject

CNativeObject(
    CGlobalObject *pGlobalObject,
    const XObject &pPrototype);

Constructs the native object.

Parameters:
pGlobalObject - the global object
pPrototype - the prototype of the constructed object

~CNativeObject

~CNativeObject();

Destroys the native object.

Function Detail

Prototype

XObject Prototype();

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

CString Class();

Returns the class of this object.

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

Returns:
the class of this object

Value

XValue Value();

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

void SetValue(const XValue &pValue);

Associates the new value with this object.

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

Parameters:
pValue - the new value

Get

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

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

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

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

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

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

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

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

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

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

XValue DefaultValue(CContext &context, int nHint);

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

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

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

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

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

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

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

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.

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

XEnumerator CreateEnumerator();

Creates an enumerator for properties of this object.

Returns:
the newly created enumerator

TypeOf

CString TypeOf();

Returns a string representing type of this object.

Returns:
the string representing type of this object

CreateObject

XObject CreateObject();

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

SetPropertyMap

void SetPropertyMap(const XPropertyMap &pPropertyMap);

Attaches a property map to this native object.

Parameters:
pPropertyMap - the property map

GetProperty

virtual XValue GetProperty(
    CContext &context,
    int nSelector);

Gets the value of the property referenced by the given selector.

Parameters:
context - the execution context
nSelector - the selector
Returns:
the value of the property referenced by the given selector

PutProperty

virtual void PutProperty(
    CContext &context,
    int nSelector,
    const XValue &pValue);

Puts the value of the property referenced by the given selector.

Parameters:
context - the execution context
nSelector - the selector
pValue - the value to put

FunctionCall

virtual XValue FunctionCall(
    CContext &context, 
    int nSelector, 
    const XObject &pThis, 
    const CList &argList);

Calls the function property referenced by the given selector.

See the description of the CBuiltinFunction class for the definition of function selectors.

Parameters:
context - the execution context
nSelector - the selector
pThis - this object
argList - the list of argument values
Returns:
the value obtained as the result of the function call

Unicorn XML Toolkit
Version 1.00.00


This document was created using Unicorn DOC++.

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