[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
mjs
mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:56:12 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 417de420b201795886e1ae6842193990ec19623f
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Feb 25 04:11:34 2002 +0000
Top level:
Stop borrowing QRegExp and QValueList.
* borrowed-classes.txt:
Added more test cases for QRegExp and QValueList.
* Tests/qt/qregexp-test.chk:
* Tests/qt/qregexp-test.cpp: (main):
* Tests/qt/qstringlist-test.cpp: (main):
* Tests/qt/qvaluelist-test.chk:
* Tests/qt/qvaluelist-test.cpp: (main):
WebCore:
Reimplemented QRegExp in terms of POSIX regexp facilities. This
will only support Latin1, however, it won't support all languages.
* src/kwq/qt/qregexp.h:
* src/kwq/KWQRegExp.mm: (QRegExp::KWQRegExpPrivate::KWQRegExpPrivate),
(QRegExp::KWQRegExpPrivate::compile),
(QRegExp::KWQRegExpPrivate::~KWQRegExpPrivate), (QRegExp::QRegExp),
(QRegExp::~QRegExp), (QRegExp::operator=), (QRegExp::pattern), (QRegExp::match):
Reimplement QValueList as a doubly-linked list, using a generic
implementation class and a templatized facade.
* src/kwq/qt/qvaluelist.h:
* src/kwq/KWQValueListImpl.h:
* src/kwq/KWQValueListImpl.mm: (KWQValueListNodeImpl::KWQValueListNodeImpl),
(KWQValueListNodeImpl::~KWQValueListNodeImpl),
(KWQValueListIteratorImpl::KWQValueListIteratorImpl),
(KWQValueListIteratorImpl::~KWQValueListIteratorImpl),
(KWQValueListIteratorImpl::operator=), (KWQValueListIteratorImpl::operator==),
(KWQValueListIteratorImpl::operator!=), (KWQValueListIteratorImpl::node),
(KWQValueListIteratorImpl::operator++), (KWQValueListIteratorImpl::operator--),
(KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate),
(KWQValueListImpl::KWQValueListPrivate::~KWQValueListPrivate),
(KWQValueListImpl::KWQValueListPrivate::copyList),
(KWQValueListImpl::KWQValueListPrivate::deleteList),
(KWQValueListImpl::KWQValueListImpl), (KWQValueListImpl::~KWQValueListImpl),
(KWQValueListImpl::clear), (KWQValueListImpl::count),
(KWQValueListImpl::isEmpty), (KWQValueListImpl::appendNode),
(KWQValueListImpl::prependNode), (KWQValueListImpl::removeEqualNodes),
(KWQValueListImpl::containsEqualNodes), (KWQValueListImpl::removeIterator),
(KWQValueListImpl::fromLast), (KWQValueListImpl::firstNode),
(KWQValueListImpl::lastNode), (KWQValueListImpl::begin), (KWQValueListImpl::end),
(KWQValueListImpl::nodeAt), (KWQValueListImpl::operator=),
(KWQValueListImpl::copyOnWrite):
* src/kwq/Makefile.am:
* src/kwq/kio/netaccess.h: Don't declare private copy constructor
- this class needs to be copyable to be stored in a QValueList!
Hack these scripts a bit so the large tables they generate are
constant data.
* src/kwq/make-charset-table.pl:
* src/kdelibs/khtml/css/makeprop:
* src/kdelibs/khtml/css/makevalues:
* src/kdelibs/khtml/misc/makeattrs:
* src/kdelibs/khtml/misc/maketags:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@666 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 53aa561..12bd970 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,53 @@
+2002-02-24 Maciej Stachowiak <mjs at apple.com>
+
+ Reimplemented QRegExp in terms of POSIX regexp facilities. This
+ will only support Latin1, however, it won't support all languages.
+
+ * src/kwq/qt/qregexp.h:
+ * src/kwq/KWQRegExp.mm: (QRegExp::KWQRegExpPrivate::KWQRegExpPrivate),
+ (QRegExp::KWQRegExpPrivate::compile),
+ (QRegExp::KWQRegExpPrivate::~KWQRegExpPrivate), (QRegExp::QRegExp),
+ (QRegExp::~QRegExp), (QRegExp::operator=), (QRegExp::pattern), (QRegExp::match):
+
+ Reimplement QValueList as a doubly-linked list, using a generic
+ implementation class and a templatized facade.
+
+ * src/kwq/qt/qvaluelist.h:
+ * src/kwq/KWQValueListImpl.h:
+ * src/kwq/KWQValueListImpl.mm: (KWQValueListNodeImpl::KWQValueListNodeImpl),
+ (KWQValueListNodeImpl::~KWQValueListNodeImpl),
+ (KWQValueListIteratorImpl::KWQValueListIteratorImpl),
+ (KWQValueListIteratorImpl::~KWQValueListIteratorImpl),
+ (KWQValueListIteratorImpl::operator=), (KWQValueListIteratorImpl::operator==),
+ (KWQValueListIteratorImpl::operator!=), (KWQValueListIteratorImpl::node),
+ (KWQValueListIteratorImpl::operator++), (KWQValueListIteratorImpl::operator--),
+ (KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate),
+ (KWQValueListImpl::KWQValueListPrivate::~KWQValueListPrivate),
+ (KWQValueListImpl::KWQValueListPrivate::copyList),
+ (KWQValueListImpl::KWQValueListPrivate::deleteList),
+ (KWQValueListImpl::KWQValueListImpl), (KWQValueListImpl::~KWQValueListImpl),
+ (KWQValueListImpl::clear), (KWQValueListImpl::count),
+ (KWQValueListImpl::isEmpty), (KWQValueListImpl::appendNode),
+ (KWQValueListImpl::prependNode), (KWQValueListImpl::removeEqualNodes),
+ (KWQValueListImpl::containsEqualNodes), (KWQValueListImpl::removeIterator),
+ (KWQValueListImpl::fromLast), (KWQValueListImpl::firstNode),
+ (KWQValueListImpl::lastNode), (KWQValueListImpl::begin), (KWQValueListImpl::end),
+ (KWQValueListImpl::nodeAt), (KWQValueListImpl::operator=),
+ (KWQValueListImpl::copyOnWrite):
+ * src/kwq/Makefile.am:
+
+ * src/kwq/kio/netaccess.h: Don't declare private copy constructor
+ - this class needs to be copyable to be stored in a QValueList!
+
+ Hack these scripts a bit so the large tables they generate are
+ constant data.
+
+ * src/kwq/make-charset-table.pl:
+ * src/kdelibs/khtml/css/makeprop:
+ * src/kdelibs/khtml/css/makevalues:
+ * src/kdelibs/khtml/misc/makeattrs:
+ * src/kdelibs/khtml/misc/maketags:
+
2002-02-23 Maciej Stachowiak <mjs at apple.com>
* src/kwq/WCLoadProgress.h: Add the forgotten WCLoadProgress.h.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 53aa561..12bd970 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,53 @@
+2002-02-24 Maciej Stachowiak <mjs at apple.com>
+
+ Reimplemented QRegExp in terms of POSIX regexp facilities. This
+ will only support Latin1, however, it won't support all languages.
+
+ * src/kwq/qt/qregexp.h:
+ * src/kwq/KWQRegExp.mm: (QRegExp::KWQRegExpPrivate::KWQRegExpPrivate),
+ (QRegExp::KWQRegExpPrivate::compile),
+ (QRegExp::KWQRegExpPrivate::~KWQRegExpPrivate), (QRegExp::QRegExp),
+ (QRegExp::~QRegExp), (QRegExp::operator=), (QRegExp::pattern), (QRegExp::match):
+
+ Reimplement QValueList as a doubly-linked list, using a generic
+ implementation class and a templatized facade.
+
+ * src/kwq/qt/qvaluelist.h:
+ * src/kwq/KWQValueListImpl.h:
+ * src/kwq/KWQValueListImpl.mm: (KWQValueListNodeImpl::KWQValueListNodeImpl),
+ (KWQValueListNodeImpl::~KWQValueListNodeImpl),
+ (KWQValueListIteratorImpl::KWQValueListIteratorImpl),
+ (KWQValueListIteratorImpl::~KWQValueListIteratorImpl),
+ (KWQValueListIteratorImpl::operator=), (KWQValueListIteratorImpl::operator==),
+ (KWQValueListIteratorImpl::operator!=), (KWQValueListIteratorImpl::node),
+ (KWQValueListIteratorImpl::operator++), (KWQValueListIteratorImpl::operator--),
+ (KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate),
+ (KWQValueListImpl::KWQValueListPrivate::~KWQValueListPrivate),
+ (KWQValueListImpl::KWQValueListPrivate::copyList),
+ (KWQValueListImpl::KWQValueListPrivate::deleteList),
+ (KWQValueListImpl::KWQValueListImpl), (KWQValueListImpl::~KWQValueListImpl),
+ (KWQValueListImpl::clear), (KWQValueListImpl::count),
+ (KWQValueListImpl::isEmpty), (KWQValueListImpl::appendNode),
+ (KWQValueListImpl::prependNode), (KWQValueListImpl::removeEqualNodes),
+ (KWQValueListImpl::containsEqualNodes), (KWQValueListImpl::removeIterator),
+ (KWQValueListImpl::fromLast), (KWQValueListImpl::firstNode),
+ (KWQValueListImpl::lastNode), (KWQValueListImpl::begin), (KWQValueListImpl::end),
+ (KWQValueListImpl::nodeAt), (KWQValueListImpl::operator=),
+ (KWQValueListImpl::copyOnWrite):
+ * src/kwq/Makefile.am:
+
+ * src/kwq/kio/netaccess.h: Don't declare private copy constructor
+ - this class needs to be copyable to be stored in a QValueList!
+
+ Hack these scripts a bit so the large tables they generate are
+ constant data.
+
+ * src/kwq/make-charset-table.pl:
+ * src/kdelibs/khtml/css/makeprop:
+ * src/kdelibs/khtml/css/makevalues:
+ * src/kdelibs/khtml/misc/makeattrs:
+ * src/kdelibs/khtml/misc/maketags:
+
2002-02-23 Maciej Stachowiak <mjs at apple.com>
* src/kwq/WCLoadProgress.h: Add the forgotten WCLoadProgress.h.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 53aa561..12bd970 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,53 @@
+2002-02-24 Maciej Stachowiak <mjs at apple.com>
+
+ Reimplemented QRegExp in terms of POSIX regexp facilities. This
+ will only support Latin1, however, it won't support all languages.
+
+ * src/kwq/qt/qregexp.h:
+ * src/kwq/KWQRegExp.mm: (QRegExp::KWQRegExpPrivate::KWQRegExpPrivate),
+ (QRegExp::KWQRegExpPrivate::compile),
+ (QRegExp::KWQRegExpPrivate::~KWQRegExpPrivate), (QRegExp::QRegExp),
+ (QRegExp::~QRegExp), (QRegExp::operator=), (QRegExp::pattern), (QRegExp::match):
+
+ Reimplement QValueList as a doubly-linked list, using a generic
+ implementation class and a templatized facade.
+
+ * src/kwq/qt/qvaluelist.h:
+ * src/kwq/KWQValueListImpl.h:
+ * src/kwq/KWQValueListImpl.mm: (KWQValueListNodeImpl::KWQValueListNodeImpl),
+ (KWQValueListNodeImpl::~KWQValueListNodeImpl),
+ (KWQValueListIteratorImpl::KWQValueListIteratorImpl),
+ (KWQValueListIteratorImpl::~KWQValueListIteratorImpl),
+ (KWQValueListIteratorImpl::operator=), (KWQValueListIteratorImpl::operator==),
+ (KWQValueListIteratorImpl::operator!=), (KWQValueListIteratorImpl::node),
+ (KWQValueListIteratorImpl::operator++), (KWQValueListIteratorImpl::operator--),
+ (KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate),
+ (KWQValueListImpl::KWQValueListPrivate::~KWQValueListPrivate),
+ (KWQValueListImpl::KWQValueListPrivate::copyList),
+ (KWQValueListImpl::KWQValueListPrivate::deleteList),
+ (KWQValueListImpl::KWQValueListImpl), (KWQValueListImpl::~KWQValueListImpl),
+ (KWQValueListImpl::clear), (KWQValueListImpl::count),
+ (KWQValueListImpl::isEmpty), (KWQValueListImpl::appendNode),
+ (KWQValueListImpl::prependNode), (KWQValueListImpl::removeEqualNodes),
+ (KWQValueListImpl::containsEqualNodes), (KWQValueListImpl::removeIterator),
+ (KWQValueListImpl::fromLast), (KWQValueListImpl::firstNode),
+ (KWQValueListImpl::lastNode), (KWQValueListImpl::begin), (KWQValueListImpl::end),
+ (KWQValueListImpl::nodeAt), (KWQValueListImpl::operator=),
+ (KWQValueListImpl::copyOnWrite):
+ * src/kwq/Makefile.am:
+
+ * src/kwq/kio/netaccess.h: Don't declare private copy constructor
+ - this class needs to be copyable to be stored in a QValueList!
+
+ Hack these scripts a bit so the large tables they generate are
+ constant data.
+
+ * src/kwq/make-charset-table.pl:
+ * src/kdelibs/khtml/css/makeprop:
+ * src/kdelibs/khtml/css/makevalues:
+ * src/kdelibs/khtml/misc/makeattrs:
+ * src/kdelibs/khtml/misc/maketags:
+
2002-02-23 Maciej Stachowiak <mjs at apple.com>
* src/kwq/WCLoadProgress.h: Add the forgotten WCLoadProgress.h.
diff --git a/WebCore/khtml/css/makeprop b/WebCore/khtml/css/makeprop
index 356a5b9..935ba11 100644
--- a/WebCore/khtml/css/makeprop
+++ b/WebCore/khtml/css/makeprop
@@ -42,7 +42,7 @@ echo -e '#endif\n' >> cssproperties.h
cat cssproperties.strip | awk '{ \
i=1; \
-print "static const char * propertyList[] = {"; \
+print "static const char * const propertyList[] = {"; \
print "\"\","; \
do { print "\"" $0 "\", "; i = i + 1 } while (getline); \
print " 0"; \
diff --git a/WebCore/khtml/css/makevalues b/WebCore/khtml/css/makevalues
index 601cc8c..009cc09 100644
--- a/WebCore/khtml/css/makevalues
+++ b/WebCore/khtml/css/makevalues
@@ -42,7 +42,7 @@ echo -e '#endif\n' >> cssvalues.h
cat cssvalues.strip | awk '{ \
i=1; \
-print "static const char * valueList[] = {"; \
+print "static const char * const valueList[] = {"; \
print "\"\","; \
do { print "\"" $0 "\", "; i = i + 1 } while (getline); \
print " 0"; \
diff --git a/WebCore/khtml/misc/makeattrs b/WebCore/khtml/misc/makeattrs
index 74ce3b7..764d161 100644
--- a/WebCore/khtml/misc/makeattrs
+++ b/WebCore/khtml/misc/makeattrs
@@ -64,7 +64,7 @@ system("/bin/sh", "-c", "gperf -c -a -L 'ANSI-C' -E -C -o -t -k '*' -NfindAttr -
system("/bin/sh", "-c", 'perl -pi -e "s/\"\"}/\"\", 0}/g" htmlattrs.c');
open(OUT, ">>htmlattrs.c");
-print OUT "\n\nstatic const char *attrList[$len] = {\n";
+print OUT "\n\nstatic const char * const attrList[$len] = {\n";
while(defined ($line = shift @a))
{
print OUT $line."\n";
diff --git a/WebCore/khtml/misc/maketags b/WebCore/khtml/misc/maketags
index 4f3c2ff..ca053f9 100644
--- a/WebCore/khtml/misc/maketags
+++ b/WebCore/khtml/misc/maketags
@@ -69,7 +69,7 @@ close header;
system("/bin/sh", "-c", "gperf -a -L 'ANSI-C' -D -E -C -l -o -t -k '*' -NfindTag -Hhash_tag -Wwordlist_tag htmltags.gperf > htmltags.c");
open(OUT, ">>htmltags.c");
-print OUT "\n\nstatic const char * tagList[] = {\n";
+print OUT "\n\nstatic const char * const tagList[] = {\n";
print OUT "\"\",\n";
while(defined ($line = shift @a))
{
diff --git a/WebCore/kwq/KWQKIONetAccess.h b/WebCore/kwq/KWQKIONetAccess.h
index 425a65d..86a6e69 100644
--- a/WebCore/kwq/KWQKIONetAccess.h
+++ b/WebCore/kwq/KWQKIONetAccess.h
@@ -69,20 +69,6 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
-private:
-
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
- UDSAtom(const UDSAtom &);
-#endif
-
-// add assignment operator
-// this private declaration prevents assignment
-#ifdef _KWQ_PEDANTIC_
- UDSAtom &operator=(const UDSAtom &);
-#endif
-
}; // class UDSAtom ============================================================
diff --git a/WebCore/kwq/KWQRegExp.h b/WebCore/kwq/KWQRegExp.h
index 89633aa..2920947 100644
--- a/WebCore/kwq/KWQRegExp.h
+++ b/WebCore/kwq/KWQRegExp.h
@@ -36,34 +36,31 @@
#include <_qregexp.h>
#else
-#include "qstring.h"
+#include <qstring.h>
+
+#include <KWQRefPtr.h>
// class QRegExp ===============================================================
class QRegExp {
public:
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QRegExp();
- QRegExp(const QString &);
+ QRegExp(const QString &, bool, bool);
+ QRegExp(const char *);
QRegExp(const QRegExp &);
~QRegExp();
- // member functions --------------------------------------------------------
-
- // operators ---------------------------------------------------------------
-
QRegExp &operator=(const QRegExp &);
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ QString pattern() const;
+ int match (const QString &, int startFrom = 0, int *matchLength = 0,
+ bool treatStartAsStartOfInput = TRUE) const;
+private:
+ class KWQRegExpPrivate;
+
+ KWQRefPtr<KWQRegExpPrivate> d;
}; // class QRegExp ============================================================
#endif // USING_BORROWED_QREGEXP
diff --git a/WebCore/kwq/KWQRegExp.mm b/WebCore/kwq/KWQRegExp.mm
new file mode 100644
index 0000000..43eddb3
--- /dev/null
+++ b/WebCore/kwq/KWQRegExp.mm
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <qregexp.h>
+
+#ifndef USING_BORROWED_QREGEXP
+
+#include <sys/types.h>
+#include <regex.h>
+
+
+class QRegExp::KWQRegExpPrivate
+{
+public:
+ KWQRegExpPrivate();
+ KWQRegExpPrivate(QString pattern);
+ ~KWQRegExpPrivate();
+
+ void compile();
+
+ QString pattern;
+ regex_t regex;
+ uint refCount;
+};
+
+QRegExp::KWQRegExpPrivate::KWQRegExpPrivate() : pattern(QString("")), refCount(0)
+{
+ compile();
+}
+
+QRegExp::KWQRegExpPrivate::KWQRegExpPrivate(QString p) : pattern(p), refCount(0)
+{
+ compile();
+}
+
+void QRegExp::KWQRegExpPrivate::compile()
+{
+ const char *cpattern = pattern.latin1();
+ regcomp(®ex, cpattern, REG_EXTENDED);
+}
+
+QRegExp::KWQRegExpPrivate::~KWQRegExpPrivate()
+{
+ regfree(®ex);
+}
+
+
+QRegExp::QRegExp() : d(new QRegExp::KWQRegExpPrivate())
+{
+}
+
+QRegExp::QRegExp(const QString &pattern, bool, bool) : d(new QRegExp::KWQRegExpPrivate(pattern))
+{
+}
+
+QRegExp::QRegExp(const char *cpattern) : d(new QRegExp::KWQRegExpPrivate(cpattern))
+{
+}
+
+
+QRegExp::QRegExp(const QRegExp &re) : d (re.d)
+{
+}
+
+QRegExp::~QRegExp()
+{
+}
+
+QRegExp &QRegExp::operator=(const QRegExp &re)
+{
+ QRegExp tmp(re);
+ KWQRefPtr<QRegExp::KWQRegExpPrivate> tmpD = tmp.d;
+
+ tmp.d = d;
+ d = tmpD;
+
+ return *this;
+}
+
+QString QRegExp::pattern() const
+{
+ return d->pattern;
+}
+
+int QRegExp::match(const QString &str, int startFrom = 0, int *matchLength = 0, bool treatStartAsStartOfInput = TRUE) const
+{
+ const char *cstring = str.latin1() + startFrom;
+
+ int flags = 0;
+
+ if (startFrom != 0 && !treatStartAsStartOfInput) {
+ flags |= REG_NOTBOL;
+ }
+
+ regmatch_t match[1];
+ int result = regexec(&d->regex, cstring, 1, match, flags);
+
+ if (result != 0) {
+ return -1;
+ } else {
+ if (matchLength != NULL) {
+ *matchLength = match[0].rm_eo - match[0].rm_so;
+ }
+ return startFrom + match[0].rm_so;
+ }
+}
+
+
+#endif
diff --git a/WebCore/kwq/KWQValueList.h b/WebCore/kwq/KWQValueList.h
index 098c10d..8aa2193 100644
--- a/WebCore/kwq/KWQValueList.h
+++ b/WebCore/kwq/KWQValueList.h
@@ -37,74 +37,74 @@
#else
#include <KWQDef.h>
+#include <KWQValueListImpl.h>
-// class QValueListIterator ====================================================
+#include <iostream>
+
+template <class T> class QValueList;
+template <class T> class QValueListConstIterator;
+
+template<class T> class QValueListNode : private KWQValueListNodeImpl {
+public:
+ QValueListNode(const T &val) : KWQValueListNodeImpl(), value(val) {}
+ ~QValueListNode() {}
+
+ T value;
+ friend class QValueList<T>;
+};
+
+// class QValueListIterator ====================================================
template<class T> class QValueListIterator {
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QValueListIterator();
- QValueListIterator(const QValueListIterator<T>&);
+ QValueListIterator() : impl() {}
+ QValueListIterator(const QValueListIterator<T> &other) : impl(other.impl) {}
- ~QValueListIterator();
-
- // member functions --------------------------------------------------------
+ ~QValueListIterator() {}
- // operators ---------------------------------------------------------------
+ QValueListIterator &operator=(const QValueListIterator &other) { impl = other.impl; return *this; }
+
+ bool operator==(const QValueListIterator<T> &other) { return impl == other.impl; }
+ bool operator!=(const QValueListIterator<T> &other) { return impl != other.impl; }
+ const T& operator*() const { return ((const QValueListNode<T> *)impl.node())->value; }
+ QValueListIterator operator++() { ++impl; return *this; }
+
+ T& operator*() { return ((QValueListNode<T> *)impl.node())->value; }
+ QValueListIterator<T>& operator--() { --impl; return *this; }
+ QValueListIterator operator++(int) { return QValueListIterator<T>(impl++); }
- QValueListIterator &operator=(const QValueListIterator &);
- bool operator==(const QValueListIterator<T>&);
- bool operator!=(const QValueListIterator<T>&);
- T& operator*();
- const T& operator*() const;
- QValueListIterator<T>& operator++();
- QValueListIterator<T>& operator++(int);
- QValueListIterator<T>& operator--();
+private:
+ QValueListIterator(const KWQValueListIteratorImpl &pImp) : impl(pImp) {}
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ KWQValueListIteratorImpl impl;
+ friend class QValueList<T>;
+ friend class QValueListConstIterator<T>;
}; // class QValueListIterator =================================================
// class QValueListConstIterator ===============================================
-
template<class T> class QValueListConstIterator {
public:
+ QValueListConstIterator() : impl() {}
+ QValueListConstIterator(const QValueListConstIterator<T> &other) : impl(other.impl) {}
+ QValueListConstIterator(const QValueListIterator<T> &other) : impl(other.impl) {}
+
+ ~QValueListConstIterator() {}
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QValueListConstIterator();
- QValueListConstIterator(const QValueListIterator<T>&);
-
- ~QValueListConstIterator();
-
- // member functions --------------------------------------------------------
-
- // operators ---------------------------------------------------------------
+ QValueListConstIterator &operator=(const QValueListConstIterator &other) { impl = other.impl; return *this; }
+ bool operator==(const QValueListConstIterator<T> &other) { return impl == other.impl; }
+ bool operator!=(const QValueListConstIterator<T> &other) { return impl != other.impl; }
+ const T& operator*() const { return ((const QValueListNode<T> *)impl.node())->value; }
+ QValueListConstIterator operator++() { ++impl; return *this; }
+ QValueListConstIterator operator++(int) { return QValueListConstIterator<T>(impl++); }
- QValueListConstIterator &operator=(const QValueListConstIterator &);
- bool operator==(const QValueListConstIterator<T>&);
- bool operator!=(const QValueListConstIterator<T>&);
- T& operator*();
- QValueListConstIterator operator++();
- QValueListConstIterator operator++(int);
+private:
+ QValueListConstIterator(const KWQValueListIteratorImpl &pImp) : impl(pImp) {}
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ KWQValueListIteratorImpl impl;
+ friend class QValueList<T>;
}; // class QValueListConstIterator ============================================
@@ -113,57 +113,76 @@ public:
template <class T> class QValueList {
public:
- // typedefs ----------------------------------------------------------------
-
typedef QValueListIterator<T> Iterator;
typedef QValueListConstIterator<T> ConstIterator;
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
// constructors, copy constructors, and destructors ------------------------
- QValueList();
- QValueList(const QValueList<T>&);
+ QValueList() : impl(deleteNode, copyNode) {}
+ QValueList(const QValueList<T>&other) : impl(other.impl) {}
- ~QValueList();
+ ~QValueList() {}
// member functions --------------------------------------------------------
- void clear();
- uint count() const;
- bool isEmpty() const;
-
- void append(const T&);
- void remove(const T&);
+ void clear() { impl.clear(); }
+ uint count() const { return impl.count(); }
+ bool isEmpty() const { return impl.isEmpty(); }
- uint contains(const T&);
+ void append(const T &val) { impl.appendNode(new QValueListNode<T>(val)); }
+ void prepend(const T &val) { impl.prependNode(new QValueListNode<T>(val)); }
+ void remove(const T &val) { QValueListNode<T> node(val); impl.removeEqualNodes(&node, nodesEqual); }
+ uint contains(const T &val) { QValueListNode<T> node(val); return impl.containsEqualNodes(&node, nodesEqual); }
- Iterator remove(Iterator);
- Iterator fromLast();
+ Iterator remove(Iterator iter) { return QValueListIterator<T>(impl.removeIterator(iter.impl)); }
+ Iterator fromLast() { return QValueListIterator<T>(impl.fromLast()); }
- const T& first() const;
- const T& last() const;
+ const T& first() const { return ((QValueListNode<T> *)impl.firstNode())->value; }
+ const T& last() const { return ((QValueListNode<T> *)impl.lastNode())->value; }
- Iterator begin();
- Iterator end();
+ Iterator begin() { return QValueListIterator<T>(impl.begin()); }
+ Iterator end() { return QValueListIterator<T>(impl.end()); }
- ConstIterator begin() const;
- ConstIterator end() const;
+ ConstIterator begin() const { return QValueListConstIterator<T>(impl.begin()); }
+ ConstIterator end() const { return QValueListConstIterator<T>(impl.end()); }
// operators ---------------------------------------------------------------
- QValueList<T>& operator=(const QValueList<T>&);
- T& operator[] (uint);
- const T& operator[] (uint) const;
- QValueList<T> &operator+=(const T &);
+ QValueList<T>& operator=(const QValueList<T>&other) { impl = other.impl; return *this; }
+ T& operator[] (uint index) { return ((QValueListNode<T> *)impl.nodeAt(index))->value; }
+ const T& operator[] (uint index) const { return ((const QValueListNode<T> *)impl.nodeAt(index))->value; }
+ QValueList<T> &operator+=(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ QValueList<T> &operator<<(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
+private:
+ KWQValueListImpl impl;
+
+ static void deleteNode(KWQValueListNodeImpl *node) { delete (QValueListNode<T> *)node; }
+ static bool nodesEqual(KWQValueListNodeImpl *a, KWQValueListNodeImpl *b) { return ((QValueListNode<T> *)a)->value == ((QValueListNode<T> *)b)->value; }
+ static KWQValueListNodeImpl *copyNode(KWQValueListNodeImpl *node) { return new QValueListNode<T>(((QValueListNode<T> *)node)->value); }
}; // class QValueList =========================================================
+
+template<class T>
+inline ostream &operator<<(ostream &o, const QValueList<T>&p)
+{
+ o <<
+ "QValueList: [size: " <<
+ (Q_UINT32)p.count() <<
+ "; items: ";
+ QValueListConstIterator<T> it = p.begin();
+ while (it != p.end()) {
+ o << *it;
+ if (++it != p.end()) {
+ o << ", ";
+ }
+ }
+ o << "]";
+ return o;
+}
+
+
#endif // USING_BORROWED_QVALUELIST
#endif
diff --git a/WebCore/kwq/KWQValueListImpl.h b/WebCore/kwq/KWQValueListImpl.h
new file mode 100644
index 0000000..810d0c5
--- /dev/null
+++ b/WebCore/kwq/KWQValueListImpl.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KWQVALUELIST_H_
+#define KWQVALUELIST_H_
+
+#include <config.h>
+
+#ifndef USING_BORROWED_QVALUELIST
+
+#include <KWQRefPtr.h>
+#include <KWQDef.h>
+
+class KWQValueListNodeImpl;
+
+class KWQValueListIteratorImpl
+{
+public:
+ KWQValueListIteratorImpl();
+ KWQValueListIteratorImpl(const KWQValueListIteratorImpl &other);
+
+ ~KWQValueListIteratorImpl();
+
+ KWQValueListIteratorImpl &operator=(const KWQValueListIteratorImpl &other);
+
+ bool operator==(const KWQValueListIteratorImpl &other);
+ bool operator!=(const KWQValueListIteratorImpl &other);
+
+ KWQValueListNodeImpl *node();
+ const KWQValueListNodeImpl *node() const;
+
+ KWQValueListIteratorImpl& operator++();
+ KWQValueListIteratorImpl operator++(int);
+ KWQValueListIteratorImpl& operator--();
+
+private:
+ KWQValueListIteratorImpl(const KWQValueListNodeImpl *n);
+
+
+ KWQValueListNodeImpl *nodeImpl;
+
+ friend class KWQValueListImpl;
+};
+
+
+class KWQValueListImpl
+{
+public:
+ KWQValueListImpl(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyNode)(KWQValueListNodeImpl *));
+ KWQValueListImpl(const KWQValueListImpl &other);
+
+ ~KWQValueListImpl();
+
+ void clear();
+ uint count() const;
+ bool isEmpty() const;
+
+ void appendNode(KWQValueListNodeImpl *node);
+ void prependNode(KWQValueListNodeImpl *node);
+ void removeEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *));
+ uint containsEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *)) const;
+
+ KWQValueListIteratorImpl removeIterator(KWQValueListIteratorImpl &iterator);
+ KWQValueListIteratorImpl fromLast();
+
+ KWQValueListNodeImpl *firstNode();
+ KWQValueListNodeImpl *lastNode();
+
+ KWQValueListNodeImpl *firstNode() const;
+ KWQValueListNodeImpl *lastNode() const;
+
+ KWQValueListIteratorImpl begin();
+ KWQValueListIteratorImpl end();
+
+ KWQValueListIteratorImpl begin() const;
+ KWQValueListIteratorImpl end() const;
+
+ KWQValueListNodeImpl *nodeAt(uint index);
+ KWQValueListNodeImpl *nodeAt(uint index) const;
+
+ KWQValueListImpl operator=(const KWQValueListImpl &other);
+
+private:
+ void copyOnWrite();
+
+ class KWQValueListPrivate;
+
+ KWQRefPtr<KWQValueListPrivate> d;
+};
+
+class KWQValueListNodeImpl
+{
+protected:
+ KWQValueListNodeImpl();
+ ~KWQValueListNodeImpl();
+
+private:
+ KWQValueListNodeImpl *prev;
+ KWQValueListNodeImpl *next;
+
+ friend class KWQValueListImpl;
+ friend class KWQValueListIteratorImpl;
+ friend class KWQValueListImpl::KWQValueListPrivate;
+};
+
+#endif
+
+#endif
diff --git a/WebCore/kwq/KWQValueListImpl.mm b/WebCore/kwq/KWQValueListImpl.mm
new file mode 100644
index 0000000..e4ac4c2
--- /dev/null
+++ b/WebCore/kwq/KWQValueListImpl.mm
@@ -0,0 +1,447 @@
+/*
+ * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <KWQValueListImpl.h>
+
+#ifndef USING_BORROWED_QVALUELIST
+
+#include <stdlib.h>
+
+KWQValueListNodeImpl::KWQValueListNodeImpl() :
+ prev(NULL),
+ next(NULL)
+{
+}
+
+KWQValueListNodeImpl::~KWQValueListNodeImpl()
+{
+}
+
+KWQValueListIteratorImpl::KWQValueListIteratorImpl() :
+ nodeImpl(NULL)
+{
+}
+
+KWQValueListIteratorImpl::KWQValueListIteratorImpl(const KWQValueListIteratorImpl &other) :
+ nodeImpl(other.nodeImpl)
+{
+}
+
+KWQValueListIteratorImpl::~KWQValueListIteratorImpl()
+{
+}
+
+KWQValueListIteratorImpl &KWQValueListIteratorImpl::operator=(const KWQValueListIteratorImpl &other)
+{
+ nodeImpl = other.nodeImpl;
+ return *this;
+}
+
+bool KWQValueListIteratorImpl::operator==(const KWQValueListIteratorImpl &other)
+{
+ return nodeImpl == other.nodeImpl;
+}
+
+bool KWQValueListIteratorImpl::operator!=(const KWQValueListIteratorImpl &other)
+{
+ return nodeImpl != other.nodeImpl;
+}
+
+KWQValueListNodeImpl *KWQValueListIteratorImpl::node()
+{
+ return nodeImpl;
+}
+
+const KWQValueListNodeImpl *KWQValueListIteratorImpl::node() const
+{
+ return nodeImpl;
+}
+
+KWQValueListIteratorImpl& KWQValueListIteratorImpl::operator++()
+{
+ if (nodeImpl != NULL) {
+ nodeImpl = nodeImpl->next;
+ }
+ return *this;
+}
+
+KWQValueListIteratorImpl KWQValueListIteratorImpl::operator++(int)
+{
+ KWQValueListIteratorImpl tmp(*this);
+
+ if (nodeImpl != NULL) {
+ nodeImpl = nodeImpl->next;
+ }
+
+ return tmp;
+}
+
+KWQValueListIteratorImpl& KWQValueListIteratorImpl::operator--()
+{
+ if (nodeImpl != NULL) {
+ nodeImpl = nodeImpl->prev;
+ }
+ return *this;
+}
+
+KWQValueListIteratorImpl::KWQValueListIteratorImpl(const KWQValueListNodeImpl *n) :
+ nodeImpl((KWQValueListNodeImpl *)n)
+{
+}
+
+
+class KWQValueListImpl::KWQValueListPrivate
+{
+public:
+ KWQValueListPrivate(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyFunc)(KWQValueListNodeImpl *));
+ KWQValueListPrivate(const KWQValueListPrivate &other);
+
+ ~KWQValueListPrivate();
+
+ KWQValueListNodeImpl *copyList(KWQValueListNodeImpl *l) const;
+ void deleteList(KWQValueListNodeImpl *l);
+
+ KWQValueListNodeImpl *head;
+
+ void (*deleteNode)(KWQValueListNodeImpl *);
+ KWQValueListNodeImpl *(*copyNode)(KWQValueListNodeImpl *);
+ uint count;
+
+ uint refCount;
+};
+
+
+KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate(void (*deleteFunc)(KWQValueListNodeImpl *),
+ KWQValueListNodeImpl *(*copyFunc)(KWQValueListNodeImpl *)) :
+ head(NULL),
+ deleteNode(deleteFunc),
+ copyNode(copyFunc),
+ count(0),
+ refCount(0)
+{
+}
+
+KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate(const KWQValueListPrivate &other) :
+ head(other.copyList(other.head)),
+ deleteNode(other.deleteNode),
+ copyNode(other.copyNode),
+ count(other.count),
+ refCount(0)
+{
+}
+
+KWQValueListImpl::KWQValueListPrivate::~KWQValueListPrivate()
+{
+ deleteList(head);
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::KWQValueListPrivate::copyList(KWQValueListNodeImpl *l) const
+{
+ KWQValueListNodeImpl *prev = NULL;
+ KWQValueListNodeImpl *node = l;
+ KWQValueListNodeImpl *head = NULL;
+
+ while (node != NULL) {
+ KWQValueListNodeImpl *copy = copyNode(node);
+ if (prev == NULL) {
+ head = copy;
+ } else {
+ prev->next = copy;
+ }
+
+ copy->prev = prev;
+ copy->next = NULL;
+
+ prev = copy;
+ node = node->next;
+ }
+
+ return head;
+}
+
+void KWQValueListImpl::KWQValueListPrivate::deleteList(KWQValueListNodeImpl *l)
+{
+ KWQValueListNodeImpl *p = l;
+
+ while (p != NULL) {
+ KWQValueListNodeImpl *next = p->next;
+ deleteNode(p);
+ p = next;
+ }
+}
+
+
+
+KWQValueListImpl::KWQValueListImpl(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyFunc)(KWQValueListNodeImpl *)) :
+ d(new KWQValueListImpl::KWQValueListPrivate(deleteFunc, copyFunc))
+{
+}
+
+KWQValueListImpl::KWQValueListImpl(const KWQValueListImpl &other) :
+ d(other.d)
+{
+}
+
+KWQValueListImpl::~KWQValueListImpl()
+{
+}
+
+void KWQValueListImpl::clear()
+{
+ d->deleteList(d->head);
+ d->head = NULL;
+ d->count = 0;
+}
+
+uint KWQValueListImpl::count() const
+{
+ return d->count;
+}
+
+bool KWQValueListImpl::isEmpty() const
+{
+ return d->count == 0;
+}
+
+void KWQValueListImpl::appendNode(KWQValueListNodeImpl *node)
+{
+ copyOnWrite();
+
+ // FIXME: maintain tail pointer to make this fast
+
+ if (d->head == NULL) {
+ d->head = node;
+ } else {
+ KWQValueListNodeImpl *p = d->head;
+
+ while (p->next != NULL) {
+ p = p->next;
+ }
+
+ p->next = node;
+ node->prev = p;
+ node->next = NULL;
+ }
+
+ d->count++;
+}
+
+void KWQValueListImpl::prependNode(KWQValueListNodeImpl *node)
+{
+ copyOnWrite();
+
+ node->next = d->head;
+ node->prev = NULL;
+ d->head = node;
+
+ if (node->next != NULL) {
+ node->next->prev = node;
+ }
+
+ d->count++;
+}
+
+void KWQValueListImpl::removeEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *))
+{
+ copyOnWrite();
+
+ KWQValueListNodeImpl *p = d->head;
+
+ while (p != NULL) {
+ KWQValueListNodeImpl *next = p->next;
+ if (equalFunc(node, p)) {
+ if (p->next != NULL) {
+ p->next->prev = p->prev;
+ }
+
+ if (p->prev != NULL) {
+ p->prev->next = p->next;
+ } else {
+ d->head = p->next;
+ }
+
+ d->deleteNode(p);
+
+ d->count--;
+ }
+ p = next;
+ }
+}
+
+uint KWQValueListImpl::containsEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *)) const
+{
+ KWQValueListNodeImpl *p = d->head;
+ unsigned contains = 0;
+
+ while (p != NULL) {
+ if (equalFunc(node, p)) {
+ ++contains;
+ }
+ p = p->next;
+ }
+
+ return contains;
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::removeIterator(KWQValueListIteratorImpl &iterator)
+{
+ copyOnWrite();
+
+ if (iterator.nodeImpl == NULL) {
+ return iterator;
+ }
+
+ KWQValueListNodeImpl *next = iterator.nodeImpl->next;
+
+ // detach node
+ if (iterator.nodeImpl->next != NULL) {
+ iterator.nodeImpl->next->prev = iterator.nodeImpl->prev;
+ }
+ if (iterator.nodeImpl->prev != NULL) {
+ iterator.nodeImpl->prev->next = iterator.nodeImpl->next;
+ } else {
+ d->head = iterator.nodeImpl->next;
+ }
+
+ d->deleteNode(iterator.nodeImpl);
+ d->count--;
+
+ return KWQValueListIteratorImpl(next);
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::fromLast()
+{
+ return KWQValueListIteratorImpl(lastNode());
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::firstNode()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->firstNode();
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::lastNode()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->lastNode();
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::firstNode() const
+{
+ return d->head;
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::lastNode() const
+{
+ // FIXME: use tail pointer
+
+ KWQValueListNodeImpl *p = d->head;
+
+ if (p == NULL) {
+ return NULL;
+ }
+
+ while (p->next != NULL) {
+ p = p->next;
+ }
+
+ return p;
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::begin()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->begin();
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::end()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->end();
+}
+
+
+KWQValueListIteratorImpl KWQValueListImpl::begin() const
+{
+ return KWQValueListIteratorImpl(firstNode());
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::end() const
+{
+ return KWQValueListIteratorImpl(NULL);
+}
+
+
+KWQValueListNodeImpl *KWQValueListImpl::nodeAt(uint index)
+{
+ copyOnWrite();
+
+ if (d->count <= index) {
+ return NULL;
+ }
+
+ KWQValueListNodeImpl *p = d->head;
+
+ for (uint i = 0; i < index; i++) {
+ p = p->next;
+ }
+
+ return p;
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::nodeAt(uint index) const
+{
+ if (d->count <= index) {
+ return NULL;
+ }
+
+ KWQValueListNodeImpl *p = d->head;
+
+ for (uint i = 0; i < index; i++) {
+ p = p->next;
+ }
+
+ return p;
+}
+
+KWQValueListImpl KWQValueListImpl::operator=(const KWQValueListImpl &other)
+{
+ KWQValueListImpl tmp(other);
+ KWQRefPtr<KWQValueListImpl::KWQValueListPrivate> tmpD = tmp.d;
+
+ tmp.d = d;
+ d = tmpD;
+
+ return *this;
+}
+
+void KWQValueListImpl::copyOnWrite()
+{
+ if (d->refCount > 1) {
+ d = KWQRefPtr<KWQValueListImpl::KWQValueListPrivate>(new KWQValueListImpl::KWQValueListPrivate(*d));
+ }
+}
+
+#endif
diff --git a/WebCore/kwq/Makefile.am b/WebCore/kwq/Makefile.am
index 8d73785..102996a 100644
--- a/WebCore/kwq/Makefile.am
+++ b/WebCore/kwq/Makefile.am
@@ -104,6 +104,7 @@ libkwq_o_SOURCES = \
KWQPointArray.mm \
KWQPushButton.mm \
KWQRadioButton.mm \
+ KWQRegExp.mm \
KWQRegion.mm \
KWQScrollView.mm \
KWQString.mm \
@@ -115,6 +116,7 @@ libkwq_o_SOURCES = \
KWQTextStorage.mm \
KWQTimer.mm \
KWQToolTip.mm \
+ KWQValueListImpl.mm \
KWQVariant.mm \
KWQVectorImpl.mm \
KWQView.mm \
diff --git a/WebCore/kwq/kio/netaccess.h b/WebCore/kwq/kio/netaccess.h
index 425a65d..86a6e69 100644
--- a/WebCore/kwq/kio/netaccess.h
+++ b/WebCore/kwq/kio/netaccess.h
@@ -69,20 +69,6 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
-private:
-
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
- UDSAtom(const UDSAtom &);
-#endif
-
-// add assignment operator
-// this private declaration prevents assignment
-#ifdef _KWQ_PEDANTIC_
- UDSAtom &operator=(const UDSAtom &);
-#endif
-
}; // class UDSAtom ============================================================
diff --git a/WebCore/kwq/make-charset-table.pl b/WebCore/kwq/make-charset-table.pl
index ef05900..ae23aee 100755
--- a/WebCore/kwq/make-charset-table.pl
+++ b/WebCore/kwq/make-charset-table.pl
@@ -17,7 +17,7 @@ my $already_wrote_one = 0;
sub emit_prefix
{
- print TABLE "static CharsetEntry table[] = {\n";
+ print TABLE "static const CharsetEntry table[] = {\n";
}
sub emit_suffix
diff --git a/WebCore/kwq/qt/qregexp.h b/WebCore/kwq/qt/qregexp.h
index 89633aa..2920947 100644
--- a/WebCore/kwq/qt/qregexp.h
+++ b/WebCore/kwq/qt/qregexp.h
@@ -36,34 +36,31 @@
#include <_qregexp.h>
#else
-#include "qstring.h"
+#include <qstring.h>
+
+#include <KWQRefPtr.h>
// class QRegExp ===============================================================
class QRegExp {
public:
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QRegExp();
- QRegExp(const QString &);
+ QRegExp(const QString &, bool, bool);
+ QRegExp(const char *);
QRegExp(const QRegExp &);
~QRegExp();
- // member functions --------------------------------------------------------
-
- // operators ---------------------------------------------------------------
-
QRegExp &operator=(const QRegExp &);
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ QString pattern() const;
+ int match (const QString &, int startFrom = 0, int *matchLength = 0,
+ bool treatStartAsStartOfInput = TRUE) const;
+private:
+ class KWQRegExpPrivate;
+
+ KWQRefPtr<KWQRegExpPrivate> d;
}; // class QRegExp ============================================================
#endif // USING_BORROWED_QREGEXP
diff --git a/WebCore/kwq/qt/qvaluelist.h b/WebCore/kwq/qt/qvaluelist.h
index 098c10d..8aa2193 100644
--- a/WebCore/kwq/qt/qvaluelist.h
+++ b/WebCore/kwq/qt/qvaluelist.h
@@ -37,74 +37,74 @@
#else
#include <KWQDef.h>
+#include <KWQValueListImpl.h>
-// class QValueListIterator ====================================================
+#include <iostream>
+
+template <class T> class QValueList;
+template <class T> class QValueListConstIterator;
+
+template<class T> class QValueListNode : private KWQValueListNodeImpl {
+public:
+ QValueListNode(const T &val) : KWQValueListNodeImpl(), value(val) {}
+ ~QValueListNode() {}
+
+ T value;
+ friend class QValueList<T>;
+};
+
+// class QValueListIterator ====================================================
template<class T> class QValueListIterator {
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QValueListIterator();
- QValueListIterator(const QValueListIterator<T>&);
+ QValueListIterator() : impl() {}
+ QValueListIterator(const QValueListIterator<T> &other) : impl(other.impl) {}
- ~QValueListIterator();
-
- // member functions --------------------------------------------------------
+ ~QValueListIterator() {}
- // operators ---------------------------------------------------------------
+ QValueListIterator &operator=(const QValueListIterator &other) { impl = other.impl; return *this; }
+
+ bool operator==(const QValueListIterator<T> &other) { return impl == other.impl; }
+ bool operator!=(const QValueListIterator<T> &other) { return impl != other.impl; }
+ const T& operator*() const { return ((const QValueListNode<T> *)impl.node())->value; }
+ QValueListIterator operator++() { ++impl; return *this; }
+
+ T& operator*() { return ((QValueListNode<T> *)impl.node())->value; }
+ QValueListIterator<T>& operator--() { --impl; return *this; }
+ QValueListIterator operator++(int) { return QValueListIterator<T>(impl++); }
- QValueListIterator &operator=(const QValueListIterator &);
- bool operator==(const QValueListIterator<T>&);
- bool operator!=(const QValueListIterator<T>&);
- T& operator*();
- const T& operator*() const;
- QValueListIterator<T>& operator++();
- QValueListIterator<T>& operator++(int);
- QValueListIterator<T>& operator--();
+private:
+ QValueListIterator(const KWQValueListIteratorImpl &pImp) : impl(pImp) {}
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ KWQValueListIteratorImpl impl;
+ friend class QValueList<T>;
+ friend class QValueListConstIterator<T>;
}; // class QValueListIterator =================================================
// class QValueListConstIterator ===============================================
-
template<class T> class QValueListConstIterator {
public:
+ QValueListConstIterator() : impl() {}
+ QValueListConstIterator(const QValueListConstIterator<T> &other) : impl(other.impl) {}
+ QValueListConstIterator(const QValueListIterator<T> &other) : impl(other.impl) {}
+
+ ~QValueListConstIterator() {}
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QValueListConstIterator();
- QValueListConstIterator(const QValueListIterator<T>&);
-
- ~QValueListConstIterator();
-
- // member functions --------------------------------------------------------
-
- // operators ---------------------------------------------------------------
+ QValueListConstIterator &operator=(const QValueListConstIterator &other) { impl = other.impl; return *this; }
+ bool operator==(const QValueListConstIterator<T> &other) { return impl == other.impl; }
+ bool operator!=(const QValueListConstIterator<T> &other) { return impl != other.impl; }
+ const T& operator*() const { return ((const QValueListNode<T> *)impl.node())->value; }
+ QValueListConstIterator operator++() { ++impl; return *this; }
+ QValueListConstIterator operator++(int) { return QValueListConstIterator<T>(impl++); }
- QValueListConstIterator &operator=(const QValueListConstIterator &);
- bool operator==(const QValueListConstIterator<T>&);
- bool operator!=(const QValueListConstIterator<T>&);
- T& operator*();
- QValueListConstIterator operator++();
- QValueListConstIterator operator++(int);
+private:
+ QValueListConstIterator(const KWQValueListIteratorImpl &pImp) : impl(pImp) {}
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ KWQValueListIteratorImpl impl;
+ friend class QValueList<T>;
}; // class QValueListConstIterator ============================================
@@ -113,57 +113,76 @@ public:
template <class T> class QValueList {
public:
- // typedefs ----------------------------------------------------------------
-
typedef QValueListIterator<T> Iterator;
typedef QValueListConstIterator<T> ConstIterator;
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
// constructors, copy constructors, and destructors ------------------------
- QValueList();
- QValueList(const QValueList<T>&);
+ QValueList() : impl(deleteNode, copyNode) {}
+ QValueList(const QValueList<T>&other) : impl(other.impl) {}
- ~QValueList();
+ ~QValueList() {}
// member functions --------------------------------------------------------
- void clear();
- uint count() const;
- bool isEmpty() const;
-
- void append(const T&);
- void remove(const T&);
+ void clear() { impl.clear(); }
+ uint count() const { return impl.count(); }
+ bool isEmpty() const { return impl.isEmpty(); }
- uint contains(const T&);
+ void append(const T &val) { impl.appendNode(new QValueListNode<T>(val)); }
+ void prepend(const T &val) { impl.prependNode(new QValueListNode<T>(val)); }
+ void remove(const T &val) { QValueListNode<T> node(val); impl.removeEqualNodes(&node, nodesEqual); }
+ uint contains(const T &val) { QValueListNode<T> node(val); return impl.containsEqualNodes(&node, nodesEqual); }
- Iterator remove(Iterator);
- Iterator fromLast();
+ Iterator remove(Iterator iter) { return QValueListIterator<T>(impl.removeIterator(iter.impl)); }
+ Iterator fromLast() { return QValueListIterator<T>(impl.fromLast()); }
- const T& first() const;
- const T& last() const;
+ const T& first() const { return ((QValueListNode<T> *)impl.firstNode())->value; }
+ const T& last() const { return ((QValueListNode<T> *)impl.lastNode())->value; }
- Iterator begin();
- Iterator end();
+ Iterator begin() { return QValueListIterator<T>(impl.begin()); }
+ Iterator end() { return QValueListIterator<T>(impl.end()); }
- ConstIterator begin() const;
- ConstIterator end() const;
+ ConstIterator begin() const { return QValueListConstIterator<T>(impl.begin()); }
+ ConstIterator end() const { return QValueListConstIterator<T>(impl.end()); }
// operators ---------------------------------------------------------------
- QValueList<T>& operator=(const QValueList<T>&);
- T& operator[] (uint);
- const T& operator[] (uint) const;
- QValueList<T> &operator+=(const T &);
+ QValueList<T>& operator=(const QValueList<T>&other) { impl = other.impl; return *this; }
+ T& operator[] (uint index) { return ((QValueListNode<T> *)impl.nodeAt(index))->value; }
+ const T& operator[] (uint index) const { return ((const QValueListNode<T> *)impl.nodeAt(index))->value; }
+ QValueList<T> &operator+=(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ QValueList<T> &operator<<(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
+private:
+ KWQValueListImpl impl;
+
+ static void deleteNode(KWQValueListNodeImpl *node) { delete (QValueListNode<T> *)node; }
+ static bool nodesEqual(KWQValueListNodeImpl *a, KWQValueListNodeImpl *b) { return ((QValueListNode<T> *)a)->value == ((QValueListNode<T> *)b)->value; }
+ static KWQValueListNodeImpl *copyNode(KWQValueListNodeImpl *node) { return new QValueListNode<T>(((QValueListNode<T> *)node)->value); }
}; // class QValueList =========================================================
+
+template<class T>
+inline ostream &operator<<(ostream &o, const QValueList<T>&p)
+{
+ o <<
+ "QValueList: [size: " <<
+ (Q_UINT32)p.count() <<
+ "; items: ";
+ QValueListConstIterator<T> it = p.begin();
+ while (it != p.end()) {
+ o << *it;
+ if (++it != p.end()) {
+ o << ", ";
+ }
+ }
+ o << "]";
+ return o;
+}
+
+
#endif // USING_BORROWED_QVALUELIST
#endif
diff --git a/WebCore/src/kdelibs/khtml/css/makeprop b/WebCore/src/kdelibs/khtml/css/makeprop
index 356a5b9..935ba11 100644
--- a/WebCore/src/kdelibs/khtml/css/makeprop
+++ b/WebCore/src/kdelibs/khtml/css/makeprop
@@ -42,7 +42,7 @@ echo -e '#endif\n' >> cssproperties.h
cat cssproperties.strip | awk '{ \
i=1; \
-print "static const char * propertyList[] = {"; \
+print "static const char * const propertyList[] = {"; \
print "\"\","; \
do { print "\"" $0 "\", "; i = i + 1 } while (getline); \
print " 0"; \
diff --git a/WebCore/src/kdelibs/khtml/css/makevalues b/WebCore/src/kdelibs/khtml/css/makevalues
index 601cc8c..009cc09 100644
--- a/WebCore/src/kdelibs/khtml/css/makevalues
+++ b/WebCore/src/kdelibs/khtml/css/makevalues
@@ -42,7 +42,7 @@ echo -e '#endif\n' >> cssvalues.h
cat cssvalues.strip | awk '{ \
i=1; \
-print "static const char * valueList[] = {"; \
+print "static const char * const valueList[] = {"; \
print "\"\","; \
do { print "\"" $0 "\", "; i = i + 1 } while (getline); \
print " 0"; \
diff --git a/WebCore/src/kdelibs/khtml/misc/makeattrs b/WebCore/src/kdelibs/khtml/misc/makeattrs
index 74ce3b7..764d161 100644
--- a/WebCore/src/kdelibs/khtml/misc/makeattrs
+++ b/WebCore/src/kdelibs/khtml/misc/makeattrs
@@ -64,7 +64,7 @@ system("/bin/sh", "-c", "gperf -c -a -L 'ANSI-C' -E -C -o -t -k '*' -NfindAttr -
system("/bin/sh", "-c", 'perl -pi -e "s/\"\"}/\"\", 0}/g" htmlattrs.c');
open(OUT, ">>htmlattrs.c");
-print OUT "\n\nstatic const char *attrList[$len] = {\n";
+print OUT "\n\nstatic const char * const attrList[$len] = {\n";
while(defined ($line = shift @a))
{
print OUT $line."\n";
diff --git a/WebCore/src/kdelibs/khtml/misc/maketags b/WebCore/src/kdelibs/khtml/misc/maketags
index 4f3c2ff..ca053f9 100644
--- a/WebCore/src/kdelibs/khtml/misc/maketags
+++ b/WebCore/src/kdelibs/khtml/misc/maketags
@@ -69,7 +69,7 @@ close header;
system("/bin/sh", "-c", "gperf -a -L 'ANSI-C' -D -E -C -l -o -t -k '*' -NfindTag -Hhash_tag -Wwordlist_tag htmltags.gperf > htmltags.c");
open(OUT, ">>htmltags.c");
-print OUT "\n\nstatic const char * tagList[] = {\n";
+print OUT "\n\nstatic const char * const tagList[] = {\n";
print OUT "\"\",\n";
while(defined ($line = shift @a))
{
diff --git a/WebCore/src/kwq/KWQRegExp.mm b/WebCore/src/kwq/KWQRegExp.mm
new file mode 100644
index 0000000..43eddb3
--- /dev/null
+++ b/WebCore/src/kwq/KWQRegExp.mm
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include <qregexp.h>
+
+#ifndef USING_BORROWED_QREGEXP
+
+#include <sys/types.h>
+#include <regex.h>
+
+
+class QRegExp::KWQRegExpPrivate
+{
+public:
+ KWQRegExpPrivate();
+ KWQRegExpPrivate(QString pattern);
+ ~KWQRegExpPrivate();
+
+ void compile();
+
+ QString pattern;
+ regex_t regex;
+ uint refCount;
+};
+
+QRegExp::KWQRegExpPrivate::KWQRegExpPrivate() : pattern(QString("")), refCount(0)
+{
+ compile();
+}
+
+QRegExp::KWQRegExpPrivate::KWQRegExpPrivate(QString p) : pattern(p), refCount(0)
+{
+ compile();
+}
+
+void QRegExp::KWQRegExpPrivate::compile()
+{
+ const char *cpattern = pattern.latin1();
+ regcomp(®ex, cpattern, REG_EXTENDED);
+}
+
+QRegExp::KWQRegExpPrivate::~KWQRegExpPrivate()
+{
+ regfree(®ex);
+}
+
+
+QRegExp::QRegExp() : d(new QRegExp::KWQRegExpPrivate())
+{
+}
+
+QRegExp::QRegExp(const QString &pattern, bool, bool) : d(new QRegExp::KWQRegExpPrivate(pattern))
+{
+}
+
+QRegExp::QRegExp(const char *cpattern) : d(new QRegExp::KWQRegExpPrivate(cpattern))
+{
+}
+
+
+QRegExp::QRegExp(const QRegExp &re) : d (re.d)
+{
+}
+
+QRegExp::~QRegExp()
+{
+}
+
+QRegExp &QRegExp::operator=(const QRegExp &re)
+{
+ QRegExp tmp(re);
+ KWQRefPtr<QRegExp::KWQRegExpPrivate> tmpD = tmp.d;
+
+ tmp.d = d;
+ d = tmpD;
+
+ return *this;
+}
+
+QString QRegExp::pattern() const
+{
+ return d->pattern;
+}
+
+int QRegExp::match(const QString &str, int startFrom = 0, int *matchLength = 0, bool treatStartAsStartOfInput = TRUE) const
+{
+ const char *cstring = str.latin1() + startFrom;
+
+ int flags = 0;
+
+ if (startFrom != 0 && !treatStartAsStartOfInput) {
+ flags |= REG_NOTBOL;
+ }
+
+ regmatch_t match[1];
+ int result = regexec(&d->regex, cstring, 1, match, flags);
+
+ if (result != 0) {
+ return -1;
+ } else {
+ if (matchLength != NULL) {
+ *matchLength = match[0].rm_eo - match[0].rm_so;
+ }
+ return startFrom + match[0].rm_so;
+ }
+}
+
+
+#endif
diff --git a/WebCore/src/kwq/KWQValueListImpl.h b/WebCore/src/kwq/KWQValueListImpl.h
new file mode 100644
index 0000000..810d0c5
--- /dev/null
+++ b/WebCore/src/kwq/KWQValueListImpl.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef KWQVALUELIST_H_
+#define KWQVALUELIST_H_
+
+#include <config.h>
+
+#ifndef USING_BORROWED_QVALUELIST
+
+#include <KWQRefPtr.h>
+#include <KWQDef.h>
+
+class KWQValueListNodeImpl;
+
+class KWQValueListIteratorImpl
+{
+public:
+ KWQValueListIteratorImpl();
+ KWQValueListIteratorImpl(const KWQValueListIteratorImpl &other);
+
+ ~KWQValueListIteratorImpl();
+
+ KWQValueListIteratorImpl &operator=(const KWQValueListIteratorImpl &other);
+
+ bool operator==(const KWQValueListIteratorImpl &other);
+ bool operator!=(const KWQValueListIteratorImpl &other);
+
+ KWQValueListNodeImpl *node();
+ const KWQValueListNodeImpl *node() const;
+
+ KWQValueListIteratorImpl& operator++();
+ KWQValueListIteratorImpl operator++(int);
+ KWQValueListIteratorImpl& operator--();
+
+private:
+ KWQValueListIteratorImpl(const KWQValueListNodeImpl *n);
+
+
+ KWQValueListNodeImpl *nodeImpl;
+
+ friend class KWQValueListImpl;
+};
+
+
+class KWQValueListImpl
+{
+public:
+ KWQValueListImpl(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyNode)(KWQValueListNodeImpl *));
+ KWQValueListImpl(const KWQValueListImpl &other);
+
+ ~KWQValueListImpl();
+
+ void clear();
+ uint count() const;
+ bool isEmpty() const;
+
+ void appendNode(KWQValueListNodeImpl *node);
+ void prependNode(KWQValueListNodeImpl *node);
+ void removeEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *));
+ uint containsEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *)) const;
+
+ KWQValueListIteratorImpl removeIterator(KWQValueListIteratorImpl &iterator);
+ KWQValueListIteratorImpl fromLast();
+
+ KWQValueListNodeImpl *firstNode();
+ KWQValueListNodeImpl *lastNode();
+
+ KWQValueListNodeImpl *firstNode() const;
+ KWQValueListNodeImpl *lastNode() const;
+
+ KWQValueListIteratorImpl begin();
+ KWQValueListIteratorImpl end();
+
+ KWQValueListIteratorImpl begin() const;
+ KWQValueListIteratorImpl end() const;
+
+ KWQValueListNodeImpl *nodeAt(uint index);
+ KWQValueListNodeImpl *nodeAt(uint index) const;
+
+ KWQValueListImpl operator=(const KWQValueListImpl &other);
+
+private:
+ void copyOnWrite();
+
+ class KWQValueListPrivate;
+
+ KWQRefPtr<KWQValueListPrivate> d;
+};
+
+class KWQValueListNodeImpl
+{
+protected:
+ KWQValueListNodeImpl();
+ ~KWQValueListNodeImpl();
+
+private:
+ KWQValueListNodeImpl *prev;
+ KWQValueListNodeImpl *next;
+
+ friend class KWQValueListImpl;
+ friend class KWQValueListIteratorImpl;
+ friend class KWQValueListImpl::KWQValueListPrivate;
+};
+
+#endif
+
+#endif
diff --git a/WebCore/src/kwq/KWQValueListImpl.mm b/WebCore/src/kwq/KWQValueListImpl.mm
new file mode 100644
index 0000000..e4ac4c2
--- /dev/null
+++ b/WebCore/src/kwq/KWQValueListImpl.mm
@@ -0,0 +1,447 @@
+/*
+ * Copyright (C) 2001 Apple Computer, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <KWQValueListImpl.h>
+
+#ifndef USING_BORROWED_QVALUELIST
+
+#include <stdlib.h>
+
+KWQValueListNodeImpl::KWQValueListNodeImpl() :
+ prev(NULL),
+ next(NULL)
+{
+}
+
+KWQValueListNodeImpl::~KWQValueListNodeImpl()
+{
+}
+
+KWQValueListIteratorImpl::KWQValueListIteratorImpl() :
+ nodeImpl(NULL)
+{
+}
+
+KWQValueListIteratorImpl::KWQValueListIteratorImpl(const KWQValueListIteratorImpl &other) :
+ nodeImpl(other.nodeImpl)
+{
+}
+
+KWQValueListIteratorImpl::~KWQValueListIteratorImpl()
+{
+}
+
+KWQValueListIteratorImpl &KWQValueListIteratorImpl::operator=(const KWQValueListIteratorImpl &other)
+{
+ nodeImpl = other.nodeImpl;
+ return *this;
+}
+
+bool KWQValueListIteratorImpl::operator==(const KWQValueListIteratorImpl &other)
+{
+ return nodeImpl == other.nodeImpl;
+}
+
+bool KWQValueListIteratorImpl::operator!=(const KWQValueListIteratorImpl &other)
+{
+ return nodeImpl != other.nodeImpl;
+}
+
+KWQValueListNodeImpl *KWQValueListIteratorImpl::node()
+{
+ return nodeImpl;
+}
+
+const KWQValueListNodeImpl *KWQValueListIteratorImpl::node() const
+{
+ return nodeImpl;
+}
+
+KWQValueListIteratorImpl& KWQValueListIteratorImpl::operator++()
+{
+ if (nodeImpl != NULL) {
+ nodeImpl = nodeImpl->next;
+ }
+ return *this;
+}
+
+KWQValueListIteratorImpl KWQValueListIteratorImpl::operator++(int)
+{
+ KWQValueListIteratorImpl tmp(*this);
+
+ if (nodeImpl != NULL) {
+ nodeImpl = nodeImpl->next;
+ }
+
+ return tmp;
+}
+
+KWQValueListIteratorImpl& KWQValueListIteratorImpl::operator--()
+{
+ if (nodeImpl != NULL) {
+ nodeImpl = nodeImpl->prev;
+ }
+ return *this;
+}
+
+KWQValueListIteratorImpl::KWQValueListIteratorImpl(const KWQValueListNodeImpl *n) :
+ nodeImpl((KWQValueListNodeImpl *)n)
+{
+}
+
+
+class KWQValueListImpl::KWQValueListPrivate
+{
+public:
+ KWQValueListPrivate(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyFunc)(KWQValueListNodeImpl *));
+ KWQValueListPrivate(const KWQValueListPrivate &other);
+
+ ~KWQValueListPrivate();
+
+ KWQValueListNodeImpl *copyList(KWQValueListNodeImpl *l) const;
+ void deleteList(KWQValueListNodeImpl *l);
+
+ KWQValueListNodeImpl *head;
+
+ void (*deleteNode)(KWQValueListNodeImpl *);
+ KWQValueListNodeImpl *(*copyNode)(KWQValueListNodeImpl *);
+ uint count;
+
+ uint refCount;
+};
+
+
+KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate(void (*deleteFunc)(KWQValueListNodeImpl *),
+ KWQValueListNodeImpl *(*copyFunc)(KWQValueListNodeImpl *)) :
+ head(NULL),
+ deleteNode(deleteFunc),
+ copyNode(copyFunc),
+ count(0),
+ refCount(0)
+{
+}
+
+KWQValueListImpl::KWQValueListPrivate::KWQValueListPrivate(const KWQValueListPrivate &other) :
+ head(other.copyList(other.head)),
+ deleteNode(other.deleteNode),
+ copyNode(other.copyNode),
+ count(other.count),
+ refCount(0)
+{
+}
+
+KWQValueListImpl::KWQValueListPrivate::~KWQValueListPrivate()
+{
+ deleteList(head);
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::KWQValueListPrivate::copyList(KWQValueListNodeImpl *l) const
+{
+ KWQValueListNodeImpl *prev = NULL;
+ KWQValueListNodeImpl *node = l;
+ KWQValueListNodeImpl *head = NULL;
+
+ while (node != NULL) {
+ KWQValueListNodeImpl *copy = copyNode(node);
+ if (prev == NULL) {
+ head = copy;
+ } else {
+ prev->next = copy;
+ }
+
+ copy->prev = prev;
+ copy->next = NULL;
+
+ prev = copy;
+ node = node->next;
+ }
+
+ return head;
+}
+
+void KWQValueListImpl::KWQValueListPrivate::deleteList(KWQValueListNodeImpl *l)
+{
+ KWQValueListNodeImpl *p = l;
+
+ while (p != NULL) {
+ KWQValueListNodeImpl *next = p->next;
+ deleteNode(p);
+ p = next;
+ }
+}
+
+
+
+KWQValueListImpl::KWQValueListImpl(void (*deleteFunc)(KWQValueListNodeImpl *), KWQValueListNodeImpl *(*copyFunc)(KWQValueListNodeImpl *)) :
+ d(new KWQValueListImpl::KWQValueListPrivate(deleteFunc, copyFunc))
+{
+}
+
+KWQValueListImpl::KWQValueListImpl(const KWQValueListImpl &other) :
+ d(other.d)
+{
+}
+
+KWQValueListImpl::~KWQValueListImpl()
+{
+}
+
+void KWQValueListImpl::clear()
+{
+ d->deleteList(d->head);
+ d->head = NULL;
+ d->count = 0;
+}
+
+uint KWQValueListImpl::count() const
+{
+ return d->count;
+}
+
+bool KWQValueListImpl::isEmpty() const
+{
+ return d->count == 0;
+}
+
+void KWQValueListImpl::appendNode(KWQValueListNodeImpl *node)
+{
+ copyOnWrite();
+
+ // FIXME: maintain tail pointer to make this fast
+
+ if (d->head == NULL) {
+ d->head = node;
+ } else {
+ KWQValueListNodeImpl *p = d->head;
+
+ while (p->next != NULL) {
+ p = p->next;
+ }
+
+ p->next = node;
+ node->prev = p;
+ node->next = NULL;
+ }
+
+ d->count++;
+}
+
+void KWQValueListImpl::prependNode(KWQValueListNodeImpl *node)
+{
+ copyOnWrite();
+
+ node->next = d->head;
+ node->prev = NULL;
+ d->head = node;
+
+ if (node->next != NULL) {
+ node->next->prev = node;
+ }
+
+ d->count++;
+}
+
+void KWQValueListImpl::removeEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *))
+{
+ copyOnWrite();
+
+ KWQValueListNodeImpl *p = d->head;
+
+ while (p != NULL) {
+ KWQValueListNodeImpl *next = p->next;
+ if (equalFunc(node, p)) {
+ if (p->next != NULL) {
+ p->next->prev = p->prev;
+ }
+
+ if (p->prev != NULL) {
+ p->prev->next = p->next;
+ } else {
+ d->head = p->next;
+ }
+
+ d->deleteNode(p);
+
+ d->count--;
+ }
+ p = next;
+ }
+}
+
+uint KWQValueListImpl::containsEqualNodes(KWQValueListNodeImpl *node, bool (*equalFunc)(KWQValueListNodeImpl *, KWQValueListNodeImpl *)) const
+{
+ KWQValueListNodeImpl *p = d->head;
+ unsigned contains = 0;
+
+ while (p != NULL) {
+ if (equalFunc(node, p)) {
+ ++contains;
+ }
+ p = p->next;
+ }
+
+ return contains;
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::removeIterator(KWQValueListIteratorImpl &iterator)
+{
+ copyOnWrite();
+
+ if (iterator.nodeImpl == NULL) {
+ return iterator;
+ }
+
+ KWQValueListNodeImpl *next = iterator.nodeImpl->next;
+
+ // detach node
+ if (iterator.nodeImpl->next != NULL) {
+ iterator.nodeImpl->next->prev = iterator.nodeImpl->prev;
+ }
+ if (iterator.nodeImpl->prev != NULL) {
+ iterator.nodeImpl->prev->next = iterator.nodeImpl->next;
+ } else {
+ d->head = iterator.nodeImpl->next;
+ }
+
+ d->deleteNode(iterator.nodeImpl);
+ d->count--;
+
+ return KWQValueListIteratorImpl(next);
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::fromLast()
+{
+ return KWQValueListIteratorImpl(lastNode());
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::firstNode()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->firstNode();
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::lastNode()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->lastNode();
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::firstNode() const
+{
+ return d->head;
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::lastNode() const
+{
+ // FIXME: use tail pointer
+
+ KWQValueListNodeImpl *p = d->head;
+
+ if (p == NULL) {
+ return NULL;
+ }
+
+ while (p->next != NULL) {
+ p = p->next;
+ }
+
+ return p;
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::begin()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->begin();
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::end()
+{
+ copyOnWrite();
+ return ((const KWQValueListImpl *)this)->end();
+}
+
+
+KWQValueListIteratorImpl KWQValueListImpl::begin() const
+{
+ return KWQValueListIteratorImpl(firstNode());
+}
+
+KWQValueListIteratorImpl KWQValueListImpl::end() const
+{
+ return KWQValueListIteratorImpl(NULL);
+}
+
+
+KWQValueListNodeImpl *KWQValueListImpl::nodeAt(uint index)
+{
+ copyOnWrite();
+
+ if (d->count <= index) {
+ return NULL;
+ }
+
+ KWQValueListNodeImpl *p = d->head;
+
+ for (uint i = 0; i < index; i++) {
+ p = p->next;
+ }
+
+ return p;
+}
+
+KWQValueListNodeImpl *KWQValueListImpl::nodeAt(uint index) const
+{
+ if (d->count <= index) {
+ return NULL;
+ }
+
+ KWQValueListNodeImpl *p = d->head;
+
+ for (uint i = 0; i < index; i++) {
+ p = p->next;
+ }
+
+ return p;
+}
+
+KWQValueListImpl KWQValueListImpl::operator=(const KWQValueListImpl &other)
+{
+ KWQValueListImpl tmp(other);
+ KWQRefPtr<KWQValueListImpl::KWQValueListPrivate> tmpD = tmp.d;
+
+ tmp.d = d;
+ d = tmpD;
+
+ return *this;
+}
+
+void KWQValueListImpl::copyOnWrite()
+{
+ if (d->refCount > 1) {
+ d = KWQRefPtr<KWQValueListImpl::KWQValueListPrivate>(new KWQValueListImpl::KWQValueListPrivate(*d));
+ }
+}
+
+#endif
diff --git a/WebCore/src/kwq/Makefile.am b/WebCore/src/kwq/Makefile.am
index 8d73785..102996a 100644
--- a/WebCore/src/kwq/Makefile.am
+++ b/WebCore/src/kwq/Makefile.am
@@ -104,6 +104,7 @@ libkwq_o_SOURCES = \
KWQPointArray.mm \
KWQPushButton.mm \
KWQRadioButton.mm \
+ KWQRegExp.mm \
KWQRegion.mm \
KWQScrollView.mm \
KWQString.mm \
@@ -115,6 +116,7 @@ libkwq_o_SOURCES = \
KWQTextStorage.mm \
KWQTimer.mm \
KWQToolTip.mm \
+ KWQValueListImpl.mm \
KWQVariant.mm \
KWQVectorImpl.mm \
KWQView.mm \
diff --git a/WebCore/src/kwq/kio/netaccess.h b/WebCore/src/kwq/kio/netaccess.h
index 425a65d..86a6e69 100644
--- a/WebCore/src/kwq/kio/netaccess.h
+++ b/WebCore/src/kwq/kio/netaccess.h
@@ -69,20 +69,6 @@ public:
// protected -------------------------------------------------------------------
// private ---------------------------------------------------------------------
-private:
-
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
- UDSAtom(const UDSAtom &);
-#endif
-
-// add assignment operator
-// this private declaration prevents assignment
-#ifdef _KWQ_PEDANTIC_
- UDSAtom &operator=(const UDSAtom &);
-#endif
-
}; // class UDSAtom ============================================================
diff --git a/WebCore/src/kwq/make-charset-table.pl b/WebCore/src/kwq/make-charset-table.pl
index ef05900..ae23aee 100755
--- a/WebCore/src/kwq/make-charset-table.pl
+++ b/WebCore/src/kwq/make-charset-table.pl
@@ -17,7 +17,7 @@ my $already_wrote_one = 0;
sub emit_prefix
{
- print TABLE "static CharsetEntry table[] = {\n";
+ print TABLE "static const CharsetEntry table[] = {\n";
}
sub emit_suffix
diff --git a/WebCore/src/kwq/qt/qregexp.h b/WebCore/src/kwq/qt/qregexp.h
index 89633aa..2920947 100644
--- a/WebCore/src/kwq/qt/qregexp.h
+++ b/WebCore/src/kwq/qt/qregexp.h
@@ -36,34 +36,31 @@
#include <_qregexp.h>
#else
-#include "qstring.h"
+#include <qstring.h>
+
+#include <KWQRefPtr.h>
// class QRegExp ===============================================================
class QRegExp {
public:
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
QRegExp();
- QRegExp(const QString &);
+ QRegExp(const QString &, bool, bool);
+ QRegExp(const char *);
QRegExp(const QRegExp &);
~QRegExp();
- // member functions --------------------------------------------------------
-
- // operators ---------------------------------------------------------------
-
QRegExp &operator=(const QRegExp &);
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ QString pattern() const;
+ int match (const QString &, int startFrom = 0, int *matchLength = 0,
+ bool treatStartAsStartOfInput = TRUE) const;
+private:
+ class KWQRegExpPrivate;
+
+ KWQRefPtr<KWQRegExpPrivate> d;
}; // class QRegExp ============================================================
#endif // USING_BORROWED_QREGEXP
diff --git a/WebCore/src/kwq/qt/qvaluelist.h b/WebCore/src/kwq/qt/qvaluelist.h
index 098c10d..8aa2193 100644
--- a/WebCore/src/kwq/qt/qvaluelist.h
+++ b/WebCore/src/kwq/qt/qvaluelist.h
@@ -37,74 +37,74 @@
#else
#include <KWQDef.h>
+#include <KWQValueListImpl.h>
-// class QValueListIterator ====================================================
+#include <iostream>
+
+template <class T> class QValueList;
+template <class T> class QValueListConstIterator;
+
+template<class T> class QValueListNode : private KWQValueListNodeImpl {
+public:
+ QValueListNode(const T &val) : KWQValueListNodeImpl(), value(val) {}
+ ~QValueListNode() {}
+
+ T value;
+ friend class QValueList<T>;
+};
+
+// class QValueListIterator ====================================================
template<class T> class QValueListIterator {
public:
-
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QValueListIterator();
- QValueListIterator(const QValueListIterator<T>&);
+ QValueListIterator() : impl() {}
+ QValueListIterator(const QValueListIterator<T> &other) : impl(other.impl) {}
- ~QValueListIterator();
-
- // member functions --------------------------------------------------------
+ ~QValueListIterator() {}
- // operators ---------------------------------------------------------------
+ QValueListIterator &operator=(const QValueListIterator &other) { impl = other.impl; return *this; }
+
+ bool operator==(const QValueListIterator<T> &other) { return impl == other.impl; }
+ bool operator!=(const QValueListIterator<T> &other) { return impl != other.impl; }
+ const T& operator*() const { return ((const QValueListNode<T> *)impl.node())->value; }
+ QValueListIterator operator++() { ++impl; return *this; }
+
+ T& operator*() { return ((QValueListNode<T> *)impl.node())->value; }
+ QValueListIterator<T>& operator--() { --impl; return *this; }
+ QValueListIterator operator++(int) { return QValueListIterator<T>(impl++); }
- QValueListIterator &operator=(const QValueListIterator &);
- bool operator==(const QValueListIterator<T>&);
- bool operator!=(const QValueListIterator<T>&);
- T& operator*();
- const T& operator*() const;
- QValueListIterator<T>& operator++();
- QValueListIterator<T>& operator++(int);
- QValueListIterator<T>& operator--();
+private:
+ QValueListIterator(const KWQValueListIteratorImpl &pImp) : impl(pImp) {}
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ KWQValueListIteratorImpl impl;
+ friend class QValueList<T>;
+ friend class QValueListConstIterator<T>;
}; // class QValueListIterator =================================================
// class QValueListConstIterator ===============================================
-
template<class T> class QValueListConstIterator {
public:
+ QValueListConstIterator() : impl() {}
+ QValueListConstIterator(const QValueListConstIterator<T> &other) : impl(other.impl) {}
+ QValueListConstIterator(const QValueListIterator<T> &other) : impl(other.impl) {}
+
+ ~QValueListConstIterator() {}
- // typedefs ----------------------------------------------------------------
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
- // constructors, copy constructors, and destructors ------------------------
-
- QValueListConstIterator();
- QValueListConstIterator(const QValueListIterator<T>&);
-
- ~QValueListConstIterator();
-
- // member functions --------------------------------------------------------
-
- // operators ---------------------------------------------------------------
+ QValueListConstIterator &operator=(const QValueListConstIterator &other) { impl = other.impl; return *this; }
+ bool operator==(const QValueListConstIterator<T> &other) { return impl == other.impl; }
+ bool operator!=(const QValueListConstIterator<T> &other) { return impl != other.impl; }
+ const T& operator*() const { return ((const QValueListNode<T> *)impl.node())->value; }
+ QValueListConstIterator operator++() { ++impl; return *this; }
+ QValueListConstIterator operator++(int) { return QValueListConstIterator<T>(impl++); }
- QValueListConstIterator &operator=(const QValueListConstIterator &);
- bool operator==(const QValueListConstIterator<T>&);
- bool operator!=(const QValueListConstIterator<T>&);
- T& operator*();
- QValueListConstIterator operator++();
- QValueListConstIterator operator++(int);
+private:
+ QValueListConstIterator(const KWQValueListIteratorImpl &pImp) : impl(pImp) {}
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ KWQValueListIteratorImpl impl;
+ friend class QValueList<T>;
}; // class QValueListConstIterator ============================================
@@ -113,57 +113,76 @@ public:
template <class T> class QValueList {
public:
- // typedefs ----------------------------------------------------------------
-
typedef QValueListIterator<T> Iterator;
typedef QValueListConstIterator<T> ConstIterator;
- // enums -------------------------------------------------------------------
- // constants ---------------------------------------------------------------
- // static member functions -------------------------------------------------
-
// constructors, copy constructors, and destructors ------------------------
- QValueList();
- QValueList(const QValueList<T>&);
+ QValueList() : impl(deleteNode, copyNode) {}
+ QValueList(const QValueList<T>&other) : impl(other.impl) {}
- ~QValueList();
+ ~QValueList() {}
// member functions --------------------------------------------------------
- void clear();
- uint count() const;
- bool isEmpty() const;
-
- void append(const T&);
- void remove(const T&);
+ void clear() { impl.clear(); }
+ uint count() const { return impl.count(); }
+ bool isEmpty() const { return impl.isEmpty(); }
- uint contains(const T&);
+ void append(const T &val) { impl.appendNode(new QValueListNode<T>(val)); }
+ void prepend(const T &val) { impl.prependNode(new QValueListNode<T>(val)); }
+ void remove(const T &val) { QValueListNode<T> node(val); impl.removeEqualNodes(&node, nodesEqual); }
+ uint contains(const T &val) { QValueListNode<T> node(val); return impl.containsEqualNodes(&node, nodesEqual); }
- Iterator remove(Iterator);
- Iterator fromLast();
+ Iterator remove(Iterator iter) { return QValueListIterator<T>(impl.removeIterator(iter.impl)); }
+ Iterator fromLast() { return QValueListIterator<T>(impl.fromLast()); }
- const T& first() const;
- const T& last() const;
+ const T& first() const { return ((QValueListNode<T> *)impl.firstNode())->value; }
+ const T& last() const { return ((QValueListNode<T> *)impl.lastNode())->value; }
- Iterator begin();
- Iterator end();
+ Iterator begin() { return QValueListIterator<T>(impl.begin()); }
+ Iterator end() { return QValueListIterator<T>(impl.end()); }
- ConstIterator begin() const;
- ConstIterator end() const;
+ ConstIterator begin() const { return QValueListConstIterator<T>(impl.begin()); }
+ ConstIterator end() const { return QValueListConstIterator<T>(impl.end()); }
// operators ---------------------------------------------------------------
- QValueList<T>& operator=(const QValueList<T>&);
- T& operator[] (uint);
- const T& operator[] (uint) const;
- QValueList<T> &operator+=(const T &);
+ QValueList<T>& operator=(const QValueList<T>&other) { impl = other.impl; return *this; }
+ T& operator[] (uint index) { return ((QValueListNode<T> *)impl.nodeAt(index))->value; }
+ const T& operator[] (uint index) const { return ((const QValueListNode<T> *)impl.nodeAt(index))->value; }
+ QValueList<T> &operator+=(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+ QValueList<T> &operator<<(const T &value) { impl.appendNode(new QValueListNode<T>(value)); return *this; }
+private:
+ KWQValueListImpl impl;
+
+ static void deleteNode(KWQValueListNodeImpl *node) { delete (QValueListNode<T> *)node; }
+ static bool nodesEqual(KWQValueListNodeImpl *a, KWQValueListNodeImpl *b) { return ((QValueListNode<T> *)a)->value == ((QValueListNode<T> *)b)->value; }
+ static KWQValueListNodeImpl *copyNode(KWQValueListNodeImpl *node) { return new QValueListNode<T>(((QValueListNode<T> *)node)->value); }
}; // class QValueList =========================================================
+
+template<class T>
+inline ostream &operator<<(ostream &o, const QValueList<T>&p)
+{
+ o <<
+ "QValueList: [size: " <<
+ (Q_UINT32)p.count() <<
+ "; items: ";
+ QValueListConstIterator<T> it = p.begin();
+ while (it != p.end()) {
+ o << *it;
+ if (++it != p.end()) {
+ o << ", ";
+ }
+ }
+ o << "]";
+ return o;
+}
+
+
#endif // USING_BORROWED_QVALUELIST
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list