<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US"> <head> <title>kjs: value.h Source File (kjs)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org" r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org" r (n 0 s 0 v 0 l 0))' /> <meta name="trademark" content="KDE e.V." /> <meta name="description" content="K Desktop Environment Homepage, KDE.org" /> <meta name="MSSmartTagsPreventParsing" content="true" /> <meta name="robots" content="all" /> <link rel="shortcut icon" href="../../favicon.ico" /> <link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" /> </head> <body> <div id="nav_header_top" align="right"> <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a> <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a> <span class="doNotDisplay">::</span> <div id="nav_header_title" align="left">KDE API Reference</div> </div> <div id="nav_header_bottom" align="right"> <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span> <div id="nav_header_bottom_right" style="text-align: left;"> / <a href="../..">API Reference</a> / <a href=".">kjs</a> </div> </div> <table id="main" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" class="menuheader" height="0"></td> <td id="contentcolumn" valign="top" rowspan="2" > <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;"> <a name="content"></a> <!-- Generated by Doxygen 1.7.4 --> <div class="header"> <div class="headertitle"> <div class="title">value.h</div> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- c-basic-offset: 2 -*-</span> <a name="l00002"></a>00002 <span class="comment">/*</span> <a name="l00003"></a>00003 <span class="comment"> * This file is part of the KDE libraries</span> <a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)</span> <a name="l00005"></a>00005 <span class="comment"> * Copyright (C) 2001 Peter Kelly (pmk@post.com)</span> <a name="l00006"></a>00006 <span class="comment"> * Copyright (C) 2003 Apple Computer, Inc.</span> <a name="l00007"></a>00007 <span class="comment"> *</span> <a name="l00008"></a>00008 <span class="comment"> * This library is free software; you can redistribute it and/or</span> <a name="l00009"></a>00009 <span class="comment"> * modify it under the terms of the GNU Library General Public</span> <a name="l00010"></a>00010 <span class="comment"> * License as published by the Free Software Foundation; either</span> <a name="l00011"></a>00011 <span class="comment"> * version 2 of the License, or (at your option) any later version.</span> <a name="l00012"></a>00012 <span class="comment"> *</span> <a name="l00013"></a>00013 <span class="comment"> * This library is distributed in the hope that it will be useful,</span> <a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00016"></a>00016 <span class="comment"> * Library General Public License for more details.</span> <a name="l00017"></a>00017 <span class="comment"> *</span> <a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU Library General Public License</span> <a name="l00019"></a>00019 <span class="comment"> * along with this library; see the file COPYING.LIB. If not, write to</span> <a name="l00020"></a>00020 <span class="comment"> * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span> <a name="l00021"></a>00021 <span class="comment"> * Boston, MA 02110-1301, USA.</span> <a name="l00022"></a>00022 <span class="comment"> *</span> <a name="l00023"></a>00023 <span class="comment"> */</span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#ifndef _KJS_VALUE_H_</span> <a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define _KJS_VALUE_H_</span> <a name="l00027"></a>00027 <span class="preprocessor"></span> <a name="l00028"></a>00028 <span class="preprocessor">#include <stdlib.h></span> <span class="comment">// Needed for size_t</span> <a name="l00029"></a>00029 <a name="l00030"></a>00030 <span class="preprocessor">#include "ustring.h"</span> <a name="l00031"></a>00031 <span class="preprocessor">#include "simple_number.h"</span> <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="comment">// Primitive data types</span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">namespace </span>KJS { <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="keyword">class </span>Value; <a name="l00038"></a>00038 <span class="keyword">class </span>ValueImp; <a name="l00039"></a>00039 <span class="keyword">class </span>ValueImpPrivate; <a name="l00040"></a>00040 <span class="keyword">class </span>Undefined; <a name="l00041"></a>00041 <span class="keyword">class </span>UndefinedImp; <a name="l00042"></a>00042 <span class="keyword">class </span>Null; <a name="l00043"></a>00043 <span class="keyword">class </span>NullImp; <a name="l00044"></a>00044 <span class="keyword">class </span>Boolean; <a name="l00045"></a>00045 <span class="keyword">class </span>BooleanImp; <a name="l00046"></a>00046 <span class="keyword">class </span>String; <a name="l00047"></a>00047 <span class="keyword">class </span>StringImp; <a name="l00048"></a>00048 <span class="keyword">class </span>Number; <a name="l00049"></a>00049 <span class="keyword">class </span>NumberImp; <a name="l00050"></a>00050 <span class="keyword">class </span>Object; <a name="l00051"></a>00051 <span class="keyword">class </span>ObjectImp; <a name="l00052"></a>00052 <span class="keyword">class </span>Reference; <a name="l00053"></a>00053 <span class="keyword">class </span>List; <a name="l00054"></a>00054 <span class="keyword">class </span>ListImp; <a name="l00055"></a>00055 <span class="keyword">class </span>Completion; <a name="l00056"></a>00056 <span class="keyword">class </span>ExecState; <a name="l00057"></a>00057 <a name="l00061"></a>00061 <span class="keyword">enum</span> Type { <a name="l00062"></a>00062 UnspecifiedType = 0, <a name="l00063"></a>00063 UndefinedType = 1, <a name="l00064"></a>00064 NullType = 2, <a name="l00065"></a>00065 BooleanType = 3, <a name="l00066"></a>00066 StringType = 4, <a name="l00067"></a>00067 NumberType = 5, <a name="l00068"></a>00068 ObjectType = 6 <a name="l00069"></a>00069 }; <a name="l00070"></a>00070 <a name="l00079"></a><a class="code" href="classKJS_1_1ValueImp.html">00079</a> <span class="keyword">class </span>KJS_EXPORT <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a> { <a name="l00080"></a>00080 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classKJS_1_1Collector.html" title="Garbage collector.">Collector</a>; <a name="l00081"></a>00081 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a>; <a name="l00082"></a>00082 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classKJS_1_1ContextImp.html" title="Execution context.">ContextImp</a>; <a name="l00083"></a>00083 <span class="keyword">public</span>: <a name="l00084"></a>00084 <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>(); <a name="l00085"></a>00085 <span class="keyword">virtual</span> ~<a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>(); <a name="l00086"></a>00086 <a name="l00087"></a>00087 <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>* ref() { <span class="keywordflow">if</span> (!SimpleNumber::is(<span class="keyword">this</span>)) refcount++; <span class="keywordflow">return</span> <span class="keyword">this</span>; } <a name="l00088"></a>00088 <span class="keywordtype">bool</span> deref() { <span class="keywordflow">if</span> (SimpleNumber::is(<span class="keyword">this</span>)) <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="keywordflow">else</span> <span class="keywordflow">return</span> (!--refcount); } <a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="keyword">virtual</span> <span class="keywordtype">void</span> mark(); <a name="l00091"></a>00091 <span class="keywordtype">bool</span> marked() <span class="keyword">const</span>; <a name="l00092"></a>00092 <span class="keywordtype">void</span>* operator new(<span class="keywordtype">size_t</span>); <a name="l00093"></a>00093 <span class="keywordtype">void</span> operator delete(<span class="keywordtype">void</span>*); <a name="l00094"></a>00094 <a name="l00100"></a>00100 <span class="keywordtype">void</span> setGcAllowed(); <a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="comment">// Will crash if called on a simple number.</span> <a name="l00103"></a>00103 <span class="keywordtype">void</span> setGcAllowedFast() { _flags |= VI_GCALLOWED; } <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="keywordtype">int</span> toInteger(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00106"></a>00106 <span class="keywordtype">int</span> toInt32(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00107"></a>00107 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> toUInt32(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00108"></a>00108 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> toUInt16(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00109"></a>00109 <a name="l00110"></a>00110 <span class="comment">// Dispatch wrappers that handle the special small number case</span> <a name="l00111"></a>00111 <a name="l00112"></a>00112 Type dispatchType() <span class="keyword">const</span>; <a name="l00113"></a>00113 <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> dispatchToPrimitive(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec, Type preferredType = UnspecifiedType) <span class="keyword">const</span>; <a name="l00114"></a>00114 <span class="keywordtype">bool</span> dispatchToBoolean(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00115"></a>00115 <span class="keywordtype">double</span> dispatchToNumber(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00116"></a>00116 <a class="code" href="classKJS_1_1UString.html" title="Unicode string class.">UString</a> dispatchToString(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00117"></a>00117 <span class="keywordtype">bool</span> dispatchToUInt32(<span class="keywordtype">unsigned</span>&) <span class="keyword">const</span>; <a name="l00118"></a>00118 <a class="code" href="classKJS_1_1Object.html" title="Represents an Object.">Object</a> dispatchToObject(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00119"></a>00119 <a name="l00120"></a>00120 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> refcount; <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="keywordtype">bool</span> isDestroyed()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _flags & VI_DESTRUCTED; } <a name="l00123"></a>00123 <a name="l00124"></a>00124 <span class="keyword">private</span>: <a name="l00125"></a>00125 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <span class="keywordtype">int</span> _flags; <a name="l00126"></a>00126 <a name="l00127"></a>00127 <span class="keyword">virtual</span> Type type() <span class="keyword">const</span> = 0; <a name="l00128"></a>00128 <a name="l00129"></a>00129 <span class="comment">// The conversion operations</span> <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="keyword">virtual</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> toPrimitive(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec, Type preferredType = UnspecifiedType) <span class="keyword">const</span> = 0; <a name="l00132"></a>00132 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> toBoolean(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span> = 0; <a name="l00133"></a>00133 <span class="keyword">virtual</span> <span class="keywordtype">double</span> toNumber(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span> = 0; <a name="l00134"></a>00134 <span class="comment">// TODO: no need for the following 4 int conversions to be virtual</span> <a name="l00135"></a>00135 <span class="keyword">virtual</span> <a class="code" href="classKJS_1_1UString.html" title="Unicode string class.">UString</a> toString(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span> = 0; <a name="l00136"></a>00136 <span class="keyword">virtual</span> <a class="code" href="classKJS_1_1Object.html" title="Represents an Object.">Object</a> toObject(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span> = 0; <a name="l00137"></a>00137 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> toUInt32(<span class="keywordtype">unsigned</span>&) <span class="keyword">const</span>; <a name="l00138"></a>00138 <a name="l00139"></a>00139 <span class="keyword">enum</span> { <a name="l00140"></a>00140 VI_MARKED = 1, <a name="l00141"></a>00141 VI_GCALLOWED = 2, <a name="l00142"></a>00142 VI_CREATED = 4, <a name="l00143"></a>00143 VI_DESTRUCTED = 8 <span class="comment">// nice word we have here :)</span> <a name="l00144"></a>00144 }; <span class="comment">// VI means VALUEIMPL</span> <a name="l00145"></a>00145 <a name="l00146"></a>00146 ValueImpPrivate *_vd; <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="comment">// Give a compile time error if we try to copy one of these.</span> <a name="l00149"></a>00149 <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>(<span class="keyword">const</span> <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>&); <a name="l00150"></a>00150 <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>& operator=(<span class="keyword">const</span> <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>&); <a name="l00151"></a>00151 }; <a name="l00152"></a>00152 <a name="l00168"></a><a class="code" href="classKJS_1_1Value.html">00168</a> <span class="keyword">class </span>KJS_EXPORT <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> { <a name="l00169"></a>00169 <span class="keyword">public</span>: <a name="l00170"></a>00170 <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a>() : rep(0) { } <a name="l00171"></a>00171 <span class="keyword">explicit</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a>(<a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a> *v); <a name="l00172"></a>00172 <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a>(<span class="keyword">const</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> &v); <a name="l00173"></a>00173 ~<a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a>(); <a name="l00174"></a>00174 <a name="l00175"></a>00175 <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a>& operator=(<span class="keyword">const</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> &v); <a name="l00182"></a><a class="code" href="classKJS_1_1Value.html#acd8509ab6b7622c16fdf021803fdd2cb">00182</a> <span class="keywordtype">bool</span> <a class="code" href="classKJS_1_1Value.html#acd8509ab6b7622c16fdf021803fdd2cb" title="Returns whether or not this is a valid value.">isValid</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep != 0; } <a name="l00187"></a><a class="code" href="classKJS_1_1Value.html#a1a8b47540a1c5dc0025f111a2c2031b4">00187</a> <span class="keywordtype">bool</span> <a class="code" href="classKJS_1_1Value.html#a1a8b47540a1c5dc0025f111a2c2031b4">isNull</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep == 0; } <a name="l00188"></a>00188 <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a> *imp()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep; } <a name="l00189"></a>00189 <a name="l00196"></a><a class="code" href="classKJS_1_1Value.html#ae452f07da93d3888448158e634d71657">00196</a> Type <a class="code" href="classKJS_1_1Value.html#ae452f07da93d3888448158e634d71657" title="Returns the type of value.">type</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->dispatchType(); } <a name="l00197"></a>00197 <a name="l00204"></a><a class="code" href="classKJS_1_1Value.html#a1704785fc8140c274b0e7ec03eb0dfe2">00204</a> <span class="keywordtype">bool</span> <a class="code" href="classKJS_1_1Value.html#a1704785fc8140c274b0e7ec03eb0dfe2" title="Checks whether or not the value is of a particular tpye.">isA</a>(Type t)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->dispatchType() == t; } <a name="l00205"></a>00205 <a name="l00210"></a><a class="code" href="classKJS_1_1Value.html#a6a2cd9a2183172e1166cf1799961383b">00210</a> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> toPrimitive(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec, <a name="l00211"></a>00211 Type preferredType = UnspecifiedType)<span class="keyword"> const</span> <a name="l00212"></a>00212 <span class="keyword"> </span>{ <span class="keywordflow">return</span> rep->dispatchToPrimitive(exec, preferredType); } <a name="l00213"></a>00213 <a name="l00217"></a><a class="code" href="classKJS_1_1Value.html#abdcb3fc1afee9326af85eec35592f0b8">00217</a> <span class="keywordtype">bool</span> <a class="code" href="classKJS_1_1Value.html#abdcb3fc1afee9326af85eec35592f0b8" title="Performs the ToBoolean type conversion operation on this value (ECMA 9.2)">toBoolean</a>(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->dispatchToBoolean(exec); } <a name="l00218"></a>00218 <a name="l00222"></a><a class="code" href="classKJS_1_1Value.html#abc006ad65a05568bbebe2c63604766b8">00222</a> <span class="keywordtype">double</span> <a class="code" href="classKJS_1_1Value.html#abc006ad65a05568bbebe2c63604766b8" title="Performs the ToNumber type conversion operation on this value (ECMA 9.3)">toNumber</a>(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->dispatchToNumber(exec); } <a name="l00223"></a>00223 <a name="l00227"></a><a class="code" href="classKJS_1_1Value.html#ac08ef408068ef1a9018559079ad3022e">00227</a> <span class="keywordtype">int</span> <a class="code" href="classKJS_1_1Value.html#ac08ef408068ef1a9018559079ad3022e" title="Performs the ToInteger type conversion operation on this value (ECMA 9.4)">toInteger</a>(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->toInteger(exec); } <a name="l00228"></a>00228 <a name="l00232"></a><a class="code" href="classKJS_1_1Value.html#aa116929fe115defe059fc6e0ddf0d362">00232</a> <span class="keywordtype">int</span> <a class="code" href="classKJS_1_1Value.html#aa116929fe115defe059fc6e0ddf0d362" title="Performs the ToInt32 type conversion operation on this value (ECMA 9.5)">toInt32</a>(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->toInt32(exec); } <a name="l00233"></a>00233 <a name="l00237"></a><a class="code" href="classKJS_1_1Value.html#a6aee2e9f36bd37afdfb2f0678f8cf69e">00237</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classKJS_1_1Value.html#a6aee2e9f36bd37afdfb2f0678f8cf69e" title="Performs the ToUInt32 type conversion operation on this value (ECMA 9.6)">toUInt32</a>(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->toUInt32(exec); } <a name="l00238"></a>00238 <a name="l00242"></a><a class="code" href="classKJS_1_1Value.html#ac7528ce04145335fe32f02d421de36e4">00242</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="classKJS_1_1Value.html#ac7528ce04145335fe32f02d421de36e4" title="Performs the ToUInt16 type conversion operation on this value (ECMA 9.7)">toUInt16</a>(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->toUInt16(exec); } <a name="l00243"></a>00243 <a name="l00247"></a><a class="code" href="classKJS_1_1Value.html#a8611b80d868cebf8dd4af2f966810874">00247</a> <a class="code" href="classKJS_1_1UString.html" title="Unicode string class.">UString</a> <a class="code" href="classKJS_1_1Value.html#a8611b80d868cebf8dd4af2f966810874" title="Performs the ToString type conversion operation on this value (ECMA 9.8)">toString</a>(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->dispatchToString(exec); } <a name="l00248"></a>00248 <a name="l00252"></a>00252 <a class="code" href="classKJS_1_1Object.html" title="Represents an Object.">Object</a> toObject(<a class="code" href="classKJS_1_1ExecState.html" title="Represents the current state of script execution.">ExecState</a> *exec) <span class="keyword">const</span>; <a name="l00253"></a>00253 <a name="l00257"></a><a class="code" href="classKJS_1_1Value.html#af2520c393d340da100f59fba8b67d288">00257</a> <span class="keywordtype">bool</span> <a class="code" href="classKJS_1_1Value.html#af2520c393d340da100f59fba8b67d288" title="Checks if we can do a lossless conversion to UInt32.">toUInt32</a>(<span class="keywordtype">unsigned</span>& i)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rep->dispatchToUInt32(i); } <a name="l00258"></a>00258 <a name="l00259"></a>00259 <span class="keyword">protected</span>: <a name="l00260"></a>00260 <a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a> *rep; <a name="l00261"></a>00261 }; <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="comment">// Primitive types</span> <a name="l00264"></a>00264 <a name="l00270"></a><a class="code" href="classKJS_1_1Undefined.html">00270</a> <span class="keyword">class </span>KJS_EXPORT <a class="code" href="classKJS_1_1Undefined.html" title="Represents an primitive Undefined value.">Undefined</a> : <span class="keyword">public</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> { <a name="l00271"></a>00271 <span class="keyword">public</span>: <a name="l00272"></a>00272 <a class="code" href="classKJS_1_1Undefined.html" title="Represents an primitive Undefined value.">Undefined</a>(); <a name="l00273"></a>00273 <a name="l00283"></a>00283 <span class="keyword">static</span> <a class="code" href="classKJS_1_1Undefined.html" title="Represents an primitive Undefined value.">Undefined</a> dynamicCast(<span class="keyword">const</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> &v); <a name="l00284"></a>00284 <span class="keyword">private</span>: <a name="l00285"></a>00285 <span class="keyword">friend</span> <span class="keyword">class </span>UndefinedImp; <a name="l00286"></a>00286 <span class="keyword">explicit</span> <a class="code" href="classKJS_1_1Undefined.html" title="Represents an primitive Undefined value.">Undefined</a>(UndefinedImp *v); <a name="l00287"></a>00287 <a name="l00288"></a>00288 }; <a name="l00289"></a>00289 <a name="l00295"></a><a class="code" href="classKJS_1_1Null.html">00295</a> <span class="keyword">class </span>KJS_EXPORT <a class="code" href="classKJS_1_1Null.html" title="Represents an primitive Null value.">Null</a> : <span class="keyword">public</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> { <a name="l00296"></a>00296 <span class="keyword">public</span>: <a name="l00297"></a>00297 <a class="code" href="classKJS_1_1Null.html" title="Represents an primitive Null value.">Null</a>(); <a name="l00298"></a>00298 <a name="l00308"></a>00308 <span class="keyword">static</span> <a class="code" href="classKJS_1_1Null.html" title="Represents an primitive Null value.">Null</a> dynamicCast(<span class="keyword">const</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> &v); <a name="l00309"></a>00309 <span class="keyword">private</span>: <a name="l00310"></a>00310 <span class="keyword">friend</span> <span class="keyword">class </span>NullImp; <a name="l00311"></a>00311 <span class="keyword">explicit</span> <a class="code" href="classKJS_1_1Null.html" title="Represents an primitive Null value.">Null</a>(NullImp *v); <a name="l00312"></a>00312 }; <a name="l00313"></a>00313 <a name="l00317"></a><a class="code" href="classKJS_1_1Boolean.html">00317</a> <span class="keyword">class </span>KJS_EXPORT <a class="code" href="classKJS_1_1Boolean.html" title="Represents an primitive Boolean value.">Boolean</a> : <span class="keyword">public</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> { <a name="l00318"></a>00318 <span class="keyword">public</span>: <a name="l00319"></a>00319 <a class="code" href="classKJS_1_1Boolean.html" title="Represents an primitive Boolean value.">Boolean</a>(<span class="keywordtype">bool</span> b = <span class="keyword">false</span>); <a name="l00320"></a>00320 <a name="l00330"></a>00330 <span class="keyword">static</span> <a class="code" href="classKJS_1_1Boolean.html" title="Represents an primitive Boolean value.">Boolean</a> dynamicCast(<span class="keyword">const</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> &v); <a name="l00331"></a>00331 <a name="l00332"></a>00332 <span class="keywordtype">bool</span> value() <span class="keyword">const</span>; <a name="l00333"></a>00333 <span class="keyword">private</span>: <a name="l00334"></a>00334 <span class="keyword">friend</span> <span class="keyword">class </span>BooleanImp; <a name="l00335"></a>00335 <span class="keyword">explicit</span> <a class="code" href="classKJS_1_1Boolean.html" title="Represents an primitive Boolean value.">Boolean</a>(BooleanImp *v); <a name="l00336"></a>00336 }; <a name="l00337"></a>00337 <a name="l00341"></a><a class="code" href="classKJS_1_1String.html">00341</a> <span class="keyword">class </span>KJS_EXPORT <a class="code" href="classKJS_1_1String.html" title="Represents an primitive String value.">String</a> : <span class="keyword">public</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> { <a name="l00342"></a>00342 <span class="keyword">public</span>: <a name="l00343"></a>00343 <a class="code" href="classKJS_1_1String.html" title="Represents an primitive String value.">String</a>(<span class="keyword">const</span> <a class="code" href="classKJS_1_1UString.html" title="Unicode string class.">UString</a> &s = <span class="stringliteral">""</span>); <a name="l00344"></a>00344 <a name="l00354"></a>00354 <span class="keyword">static</span> <a class="code" href="classKJS_1_1String.html" title="Represents an primitive String value.">String</a> dynamicCast(<span class="keyword">const</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> &v); <a name="l00355"></a>00355 <a name="l00356"></a>00356 <a class="code" href="classKJS_1_1UString.html" title="Unicode string class.">UString</a> value() <span class="keyword">const</span>; <a name="l00357"></a>00357 <span class="keyword">private</span>: <a name="l00358"></a>00358 <span class="keyword">friend</span> <span class="keyword">class </span>StringImp; <a name="l00359"></a>00359 <span class="keyword">explicit</span> <a class="code" href="classKJS_1_1String.html" title="Represents an primitive String value.">String</a>(StringImp *v); <a name="l00360"></a>00360 }; <a name="l00361"></a>00361 <a name="l00362"></a>00362 <span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">double</span> NaN; <a name="l00363"></a>00363 <span class="keyword">extern</span> <span class="keyword">const</span> <span class="keywordtype">double</span> Inf; <a name="l00364"></a>00364 <a name="l00368"></a><a class="code" href="classKJS_1_1Number.html">00368</a> <span class="keyword">class </span>KJS_EXPORT <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a> : <span class="keyword">public</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> { <a name="l00369"></a>00369 <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classKJS_1_1ValueImp.html" title="ValueImp is the base type for all primitives (Undefined, Null, Boolean, String, Number) and objects i...">ValueImp</a>; <a name="l00370"></a>00370 <span class="keyword">public</span>: <a name="l00371"></a>00371 <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a>(<span class="keywordtype">int</span> i); <a name="l00372"></a>00372 <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> u); <a name="l00373"></a>00373 <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a>(<span class="keywordtype">double</span> d = 0.0); <a name="l00374"></a>00374 <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a>(<span class="keywordtype">long</span> <span class="keywordtype">int</span> l); <a name="l00375"></a>00375 <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a>(<span class="keywordtype">long</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> l); <a name="l00376"></a>00376 <a name="l00377"></a>00377 <span class="keywordtype">double</span> value() <span class="keyword">const</span>; <a name="l00378"></a>00378 <span class="keywordtype">int</span> intValue() <span class="keyword">const</span>; <a name="l00379"></a>00379 <a name="l00380"></a>00380 <span class="keywordtype">bool</span> isNaN() <span class="keyword">const</span>; <a name="l00381"></a>00381 <span class="keywordtype">bool</span> isInf() <span class="keyword">const</span>; <a name="l00382"></a>00382 <a name="l00392"></a>00392 <span class="keyword">static</span> <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a> dynamicCast(<span class="keyword">const</span> <a class="code" href="classKJS_1_1Value.html" title="Value objects are act as wrappers ("smart pointers") around ValueImp objects and their descendents...">Value</a> &v); <a name="l00393"></a>00393 <span class="keyword">private</span>: <a name="l00394"></a>00394 <span class="keyword">friend</span> <span class="keyword">class </span>NumberImp; <a name="l00395"></a>00395 <span class="keyword">explicit</span> <a class="code" href="classKJS_1_1Number.html" title="Represents an primitive Number value.">Number</a>(NumberImp *v); <a name="l00396"></a>00396 }; <a name="l00397"></a>00397 <a name="l00398"></a>00398 } <span class="comment">// namespace</span> <a name="l00399"></a>00399 <a name="l00400"></a>00400 <span class="preprocessor">#endif // _KJS_VALUE_H_</span> </pre></div></div> </div> </div></div> </td> </tr> <tr> <td valign="top" id="leftmenu" width="25%"> <a name="navigation"></a> <div class="menu_box"><h2>kjs</h2> <div class="nav_list"> <ul><li><a href="index.html">Main Page</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul> <!-- <h2>Class Picker</h2> <div style="text-align: center;"> <form name="guideform"> <select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> <option value="annotated.html">-- Choose --</option> <option value="classKJS_1_1BinaryLogicalNode.html">kjs::binarylogicalnode</option>, <option value="classKJS_1_1Boolean.html">kjs::boolean</option>, <option value="classKJS_1_1Collector.html">kjs::collector</option>, <option value="classKJS_1_1Completion.html">kjs::completion</option>, <option value="classKJS_1_1ConditionalNode.html">kjs::conditionalnode</option>, <option value="classKJS_1_1Context.html">kjs::context</option>, <option value="classKJS_1_1ContextImp.html">kjs::contextimp</option>, <option value="classKJS_1_1CString.html">kjs::cstring</option>, <option value="classKJS_1_1Error.html">kjs::error</option>, <option value="classKJS_1_1ExecState.html">kjs::execstate</option>, <option value="classKJS_1_1FunctionImp.html">kjs::functionimp</option>, <option value="classKJS_1_1FunctionPrototypeImp.html">kjs::functionprototypeimp</option>, <option value="classKJS_1_1Identifier.html">kjs::identifier</option>, <option value="classKJS_1_1InternalFunctionImp.html">kjs::internalfunctionimp</option>, <option value="classKJS_1_1Interpreter.html">kjs::interpreter</option>, <option value="classKJS_1_1LabelStack.html">kjs::labelstack</option>, <option value="classKJS_1_1List.html">kjs::list</option>, <option value="classKJS_1_1ListIterator.html">kjs::listiterator</option>, <option value="classKJS_1_1Lookup.html">kjs::lookup</option>, <option value="classKJS_1_1Null.html">kjs::null</option>, <option value="classKJS_1_1Number.html">kjs::number</option>, <option value="classKJS_1_1Object.html">kjs::object</option>, <option value="classKJS_1_1PropertyMap.html">kjs::propertymap</option>, <option value="classKJS_1_1Reference.html">kjs::reference</option>, <option value="classKJS_1_1ReferenceList.html">kjs::referencelist</option>, <option value="classKJS_1_1ReferenceListIterator.html">kjs::referencelistiterator</option>, <option value="classKJS_1_1SavedProperties.html">kjs::savedproperties</option>, <option value="classKJS_1_1ScopeChain.html">kjs::scopechain</option>, <option value="classKJS_1_1ScopeChainNode.html">kjs::scopechainnode</option>, <option value="classKJS_1_1String.html">kjs::string</option>, <option value="classKJS_1_1UCharReference.html">kjs::ucharreference</option>, <option value="classKJS_1_1Undefined.html">kjs::undefined</option>, <option value="classKJS_1_1UString.html">kjs::ustring</option>, <option value="classKJS_1_1Value.html">kjs::value</option>, <option value="classKJS_1_1ValueImp.html">kjs::valueimp</option>, </select> </form> </div> --> </div></div> <div class="menu_box"><h2>API Dox</h2> <div class="nav_list"> <ul> <li><a href="../../arts/html/index.html">arts</a></li><li><a href="../../dcop/html/index.html">dcop</a></li><li><a href="../../dnssd/html/index.html">dnssd</a></li><li><a href="../../interfaces/html/index.html">interfaces</a></li><li> <a href="../../interfaces/kimproxy/interface/html/index.html">interface</a></li><li> <a href="../../interfaces/kimproxy/library/html/index.html">library</a></li><li> <a href="../../interfaces/kspeech/html/index.html">kspeech</a></li><li> <a href="../../interfaces/ktexteditor/html/index.html">ktexteditor</a></li><li><a href="../../kabc/html/index.html">kabc</a></li><li><a href="../../kate/html/index.html">kate</a></li><li><a href="../../kcmshell/html/index.html">kcmshell</a></li><li><a href="../../kdecore/html/index.html">kdecore</a></li><li><a href="../../kded/html/index.html">kded</a></li><li><a href="../../kdefx/html/index.html">kdefx</a></li><li><a href="../../kdeprint/html/index.html">kdeprint</a></li><li><a href="../../kdesu/html/index.html">kdesu</a></li><li><a href="../../kdeui/html/index.html">kdeui</a></li><li><a href="../../kdoctools/html/index.html">kdoctools</a></li><li><a href="../../khtml/html/index.html">khtml</a></li><li><a href="../../kimgio/html/index.html">kimgio</a></li><li><a href="../../kinit/html/index.html">kinit</a></li><li><a href="../../kio/html/index.html">kio</a></li><li> <a href="../../kio/bookmarks/html/index.html">bookmarks</a></li><li> <a href="../../kio/httpfilter/html/index.html">httpfilter</a></li><li> <a href="../../kio/kfile/html/index.html">kfile</a></li><li> <a href="../../kio/kio/html/index.html">kio</a></li><li> <a href="../../kio/kioexec/html/index.html">kioexec</a></li><li> <a href="../../kio/kpasswdserver/html/index.html">kpasswdserver</a></li><li> <a href="../../kio/kssl/html/index.html">kssl</a></li><li><a href="../../kioslave/html/index.html">kioslave</a></li><li> <a href="../../kioslave/http/html/index.html">http</a></li><li><a href="../../kjs/html/index.html">kjs</a></li><li><a href="../../kmdi/html/index.html">kmdi</a></li><li> <a href="../../kmdi/kmdi/html/index.html">kmdi</a></li><li><a href="../../knewstuff/html/index.html">knewstuff</a></li><li><a href="../../kparts/html/index.html">kparts</a></li><li><a href="../../kresources/html/index.html">kresources</a></li><li><a href="../../kspell2/html/index.html">kspell2</a></li><li><a href="../../kunittest/html/index.html">kunittest</a></li><li><a href="../../kutils/html/index.html">kutils</a></li><li><a href="../../kwallet/html/index.html">kwallet</a></li><li><a href="../../libkmid/html/index.html">libkmid</a></li><li><a href="../../libkscreensaver/html/index.html">libkscreensaver</a></li> </ul></div></div> </td> </tr> </table> <span class="doNotDisplay"> <a href="http://www.kde.org/" accesskey="8">KDE Home</a> | <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> | <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a> </span> <div style="height: 8px"></div> <div id="footer"> <div id="footer_left"> Maintained by <a href="mailto:groot@kde.org">Adriaan de Groot</a> and <a href="mailto:winter@kde.org">Allen Winter</a>. <br/> KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div> <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div> </div> <!-- WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL BE BLOCKED INSTANTLY AND PERMANENTLY! <a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a> WARNING END --> </body> </html>