\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=52pt]{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 
Object\-Imp $\ast$ {\bf imp} () const \label{classKJS_1_1Object_a2}

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

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

\item 
{\bf Value} {\bf prototype} () const 
\item 
{\bf UString} {\bf class\-Name} () const 
\item 
{\bf Value} {\bf get} ({\bf Exec\-State} $\ast$exec, const {\bf Identifier} \&property\-Name) const 
\item 
{\bf Value} {\bf get} ({\bf Exec\-State} $\ast$exec, unsigned property\-Name) const \label{classKJS_1_1Object_a8}

\item 
void {\bf put} ({\bf Exec\-State} $\ast$exec, const {\bf Identifier} \&property\-Name, const {\bf Value} \&value, int attr=None)
\item 
void {\bf put} ({\bf Exec\-State} $\ast$exec, unsigned property\-Name, const {\bf Value} \&value, int attr=None)\label{classKJS_1_1Object_a10}

\item 
bool {\bf can\-Put} ({\bf Exec\-State} $\ast$exec, const {\bf Identifier} \&property\-Name) const 
\item 
bool {\bf has\-Property} ({\bf Exec\-State} $\ast$exec, const {\bf Identifier} \&property\-Name) const 
\item 
bool {\bf has\-Property} ({\bf Exec\-State} $\ast$exec, unsigned property\-Name) const \label{classKJS_1_1Object_a13}

\item 
bool {\bf delete\-Property} ({\bf Exec\-State} $\ast$exec, const {\bf Identifier} \&property\-Name)
\item 
bool {\bf delete\-Property} ({\bf Exec\-State} $\ast$exec, unsigned property\-Name)\label{classKJS_1_1Object_a15}

\item 
{\bf Value} {\bf default\-Value} ({\bf Exec\-State} $\ast$exec, Type hint) const 
\item 
bool {\bf implements\-Construct} () const 
\item 
{\bf Object} {\bf construct} ({\bf Exec\-State} $\ast$exec, const {\bf List} \&args)
\item 
bool {\bf implements\-Call} () const 
\item 
{\bf Value} {\bf call} ({\bf Exec\-State} $\ast$exec, {\bf Object} \&this\-Obj, const {\bf List} \&args)
\item 
bool {\bf implements\-Has\-Instance} () const 
\item 
{\bf Boolean} {\bf has\-Instance} ({\bf Exec\-State} $\ast$exec, const {\bf Value} \&value)
\item 
const {\bf Scope\-Chain} \& {\bf scope} () const 
\item 
void {\bf set\-Scope} (const {\bf Scope\-Chain} \&s)\label{classKJS_1_1Object_a24}

\item 
{\bf Reference\-List} {\bf prop\-List} ({\bf Exec\-State} $\ast$exec, bool recursive=true)
\item 
{\bf Value} {\bf internal\-Value} () const 
\item 
void {\bf set\-Internal\-Value} (const {\bf Value} \&v)
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static {\bf Object} {\bf dynamic\-Cast} (const {\bf Value} \&v)
\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 81 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\-Valid()}{\rm (p.\,\pageref{classKJS_1_1Value_a5})} 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 46 of file object.cpp.

Referenced by KJS::Error::create().\index{KJS::Object@{KJS::Object}!prototype@{prototype}}
\index{prototype@{prototype}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} KJS::Object::prototype () const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a5}


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 656 of file object.h.\index{KJS::Object@{KJS::Object}!className@{className}}
\index{className@{className}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf UString} KJS::Object::class\-Name () const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a6}


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 659 of file object.h.\index{KJS::Object@{KJS::Object}!get@{get}}
\index{get@{get}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} KJS::Object::get ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf Identifier} \& {\em property\-Name}) const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a7}


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 662 of file object.h.

Referenced by KJS::Reference::get\-Value().\index{KJS::Object@{KJS::Object}!put@{put}}
\index{put@{put}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KJS::Object::put ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf Identifier} \& {\em property\-Name}, const {\bf Value} \& {\em value}, int {\em attr} = {\tt None})\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a9}


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 value}]The value to set \end{description}
\end{Desc}


Definition at line 668 of file object.h.

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 KJS::Object::can\-Put ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf Identifier} \& {\em property\-Name}) const\hspace{0.3cm}{\tt  [inline]}}\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 674 of file object.h.\index{KJS::Object@{KJS::Object}!hasProperty@{hasProperty}}
\index{hasProperty@{hasProperty}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KJS::Object::has\-Property ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf Identifier} \& {\em property\-Name}) const\hspace{0.3cm}{\tt  [inline]}}\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 677 of file object.h.\index{KJS::Object@{KJS::Object}!deleteProperty@{deleteProperty}}
\index{deleteProperty@{deleteProperty}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KJS::Object::delete\-Property ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf Identifier} \& {\em property\-Name})\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a14}


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 683 of file object.h.\index{KJS::Object@{KJS::Object}!defaultValue@{defaultValue}}
\index{defaultValue@{defaultValue}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} KJS::Object::default\-Value ({\bf Exec\-State} $\ast$ {\em exec}, Type {\em hint}) const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a16}


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 689 of file object.h.\index{KJS::Object@{KJS::Object}!implementsConstruct@{implementsConstruct}}
\index{implementsConstruct@{implementsConstruct}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KJS::Object::implements\-Construct () const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a17}


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

If this returns false you should not call the {\bf construct()}{\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 construct()}{\rm (p.\,\pageref{classKJS_1_1Object_a18})} method, otherwise false \end{Desc}


Definition at line 692 of file object.h.\index{KJS::Object@{KJS::Object}!construct@{construct}}
\index{construct@{construct}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Object} KJS::Object::construct ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf List} \& {\em args})\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a18}


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_a20})} 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_a17})} 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_a20})} 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 695 of file object.h.

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 KJS::Object::implements\-Call () const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a19}


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

If this returns false you should not call the {\bf call()}{\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 call()}{\rm (p.\,\pageref{classKJS_1_1Object_a20})} method, otherwise false \end{Desc}


Definition at line 698 of file object.h.\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_a20}


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_a19})} 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_a20})} 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 54 of file object.cpp.

References KJS::Error::create().\index{KJS::Object@{KJS::Object}!implementsHasInstance@{implementsHasInstance}}
\index{implementsHasInstance@{implementsHasInstance}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KJS::Object::implements\-Has\-Instance () const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a21}


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

If this returns false you should not call the {\bf has\-Instance()}{\rm (p.\,\pageref{classKJS_1_1Object_a22})} 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_a22})} method, otherwise false \end{Desc}


Definition at line 701 of file object.h.\index{KJS::Object@{KJS::Object}!hasInstance@{hasInstance}}
\index{hasInstance@{hasInstance}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Boolean} KJS::Object::has\-Instance ({\bf Exec\-State} $\ast$ {\em exec}, const {\bf Value} \& {\em value})\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a22}


Checks whether value delegates behavior 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 behavior to this object, otherwise false \end{Desc}


Definition at line 704 of file object.h.\index{KJS::Object@{KJS::Object}!scope@{scope}}
\index{scope@{scope}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}const {\bf Scope\-Chain} \& KJS::Object::scope () const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a23}


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:



\footnotesize\begin{verbatim} function f() {

   function b() {
     return prototype;
   }

   var x = 4;
   // do some stuff
 }
 f.prototype = new String();
\end{verbatim}
\normalsize


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[Returns:]The function's scope \end{Desc}


Definition at line 707 of file object.h.\index{KJS::Object@{KJS::Object}!propList@{propList}}
\index{propList@{propList}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Reference\-List} KJS::Object::prop\-List ({\bf Exec\-State} $\ast$ {\em exec}, bool {\em recursive} = {\tt true})\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a25}


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_a9})}.

\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 713 of file object.h.\index{KJS::Object@{KJS::Object}!internalValue@{internalValue}}
\index{internalValue@{internalValue}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf Value} KJS::Object::internal\-Value () const\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a26}


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 716 of file object.h.\index{KJS::Object@{KJS::Object}!setInternalValue@{setInternalValue}}
\index{setInternalValue@{setInternalValue}!KJS::Object@{KJS::Object}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KJS::Object::set\-Internal\-Value (const {\bf Value} \& {\em v})\hspace{0.3cm}{\tt  [inline]}}\label{classKJS_1_1Object_a27}


Sets the internal value of the object. 

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


Definition at line 719 of file object.h.

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