\section{KJS::Object Class Reference}
\label{classKJS_1_1Object}\index{KJS::Object@{KJS::Object}}
Represents an {\bf Object}{\rm (p.\,\pageref{classKJS_1_1Object})}.  


{\tt \#include $<$object.h$>$}

Inheritance diagram for KJS::Object:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=50pt]{classKJS_1_1Object__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KJS::Object:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=59pt]{classKJS_1_1Object__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Object} (Object\-Imp $\ast$v)\label{classKJS_1_1Object_a1}

\item 
{\bf Object} (const  {\bf Object} \&v)\label{classKJS_1_1Object_a2}

\item 
{\bf Object} \& {\bf operator=} (const  {\bf Object} \&v)\label{classKJS_1_1Object_a4}

\item 
virtual const  {\bf Class\-Info} $\ast$ {\bf class\-Info} () const \label{classKJS_1_1Object_a5}

\item 
bool {\bf inherits} (const  {\bf Class\-Info} $\ast$cinfo) const \label{classKJS_1_1Object_a6}

\item 
{\bf Value} {\bf prototype} () const 
\begin{CompactList}\small\item\em Returns the prototype of this object. \item\end{CompactList}\item 
{\bf UString} {\bf class\-Name} () const 
\begin{CompactList}\small\item\em Returns the class name of the object. \item\end{CompactList}\item 
{\bf Value} {\bf get} ({\bf Exec\-State} $\ast$exec, const  {\bf UString} \&property\-Name) const 
\begin{CompactList}\small\item\em Retrieves the specified property from the object. \item\end{CompactList}\item 
void {\bf put} ({\bf Exec\-State} $\ast$exec, const  {\bf UString} \&property\-Name, const  {\bf Value} \&value, int attr=None)
\begin{CompactList}\small\item\em Sets the specified property. \item\end{CompactList}\item 
bool {\bf can\-Put} ({\bf Exec\-State} $\ast$exec, const  {\bf UString} \&property\-Name) const 
\begin{CompactList}\small\item\em Used to check whether or not a particular property is allowed to be set on an object. \item\end{CompactList}\item 
bool {\bf has\-Property} ({\bf Exec\-State} $\ast$exec, const  {\bf UString} \&property\-Name) const 
\begin{CompactList}\small\item\em Checks to see whether the object (or any object in it's prototype chain) has a property with the specified name. \item\end{CompactList}\item 
bool {\bf delete\-Property} ({\bf Exec\-State} $\ast$exec, const  {\bf UString} \&property\-Name)
\begin{CompactList}\small\item\em Removes the specified property from the object. \item\end{CompactList}\item 
{\bf Value} {\bf default\-Value} ({\bf Exec\-State} $\ast$exec, Type hint) const 
\begin{CompactList}\small\item\em Converts the object into a primitive value. \item\end{CompactList}\item 
bool {\bf implements\-Construct} () const 
\begin{CompactList}\small\item\em Whether or not the object implements the {\bf construct()}{\rm (p.\,\pageref{classKJS_1_1Object_a16})} method. \item\end{CompactList}\item 
{\bf Object} {\bf construct} ({\bf Exec\-State} $\ast$exec, const  {\bf List} \&args)
\begin{CompactList}\small\item\em Creates a new object based on this object. \item\end{CompactList}\item 
bool {\bf implements\-Call} () const 
\begin{CompactList}\small\item\em Whether or not the object implements the {\bf call()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} method. \item\end{CompactList}\item 
{\bf Value} {\bf call} ({\bf Exec\-State} $\ast$exec, {\bf Object} \&this\-Obj, const  {\bf List} \&args)
\begin{CompactList}\small\item\em Calls this object as if it is a function. \item\end{CompactList}\item 
bool {\bf implements\-Has\-Instance} () const 
\begin{CompactList}\small\item\em Whether or not the object implements the {\bf has\-Instance()}{\rm (p.\,\pageref{classKJS_1_1Object_a20})} method. \item\end{CompactList}\item 
{\bf Boolean} {\bf has\-Instance} ({\bf Exec\-State} $\ast$exec, const  {\bf Value} \&value)
\begin{CompactList}\small\item\em Checks whether value delegates behaviour to this object. \item\end{CompactList}\item 
const  {\bf List} {\bf scope} () const 
\begin{CompactList}\small\item\em Returns the scope of this object. \item\end{CompactList}\item 
void {\bf set\-Scope} (const  {\bf List} \&s)\label{classKJS_1_1Object_a22}

\item 
{\bf List} {\bf prop\-List} ({\bf Exec\-State} $\ast$exec, bool recursive=true)
\begin{CompactList}\small\item\em Returns a {\bf List}{\rm (p.\,\pageref{classKJS_1_1List})} of References to all the properties of the object. \item\end{CompactList}\item 
{\bf Value} {\bf internal\-Value} () const 
\begin{CompactList}\small\item\em Returns the internal value of the object. \item\end{CompactList}\item 
void {\bf set\-Internal\-Value} (const  {\bf Value} \&v)
\begin{CompactList}\small\item\em Sets the internal value of the object. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
{\bf Object} {\bf dynamic\-Cast} (const  {\bf Value} \&v)
\begin{CompactList}\small\item\em Converts a {\bf Value}{\rm (p.\,\pageref{classKJS_1_1Value})} into an {\bf Object}{\rm (p.\,\pageref{classKJS_1_1Object})}. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Represents an {\bf Object}{\rm (p.\,\pageref{classKJS_1_1Object})}. 

This is a wrapper for Object\-Imp 



Definition at line 76 of file object.h.

\subsection{Member Function Documentation}
\index{KJS::Object@{KJS::Object}!dynamicCast@{dynamicCast}}
\index{dynamicCast@{dynamicCast}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Object::dynamic\-Cast (const {\bf Value} \& {\em v})\hspace{0.3cm}{\tt  [static]}}\label{classKJS_1_1Object_e0}


Converts a {\bf Value}{\rm (p.\,\pageref{classKJS_1_1Value})} into an {\bf Object}{\rm (p.\,\pageref{classKJS_1_1Object})}. 

If the value's type is not Object\-Type, 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 Object\-Type, you should check the {\bf is\-Null}{\rm (p.\,\pageref{classKJS_1_1Value_a6})}() methods afterwards before calling any methods on the {\bf Object}{\rm (p.\,\pageref{classKJS_1_1Object})}.

\begin{Desc}
\item[Returns:]The value converted to an object \end{Desc}


Definition at line 77 of file object.cpp.

References KJS::Value::imp(), KJS::Value::is\-Null(), and KJS::Value::type().\index{KJS::Object@{KJS::Object}!prototype@{prototype}}
\index{prototype@{prototype}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} Object::prototype () const}\label{classKJS_1_1Object_a7}


Returns the prototype of this object. 

Note that this is not the same as the \char`\"{}prototype\char`\"{} property.

See ECMA 8.6.2

\begin{Desc}
\item[Returns:]The object's prototype \end{Desc}


Definition at line 85 of file object.cpp.\index{KJS::Object@{KJS::Object}!className@{className}}
\index{className@{className}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf UString} Object::class\-Name () const}\label{classKJS_1_1Object_a8}


Returns the class name of the object. 

See ECMA 8.6.2

\begin{Desc}
\item[Returns:]The object's class name \end{Desc}


Definition at line 90 of file object.cpp.\index{KJS::Object@{KJS::Object}!get@{get}}
\index{get@{get}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} Object::get ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf UString} \& {\em property\-Name}) const}\label{classKJS_1_1Object_a9}


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 {\bf Undefined}{\rm (p.\,\pageref{classKJS_1_1Undefined})}.

See ECMA 8.6.2.1

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em property\-Name}]The name of the property to retrieve\end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The specified property, or {\bf Undefined}{\rm (p.\,\pageref{classKJS_1_1Undefined})} \end{Desc}


Definition at line 95 of file object.cpp.\index{KJS::Object@{KJS::Object}!put@{put}}
\index{put@{put}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Object::put ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf UString} \& {\em property\-Name}, const {\bf Value} \& {\em value}, int {\em attr} = None)}\label{classKJS_1_1Object_a10}


Sets the specified property. 

See ECMA 8.6.2.2

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em property\-Name}]The name of the property to set \item[{\em property\-Value}]The value to set \end{description}
\end{Desc}


Definition at line 100 of file object.cpp.

Referenced by KJS::Error::create().\index{KJS::Object@{KJS::Object}!canPut@{canPut}}
\index{canPut@{canPut}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Object::can\-Put ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf UString} \& {\em property\-Name}) const}\label{classKJS_1_1Object_a11}


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

See ECMA 8.6.2.3

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em property\-Name}]The name of the property \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if the property can be set, otherwise false \end{Desc}


Definition at line 105 of file object.cpp.\index{KJS::Object@{KJS::Object}!hasProperty@{hasProperty}}
\index{hasProperty@{hasProperty}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Object::has\-Property ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf UString} \& {\em property\-Name}) const}\label{classKJS_1_1Object_a12}


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

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em property\-Name}]The name of the property to check for \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if the object has the property, otherwise false \end{Desc}


Definition at line 110 of file object.cpp.\index{KJS::Object@{KJS::Object}!deleteProperty@{deleteProperty}}
\index{deleteProperty@{deleteProperty}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Object::delete\-Property ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf UString} \& {\em property\-Name})}\label{classKJS_1_1Object_a13}


Removes the specified property from the object. 

See ECMA 8.6.2.5

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em property\-Name}]The name of the property to delete \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if the property was successfully deleted or did not exist on the object. false if deleting the specified property is not allowed. \end{Desc}


Definition at line 115 of file object.cpp.\index{KJS::Object@{KJS::Object}!defaultValue@{defaultValue}}
\index{defaultValue@{defaultValue}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} Object::default\-Value ({\bf Exec\-State} $\ast$ {\em exec}, Type {\em hint}) const}\label{classKJS_1_1Object_a14}


Converts the object into a primitive value. 

The value return may differ depending on the supplied hint

See ECMA 8.6.2.6

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em hint}]The desired primitive type to convert to \end{description}
\end{Desc}
\begin{Desc}
\item[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. \end{Desc}


Definition at line 120 of file object.cpp.\index{KJS::Object@{KJS::Object}!implementsConstruct@{implementsConstruct}}
\index{implementsConstruct@{implementsConstruct}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Object::implements\-Construct () const}\label{classKJS_1_1Object_a15}


Whether or not the object implements the {\bf construct()}{\rm (p.\,\pageref{classKJS_1_1Object_a16})} method. 

If this returns false you should not call the {\bf construct()}{\rm (p.\,\pageref{classKJS_1_1Object_a16})} method on this object (typically, an assertion will fail to indicate this).

\begin{Desc}
\item[Returns:]true if this object implements the {\bf construct()}{\rm (p.\,\pageref{classKJS_1_1Object_a16})} method, otherwise false \end{Desc}


Definition at line 125 of file object.cpp.\index{KJS::Object@{KJS::Object}!construct@{construct}}
\index{construct@{construct}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} Object::construct ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf List} \& {\em args})}\label{classKJS_1_1Object_a16}


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 \char`\"{}prototype\char`\"{} property 3. The {\bf call()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} 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 Exec\-State::had\-Exception(). Under some circumstances, the exception object may also be returned.

Note: This function should not be called if {\bf implements\-Construct()}{\rm (p.\,\pageref{classKJS_1_1Object_a15})} returns false, in which case it will result in an assertion failure.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em args}]The arguments to be passed to {\bf call()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} once the new object has been created \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The newly created \& initialized object \end{Desc}


Definition at line 130 of file object.cpp.

Referenced by KJS::Error::create().\index{KJS::Object@{KJS::Object}!implementsCall@{implementsCall}}
\index{implementsCall@{implementsCall}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Object::implements\-Call () const}\label{classKJS_1_1Object_a17}


Whether or not the object implements the {\bf call()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} method. 

If this returns false you should not call the {\bf call()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} method on this object (typically, an assertion will fail to indicate this).

\begin{Desc}
\item[Returns:]true if this object implements the {\bf call()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} method, otherwise false \end{Desc}


Definition at line 135 of file object.cpp.\index{KJS::Object@{KJS::Object}!call@{call}}
\index{call@{call}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} Object::call ({\bf Exec\-State} $\ast$ {\em exec}, {\bf Object} \& {\em this\-Obj}, const {\bf List} \& {\em args})}\label{classKJS_1_1Object_a18}


Calls this object as if it is a function. 

Note: This function should not be called if {\bf implements\-Call()}{\rm (p.\,\pageref{classKJS_1_1Object_a17})} returns false, in which case it will result in an assertion failure.

See ECMA 8.6.2.3

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em this\-Obj}]The obj to be used as \char`\"{}this\char`\"{} within function execution. Note that in most cases this will be different from the C++ \char`\"{}this\char`\"{} object. For example, if the ECMAScript code \char`\"{}window.location.to\-String()\char`\"{} is executed, {\bf call()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} will be invoked on the C++ object which implements the to\-String method, with the this\-Obj being window.location \item[{\em args}]{\bf List}{\rm (p.\,\pageref{classKJS_1_1List})} of arguments to be passed to the function \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The return value from the function \end{Desc}


Definition at line 140 of file object.cpp.

References KJS::Exec\-State::set\-Exception().\index{KJS::Object@{KJS::Object}!implementsHasInstance@{implementsHasInstance}}
\index{implementsHasInstance@{implementsHasInstance}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool Object::implements\-Has\-Instance () const}\label{classKJS_1_1Object_a19}


Whether or not the object implements the {\bf has\-Instance()}{\rm (p.\,\pageref{classKJS_1_1Object_a20})} method. 

If this returns false you should not call the {\bf has\-Instance()}{\rm (p.\,\pageref{classKJS_1_1Object_a20})} method on this object (typically, an assertion will fail to indicate this).

\begin{Desc}
\item[Returns:]true if this object implements the {\bf has\-Instance()}{\rm (p.\,\pageref{classKJS_1_1Object_a20})} method, otherwise false \end{Desc}


Definition at line 164 of file object.cpp.\index{KJS::Object@{KJS::Object}!hasInstance@{hasInstance}}
\index{hasInstance@{hasInstance}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Boolean} Object::has\-Instance ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf Value} \& {\em value})}\label{classKJS_1_1Object_a20}


Checks whether value delegates behaviour to this object. 

Used by the instanceof operator.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em value}]The value to check \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]true if value delegates behaviour to this object, otherwise false \end{Desc}


Definition at line 169 of file object.cpp.\index{KJS::Object@{KJS::Object}!scope@{scope}}
\index{scope@{scope}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const  {\bf List} Object::scope () const}\label{classKJS_1_1Object_a21}


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();

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 {\bf String}{\rm (p.\,\pageref{classKJS_1_1String})} object that was assigned to f.prototype.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]The function's scope \end{Desc}


Definition at line 174 of file object.cpp.\index{KJS::Object@{KJS::Object}!propList@{propList}}
\index{propList@{propList}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf List} Object::prop\-List ({\bf Exec\-State} $\ast$ {\em exec}, bool {\em recursive} = true)}\label{classKJS_1_1Object_a23}


Returns a {\bf List}{\rm (p.\,\pageref{classKJS_1_1List})} of References to all the properties of the object. 

Used in \char`\"{}for x in y\char`\"{} 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 Object\-Impl to provide the appearance of having extra properties other than those set specifically with {\bf put()}{\rm (p.\,\pageref{classKJS_1_1Object_a10})}.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em exec}]The current execution state \item[{\em recursive}]Whether or not properties in the object's prototype chain should be included in the list. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]A {\bf List}{\rm (p.\,\pageref{classKJS_1_1List})} of References to properties of the object. \end{Desc}


Definition at line 184 of file object.cpp.\index{KJS::Object@{KJS::Object}!internalValue@{internalValue}}
\index{internalValue@{internalValue}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} Object::internal\-Value () const}\label{classKJS_1_1Object_a24}


Returns the internal value of the object. 

This is used for objects such as {\bf String}{\rm (p.\,\pageref{classKJS_1_1String})} and {\bf Boolean}{\rm (p.\,\pageref{classKJS_1_1Boolean})} which are wrappers for native types. The interal value is the actual value represented by the wrapper objects.

\begin{Desc}
\item[See also:]ECMA 8.6.2 \end{Desc}
\begin{Desc}
\item[Returns:]The internal value of the object \end{Desc}


Definition at line 189 of file object.cpp.\index{KJS::Object@{KJS::Object}!setInternalValue@{setInternalValue}}
\index{setInternalValue@{setInternalValue}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void Object::set\-Internal\-Value (const {\bf Value} \& {\em v})}\label{classKJS_1_1Object_a25}


Sets the internal value of the object. 

\begin{Desc}
\item[See also:]{\bf internal\-Value()}{\rm (p.\,\pageref{classKJS_1_1Object_a24})}\end{Desc}
\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em v}]The new internal value \end{description}
\end{Desc}


Definition at line 194 of file object.cpp.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
object.h\item 
object.cpp\end{CompactItemize}
