types.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "value.h"
00026 #include "object.h"
00027 #include "types.h"
00028 #include "interpreter.h"
00029
00030 #include <assert.h>
00031 #include <math.h>
00032 #include <stdio.h>
00033
00034 #include "internal.h"
00035 #include "collector.h"
00036 #include "operations.h"
00037 #include "error_object.h"
00038 #include "nodes.h"
00039
00040 using namespace KJS;
00041
00042
00043
00044 Reference::Reference(const Object& b, const UString& p)
00045 : Value(new ReferenceImp(b,p))
00046 {
00047 }
00048
00049 Reference::Reference(const Null& b, const UString& p)
00050 : Value(new ReferenceImp(b,p))
00051 {
00052 }
00053
00054 Reference::Reference(ReferenceImp *v) : Value(v)
00055 {
00056 }
00057
00058 Reference::Reference(const Reference &v) : Value(v)
00059 {
00060 }
00061
00062 Reference::Reference(const Value& v) : Value(v)
00063 {
00064 }
00065
00066 Reference::~Reference()
00067 {
00068 }
00069
00070 Reference& Reference::operator=(const Reference &v)
00071 {
00072 Value::operator=(v);
00073 return *this;
00074 }
00075
00076 Reference Reference::dynamicCast(const Value &v)
00077 {
00078 if (v.isNull() || v.type() != ReferenceType)
00079 return 0;
00080
00081 return static_cast<ReferenceImp*>(v.imp());
00082 }
00083
00084
00085
00086
00087
00088 ListIterator::ListIterator(ListNode *n) : node(n)
00089 {
00090 }
00091
00092 ListIterator::ListIterator(const List &l)
00093 : node(static_cast<ListImp*>(l.imp())->hook->next)
00094 {
00095 }
00096
00097 ListIterator& ListIterator::operator=(const ListIterator &iterator)
00098 {
00099 node=iterator.node;
00100 return *this;
00101 }
00102
00103 ListIterator::ListIterator(const ListIterator &i) : node(i.node)
00104 {
00105 }
00106
00107 ListIterator::~ListIterator()
00108 {
00109 }
00110
00111 ValueImp* ListIterator::operator->() const
00112 {
00113 return node->member;
00114 }
00115
00116
00117 Value ListIterator::operator*() const
00118 {
00119 return Value(node->member);
00120 }
00121
00122
00123 Value ListIterator::operator++()
00124 {
00125 node = node->next;
00126 return Value(node->member);
00127 }
00128
00129 Value ListIterator::operator++(int)
00130 {
00131 const ListNode *n = node;
00132 ++*this;
00133 return Value(n->member);
00134 }
00135
00136 Value ListIterator::operator--()
00137 {
00138 node = node->prev;
00139 return Value(node->member);
00140 }
00141
00142 Value ListIterator::operator--(int)
00143 {
00144 const ListNode *n = node;
00145 --*this;
00146 return Value(n->member);
00147 }
00148
00149 bool ListIterator::operator==(const ListIterator &it) const
00150 {
00151 return (node==it.node);
00152 }
00153
00154 bool ListIterator::operator!=(const ListIterator &it) const
00155 {
00156 return (node!=it.node);
00157 }
00158
00159
00160
00161 List::List()
00162 : Value(new ListImp())
00163 {
00164
00165 }
00166
00167 List::List(ListImp *v) : Value(v)
00168 {
00169
00170 }
00171
00172 List::List(const List &v) : Value(v)
00173 {
00174
00175 }
00176
00177 List::~List()
00178 {
00179
00180 }
00181
00182 List& List::operator=(const List &v)
00183 {
00184
00185 Value::operator=(v);
00186 return *this;
00187 }
00188
00189 List List::dynamicCast(const Value &v)
00190 {
00191 if (v.isNull() || v.type() != ListType)
00192 return 0;
00193
00194 return static_cast<ListImp*>(v.imp());
00195 }
00196
00197 void List::append(const Value& val)
00198 {
00199 static_cast<ListImp*>(rep)->append(val);
00200 }
00201
00202 void List::prepend(const Value& val)
00203 {
00204 static_cast<ListImp*>(rep)->prepend(val);
00205 }
00206
00207 void List::appendList(const List& lst)
00208 {
00209 static_cast<ListImp*>(rep)->appendList(lst);
00210 }
00211
00212 void List::prependList(const List& lst)
00213 {
00214 static_cast<ListImp*>(rep)->prependList(lst);
00215 }
00216
00217 void List::removeFirst()
00218 {
00219 static_cast<ListImp*>(rep)->removeFirst();
00220 }
00221
00222 void List::removeLast()
00223 {
00224 static_cast<ListImp*>(rep)->removeLast();
00225 }
00226
00227 void List::remove(const Value &val)
00228 {
00229 static_cast<ListImp*>(rep)->remove(val);
00230 }
00231
00232 void List::clear()
00233 {
00234 static_cast<ListImp*>(rep)->clear();
00235 }
00236
00237 List List::copy() const
00238 {
00239 return static_cast<ListImp*>(rep)->copy();
00240 }
00241
00242 ListIterator List::begin() const
00243 {
00244 return static_cast<ListImp*>(rep)->begin();
00245 }
00246
00247 ListIterator List::end() const
00248 {
00249 return static_cast<ListImp*>(rep)->end();
00250 }
00251
00252 bool List::isEmpty() const
00253 {
00254 return static_cast<ListImp*>(rep)->isEmpty();
00255 }
00256
00257 int List::size() const
00258 {
00259 return static_cast<ListImp*>(rep)->size();
00260 }
00261
00262 Value List::at(int i) const
00263 {
00264 return static_cast<ListImp*>(rep)->at(i);
00265 }
00266
00267 Value List::operator[](int i) const
00268 {
00269 return static_cast<ListImp*>(rep)->at(i);
00270 }
00271
00272 const List List::empty()
00273 {
00274 return ListImp::empty();
00275 }
00276
00277 #ifdef KJS_DEBUG_MEM
00278 void List::globalClear()
00279 {
00280 delete ListImp::emptyList;
00281 ListImp::emptyList = 0L;
00282 }
00283 #endif
00284
00285
00286
00287
00288 Completion::Completion(ComplType c, const Value& v, const UString &t)
00289 : Value(new CompletionImp(c,v,t))
00290 {
00291 }
00292
00293 Completion::Completion(CompletionImp *v) : Value(v)
00294 {
00295 }
00296
00297 Completion::Completion(const Completion &v) : Value(v)
00298 {
00299 }
00300
00301 Completion::~Completion()
00302 {
00303 }
00304
00305 Completion& Completion::operator=(const Completion &v)
00306 {
00307 Value::operator=(v);
00308 return *this;
00309 }
00310
00311 Completion Completion::dynamicCast(const Value &v)
00312 {
00313 if (v.isNull() || v.type() != CompletionType)
00314 return 0;
00315
00316 return static_cast<CompletionImp*>(v.imp());
00317 }
00318
00319 ComplType Completion::complType() const
00320 {
00321 return static_cast<CompletionImp*>(rep)->complType();
00322 }
00323
00324 Value Completion::value() const
00325 {
00326 return static_cast<CompletionImp*>(rep)->value();
00327 }
00328
00329 UString Completion::target() const
00330 {
00331 return static_cast<CompletionImp*>(rep)->target();
00332 }
00333
00334 bool Completion::isValueCompletion() const
00335 {
00336 return !value().isNull();
00337 }
This file is part of the documentation for kdelibs Version 3.1.5.