Commit 3964a7b6 authored by mjs's avatar mjs

Another step towards the List conversion: stop inheriting from Value.

        * kjs/types.cpp:
        (ListIterator::ListIterator):
        (List::List):
        (List::operator=):
        (List::~List):
        (List::mark):
        (List::append):
        (List::prepend):
        (List::appendList):
        (List::prependList):
        (List::removeFirst):
        (List::removeLast):
        (List::remove):
        (List::clear):
        (List::copy):
        (List::begin):
        (List::end):
        (List::isEmpty):
        (List::size):
        (List::at):
        (List::operator[]):
        * kjs/types.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2744 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 07c921f4
2002-11-18 Maciej Stachowiak <mjs@apple.com>
Another step towards the List conversion: stop inheriting from Value.
* kjs/types.cpp:
(ListIterator::ListIterator):
(List::List):
(List::operator=):
(List::~List):
(List::mark):
(List::append):
(List::prepend):
(List::appendList):
(List::prependList):
(List::removeFirst):
(List::removeLast):
(List::remove):
(List::clear):
(List::copy):
(List::begin):
(List::end):
(List::isEmpty):
(List::size):
(List::at):
(List::operator[]):
* kjs/types.h:
2002-11-18 Maciej Stachowiak <mjs@apple.com>
Partway to removing Value from List. Created a marking List
......
2002-11-18 Maciej Stachowiak <mjs@apple.com>
Another step towards the List conversion: stop inheriting from Value.
* kjs/types.cpp:
(ListIterator::ListIterator):
(List::List):
(List::operator=):
(List::~List):
(List::mark):
(List::append):
(List::prepend):
(List::appendList):
(List::prependList):
(List::removeFirst):
(List::removeLast):
(List::remove):
(List::clear):
(List::copy):
(List::begin):
(List::end):
(List::isEmpty):
(List::size):
(List::at):
(List::operator[]):
* kjs/types.h:
2002-11-18 Maciej Stachowiak <mjs@apple.com>
Partway to removing Value from List. Created a marking List
......
2002-11-18 Maciej Stachowiak <mjs@apple.com>
Another step towards the List conversion: stop inheriting from Value.
* kjs/types.cpp:
(ListIterator::ListIterator):
(List::List):
(List::operator=):
(List::~List):
(List::mark):
(List::append):
(List::prepend):
(List::appendList):
(List::prependList):
(List::removeFirst):
(List::removeLast):
(List::remove):
(List::clear):
(List::copy):
(List::begin):
(List::end):
(List::isEmpty):
(List::size):
(List::at):
(List::operator[]):
* kjs/types.h:
2002-11-18 Maciej Stachowiak <mjs@apple.com>
Partway to removing Value from List. Created a marking List
......
......@@ -114,7 +114,7 @@ ListIterator::ListIterator(ListNode *n) : node(n)
}
ListIterator::ListIterator(const List &l)
: node(static_cast<ListImp*>(l.imp())->hook->next)
: node(l.imp->hook->next)
{
}
......@@ -169,130 +169,136 @@ bool ListIterator::operator!=(const ListIterator &it) const
// ------------------------------ List -----------------------------------------
List::List(bool needsMarking)
: Value(needsMarking ? ListImp::empty() : new ListImp()),
m_needsMarking(needsMarking)
: m_needsMarking(needsMarking)
{
if (m_needsMarking) {
imp()->deref();
imp = m_needsMarking ? ListImp::empty() : new ListImp();
if (!m_needsMarking) {
imp->ref();
}
}
List::List(const List& l)
: Value(l),
m_needsMarking(false)
: m_needsMarking(false)
{
imp = l.imp;
if (!m_needsMarking) {
imp->ref();
}
}
List::List(ListImp *imp)
: Value(imp),
m_needsMarking(false)
List::List(ListImp *p_imp)
: m_needsMarking(false)
{
imp = p_imp;
if (!m_needsMarking) {
imp->ref();
}
}
List& List::operator=(const List& l)
{
if (m_needsMarking) {
imp()->ref();
if (!m_needsMarking) {
l.imp->ref();
imp->deref();
}
Value::operator=(l);
if (m_needsMarking) {
imp()->deref();
}
imp = l.imp;
return *this;
}
List::~List()
{
if (m_needsMarking) {
imp()->ref();
if (!m_needsMarking) {
imp->deref();
}
}
void List::mark()
{
if (!imp()->marked()) {
imp()->mark();
if (!imp->marked()) {
imp->mark();
}
}
void List::append(const Value& val)
{
static_cast<ListImp*>(rep)->append(val);
imp->append(val);
}
void List::prepend(const Value& val)
{
static_cast<ListImp*>(rep)->prepend(val);
imp->prepend(val);
}
void List::appendList(const List& lst)
{
static_cast<ListImp*>(rep)->appendList(lst);
imp->appendList(lst);
}
void List::prependList(const List& lst)
{
static_cast<ListImp*>(rep)->prependList(lst);
imp->prependList(lst);
}
void List::removeFirst()
{
static_cast<ListImp*>(rep)->removeFirst();
imp->removeFirst();
}
void List::removeLast()
{
static_cast<ListImp*>(rep)->removeLast();
imp->removeLast();
}
void List::remove(const Value &val)
{
static_cast<ListImp*>(rep)->remove(val);
imp->remove(val);
}
void List::clear()
{
static_cast<ListImp*>(rep)->clear();
imp->clear();
}
List List::copy() const
{
return static_cast<ListImp*>(rep)->copy();
return imp->copy();
}
ListIterator List::begin() const
{
return static_cast<ListImp*>(rep)->begin();
return imp->begin();
}
ListIterator List::end() const
{
return static_cast<ListImp*>(rep)->end();
return imp->end();
}
bool List::isEmpty() const
{
return static_cast<ListImp*>(rep)->isEmpty();
return imp->isEmpty();
}
int List::size() const
{
return static_cast<ListImp*>(rep)->size();
return imp->size();
}
Value List::at(int i) const
{
return static_cast<ListImp*>(rep)->at(i);
return imp->at(i);
}
Value List::operator[](int i) const
{
return static_cast<ListImp*>(rep)->at(i);
return imp->at(i);
}
const List List::empty()
......
......@@ -104,7 +104,7 @@ namespace KJS {
* The list is explicitly shared. Note that while copy() returns a
* copy of the list the referenced objects are still shared.
*/
class List : private Value {
class List {
friend class ListIterator;
public:
List(bool needsMarking = false);
......@@ -197,8 +197,10 @@ namespace KJS {
static void markEmptyList();
private:
List(ListImp *);
ListImp *imp() const { return (ListImp *)Value::imp(); }
ListImp *imp;
bool m_needsMarking;
friend class ListNode;
};
}; // namespace
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment