Mercurial > hg > octave-terminal
changeset 4219:23d06c9e1edd
[project @ 2002-12-06 21:29:17 by jwe]
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2002-12-06 John W. Eaton <jwe@bevo.che.wisc.edu> + + * oct-alloc.h (DECLARE_OCTAVE_ALLOCATOR): Also declare and define + a placement operator new. + 2002-12-03 John W. Eaton <jwe@bevo.che.wisc.edu> * Matrix.h: Include mx-ops.h too.
--- a/liboctave/oct-alloc.h +++ b/liboctave/oct-alloc.h @@ -61,6 +61,8 @@ #define DECLARE_OCTAVE_ALLOCATOR \ public: \ + void *operator new (size_t size, void *p) \ + { return ::operator new (size, p); } \ void *operator new (size_t size) { return allocator.alloc (size); } \ void operator delete (void *p, size_t size) { allocator.free (p, size); } \ private: \
deleted file mode 100644 --- a/src/BaseSLList.cc +++ /dev/null @@ -1,257 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <climits> - -#include "BaseSLList.h" - -#include "error.h" - -void BaseSLList::error(const char* msg) const -{ - ::error ("SLList: %s", msg); -} - -int BaseSLList::length() const -{ - int l = 0; - BaseSLNode* t = last; - if (t != 0) do { ++l; t = t->tl; } while (t != last); - return l; -} - -void BaseSLList::clear() -{ - if (last == 0) - return; - - BaseSLNode* p = last->tl; - last->tl = 0; - last = 0; - - while (p != 0) - { - BaseSLNode* nxt = p->tl; - delete_node(p); - p = nxt; - } -} - - -// Note: This is an internal method. It does *not* free old contents! - -void BaseSLList::copy(const BaseSLList& a) -{ - if (a.last == 0) - last = 0; - else - { - BaseSLNode* p = a.last->tl; - BaseSLNode* h = copy_node(p->item()); - last = h; - for (;;) - { - if (p == a.last) - { - last->tl = h; - return; - } - p = p->tl; - BaseSLNode* n = copy_node(p->item()); - last->tl = n; - last = n; - } - } -} - -BaseSLList& BaseSLList::operator = (const BaseSLList& a) -{ - if (last != a.last) - { - clear(); - copy(a); - } - return *this; -} - -Pix BaseSLList::prepend(const void *datum) -{ - return prepend(copy_node(datum)); -} - - -Pix BaseSLList::prepend(BaseSLNode* t) -{ - if (t == 0) return 0; - if (last == 0) - t->tl = last = t; - else - { - t->tl = last->tl; - last->tl = t; - } - return Pix(t); -} - - -Pix BaseSLList::append(const void *datum) -{ - return append(copy_node(datum)); -} - -Pix BaseSLList::append(BaseSLNode* t) -{ - if (t == 0) return 0; - if (last == 0) - t->tl = last = t; - else - { - t->tl = last->tl; - last->tl = t; - last = t; - } - return Pix(t); -} - -void BaseSLList::join(BaseSLList& b) -{ - BaseSLNode* t = b.last; - b.last = 0; - if (last == 0) - last = t; - else if (t != 0) - { - BaseSLNode* f = last->tl; - last->tl = t->tl; - t->tl = f; - last = t; - } -} - -Pix BaseSLList::ins_after(Pix p, const void *datum) -{ - BaseSLNode* u = (BaseSLNode*)p; - BaseSLNode* t = copy_node(datum); - if (last == 0) - t->tl = last = t; - else if (u == 0) // ins_after 0 means prepend - { - t->tl = last->tl; - last->tl = t; - } - else - { - t->tl = u->tl; - u->tl = t; - if (u == last) - last = t; - } - return Pix(t); -} - -void BaseSLList::del_after(Pix p) -{ - BaseSLNode* u = (BaseSLNode*)p; - if (last == 0 || u == last) error("cannot del_after last"); - if (u == 0) u = last; // del_after 0 means delete first - BaseSLNode* t = u->tl; - if (u == t) - last = 0; - else - { - u->tl = t->tl; - if (last == t) - last = u; - } - delete_node(t); -} - -int BaseSLList::owns(Pix p) const -{ - BaseSLNode* t = last; - if (t != 0 && p != 0) - { - do - { - if (Pix(t) == p) return 1; - t = t->tl; - } while (t != last); - } - return 0; -} - -int BaseSLList::remove_front(void *dst, int signal_error) -{ - if (last) - { - BaseSLNode* t = last->tl; - copy_item(dst, t->item()); - if (t == last) - last = 0; - else - last->tl = t->tl; - delete_node(t); - return 1; - } - if (signal_error) - error("remove_front of empty list"); - return 0; -} - -void BaseSLList::del_front() -{ - if (last == 0) error("del_front of empty list"); - BaseSLNode* t = last->tl; - if (t == last) - last = 0; - else - last->tl = t->tl; - delete_node(t); -} - -int BaseSLList::OK() const -{ - int v = 1; - if (last != 0) - { - BaseSLNode* t = last; - long count = LONG_MAX; // Lots of chances to find last! - do - { - count--; - t = t->tl; - } while (count > 0 && t != last); - v &= count > 0; - } - if (!v) error("invariant failure"); - return v; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/BaseSLList.h +++ /dev/null @@ -1,75 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef _BaseSLList_h -#define _BaseSLList_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#undef OK - -#include <Pix.h> - -struct BaseSLNode -{ - union { - struct BaseSLNode *tl; - double dummy; /* To force correct alignment */ - }; - void *item() {return (void*)(this+1);} // Return ((SLNode<T>*)this)->hd -}; - -class -BaseSLList -{ - protected: - BaseSLNode *last; - virtual void delete_node(BaseSLNode*node) = 0; - virtual BaseSLNode* copy_node(const void* datum) = 0; - virtual void copy_item(void *dst, void *src) = 0; - virtual ~BaseSLList() { } - BaseSLList() { last = 0; } - void copy(const BaseSLList&); - BaseSLList& operator = (const BaseSLList& a); - Pix ins_after(Pix p, const void *datum); - Pix prepend(const void *datum); - Pix append(const void *datum); - int remove_front(void *dst, int signal_error = 0); - void join(BaseSLList&); - public: - int length() const; - int empty() const { return last == 0; } - void clear(); - Pix prepend(BaseSLNode*); - Pix append(BaseSLNode*); - int OK() const; - void error(const char* msg) const; - void del_after(Pix p); - int owns(Pix p) const; - void del_front(); -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
--- a/src/Cell.h +++ b/src/Cell.h @@ -46,7 +46,7 @@ Cell (const octave_value& val) : Array2<octave_value> (1, 1, val) { } - Cell (int n, int m, const octave_value& val = octave_value ()) + Cell (int n, int m, const octave_value& val = resize_fill_value ()) : Array2<octave_value> (n, m, val) { } Cell (const Array2<octave_value>& c) @@ -69,7 +69,7 @@ // XXX FIXME XXX bool is_true (void) const { return false; } - static octave_value resize_fill_value (void) { return octave_value (); } + static octave_value resize_fill_value (void) { return Matrix (); } }; #endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,73 @@ +2002-12-06 John W. Eaton <jwe@bevo.che.wisc.edu> + + * pt-mat.cc (class tm_row_const::tm_row_const_rep): Derive from + octave_base_list instead of SLList. Fix tm_row_const member + functions as needed, change all uses. + (class tm_const): Derive from octave_base_list, not SLList. Fix + member functions as needed, change all uses. + * pt-mat.h (class tree_matrix): Derive from octave_base_list + instead of including SLList object as data member. Fix member + functions as needed, change all uses. + + * pt-idx.h (tree_index_expression::args, + tree_index_expression::arg_nm, tree_index_expression::dyn_field): + Now std::list, not SLList. Fix member functions as needed, change + all uses. + + * oct-map.h (Octave_map::map): Now std::map instead of CHMap. + Fix member functions as needed, change all uses. + + * oct-lvalue.h (octave_lvalue::idx): Now std::list instead of + SLList object. Fix member functions as needed, change all uses. + + * dynamic-ld.cc (octave_shlib_list::lib_list): Now std::list + instead of DLList object. Fix member functions as needed, change + all uses. + + * ov.h (octave_value::subsref, octave_value::subsasgn): + Index arg is not std::list, not SLList. Change all derived + classes, all uses. + + * pt-stmt.h (tree_statement_list): Derive from base_octave_list + object instead of including SLList object as data member. Fix + member functions as needed, change all uses. + * pt-select.h (tree_switch_case_list): Likewise. + (tree_if_command_list): Likewise. + * pt-misc.h (tree_parameter_list, tree_return_list, + tree_va_return_list): Likewise. + * pt-plot.h (subplot_list): Likewise. + * pt-mat.h (tree_matrix): Likewise. + * pt-decl.h (tree_decl_init_list): Likewise. + * pt-arg-list.h (tree_argument_list): Likewise. + * comment-list.h (octave_comment_list): Likewise. + + * BaseSLList.cc, DLList.cc, Map.cc, SLList.cc, SLStack.cc, + Stack.cc: Delete. + * Makefile.in (DIST_SRC): Delete them from the list. + + * BaseSLList.h, DLList.h, Map.h, Pix.h, SLList.h, SLStack.h, + Stack.h: Delete + * Makefile.in (INCLUDES): Delete them from the list. + + * Map-oct-obj.cc, SLList-expr.cc, SLList-misc.cc, SLList-plot.cc, + SLList-tc.cc, SLList-tm.cc: Delete. + * Makefile.in (TI_XSRC): Delete them from the list. + + * ov-base-mat.cc (octave_base_matrix::assign): Pass + MT::resize_fill_value () as third arg for ::assign. + + * Cell.h (Cell::resize_fill_value): Use empty Matrix object, not + undefined octave_value object. + (Cell::Cell (int, int, const octave_value&)): Use + resize_fill_value () as default value, not undefined octave_value + object. + +2002-12-05 John W. Eaton <jwe@bevo.che.wisc.edu> + + * Makefile.in (DEFUN_PATTERN): Make it work for DEFCMD too. + + * base-list.h: New file. + 2002-12-04 John W. Eaton <jwe@bevo.che.wisc.edu> * toplev.cc (octave_interpreter_ready): New global variable.
deleted file mode 100644 --- a/src/DLList.cc +++ /dev/null @@ -1,331 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <climits> - -#include "DLList.h" - -#include "error.h" - -void BaseDLList::error(const char* msg) const -{ - ::error ("DLList: %s", msg); -} - -int BaseDLList::length() const -{ - int l = 0; - BaseDLNode* t = h; - if (t != 0) do { ++l; t = t->fd; } while (t != h); - return l; -} - -// Note: This is an internal method. It does *not* free old contents! - -void BaseDLList::copy(const BaseDLList& a) -{ - if (a.h == 0) - h = 0; - else - { - BaseDLNode* p = a.h; - BaseDLNode* t = copy_node(p->item()); - h = t; - p = p->fd; - while (p != a.h) - { - BaseDLNode* n = copy_node(p->item()); - t->fd = n; - n->bk = t; - t = n; - p = p->fd; - } - t->fd = h; - h->bk = t; - return; - } -} - -void BaseDLList::clear() -{ - if (h == 0) - return; - - BaseDLNode* p = h->fd; - h->fd = 0; - h = 0; - - while (p != 0) - { - BaseDLNode* nxt = p->fd; - delete_node(p); - p = nxt; - } -} - -BaseDLList& BaseDLList::operator = (const BaseDLList& a) -{ - if (h != a.h) - { - clear(); - copy(a); - } - return *this; -} - - -Pix BaseDLList::prepend(const void *datum) -{ - BaseDLNode* t = copy_node(datum); - if (h == 0) - t->fd = t->bk = h = t; - else - { - t->fd = h; - t->bk = h->bk; - h->bk->fd = t; - h->bk = t; - h = t; - } - return Pix(t); -} - -Pix BaseDLList::append(const void *datum) -{ - BaseDLNode* t = copy_node(datum); - if (h == 0) - t->fd = t->bk = h = t; - else - { - t->bk = h->bk; - t->bk->fd = t; - t->fd = h; - h->bk = t; - } - return Pix(t); -} - -Pix BaseDLList::ins_after(Pix p, const void *datum) -{ - if (p == 0) return prepend(datum); - BaseDLNode* u = (BaseDLNode*) p; - BaseDLNode* t = copy_node(datum); - t->bk = u; - t->fd = u->fd; - u->fd->bk = t; - u->fd = t; - return Pix(t); -} - -Pix BaseDLList::ins_before(Pix p, const void *datum) -{ - if (p == 0) error("null Pix"); - BaseDLNode* u = (BaseDLNode*) p; - BaseDLNode* t = copy_node(datum); - t->bk = u->bk; - t->fd = u; - u->bk->fd = t; - u->bk = t; - if (u == h) h = t; - return Pix(t); -} - -void BaseDLList::join(BaseDLList& b) -{ - BaseDLNode* t = b.h; - b.h = 0; - if (h == 0) - h = t; - else if (t != 0) - { - BaseDLNode* l = t->bk; - h->bk->fd = t; - t->bk = h->bk; - h->bk = l; - l->fd = h; - } -} - -int BaseDLList::owns(Pix p) const -{ - BaseDLNode* t = h; - if (t != 0 && p != 0) - { - do - { - if (Pix(t) == p) return 1; - t = t->fd; - } while (t != h); - } - return 0; -} - -void BaseDLList::del(Pix& p, int dir) -{ - if (p == 0) error("null Pix"); - BaseDLNode* t = (BaseDLNode*) p; - if (t->fd == t) - { - h = 0; - p = 0; - } - else - { - if (dir < 0) - { - if (t == h) - p = 0; - else - p = Pix(t->bk); - } - else - { - if (t == h->bk) - p = 0; - else - p = Pix(t->fd); - } - t->bk->fd = t->fd; - t->fd->bk = t->bk; - if (t == h) h = t->fd; - } - delete_node(t); -} - -void BaseDLList::del_after(Pix& p) -{ - if (p == 0) - { - del_front(); - return; - } - - BaseDLNode* b = (BaseDLNode*) p; - BaseDLNode* t = b->fd; - - if (b == t) - { - h = 0; - p = 0; - } - else - { - t->bk->fd = t->fd; - t->fd->bk = t->bk; - if (t == h) h = t->fd; - } - delete_node(t); -} - -void BaseDLList::remove_front(void *dst) -{ - if (h == 0) - error("remove_front of empty list"); - else { - BaseDLNode* t = h; - copy_item(dst, t->item()); - if (h->fd == h) - h = 0; - else - { - h->fd->bk = h->bk; - h->bk->fd = h->fd; - h = h->fd; - } - delete_node(t); - } -} - -void BaseDLList::del_front() -{ - if (h == 0) - error("del_front of empty list"); - BaseDLNode* t = h; - if (h->fd == h) - h = 0; - else - { - h->fd->bk = h->bk; - h->bk->fd = h->fd; - h = h->fd; - } - delete_node(t); -} - -void BaseDLList::remove_rear(void *dst) -{ - if (h == 0) - error("remove_rear of empty list"); - else - { - BaseDLNode* t = h->bk; - copy_item(dst, t->item()); - if (h->fd == h) - h = 0; - else - { - t->fd->bk = t->bk; - t->bk->fd = t->fd; - } - delete_node(t); - } -} - -void BaseDLList::del_rear() -{ - if (h == 0) - error("del_rear of empty list"); - BaseDLNode* t = h->bk; - if (h->fd == h) - h = 0; - else - { - t->fd->bk = t->bk; - t->bk->fd = t->fd; - } - delete_node(t); -} - - -int BaseDLList::OK() const -{ - int v = 1; - if (h != 0) - { - BaseDLNode* t = h; - long count = LONG_MAX; // Lots of chances to find h! - do - { - count--; - v &= t->bk->fd == t; - v &= t->fd->bk == t; - t = t->fd; - } while (v && count > 0 && t != h); - v &= count > 0; - } - if (!v) error("invariant failure"); - return v; -}
deleted file mode 100644 --- a/src/DLList.h +++ /dev/null @@ -1,145 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - - -#ifndef _DLList_h -#define _DLList_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#undef OK - -#include <Pix.h> - -struct BaseDLNode { - BaseDLNode *bk; - BaseDLNode *fd; - void *item() {return (void*)(this+1);} //Return ((DLNode<T>*)this)->hd -}; - -template<class T> -class -DLNode : public BaseDLNode -{ - public: - T hd; - DLNode() { } - DLNode(const T& h, DLNode* p = 0, DLNode* n = 0) - : hd(h) { bk = p; fd = n; } - ~DLNode() { } -}; - -class -BaseDLList -{ - protected: - BaseDLNode *h; - - BaseDLList() { h = 0; } - void copy(const BaseDLList&); - BaseDLList& operator= (const BaseDLList& a); - virtual void delete_node(BaseDLNode*node) = 0; - virtual BaseDLNode* copy_node(const void* datum) = 0; - virtual void copy_item(void *dst, void *src) = 0; - virtual ~BaseDLList() { } - - Pix prepend(const void*); - Pix append(const void*); - Pix ins_after(Pix p, const void *datum); - Pix ins_before(Pix p, const void *datum); - void remove_front(void *dst); - void remove_rear(void *dst); - void join(BaseDLList&); - - public: - int empty() const { return h == 0; } - int length() const; - void clear(); - void error(const char* msg) const; - int owns(Pix p) const; - int OK() const; - void del(Pix& p, int dir = 1); - void del_after(Pix& p); - void del_front(); - void del_rear(); -}; - -template <class T> -class -DLList : public BaseDLList -{ - //friend class <T>DLListTrav; - - virtual void delete_node(BaseDLNode *node) { delete (DLNode<T>*)node; } - virtual BaseDLNode* copy_node(const void *datum) - { return new DLNode<T>(*(const T*)datum); } - virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } - - public: - DLList() : BaseDLList() { } - DLList(const DLList<T>& a) : BaseDLList() { copy(a); } - - DLList<T>& operator = (const DLList<T>& a) - { BaseDLList::operator=((const BaseDLList&) a); return *this; } - virtual ~DLList() { clear(); } - - Pix prepend(const T& item) {return BaseDLList::prepend(&item);} - Pix append(const T& item) {return BaseDLList::append(&item);} - - void join(DLList<T>& a) { BaseDLList::join(a); } - - T& front() { - if (h == 0) error("front: empty list"); - return ((DLNode<T>*)h)->hd; } - T& rear() { - if (h == 0) error("rear: empty list"); - return ((DLNode<T>*)h->bk)->hd; - } - const T& front() const { - if (h == 0) error("front: empty list"); - return ((DLNode<T>*)h)->hd; } - const T& rear() const { - if (h == 0) error("rear: empty list"); - return ((DLNode<T>*)h->bk)->hd; - } - T remove_front() { T dst; BaseDLList::remove_front(&dst); return dst; } - T remove_rear() { T dst; BaseDLList::remove_rear(&dst); return dst; } - - T& operator () (Pix p) { - if (p == 0) error("null Pix"); - return ((DLNode<T>*)p)->hd; - } - const T& operator () (Pix p) const { - if (p == 0) error("null Pix"); - return ((DLNode<T>*)p)->hd; - } - Pix first() const { return Pix(h); } - Pix last() const { return (h == 0) ? 0 : Pix(h->bk); } - void next(Pix& p) const - { p = (p == 0 || h == 0 || p == h->bk)? 0 : Pix(((DLNode<T>*)p)->fd); } - void prev(Pix& p) const - { p = (p == 0 || p == h)? 0 : Pix(((DLNode<T>*)p)->bk); } - Pix ins_after(Pix p, const T& item) - {return BaseDLList::ins_after(p, &item); } - Pix ins_before(Pix p, const T& item) - {return BaseDLList::ins_before(p, &item);} -}; - -#endif
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -79,8 +79,7 @@ pt-jump.h pt-loop.h pt-mat.h pt-misc.h pt-plot.h \ pt-pr-code.h pt-select.h pt-stmt.h pt-unop.h pt-walk.h \ -INCLUDES := BaseSLList.h Cell.h DLList.h Map.h Pix.h SLList.h \ - SLStack.h Stack.h c-file-ptr-stream.h comment-list.h defun-dld.h \ +INCLUDES := Cell.h c-file-ptr-stream.h comment-list.h defun-dld.h \ defun-int.h defun.h dirfns.h dynamic-ld.h error.h file-io.h \ fn-cache.h gripes.h help.h input.h lex.h load-save.h \ oct-fstrm.h oct-hist.h oct-iostrm.h oct-map.h oct-obj.h \ @@ -90,8 +89,7 @@ siglist.h symtab.h sysdep.h token.h toplev.h unwind-prot.h utils.h \ variables.h version.h xdiv.h xpow.h $(OV_INCLUDES) $(PT_INCLUDES) -TI_XSRC := Array-oc.cc Array-os.cc Array-sym.cc Array-tc.cc Map-oct-obj.cc \ - SLList-expr.cc SLList-misc.cc SLList-plot.cc SLList-tc.cc SLList-tm.cc +TI_XSRC := Array-oc.cc Array-os.cc Array-sym.cc Array-tc.cc TI_SRC := $(addprefix TEMPLATE-INST/, $(TI_XSRC)) @@ -121,8 +119,7 @@ pt-loop.cc pt-mat.cc pt-misc.cc pt-plot.cc pt-pr-code.cc \ pt-select.cc pt-stmt.cc pt-unop.cc -DIST_SRC := BaseSLList.cc Cell.cc DLList.cc Map.cc SLList.cc \ - SLStack.cc Stack.cc c-file-ptr-stream.cc comment-list.cc \ +DIST_SRC := Cell.cc c-file-ptr-stream.cc comment-list.cc \ cutils.c data.cc debug.cc defaults.cc defun.cc dirfns.cc \ dynamic-ld.cc error.cc file-io.cc fn-cache.cc gripes.cc \ help.cc input.cc lex.l load-save.cc main.c mappers.cc \ @@ -166,7 +163,7 @@ # so we have to repeat ourselves because some stupid egreps don't like # empty elements in alternation patterns. -DEFUN_PATTERN = "^[ \t]*DEFU(N|N_DLD|N_TEXT|N_MAPPER)[ \t]*\\(" +DEFUN_PATTERN = "^[ \t]*DEF(CMD|UN|UN_DLD|UN_TEXT|UN_MAPPER)[ \t]*\\(" DLD_DEF_FILES := $(patsubst %.cc, %.df, $(DLD_XSRC))
deleted file mode 100644 --- a/src/Map.cc +++ /dev/null @@ -1,303 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' versions -of Map and CHMap from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <iostream> - -#include "Map.h" - -template <class C> -unsigned int -CHMap<C>::hash (const std::string& str) const -{ - unsigned h = 0; - for (unsigned i = 0; i < str.length (); i++) - h = h * 33 + str[i]; - return h; -} - -template <class C> -Pix -Map<C>::seek (const std::string& item) const -{ - Pix i = 0; - - for (i = first (); i != 0 && key (i) != item; next (i)) - ; // Skip items until match found. - - return i; -} - -template <class C> -int -Map<C>::owns (Pix idx) const -{ - if (idx == 0) - return 0; - - for (Pix i = first (); i != 0; next (i)) - if (i == idx) - return 1; - - return 0; -} - -template <class C> -void -Map<C>::clear (void) -{ - Pix i = first (); - while (i != 0) - { - del (key (i)); - i = first (); - } -} - -template <class C> -int -Map<C>::contains (const std::string& item) const -{ - return seek (item) != 0; -} - -template <class C> -void -Map<C>::error (const std::string& msg) const -{ - std::cerr << "Map: " << msg << "\n"; -} - -// CHMap class. - -#define index_to_CHptr(i) (X_CAST (void *, (i << 1) + 1)) - -template <class C> -CHMap<C>::CHMap (const C& dflt, unsigned int sz) : Map<C> (dflt) -{ - tab = new CHNode<C>* [size = sz]; - for (unsigned int i = 0; i < size; ++i) - tab[i] = static_cast<CHNode<C> *> (index_to_CHptr (i+1)); - count = 0; -} - -template <class C> -CHMap<C>::CHMap (const CHMap& a) : Map<C> (a.def) -{ - tab = new CHNode<C>* [size = a.size]; - for (unsigned int i = 0; i < size; ++i) - tab[i] = static_cast<CHNode<C> *> (index_to_CHptr (i+1)); - count = 0; - for (Pix p = a.first (); p; a.next (p)) - (*this) [a.key (p)] = a.contents (p); -} - -template <class C> -CHMap<C>& -CHMap<C>::operator = (const CHMap& a) -{ - Map<C>::operator = (*this); - - unsigned int old_size = a.size; - - CHNode<C> **old_tab = tab; - old_size = a.size; - - size = old_size; - tab = new CHNode<C>* [size]; - - for (unsigned int i = 0; i < size; ++i) - tab[i] = static_cast<CHNode<C> *> (index_to_CHptr (i+1)); - - for (Pix p = a.first (); p; a.next (p)) - (*this) [a.key (p)] = a.contents (p); - - for (unsigned int i = 0; i < old_size; ++i) - { - CHNode<C> *p = old_tab[i]; - old_tab[i] = static_cast<CHNode<C> *> (index_to_CHptr (i+1)); - while (p->goodCHptr ()) - { - CHNode<C> *nxt = p->tl; - delete p; - p = nxt; - } - } - delete [] old_tab; - - return *this; -} - -template <class C> -Pix -CHMap<C>::seek (const std::string& key) const -{ - unsigned int h = hash (key) % size; - - for (CHNode<C> *t = tab[h]; t->goodCHptr (); t = t->tl) - if (key == t->hd) - return Pix (t); - - return 0; -} - -template <class C> -C& -CHMap<C>::operator [] (const std::string& item) -{ - unsigned int h = hash (item) % size; - - CHNode<C> *t = 0; - for (t = tab[h]; t->goodCHptr (); t = t->tl) - if (item == t->hd) - return t->cont; - - t = new CHNode<C> (item, def, tab[h]); - tab[h] = t; - ++count; - return t->cont; -} - -template <class C> -void -CHMap<C>::del (const std::string& key) -{ - unsigned int h = hash (key) % size; - - CHNode<C> *t = tab[h]; - CHNode<C> *trail = t; - while (t->goodCHptr ()) - { - if (key == t->hd) - { - if (trail == t) - tab[h] = t->tl; - else - trail->tl = t->tl; - delete t; - --count; - return; - } - trail = t; - t = t->tl; - } -} - -template <class C> -void -CHMap<C>::clear (void) -{ - for (unsigned int i = 0; i < size; ++i) - { - CHNode<C> *p = tab[i]; - tab[i] = static_cast<CHNode<C> *> (index_to_CHptr (i+1)); - while (p->goodCHptr ()) - { - CHNode<C> *nxt = p->tl; - delete p; - p = nxt; - } - } - count = 0; -} - -template <class C> -Pix -CHMap<C>::first (void) const -{ - for (unsigned int i = 0; i < size; ++i) - if (tab[i]->goodCHptr ()) - return Pix (tab[i]); - return 0; -} - -template <class C> -void -CHMap<C>::next (Pix& p) const -{ - CHNode<C> *t = (static_cast<CHNode<C> *> (p))->tl; - if (t->goodCHptr ()) - p = Pix (t); - else - { - for (unsigned int i = t->CHptr_to_index (); i < size; ++i) - { - if (tab[i]->goodCHptr ()) - { - p = Pix (tab[i]); - return; - } - } - p = 0; - } -} - -template <class C> -int -CHMap<C>::OK (void) const -{ - int v = tab != 0; - int n = 0; - - for (unsigned int i = 0; i < size; ++i) - { - CHNode<C> *p = 0; - - for (p = tab[i]; p->goodCHptr (); p = p->tl) - ++n; - - v &= p->CHptr_to_index () == i + 1; - } - - v &= count == n; - - if (! v) - error ("invariant failure"); - - return v; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/Map.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' versions -of Map and CHMap from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if ! defined (octave_Map_h) -#define octave_Map_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include <string> - -#include <Pix.h> - -template <class C> -class -Map -{ -protected: - int count; - C def; - -public: - Map (const C& dflt) : count (0), def (dflt) { } - - Map (const Map& m) : count (m.count), def (m.def) { } - - Map& operator = (const Map& m) - { - count = m.count; - def = m.def; - - return *this; - } - - virtual ~Map (void) { } - - int length (void) const { return count; } // current number of items - int empty (void) const { return count == 0; } - - virtual int contains (const std::string& key) const; // is key mapped? - - virtual void clear (void); // delete all items - - virtual C& operator [] (const std::string& key) = 0; // access contents by key - - virtual void del (const std::string& key) = 0; // delete entry - - virtual Pix first (void) const = 0; // Pix of first item or 0 - virtual void next (Pix& i) const = 0; // advance to next or 0 - virtual std::string key (Pix i) const = 0; // access key at i - virtual C& contents (Pix i) const = 0; // access contents at i - - virtual int owns (Pix i) const; // is i a valid Pix ? - virtual Pix seek (const std::string& key) const; // Pix of key - - C& dflt (void) { return def; } // access default val - - void error (const std::string& msg) const; - - virtual int OK (void) const = 0; // rep invariant -}; - -template <class C> -struct CHNode -{ - CHNode *tl; - std::string hd; - C cont; - - CHNode (void) : tl (0), hd (), cont () { } - - CHNode (const std::string& h, const C& c, CHNode *t = 0) - : tl (t), hd (h), cont (c) { } - - ~CHNode (void) { } - - // The nodes are linked together serially via a version of a trick - // used in some vtables: odd pointers are actually links to the next - // table entry. Not terrible, but not wonderful either. - - int goodCHptr (void) - { return ((((unsigned long) this) & 1) == 0); } - - unsigned int CHptr_to_index (void) - { return (((unsigned long) this) >> 1); } -}; - -#ifndef DEFAULT_INITIAL_CAPACITY -#define DEFAULT_INITIAL_CAPACITY 8 -#endif - -template <class C> -class -CHMap : public Map<C> -{ -protected: - CHNode<C> **tab; - unsigned int size; - -public: - CHMap (const C& dflt, unsigned int sz = DEFAULT_INITIAL_CAPACITY); - - CHMap (const CHMap& a); - - CHMap& operator = (const CHMap& a); - - ~CHMap (void) - { - clear (); - delete [] tab; - } - - C& operator [] (const std::string& key); - - void del (const std::string& key); - - Pix first (void) const; - void next (Pix& i) const; - - std::string key (Pix p) const - { - if (p == 0) - error ("null Pix"); - - return ((CHNode<C> *) p)->hd; - } - - C& contents (Pix p) const - { - if (p == 0) - error ("null Pix"); - - return ((CHNode<C> *) p)->cont; - } - - Pix seek (const std::string& key) const; - - int contains (const std::string& key) const - { - return seek (key) != 0; - } - - void clear (void); - int OK (void) const; - - unsigned int hash (const std::string& str) const; -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/Pix.h +++ /dev/null @@ -1,5 +0,0 @@ - -#ifndef _Pix_h -#define _Pix_h 1 -typedef void* Pix; -#endif
deleted file mode 100644 --- a/src/SLList.cc +++ /dev/null @@ -1,39 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "SLList.h" - -template <class T> -SLList<T>::~SLList (void) -{ - clear(); -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/SLList.h +++ /dev/null @@ -1,99 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#ifndef _SLList_h -#define _SLList_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include <Pix.h> - -#include "BaseSLList.h" - -template<class T> -class -SLNode : public BaseSLNode -{ - public: - T hd; // Data part of node - SLNode() { } - SLNode(const T& h, SLNode* t = 0) - : hd(h) { tl = t; } - ~SLNode() { } -}; - -template <class T> -class -SLList : public BaseSLList -{ - private: - virtual void delete_node(BaseSLNode *node) { delete (SLNode<T>*)node; } - virtual BaseSLNode* copy_node(const void *datum) - { return new SLNode<T>(*(const T*)datum); } - virtual void copy_item(void *dst, void *src) { *(T*)dst = *(T*)src; } - -public: - SLList() : BaseSLList() { } - SLList(const SLList<T>& a) : BaseSLList() { copy(a); } - SLList<T>& operator = (const SLList<T>& a) - { BaseSLList::operator=((const BaseSLList&) a); return *this; } - ~SLList (void); - - Pix prepend(const T& item) {return BaseSLList::prepend(&item);} - Pix append(const T& item) {return BaseSLList::append(&item);} - Pix prepend(SLNode<T>* node) {return BaseSLList::prepend(node);} - Pix append(SLNode<T>* node) {return BaseSLList::append(node);} - - T& operator () (Pix p) { - if (p == 0) error("null Pix"); - return ((SLNode<T>*)(p))->hd; } - const T& operator () (Pix p) const { - if (p == 0) error("null Pix"); - return ((SLNode<T>*)(p))->hd; } - inline Pix first() const { return (last == 0) ? 0 : Pix(last->tl); } - void next(Pix& p) const - { p = (p == 0 || p == last) ? 0 : Pix(((SLNode<T>*)(p))->tl); } - Pix ins_after(Pix p, const T& item) - { return BaseSLList::ins_after(p, &item); } - void join(SLList<T>& a) { BaseSLList::join(a); } - - T& front() { - if (last == 0) error("front: empty list"); - return ((SLNode<T>*)last->tl)->hd; } - T& rear() { - if (last == 0) error("rear: empty list"); - return ((SLNode<T>*)last)->hd; } - const T& front() const { - if (last == 0) error("front: empty list"); - return ((SLNode<T>*)last->tl)->hd; } - const T& rear() const { - if (last == 0) error("rear: empty list"); - return ((SLNode<T>*)last)->hd; } - int remove_front(T& x) { return BaseSLList::remove_front(&x); } - T remove_front() { T dst; BaseSLList::remove_front(&dst, 1); return dst; } -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/SLStack.cc +++ /dev/null @@ -1,43 +0,0 @@ -// This may look like C code, but it is really -*- C++ -*- -/* -Copyright (C) 1988, 1992 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -This file is part of the GNU C++ Library. This library is free -software; you can redistribute it and/or modify it under the terms of -the GNU Library General Public License as published by the Free -Software Foundation; either version 2 of the License, or (at your -option) any later version. This library is distributed in the hope -that it will be useful, but WITHOUT ANY WARRANTY; without even the -implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the GNU Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with this library; if not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "SLStack.h" - -template <class T> -SLStack<T>& -SLStack<T>::operator = (const SLStack<T>& s) -{ - if (this != &s) - p = s.p; - - return *this; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/SLStack.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' version -of SLStack from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if !defined (_SLStack_h) -#define _SLStack_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -#include "SLList.h" -#include "Stack.h" - -template <class T> -class -SLStack : public Stack<T> -{ -private: - - SLList<T> p; - -public: - - SLStack (void) : p () { } - - SLStack (const SLStack<T>& s) : p (s.p) { } - - ~SLStack (void) { } - - SLStack<T>& operator = (const SLStack<T>& s); - - void push (const T& item) { p.prepend (item); } - - T pop (void) { return p.remove_front (); } - - T& top (void) { return p.front (); } - - void del_top (void) { p.del_front (); } - - int empty (void) { return p.empty (); } - - int full (void) { return 0; } - - int length (void) { return p.length (); } - - void clear (void) { p.clear (); } - - int OK (void) { return p.OK (); } -}; - -#endif - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/Stack.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma implementation -#endif - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <iostream> - -#include "Stack.h" - -template <class T> -void -Stack<T>::error (const char *msg) -{ - std::cerr << msg; -} - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/Stack.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/* - -The classes in this file are derived from the old `genclass' version -of Stack from libg++, originally: - - Copyright (C) 1988 Free Software Foundation - written by Doug Lea (dl@rocky.oswego.edu) - -and distributed under the terms of the GNU Library General Public -License as published by the Free Software Foundation. - -*/ - -#if !defined (_Stack_h) -#define _Stack_h 1 - -#if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) -#pragma interface -#endif - -template <class T> -class -Stack -{ - public: - - Stack (void) { } - - virtual ~Stack (void) { } - - virtual void push (const T& item) = 0; - - virtual T pop (void) = 0; - virtual T& top (void) = 0; - - virtual void del_top (void) = 0; - - virtual int empty (void) = 0; - virtual int full (void) = 0; - virtual int length (void) = 0; - - virtual void clear (void) = 0; - - void error (const char *msg); - - virtual int OK (void) = 0; -}; - -#endif
deleted file mode 100644 --- a/src/TEMPLATE-INST/Map-oct-obj.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - -Copyright (C) 2002 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Maps of octave_value_lists. - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "Map.h" -#include "Map.cc" - -#include "oct-obj.h" - -template class Map<octave_value_list>; -template class CHNode<octave_value_list>; -template class CHMap<octave_value_list>; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/TEMPLATE-INST/SLList-expr.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "oct-obj.h" -#include "pt-exp.h" -#include "pt-id.h" -#include "pt-idx.h" - -template class SLNode<tree_expression *>; -template class SLList<tree_expression *>; - -template class SLNode<tree_identifier *>; -template class SLList<tree_identifier *>; - -template class SLNode<tree_index_expression *>; -template class SLList<tree_index_expression *>; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/TEMPLATE-INST/SLList-misc.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "ov.h" -#include "pt-arg-list.h" -#include "pt-decl.h" -#include "pt-select.h" -#include "pt-stmt.h" - -template class SLNode<tree_argument_list *>; -template class SLList<tree_argument_list *>; - -template class SLNode<tree_statement *>; -template class SLList<tree_statement *>; - -template class SLNode<tree_if_clause *>; -template class SLList<tree_if_clause *>; - -template class SLList<tree_switch_case *>; -template class SLNode<tree_switch_case *>; - -template class SLList<tree_decl_elt *>; -template class SLNode<tree_decl_elt *>; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/TEMPLATE-INST/SLList-plot.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "ov.h" -#include "pt-plot.h" - -template class SLNode<subplot *>; -template class SLList<subplot *>; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/TEMPLATE-INST/SLList-tc.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Lists of various values. - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "oct-obj.h" - -template class SLNode<octave_value>; -template class SLList<octave_value>; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
deleted file mode 100644 --- a/src/TEMPLATE-INST/SLList-tm.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - -Copyright (C) 1996, 1997 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -// Instantiate Stacks of tree_matrix* values. - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "SLList.h" -#include "SLList.cc" - -#include "oct-obj.h" -#include "pt-mat.h" - -template class SLNode<tree_matrix *>; -template class SLList<tree_matrix *>; - -/* -;;; Local Variables: *** -;;; mode: C++ *** -;;; End: *** -*/
--- a/src/comment-list.cc +++ b/src/comment-list.cc @@ -33,11 +33,6 @@ #include "comment-list.h" #include "error.h" -#include "SLList.h" -#include "SLList.cc" - -template class SLList<octave_comment_elt>; - octave_comment_buffer *octave_comment_buffer::instance = 0; bool
--- a/src/comment-list.h +++ b/src/comment-list.h @@ -29,7 +29,7 @@ #include <string> -#include <SLList.h> +#include <base-list.h> extern std::string get_comment_text (void); @@ -85,43 +85,16 @@ }; class -octave_comment_list +octave_comment_list : public octave_base_list<octave_comment_elt> { public: - octave_comment_list (void) : lst () { } - - ~octave_comment_list (void) { } + void append (const octave_comment_elt& elt) + { octave_base_list<octave_comment_elt>::append (elt); } void append (const std::string& s, octave_comment_elt::comment_type t = octave_comment_elt::unknown) - { lst.append (octave_comment_elt (s, t)); } - - octave_comment_list (const octave_comment_list& ocb) - : lst (ocb.lst) { } - - octave_comment_list& operator = (const octave_comment_list& ocb) - { - if (this != &ocb) - lst = ocb.lst; - - return *this; - } - - int length (void) const { return lst.length (); } - - octave_comment_elt& operator () (Pix p) { return lst (p); } - - const octave_comment_elt& operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - -private: - - // The list of comments. - SLList<octave_comment_elt> lst; + { append (octave_comment_elt (s, t)); } }; class
--- a/src/dynamic-ld.cc +++ b/src/dynamic-ld.cc @@ -24,11 +24,11 @@ #include <config.h> #endif +#include <list> + #include "oct-time.h" #include "file-stat.h" -#include "DLList.h" - #include <defaults.h> #include "defun.h" @@ -42,9 +42,6 @@ // functions to be cleared. static bool Vwarn_reload_forces_clear; -template class DLNode<octave_shlib>; -template class DLList<octave_shlib>; - class octave_shlib_list { @@ -75,7 +72,7 @@ static bool instance_ok (void); // List of libraries we have loaded. - DLList<octave_shlib> lib_list; + std::list<octave_shlib> lib_list; // No copying! @@ -89,19 +86,22 @@ void octave_shlib_list::do_append (const octave_shlib& shl) { - lib_list.append (shl); + lib_list.push_back (shl); } void octave_shlib_list::do_remove (octave_shlib& shl) { - for (Pix p = lib_list.first (); p != 0; lib_list.next (p)) + + for (std::list<octave_shlib>::iterator p = lib_list.begin (); + p != lib_list.end (); + p++) { - if (lib_list(p) == shl) + if (*p == shl) { shl.close (); - lib_list.del (p); + lib_list.erase (p); break; } @@ -116,13 +116,15 @@ shl = octave_shlib (); - for (Pix p = lib_list.first (); p != 0; lib_list.next (p)) + for (std::list<octave_shlib>::iterator p = lib_list.begin (); + p != lib_list.end (); + p++) { - function = lib_list(p).search (fcn_name, mangler); + function = p->search (fcn_name, mangler); if (function) { - shl = lib_list(p); + shl = *p; break; }
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -3855,8 +3855,8 @@ // recursively add each element of the structure to this group Octave_map m = tc.map_value (); - Pix i = m.first (); - while (i) + Octave_map::iterator i = m.begin (); + while (i != m.end ()) { bool retval2 = add_hdf5_data (data_id, m.contents (i), m.key (i), "", @@ -3864,8 +3864,7 @@ if (! retval2) goto error_cleanup; - // advance i to next element, or 0 - m.next (i); + i++; } } else @@ -4196,21 +4195,20 @@ // an Octave structure */ // recursively write each element of the structure Octave_map m = tc.map_value (); - Pix i; { char buf[32]; FOUR_BYTE_INT maxfieldnamelength = 32; int fieldcnt = 0; - for (i = m.first (); i; m.next (i)) + for (Octave_map::iterator i = m.begin (); i != m.end (); i++) fieldcnt++; write_mat5_tag (os, miINT32, 4); os.write ((char *)&maxfieldnamelength, 4); write_mat5_tag (os, miINT8, fieldcnt*32); - - for (i = m.first (); i; m.next (i)) + + for (Octave_map::iterator i = m.begin (); i != m.end (); i++) { // write the name of each element std::string tstr = m.key (i); @@ -4219,7 +4217,7 @@ os.write (buf, 32); } - for (i = m.first (); i; m.next (i)) + for (Octave_map::iterator i = m.begin (); i != m.end (); i++) { // write the data of each element bool retval2 = save_mat5_binary_element (os, m.contents (i), "",
--- a/src/oct-lvalue.cc +++ b/src/oct-lvalue.cc @@ -42,7 +42,7 @@ void octave_lvalue::set_index (const std::string& t, - const SLList<octave_value_list>& i) + const std::list<octave_value_list>& i) { if (! index_set) {
--- a/src/oct-lvalue.h +++ b/src/oct-lvalue.h @@ -28,8 +28,6 @@ #include <string> -#include "SLList.h" - #include "oct-obj.h" #include "pt-idx.h" #include "symtab.h" @@ -78,7 +76,7 @@ void assign (octave_value::assign_op, const octave_value&); - void set_index (const std::string& t, const SLList<octave_value_list>& i); + void set_index (const std::string& t, const std::list<octave_value_list>& i); void clear_index (void) { type = std::string (); idx.clear (); } @@ -93,7 +91,7 @@ std::string type; - SLList<octave_value_list> idx; + std::list<octave_value_list> idx; symbol_record::change_function chg_fcn;
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -37,9 +37,9 @@ octave_value_list Octave_map::operator [] (const std::string& key) const { - Pix p = map.seek (key); + const_iterator p = seek (key); - return p ? map.contents (p) : octave_value_list (); + return p != end () ? p->second : octave_value_list (); } string_vector @@ -50,7 +50,7 @@ string_vector names (len); int i = 0; - for (Pix p = first (); p != 0; next (p)) + for (const_iterator p = begin (); p != end (); p++) names[i++] = key (p); return names; @@ -61,7 +61,7 @@ { if (array_len == 0 && length () != 0) { - Pix p = first (); + const_iterator p = begin (); array_len = contents(p).length (); } @@ -142,7 +142,7 @@ } else if (rhs_len > len) { - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) contents(p).resize (rhs_len, fill_value); array_len = rhs_len; @@ -157,11 +157,11 @@ Octave_map& Octave_map::assign (const std::string& key, const octave_value_list& rhs) { - if (map.empty ()) + if (empty ()) map[key] = rhs; else { - octave_value_list tmp = map.contents (map.first ()); + octave_value_list tmp = contents (begin ()); if (tmp.length () == rhs.length ()) map[key] = rhs; @@ -177,7 +177,7 @@ { Octave_map retval; - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { octave_value_list tmp = contents(p).index (idx);
--- a/src/oct-map.h +++ b/src/oct-map.h @@ -27,7 +27,7 @@ #pragma interface #endif -#include "Map.h" +#include <map> #include "oct-obj.h" @@ -37,10 +37,14 @@ Octave_map { public: - Octave_map (void) : map (octave_value_list ()), array_len (0) { } + + typedef std::map<std::string, octave_value_list>::iterator iterator; + typedef std::map<std::string, octave_value_list>::const_iterator const_iterator; + + Octave_map (void) : map (), array_len (0) { } Octave_map (const std::string& key, const octave_value& value) - : map (octave_value_list ()), array_len (1) + : map (), array_len (1) { map[key] = octave_value_list (value); } @@ -61,7 +65,7 @@ ~Octave_map (void) { } // This is the number of keys. - int length (void) const { return map.length (); } + int length (void) const { return map.size (); } int empty (void) const { return map.empty (); } @@ -69,18 +73,31 @@ octave_value_list operator [] (const std::string& key) const; - void del (const std::string& key) { map.del (key); } + void del (const std::string& key) + { + iterator p = map.find (key); + if (p != map.end ()) + map.erase (p); + } - Pix first (void) const { return map.first (); } - void next (Pix& i) const { map.next (i); } + iterator begin (void) { return iterator (map.begin ()); } + const_iterator begin (void) const { return const_iterator (map.begin ()); } + + iterator end (void) { return iterator (map.end ()); } + const_iterator end (void) const { return const_iterator (map.end ()); } - std::string key (Pix p) const { return map.key (p); } + std::string key (const_iterator p) const { return p->first; } - octave_value_list& contents (Pix p) const { return map.contents (p); } + octave_value_list& contents (const_iterator p) + { return operator [] (key(p)); } - Pix seek (const std::string& key) const { return map.seek (key); } + octave_value_list contents (const_iterator p) const + { return operator [] (key(p)); } - int contains (const std::string& key) const { return map.contains (key); } + const_iterator seek (const std::string& key) const { return map.find (key); } + + int contains (const std::string& key) const + { return (seek (key) != map.end ()); } void clear (void) { map.clear (); } @@ -104,7 +121,7 @@ private: // The map of names to values. - CHMap<octave_value_list> map; + std::map<std::string, octave_value_list> map; // The current size of this struct array; mutable int array_len;
--- a/src/ov-base-mat.cc +++ b/src/ov-base-mat.cc @@ -40,7 +40,7 @@ template <class MT> octave_value octave_base_matrix<MT>::subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval; @@ -68,7 +68,7 @@ template <class MT> octave_value octave_base_matrix<MT>::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval; @@ -144,11 +144,6 @@ return retval; } -#if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) -template <class MT> -extern void assign (MT&, const MT&); -#endif - template <class MT> void octave_base_matrix<MT>::assign (const octave_value_list& idx, const MT& rhs) @@ -165,7 +160,7 @@ matrix.set_index (i); matrix.set_index (j); - ::assign (matrix, rhs); + ::assign (matrix, rhs, MT::resize_fill_value ()); } break; @@ -175,7 +170,7 @@ matrix.set_index (i); - ::assign (matrix, rhs); + ::assign (matrix, rhs, MT::resize_fill_value ()); } break;
--- a/src/ov-base-mat.h +++ b/src/ov-base-mat.h @@ -67,10 +67,10 @@ octave_value *empty_clone (void) const { return new octave_base_matrix (); } octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); octave_value do_index_op (const octave_value_list& idx, int resize_ok);
--- a/src/ov-base-scalar.cc +++ b/src/ov-base-scalar.cc @@ -40,7 +40,7 @@ template <class ST> octave_value octave_base_scalar<ST>::subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval; @@ -68,7 +68,7 @@ template <class ST> octave_value octave_base_scalar<ST>::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval;
--- a/src/ov-base-scalar.h +++ b/src/ov-base-scalar.h @@ -60,10 +60,10 @@ ~octave_base_scalar (void) { } octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); int rows (void) const { return 1; }
--- a/src/ov-base.cc +++ b/src/ov-base.cc @@ -54,7 +54,7 @@ octave_value octave_base_value::subsref (const std::string, - const SLList<octave_value_list>&) + const std::list<octave_value_list>&) { std::string nm = type_name (); error ("can't perform indexing operations for %s type", nm.c_str ()); @@ -63,7 +63,7 @@ octave_value_list octave_base_value::subsref (const std::string, - const SLList<octave_value_list>&, int) + const std::list<octave_value_list>&, int) { std::string nm = type_name (); error ("can't perform indexing operations for %s type", nm.c_str ()); @@ -96,7 +96,7 @@ octave_value octave_base_value::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval;
--- a/src/ov-base.h +++ b/src/ov-base.h @@ -72,10 +72,10 @@ { return static_cast<octave_value *> (0); } octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); octave_value_list subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout); octave_value do_index_op (const octave_value_list& idx, int resize_ok); @@ -89,7 +89,7 @@ idx_vector index_vector (void) const; octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); int rows (void) const { return -1; }
--- a/src/ov-builtin.cc +++ b/src/ov-builtin.cc @@ -53,7 +53,7 @@ octave_value_list octave_builtin::subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout) { octave_value_list retval; @@ -86,7 +86,7 @@ // do? If it is not, then what should happen for stat("file").size, // for exmaple? - if (idx.length () > 1) + if (idx.size () > 1) retval = retval(0).next_subsref (type, idx); return retval;
--- a/src/ov-builtin.h +++ b/src/ov-builtin.h @@ -51,7 +51,7 @@ ~octave_builtin (void) { } octave_value_list subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout); octave_function *function_value (bool) { return this; }
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -53,7 +53,7 @@ octave_value octave_cell::subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval; @@ -104,7 +104,7 @@ octave_value octave_cell::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval; @@ -126,9 +126,9 @@ if (! error_state) { - SLList<octave_value_list> next_idx (idx); + std::list<octave_value_list> next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); } @@ -148,9 +148,9 @@ { tmp = tcell(0,0); - SLList<octave_value_list> next_idx (idx); + std::list<octave_value_list> next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); }
--- a/src/ov-cell.h +++ b/src/ov-cell.h @@ -74,10 +74,10 @@ #endif octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); bool is_defined (void) const { return true; }
--- a/src/ov-cs-list.cc +++ b/src/ov-cs-list.cc @@ -46,7 +46,7 @@ octave_value octave_list::subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval; @@ -118,7 +118,7 @@ octave_value octave_list::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval; @@ -140,9 +140,9 @@ if (! error_state) { - SLList<octave_value_list> next_idx (idx); + std::list<octave_value_list> next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); }
--- a/src/ov-cs-list.h +++ b/src/ov-cs-list.h @@ -66,12 +66,12 @@ #if 0 octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); octave_value do_index_op (const octave_value_list& idx, int resize_ok); octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); void assign (const octave_value_list& idx, const octave_value& rhs);
--- a/src/ov-list.cc +++ b/src/ov-list.cc @@ -44,7 +44,7 @@ octave_value octave_list::subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval; @@ -116,7 +116,7 @@ octave_value octave_list::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval; @@ -138,9 +138,9 @@ if (! error_state) { - SLList<octave_value_list> next_idx (idx); + std::list<octave_value_list> next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs); }
--- a/src/ov-list.h +++ b/src/ov-list.h @@ -65,12 +65,12 @@ octave_value *empty_clone (void) const { return new octave_list (); } octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); octave_value do_index_op (const octave_value_list& idx, int resize_ok); octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); void assign (const octave_value_list& idx, const octave_value& rhs);
--- a/src/ov-mapper.cc +++ b/src/ov-mapper.cc @@ -245,7 +245,7 @@ octave_value_list octave_mapper::subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout) { octave_value_list retval;
--- a/src/ov-mapper.h +++ b/src/ov-mapper.h @@ -67,7 +67,7 @@ octave_function *function_value (bool) { return this; } octave_value_list subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout); octave_value_list
--- a/src/ov-range.cc +++ b/src/ov-range.cc @@ -83,7 +83,7 @@ octave_value octave_range::subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval;
--- a/src/ov-range.h +++ b/src/ov-range.h @@ -40,7 +40,6 @@ #include "oct-alloc.h" #include "str-vec.h" -#include "SLList.h" #include "error.h" #include "ov-base.h" #include "ov-typeinfo.h" @@ -87,7 +86,7 @@ octave_value *try_narrowing_conversion (void); octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); octave_value do_index_op (const octave_value_list& idx, int resize_ok);
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -51,9 +51,9 @@ std::string nm = idx(0).string_value (); - Pix p = map.seek (nm); + Octave_map::const_iterator p = map.seek (nm); - if (p) + if (p != map.end ()) retval = map.contents (p); else error ("structure has no member `%s'", nm.c_str ()); @@ -87,7 +87,7 @@ octave_value octave_struct::subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval; @@ -99,9 +99,8 @@ { if (type.length () > 1 && type[1] == '.') { - Pix p = idx.first (); - idx.next (p); - octave_value_list key_idx = idx(p); + std::list<octave_value_list>::const_iterator p = idx.begin (); + octave_value_list key_idx = *++p; octave_value_list tmp = dotref (key_idx); @@ -183,7 +182,7 @@ octave_value octave_struct::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval; @@ -200,13 +199,12 @@ { if (type.length () > 1 && type[1] == '.') { - Pix p = idx.first (); - octave_value_list t_idx = idx(p); + std::list<octave_value_list>::const_iterator p = idx.begin (); + octave_value_list t_idx = *p; if (t_idx.length () == 1) { - idx.next (p); - octave_value_list key_idx = idx(p); + octave_value_list key_idx = *++p; assert (key_idx.length () == 1); @@ -231,13 +229,13 @@ if (! error_state) { - SLList<octave_value_list> next_idx (idx); + std::list<octave_value_list> next_idx (idx); // We handled two index elements, so subsasgn to // needs to skip both of them. - next_idx.remove_front (); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); + next_idx.erase (next_idx.begin ()); u.make_unique (); @@ -273,9 +271,9 @@ if (! error_state) { - SLList<octave_value_list> next_idx (idx); + std::list<octave_value_list> next_idx (idx); - next_idx.remove_front (); + next_idx.erase (next_idx.begin ()); u.make_unique (); @@ -301,9 +299,8 @@ { if (n > 1 && type[1] == '.') { - Pix p = idx.first (); - idx.next (p); - octave_value_list key_idx = idx(p); + std::list<octave_value_list>::const_iterator p = idx.begin (); + octave_value_list key_idx = *++p; assert (key_idx.length () == 1); @@ -418,7 +415,7 @@ int n = map.array_length (); - for (Pix p = map.first (); p; map.next (p)) + for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++) { std::string key = map.key (p); octave_value_list val = map.contents (p);
--- a/src/ov-struct.h +++ b/src/ov-struct.h @@ -70,13 +70,13 @@ octave_value_list dotref (const octave_value_list& idx); octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); static octave_value numeric_conv (const octave_value_list& val, const std::string& type); octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); int rows (void) const { return map.rows (); }
--- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -284,7 +284,7 @@ tree_parameter_list *tmp = static_cast<tree_parameter_list *> (lst); if (tmp) - tmp->clear (); + tmp->undefine (); } static void @@ -305,7 +305,7 @@ octave_value_list octave_user_function::subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout) { octave_value_list retval; @@ -332,7 +332,7 @@ // octave_value_list::next_subsref member function? See also // octave_builtin::subsref. - if (idx.length () > 1) + if (idx.size () > 1) retval = retval(0).next_subsref (type, idx); return retval;
--- a/src/ov-usr-fcn.h +++ b/src/ov-usr-fcn.h @@ -140,7 +140,7 @@ } octave_value_list subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout); octave_value_list
--- a/src/ov.cc +++ b/src/ov.cc @@ -568,7 +568,7 @@ octave_value_list octave_value::subsref (const std::string type, - const SLList<octave_value_list>& idx, int nargout) + const std::list<octave_value_list>& idx, int nargout) { if (is_constant ()) return rep->subsref (type, idx); @@ -578,16 +578,16 @@ octave_value octave_value::next_subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int skip) { assert (skip > 0); - if (idx.length () > skip) + if (idx.size () > skip) { - SLList<octave_value_list> new_idx (idx); + std::list<octave_value_list> new_idx (idx); for (int i = 0; i < skip; i++) - new_idx.remove_front (); + new_idx.erase (new_idx.begin ()); return subsref (type.substr (skip), new_idx); } else @@ -629,7 +629,7 @@ octave_value octave_value::subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { return rep->subsasgn (type, idx, rhs); @@ -637,7 +637,7 @@ octave_value octave_value::assign (assign_op op, const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval; @@ -1080,7 +1080,7 @@ octave_value octave_value::numeric_assign (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs) { octave_value retval; @@ -1433,7 +1433,7 @@ octave_value octave_value::do_non_const_unary_op (unary_op op, const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { octave_value retval;
--- a/src/ov.h +++ b/src/ov.h @@ -31,6 +31,7 @@ #include <iostream> #include <string> +#include <list> #include "Range.h" #include "idx-vector.h" @@ -38,8 +39,6 @@ #include "oct-alloc.h" #include "str-vec.h" -#include "SLList.h" - class Cell; class Octave_map; class octave_stream; @@ -244,24 +243,24 @@ { return rep->try_narrowing_conversion (); } virtual octave_value subsref (const std::string type, - const SLList<octave_value_list>& idx) + const std::list<octave_value_list>& idx) { return rep->subsref (type, idx); } octave_value subsref (const std::string type, const octave_value_list& idx) { - SLList<octave_value_list> i; + std::list<octave_value_list> i; - i.append (idx); + i.push_back (idx); return rep->subsref (type, i); } virtual octave_value_list subsref (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, int nargout); octave_value next_subsref (const std::string type, const - SLList<octave_value_list>& idx, + std::list<octave_value_list>& idx, int skip = 1); virtual octave_value do_index_op (const octave_value_list& idx, @@ -275,11 +274,11 @@ do_multi_index_op (int nargout, const octave_value_list& idx); virtual octave_value subsasgn (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); octave_value assign (assign_op op, const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); const octave_value& assign (assign_op, const octave_value& rhs); @@ -529,7 +528,7 @@ void do_non_const_unary_op (unary_op op, const octave_value_list& idx); octave_value do_non_const_unary_op (unary_op op, const std::string type, - const SLList<octave_value_list>& idx); + const std::list<octave_value_list>& idx); friend octave_value do_binary_op (binary_op op, const octave_value& a, @@ -547,7 +546,7 @@ // This should only be called for derived types. octave_value numeric_assign (const std::string type, - const SLList<octave_value_list>& idx, + const std::list<octave_value_list>& idx, const octave_value& rhs); void reset_indent_level (void) const
--- a/src/parse.y +++ b/src/parse.y @@ -2786,7 +2786,7 @@ { if (lexer_flags.defining_func && Vwarn_missing_semicolon) { - tree_statement *tmp = t->rear(); + tree_statement *tmp = t->back(); if (tmp->is_expression ()) warning ("missing semicolon near line %d, column %d in file `%s'", @@ -2803,7 +2803,7 @@ { case ';': { - tree_statement *tmp = list->rear (); + tree_statement *tmp = list->back (); tmp->set_print_flag (0); } break;
--- a/src/pt-arg-list.cc +++ b/src/pt-arg-list.cc @@ -47,10 +47,11 @@ tree_argument_list::~tree_argument_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_expression *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } @@ -59,9 +60,9 @@ { int retval = 0; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p; // XXX FIXME XXX -- need to be able to determine whether elt is // an expression that could evaluate to a cs-list object, and if @@ -76,9 +77,9 @@ bool tree_argument_list::all_elements_are_constant (void) const { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p; if (! elt->is_constant ()) return false; @@ -100,11 +101,11 @@ int args_len = len; args.resize (args_len); - Pix p = lst.first (); + iterator p = begin (); int j = 0; for (int k = 0; k < len; k++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p++; if (elt) { @@ -149,7 +150,6 @@ else args(j++) = tmp; } - next (p); } else { @@ -172,9 +172,9 @@ int k = 0; - for (Pix p = lst.first (); p; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_expression *elt = lst (p); + tree_expression *elt = *p; retval(k++) = elt->str_print_code (); }
--- a/src/pt-arg-list.h +++ b/src/pt-arg-list.h @@ -27,8 +27,6 @@ #pragma interface #endif -#include <SLList.h> - class octave_value_list; class tree_expression; @@ -37,38 +35,29 @@ #include "str-vec.h" +#include "base-list.h" + // Argument lists. Used to hold the list of expressions that are the // arguments in a function call or index expression. class -tree_argument_list +tree_argument_list : public octave_base_list<tree_expression *> { public: - tree_argument_list (void) - : lst () { } + tree_argument_list (void) { } - tree_argument_list (tree_expression *t) - : lst () { lst.append (t); } + tree_argument_list (tree_expression *t) { append (t); } ~tree_argument_list (void); - int length (void) const { return lst.length (); } - - void append (tree_expression *&s) { lst.append (s); } - void append (tree_expression * const &s) { lst.append (s); } - - tree_expression *&operator () (Pix p) { return lst (p); } - - tree_expression * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - - int remove_front (tree_expression *x) { return lst.remove_front (x); } - - tree_expression *remove_front (void) { return lst.remove_front (); } + tree_expression *remove_front (void) + { + iterator p = begin (); + tree_expression *retval = *p; + erase (p); + return retval; + } int nargout_count (void) const; @@ -82,9 +71,6 @@ private: - // The list of argument list elements. - SLList<tree_expression *> lst; - // No copying! tree_argument_list (const tree_argument_list&);
--- a/src/pt-assign.cc +++ b/src/pt-assign.cc @@ -230,9 +230,11 @@ retval.resize (n, octave_value ()); - for (Pix p = lhs->first (); p != 0; lhs->next (p)) + for (tree_argument_list::iterator p = lhs->begin (); + p != lhs->end (); + p++) { - tree_expression *lhs_elt = lhs->operator () (p); + tree_expression *lhs_elt = *p; if (lhs_elt) {
--- a/src/pt-bp.cc +++ b/src/pt-bp.cc @@ -114,9 +114,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_argument_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_expression *elt = lst(p); + tree_expression *elt = *p; if (elt) elt->accept (*this); @@ -220,9 +220,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_decl_init_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_decl_elt *elt = lst(p); + tree_decl_elt *elt = *p; if (elt) elt->accept (*this); @@ -334,9 +334,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_if_command_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_if_clause *elt = lst(p); + tree_if_clause *elt = *p; if (elt) elt->accept (*this); @@ -354,13 +354,16 @@ if (expr && expr->line () >= line) take_action (*expr); - SLList<tree_argument_list *> lst = cmd.arg_lists (); + std::list<tree_argument_list *> lst = cmd.arg_lists (); + if (! lst.empty ()) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (std::list<tree_argument_list *>::iterator p = lst.begin (); + p != lst.end (); + p++) { - tree_argument_list *elt = lst(p); + tree_argument_list *elt = *p; elt->accept (*this); } @@ -373,12 +376,11 @@ if (found) return; - Pix p = mat.first (); + tree_matrix::iterator p = mat.begin (); - while (p) + while (p != mat.end ()) { - tree_argument_list *elt = mat(p); - mat.next (p); + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); @@ -391,12 +393,11 @@ if (found) return; - Pix p = cell.first (); + tree_cell::iterator p = cell.begin (); - while (p) + while (p != cell.end ()) { - tree_argument_list *elt = cell (p); - cell.next (p); + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); @@ -446,12 +447,11 @@ if (found) return; - Pix p = lst.first (); + tree_parameter_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_identifier *elt = lst(p); - lst.next (p); + tree_identifier *elt = *p++; if (elt) elt->accept (*this); @@ -529,12 +529,11 @@ if (found) return; - Pix p = lst.first (); + tree_return_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_index_expression *elt = lst(p); - lst.next (p); + tree_index_expression *elt = *p++; if (elt) elt->accept (*this); @@ -577,9 +576,9 @@ if (found) return; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_statement_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_statement *elt = lst(p); + tree_statement *elt = *p; if (elt) elt->accept (*this); @@ -636,16 +635,14 @@ if (found) return; - Pix p = lst.first (); + tree_switch_case_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_switch_case *elt = lst(p); + tree_switch_case *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } }
--- a/src/pt-cell.cc +++ b/src/pt-cell.cc @@ -53,9 +53,9 @@ int nr = length (); int nc = -1; - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_argument_list *elt = this->operator () (p); + tree_argument_list *elt = *p; if (nc < 0) nc = elt->length (); @@ -70,9 +70,9 @@ int i = 0; - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_argument_list *elt = this->operator () (p); + tree_argument_list *elt = *p; octave_value_list row = elt->convert_to_const_vector ();
--- a/src/pt-cell.h +++ b/src/pt-cell.h @@ -35,8 +35,6 @@ class tree_walker; -#include <SLList.h> - #include "pt-mat.h" // General cells.
--- a/src/pt-check.cc +++ b/src/pt-check.cc @@ -36,13 +36,11 @@ void tree_checker::visit_argument_list (tree_argument_list& lst) { - Pix p = lst.first (); + tree_argument_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_expression *elt = lst (p); - - lst.next (p); + tree_expression *elt = *p++; if (elt) { @@ -121,13 +119,11 @@ void tree_checker::visit_decl_init_list (tree_decl_init_list& lst) { - Pix p = lst.first (); + tree_decl_init_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_decl_elt *elt = lst (p); - - lst.next (p); + tree_decl_elt *elt = *p++; if (elt) elt->accept (*this); @@ -227,16 +223,14 @@ void tree_checker::visit_if_command_list (tree_if_command_list& lst) { - Pix p = lst.first (); + tree_if_command_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_if_clause *elt = lst (p); + tree_if_clause *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } @@ -248,31 +242,41 @@ if (e) e->accept (*this); - SLList<tree_argument_list *> lst = expr.arg_lists (); + std::list<tree_argument_list *> lst = expr.arg_lists (); - Pix p = lst.first (); + std::list<tree_argument_list *>::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } void tree_checker::visit_matrix (tree_matrix& lst) { - Pix p = lst.first (); + tree_matrix::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); + tree_argument_list *elt = *p++; + + if (elt) + elt->accept (*this); + } +} - lst.next (p); +void +tree_checker::visit_cell (tree_cell& lst) +{ + tree_matrix::iterator p = lst.begin (); + + while (p != lst.end ()) + { + tree_argument_list *elt = *p++; if (elt) elt->accept (*this); @@ -312,13 +316,11 @@ void tree_checker::visit_parameter_list (tree_parameter_list& lst) { - Pix p = lst.first (); + tree_parameter_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_identifier *elt = lst (p); - - lst.next (p); + tree_identifier *elt = *p++; if (elt) elt->accept (*this); @@ -398,13 +400,11 @@ void tree_checker::visit_return_list (tree_return_list& lst) { - Pix p = lst.first (); + tree_return_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_index_expression *elt = lst (p); - - lst.next (p); + tree_index_expression *elt = *p++; if (elt) elt->accept (*this); @@ -447,9 +447,9 @@ void tree_checker::visit_statement_list (tree_statement_list& lst) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_statement_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_statement *elt = lst (p); + tree_statement *elt = *p; if (elt) elt->accept (*this); @@ -483,13 +483,11 @@ void tree_checker::visit_subplot_list (subplot_list& lst) { - Pix p = lst.first (); + subplot_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - subplot *elt = lst (p); - - lst.next (p); + subplot *elt = *p++; if (elt) elt->accept (*this); @@ -551,16 +549,14 @@ void tree_checker::visit_switch_case_list (tree_switch_case_list& lst) { - Pix p = lst.first (); + tree_switch_case_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_switch_case *elt = lst (p); + tree_switch_case *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } }
--- a/src/pt-check.h +++ b/src/pt-check.h @@ -75,6 +75,8 @@ void visit_matrix (tree_matrix&); + void visit_cell (tree_cell&); + void visit_multi_assignment (tree_multi_assignment&); void visit_no_op_command (tree_no_op_command&);
--- a/src/pt-decl.cc +++ b/src/pt-decl.cc @@ -63,9 +63,11 @@ void tree_decl_init_list::eval (tree_decl_elt::eval_fcn f) { - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - f (*(this->operator () (p))); + tree_decl_elt *elt = *p; + + f (*elt); if (error_state) break;
--- a/src/pt-decl.h +++ b/src/pt-decl.h @@ -27,8 +27,6 @@ #pragma interface #endif -#include <SLList.h> - class tree_expression; class tree_identifier; @@ -36,6 +34,7 @@ #include <string> +#include "base-list.h" #include "pt-cmd.h" // List of expressions that make up a declaration statement. @@ -76,45 +75,30 @@ }; class -tree_decl_init_list +tree_decl_init_list : public octave_base_list<tree_decl_elt *> { public: - tree_decl_init_list (void) - : lst () { } + tree_decl_init_list (void) { } - tree_decl_init_list (tree_decl_elt *t) - : lst () { lst.append (t); } + tree_decl_init_list (tree_decl_elt *t) { append (t); } ~tree_decl_init_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_decl_elt *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_decl_elt *&s) { lst.append (s); } - void append (tree_decl_elt * const &s) { lst.append (s); } - - tree_decl_elt *&operator () (Pix p) { return lst (p); } - - tree_decl_elt * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void eval (tree_decl_elt::eval_fcn); void accept (tree_walker& tw); private: - // The list of variables/initializers. - SLList<tree_decl_elt *> lst; - // No copying! tree_decl_init_list (const tree_decl_init_list&);
--- a/src/pt-idx.cc +++ b/src/pt-idx.cc @@ -42,11 +42,6 @@ #include "utils.h" #include "variables.h" -#include "SLList.cc" - -template class SLNode<string_vector>; -template class SLList<string_vector>; - // Index expressions. tree_index_expression::tree_index_expression (tree_expression *e, @@ -79,28 +74,28 @@ void tree_index_expression::append (tree_argument_list *lst, char t) { - args.append (lst); + args.push_back (lst); type.append (1, t); - arg_nm.append (lst ? lst->get_arg_names () : string_vector ()); - dyn_field.append (static_cast<tree_expression *> (0)); + arg_nm.push_back (lst ? lst->get_arg_names () : string_vector ()); + dyn_field.push_back (static_cast<tree_expression *> (0)); } void tree_index_expression::append (const std::string& n) { - args.append (static_cast<tree_argument_list *> (0)); + args.push_back (static_cast<tree_argument_list *> (0)); type.append ("."); - arg_nm.append (n); - dyn_field.append (static_cast<tree_expression *> (0)); + arg_nm.push_back (n); + dyn_field.push_back (static_cast<tree_expression *> (0)); } void tree_index_expression::append (tree_expression *df) { - args.append (static_cast<tree_argument_list *> (0)); + args.push_back (static_cast<tree_argument_list *> (0)); type.append ("."); - arg_nm.append (""); - dyn_field.append (df); + arg_nm.push_back (""); + dyn_field.push_back (df); } tree_index_expression::~tree_index_expression (void) @@ -109,8 +104,9 @@ while (! args.empty ()) { - tree_argument_list *t = args.remove_front (); - delete t; + std::list<tree_argument_list *>::iterator p = args.begin (); + delete *p; + args.erase (p); } } @@ -171,13 +167,15 @@ } std::string -tree_index_expression::get_struct_index (Pix p_arg_nm, Pix p_dyn_field) const +tree_index_expression::get_struct_index + (std::list<string_vector>::const_iterator p_arg_nm, + std::list<tree_expression *>::const_iterator p_dyn_field) const { - std::string fn = arg_nm(p_arg_nm)(0); + std::string fn = (*p_arg_nm)(0); if (fn.empty ()) { - tree_expression *df = dyn_field (p_dyn_field); + tree_expression *df = *p_dyn_field; if (df) { @@ -201,14 +199,14 @@ Octave_map tree_index_expression::make_arg_struct (void) const { - int n = args.length (); + int n = args.size (); octave_value_list subs_list (n, octave_value ()); octave_value_list type_list (n, octave_value ()); - Pix p_args = args.first (); - Pix p_arg_nm = arg_nm.first (); - Pix p_dyn_field = dyn_field.first (); + std::list<tree_argument_list *>::const_iterator p_args = args.begin (); + std::list<string_vector>::const_iterator p_arg_nm = arg_nm.begin (); + std::list<tree_expression *>::const_iterator p_dyn_field = dyn_field.begin (); Octave_map m; @@ -217,11 +215,11 @@ switch (type[i]) { case '(': - subs_list(i) = make_subs_cell (args(p_args), arg_nm(p_arg_nm)); + subs_list(i) = make_subs_cell (*p_args, *p_arg_nm); break; case '{': - subs_list(i) = make_subs_cell (args(p_args), arg_nm(p_arg_nm)); + subs_list(i) = make_subs_cell (*p_args, *p_arg_nm); break; case '.': @@ -240,9 +238,9 @@ if (error_state) return m; - args.next (p_args); - arg_nm.next (p_arg_nm); - dyn_field.next (p_dyn_field); + p_args++; + p_arg_nm++; + p_dyn_field++; } m ["subs"] = subs_list; @@ -263,29 +261,29 @@ if (! error_state) { - SLList<octave_value_list> idx; + std::list<octave_value_list> idx; - int n = args.length (); + int n = args.size (); - Pix p_args = args.first (); - Pix p_arg_nm = arg_nm.first (); - Pix p_dyn_field = dyn_field.first (); + std::list<tree_argument_list *>::iterator p_args = args.begin (); + std::list<string_vector>::iterator p_arg_nm = arg_nm.begin (); + std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin (); for (int i = 0; i < n; i++) { switch (type[i]) { case '(': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '{': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '.': { - idx.append (get_struct_index (p_arg_nm, p_dyn_field)); + idx.push_back (get_struct_index (p_arg_nm, p_dyn_field)); if (error_state) eval_error (); @@ -299,9 +297,9 @@ if (error_state) break; - args.next (p_args); - arg_nm.next (p_arg_nm); - dyn_field.next (p_dyn_field); + p_args++; + p_arg_nm++; + p_dyn_field++; } if (! error_state) @@ -329,29 +327,29 @@ { octave_lvalue retval; - SLList<octave_value_list> idx; + std::list<octave_value_list> idx; - int n = args.length (); + int n = args.size (); - Pix p_args = args.first (); - Pix p_arg_nm = arg_nm.first (); - Pix p_dyn_field = dyn_field.first (); + std::list<tree_argument_list *>::iterator p_args = args.begin (); + std::list<string_vector>::iterator p_arg_nm = arg_nm.begin (); + std::list<tree_expression *>::iterator p_dyn_field = dyn_field.begin (); for (int i = 0; i < n; i++) { switch (type[i]) { case '(': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '{': - idx.append (make_value_list (args(p_args), arg_nm(p_arg_nm))); + idx.push_back (make_value_list (*p_args, *p_arg_nm)); break; case '.': { - idx.append (get_struct_index (p_arg_nm, p_dyn_field)); + idx.push_back (get_struct_index (p_arg_nm, p_dyn_field)); if (error_state) eval_error (); @@ -365,9 +363,9 @@ if (error_state) break; - args.next (p_args); - arg_nm.next (p_arg_nm); - dyn_field.next (p_dyn_field); + p_args++; + p_arg_nm++; + p_dyn_field++; } if (! error_state)
--- a/src/pt-idx.h +++ b/src/pt-idx.h @@ -27,6 +27,8 @@ #pragma interface #endif +#include <list> + class tree_argument_list; class tree_walker; @@ -36,7 +38,6 @@ class octave_value_list; class octave_lvalue; -#include "SLList.h" #include "str-vec.h" #include "pt-exp.h" @@ -71,11 +72,11 @@ tree_expression *expression (void) { return expr; } - SLList<tree_argument_list *> arg_lists (void) { return args; } + std::list<tree_argument_list *> arg_lists (void) { return args; } std::string type_tags (void) { return type; } - SLList<string_vector> arg_names (void) { return arg_nm; } + std::list<string_vector> arg_names (void) { return arg_nm; } bool lvalue_ok (void) const { return expr->lvalue_ok (); } @@ -97,21 +98,24 @@ tree_expression *expr; // The indices (only valid if type == paren || type == brace). - SLList<tree_argument_list *> args; + std::list<tree_argument_list *> args; // The type of this index expression. std::string type; // The names of the arguments. Used for constant struct element // references. - SLList<string_vector> arg_nm; + std::list<string_vector> arg_nm; // The list of dynamic field names, if any. - SLList<tree_expression *> dyn_field; + std::list<tree_expression *> dyn_field; Octave_map make_arg_struct (void) const; - std::string get_struct_index (Pix p_arg_nm, Pix p_dyn_field) const; + std::string + get_struct_index + (std::list<string_vector>::const_iterator p_arg_nm, + std::list<tree_expression *>::const_iterator p_dyn_field) const; // No copying!
--- a/src/pt-loop.cc +++ b/src/pt-loop.cc @@ -373,7 +373,9 @@ { Octave_map tmp_val (rhs.map_value ()); - for (Pix p = tmp_val.first (); p != 0; tmp_val.next (p)) + for (Octave_map::iterator p = tmp_val.begin (); + p != tmp_val.end (); + p++) { MAYBE_DO_BREAKPOINT; @@ -476,21 +478,19 @@ // is set to value and the second is set to the name of the // structure element. - Pix p = lhs->first (); - tree_expression *elt = lhs->operator () (p); + tree_argument_list::iterator p = lhs->begin (); + tree_expression *elt = *p++; octave_lvalue val_ref = elt->lvalue (); - - lhs->next (p); - elt = lhs->operator () (p); + elt = *p; octave_lvalue key_ref = elt->lvalue (); Octave_map tmp_val (rhs.map_value ()); - for (p = tmp_val.first (); p != 0; tmp_val.next (p)) + for (Octave_map::iterator q = tmp_val.begin (); q != tmp_val.end (); p++) { - octave_value key = tmp_val.key (p); + octave_value key = tmp_val.key (q); - octave_value_list val_lst = tmp_val.contents (p); + octave_value_list val_lst = tmp_val.contents (q); int n = tmp_val.array_length ();
--- a/src/pt-mat.cc +++ b/src/pt-mat.cc @@ -66,17 +66,17 @@ private: class - tm_row_const_rep : public SLList<octave_value> + tm_row_const_rep : public octave_base_list<octave_value> { public: tm_row_const_rep (void) - : SLList<octave_value> (), count (1), nr (0), nc (0), + : count (1), nr (0), nc (0), all_str (false), some_str (false), is_cmplx (false), all_mt (true), ok (false) { } tm_row_const_rep (const tree_argument_list& row) - : SLList<octave_value> (), count (1), nr (0), nc (0), + : count (1), nr (0), nc (0), all_str (false), some_str (false), is_cmplx (false), all_mt (true), ok (false) { init (row); } @@ -111,6 +111,9 @@ public: + typedef tm_row_const_rep::iterator iterator; + typedef tm_row_const_rep::const_iterator const_iterator; + tm_row_const (void) : rep (0) { } @@ -154,15 +157,13 @@ bool complex_p (void) const { return rep->is_cmplx; } bool all_empty_p (void) const { return rep->all_mt; } - octave_value& operator () (Pix p) { return rep->operator () (p); } - - const octave_value& operator () (Pix p) const - { return rep->operator () (p); } + operator bool () const { return (rep && rep->ok); } - Pix first (void) const { return rep->first (); } - void next (Pix& p) const { rep->next (p); } - - operator bool () const { return (rep && rep->ok); } + iterator begin (void) { return rep->begin (); } + const_iterator begin (void) const { return rep->begin (); } + + iterator end (void) { return rep->end (); } + const_iterator end (void) const { return rep->end (); } private: @@ -176,9 +177,11 @@ bool first_elem = true; - for (Pix p = row.first (); p != 0; row.next (p)) + for (tree_argument_list::const_iterator p = row.begin (); + p != row.end (); + p++) { - tree_expression *elt = row (p); + tree_expression *elt = *p; octave_value tmp = elt->rvalue (); @@ -267,19 +270,13 @@ ::warning ("%s near line %d, column %d", msg, l, c); } -#include "SLList.h" -#include "SLList.cc" - -template class SLNode<tm_row_const>; -template class SLList<tm_row_const>; - class -tm_const : public SLList<tm_row_const> +tm_const : public octave_base_list<tm_row_const> { public: tm_const (const tree_matrix& tm) - : SLList<tm_row_const> (), nr (0), nc (0), + : nr (0), nc (0), all_str (false), some_str (false), is_cmplx (false), all_mt (true), ok (false) { init (tm); } @@ -329,9 +326,9 @@ // numeric matrix -- collections of strings can have elements of // different lengths. - for (Pix p = tm.first (); p != 0; tm.next (p)) + for (tree_matrix::const_iterator p = tm.begin (); p != tm.end (); p++) { - tree_argument_list *elt = tm (p); + tree_argument_list *elt = *p; tm_row_const tmp (*elt); @@ -357,9 +354,9 @@ if (! error_state) { - for (Pix p = first (); p != 0; next (p)) + for (iterator p = begin (); p != end (); p++) { - tm_row_const elt = this->operator () (p); + tm_row_const elt = *p; int this_elt_nr = elt.rows (); int this_elt_nc = elt.cols (); @@ -406,19 +403,20 @@ tree_matrix::~tree_matrix (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_argument_list *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } bool tree_matrix::all_elements_are_constant (void) const { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (const_iterator p = begin (); p != end (); p++) { - tree_argument_list *elt = lst (p); + tree_argument_list *elt = *p; if (! elt->all_elements_are_constant ()) return false; @@ -488,15 +486,15 @@ int put_row = 0; - for (Pix p = tmp.first (); p != 0; tmp.next (p)) + for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++) { int put_col = 0; - tm_row_const row = tmp (p); + tm_row_const row = *p; - for (Pix q = row.first (); q != 0; row.next (q)) + for (tm_row_const::iterator q = row.begin (); q != row.end (); q++) { - octave_value elt = row (q); + octave_value elt = *q; if (found_complex) {
--- a/src/pt-mat.h +++ b/src/pt-mat.h @@ -35,40 +35,27 @@ class tree_walker; -#include <SLList.h> - +#include "base-list.h" #include "pt-exp.h" // General matrices. This allows us to construct matrices from // other matrices, variables, and functions. class -tree_matrix : public tree_expression +tree_matrix : public tree_expression, + public octave_base_list<tree_argument_list *> { public: tree_matrix (tree_argument_list *row = 0, int line = -1, int column = -1) - : tree_expression (line, column), lst () + : tree_expression (line, column) { if (row) - lst.append (row); + append (row); } ~tree_matrix (void); - int length (void) const { return lst.length (); } - - void append (tree_argument_list *&s) { lst.append (s); } - void append (tree_argument_list * const &s) { lst.append (s); } - - tree_argument_list *&operator () (Pix p) { return lst (p); } - - tree_argument_list * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - bool all_elements_are_constant (void) const; bool rvalue_ok (void) const { return true; } @@ -81,9 +68,6 @@ private: - // The list matrix elements for this row. - SLList<tree_argument_list *> lst; - // No copying! tree_matrix (const tree_matrix&);
--- a/src/pt-misc.cc +++ b/src/pt-misc.cc @@ -28,8 +28,6 @@ #include <config.h> #endif -#include <SLList.h> - #include "error.h" #include "ov.h" #include "oct-lvalue.h" @@ -42,19 +40,20 @@ tree_parameter_list::~tree_parameter_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_identifier *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } void tree_parameter_list::mark_as_formal_parameters (void) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p; elt->mark_as_formal_parameter (); } } @@ -62,9 +61,9 @@ void tree_parameter_list::initialize_undefined_elements (octave_value& val) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p; if (! elt->is_defined ()) { @@ -85,11 +84,11 @@ int expected_nargin = length (); - Pix p = lst.first (); + iterator p = begin (); for (int i = 0; i < expected_nargin; i++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p++; octave_lvalue ref = elt->lvalue (); @@ -105,27 +104,23 @@ } else ref.assign (octave_value::op_asn_eq, octave_value ()); - - lst.next (p); } } void -tree_parameter_list::clear (void) +tree_parameter_list::undefine (void) { int len = length (); - Pix p = lst.first (); + iterator p = begin (); for (int i = 0; i < len; i++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p++; octave_lvalue ref = elt->lvalue (); ref.assign (octave_value::op_asn_eq, octave_value ()); - - lst.next (p); } } @@ -142,22 +137,21 @@ int i = 0; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = this->operator () (p); + tree_identifier *elt = *p; if (elt->is_defined ()) - retval(i) = elt->rvalue (); - - i++; + retval(i++) = elt->rvalue (); } if (vr_list) { - for (Pix p = vr_list->first (); p != 0; vr_list->next (p)) + for (tree_va_return_list::iterator p = vr_list->begin (); + p != vr_list->end (); + p++) { - retval(i) = vr_list->operator () (p); - i++; + retval(i++) = *p; } } @@ -169,9 +163,9 @@ { bool status = true; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_identifier *elt = lst (p); + tree_identifier *elt = *p; if (! elt->is_defined ()) { @@ -193,10 +187,11 @@ tree_return_list::~tree_return_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_index_expression *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } }
--- a/src/pt-misc.h +++ b/src/pt-misc.h @@ -27,8 +27,6 @@ #pragma interface #endif -#include <SLList.h> - class octave_value; class octave_value_list; @@ -38,36 +36,25 @@ class tree_walker; +#include "base-list.h" + // Parameter lists. Used to hold the list of input and output // parameters in a function definition. Elements are identifiers // only. class -tree_parameter_list +tree_parameter_list : public octave_base_list<tree_identifier *> { public: tree_parameter_list (void) - : lst (), marked_for_varargs (0) { } + : marked_for_varargs (0) { } tree_parameter_list (tree_identifier *t) - : lst (), marked_for_varargs (0) { lst.append (t); } + : marked_for_varargs (0) { append (t); } ~tree_parameter_list (void); - int length (void) const { return lst.length (); } - - void append (tree_identifier *&s) { lst.append (s); } - void append (tree_identifier * const &s) { lst.append (s); } - - tree_identifier *&operator () (Pix p) { return lst (p); } - - tree_identifier * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void mark_as_formal_parameters (void); void mark_varargs (void) { marked_for_varargs = 1; } @@ -82,7 +69,7 @@ void define_from_arg_vector (const octave_value_list& args); - void clear (void); + void undefine (void); bool is_defined (void); @@ -92,9 +79,6 @@ private: - // The list of identifiers in the parameter list. - SLList<tree_identifier *> lst; - int marked_for_varargs; // No copying! @@ -108,36 +92,20 @@ // assignment expressions. class -tree_return_list +tree_return_list : public octave_base_list<tree_index_expression *> { public: - tree_return_list (void) - : lst () { } + tree_return_list (void) { } - tree_return_list (tree_index_expression *t) - : lst () { lst.append (t); } + tree_return_list (tree_index_expression *t) { append (t); } ~tree_return_list (void); - void append (tree_index_expression *&s) { lst.append (s); } - void append (tree_index_expression * const &s) { lst.append (s); } - - tree_index_expression *&operator () (Pix p) { return lst (p); } - - tree_index_expression * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void accept (tree_walker& tw); private: - // The list of expressions in the return list. - SLList<tree_index_expression *> lst; - // No copying! tree_return_list (const tree_return_list&); @@ -146,36 +114,16 @@ }; class -tree_va_return_list +tree_va_return_list : public octave_base_list<octave_value> { public: - tree_va_return_list (void) : lst () { } + tree_va_return_list (void) { } ~tree_va_return_list (void) { } - int length (void) const { return lst.length (); } - - void clear (void) { lst.clear (); } - - int empty (void) const { return lst.empty (); } - - void append (octave_value& s) { lst.append (s); } - void append (const octave_value& s) { lst.append (s); } - - octave_value& operator () (Pix p) { return lst (p); } - - const octave_value& operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - private: - // The list of values in the va return list. - SLList<octave_value> lst; - // No copying! tree_va_return_list (const tree_va_return_list&);
--- a/src/pt-plot.cc +++ b/src/pt-plot.cc @@ -815,27 +815,18 @@ tw.visit_subplot (*this); } -subplot_list::~subplot_list (void) -{ - while (! lst.empty ()) - { - subplot *t = lst.remove_front (); - delete t; - } -} - int subplot_list::print (int ndim, OSSTREAM& plot_buf) { int status = 0; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - subplot *elt = lst (p); + subplot *elt = *p; plot_line_count++; - if (p != first ()) + if (p != begin ()) plot_buf << ",\\\n "; status = elt->print (ndim, plot_buf);
--- a/src/pt-plot.h +++ b/src/pt-plot.h @@ -45,10 +45,9 @@ #include <string> -#include <SLList.h> - #include "dColVector.h" +#include "base-list.h" #include "pt-cmd.h" class @@ -396,28 +395,23 @@ }; class -subplot_list +subplot_list : public octave_base_list<subplot *> { public: - subplot_list (void) - : lst () { } + subplot_list (void) { } - subplot_list (subplot *t) - : lst () { lst.append (t); } - - ~subplot_list (void); + subplot_list (subplot *t) { append (t); } - void append (subplot *&s) { lst.append (s); } - void append (subplot * const &s) { lst.append (s); } - - subplot *&operator () (Pix p) { return lst (p); } - - subplot * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } + ~subplot_list (void) + { + while (! empty ()) + { + iterator p = begin (); + delete *p; + erase (p); + } + } int print (int ndim, OSSTREAM& plot_buf); @@ -425,9 +419,6 @@ private: - // The list of subplot commands. - SLList<subplot *> lst; - // No copying! subplot_list (const subplot_list&);
--- a/src/pt-pr-code.cc +++ b/src/pt-pr-code.cc @@ -41,19 +41,17 @@ void tree_print_code::visit_argument_list (tree_argument_list& lst) { - Pix p = lst.first (); + tree_argument_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_expression *elt = lst (p); - - lst.next (p); + tree_expression *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -164,19 +162,17 @@ void tree_print_code::visit_decl_init_list (tree_decl_init_list& lst) { - Pix p = lst.first (); + tree_decl_init_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_decl_elt *elt = lst (p); - - lst.next (p); + tree_decl_elt *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -436,13 +432,13 @@ void tree_print_code::visit_if_command_list (tree_if_command_list& lst) { - Pix p = lst.first (); + tree_if_command_list::iterator p = lst.begin (); bool first_elt = true; - while (p) + while (p != lst.end ()) { - tree_if_clause *elt = lst (p); + tree_if_clause *elt = *p++; if (elt) { @@ -462,7 +458,6 @@ } first_elt = false; - lst.next (p); } } @@ -484,14 +479,14 @@ expr_has_parens = e->is_postfix_indexed (); } - SLList<tree_argument_list *> arg_lists = expr.arg_lists (); + std::list<tree_argument_list *> arg_lists = expr.arg_lists (); std::string type_tags = expr.type_tags (); - SLList<string_vector> arg_names = expr.arg_names (); + std::list<string_vector> arg_names = expr.arg_names (); int n = type_tags.length (); - Pix arg_lists_p = arg_lists.first (); - Pix arg_names_p = arg_names.first (); + std::list<tree_argument_list *>::iterator p_arg_lists = arg_lists.begin (); + std::list<string_vector>::iterator p_arg_names = arg_names.begin (); for (int i = 0; i < n; i++) { @@ -500,7 +495,7 @@ case '(': { os << " ("; - tree_argument_list *l = arg_lists (arg_lists_p); + tree_argument_list *l = *p_arg_lists; if (l) l->accept (*this); os << ")"; @@ -510,7 +505,7 @@ case '{': { os << " {"; - tree_argument_list *l = arg_lists (arg_lists_p); + tree_argument_list *l = *p_arg_lists; if (l) l->accept (*this); os << "}"; @@ -519,7 +514,7 @@ case '.': { - string_vector nm = arg_names (arg_names_p); + string_vector nm = *p_arg_names; assert (nm.length () == 1); os << "." << nm(0); } @@ -529,8 +524,8 @@ panic_impossible (); } - arg_lists.next (arg_lists_p); - arg_names.next (arg_names_p); + p_arg_lists++; + p_arg_names++; } print_parens (expr, ")"); @@ -545,19 +540,17 @@ os << "["; - Pix p = lst.first (); + tree_matrix::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); - - lst.next (p); + tree_argument_list *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << "; "; } } @@ -576,19 +569,17 @@ os << "{"; - Pix p = lst.first (); + tree_cell::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_argument_list *elt = lst (p); - - lst.next (p); + tree_argument_list *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << "; "; } } @@ -653,19 +644,17 @@ void tree_print_code::visit_parameter_list (tree_parameter_list& lst) { - Pix p = lst.first (); + tree_parameter_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_identifier *elt = lst (p); - - lst.next (p); + tree_identifier *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -792,19 +781,17 @@ void tree_print_code::visit_return_list (tree_return_list& lst) { - Pix p = lst.first (); + tree_return_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_index_expression *elt = lst (p); - - lst.next (p); + tree_index_expression *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ", "; } } @@ -867,9 +854,9 @@ void tree_print_code::visit_statement_list (tree_statement_list& lst) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (tree_statement_list::iterator p = lst.begin (); p != lst.end (); p++) { - tree_statement *elt = lst (p); + tree_statement *elt = *p; if (elt) elt->accept (*this); @@ -918,19 +905,17 @@ void tree_print_code::visit_subplot_list (subplot_list& lst) { - Pix p = lst.first (); + subplot_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - subplot *elt = lst (p); - - lst.next (p); + subplot *elt = *p++; if (elt) { elt->accept (*this); - if (p) + if (p != lst.end ()) os << ","; } } @@ -1025,16 +1010,14 @@ void tree_print_code::visit_switch_case_list (tree_switch_case_list& lst) { - Pix p = lst.first (); + tree_switch_case_list::iterator p = lst.begin (); - while (p) + while (p != lst.end ()) { - tree_switch_case *elt = lst (p); + tree_switch_case *elt = *p++; if (elt) elt->accept (*this); - - lst.next (p); } } @@ -1347,17 +1330,15 @@ { if (comment_list) { - Pix p = comment_list->first (); + octave_comment_list::iterator p = comment_list->begin (); - while (p) + while (p != comment_list->end ()) { - octave_comment_elt elt = comment_list->operator () (p); + octave_comment_elt elt = *p++; print_comment_elt (elt); - comment_list->next (p); - - if (p) + if (p != comment_list->end ()) newline (); } }
--- a/src/pt-select.cc +++ b/src/pt-select.cc @@ -73,9 +73,9 @@ void tree_if_command_list::eval (void) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_if_clause *t = lst (p); + tree_if_clause *t = *p; if (t->eval () || error_state) break; @@ -230,9 +230,9 @@ void tree_switch_case_list::eval (const octave_value& val) { - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_switch_case *t = lst (p); + tree_switch_case *t = *p; if (t->eval (val) || error_state) break;
--- a/src/pt-select.h +++ b/src/pt-select.h @@ -27,13 +27,12 @@ #pragma interface #endif -#include <SLList.h> - class expression; class tree_statement_list; class tree_walker; +#include "base-list.h" #include "comment-list.h" #include "pt-cmd.h" @@ -88,45 +87,30 @@ }; class -tree_if_command_list +tree_if_command_list : public octave_base_list<tree_if_clause *> { public: - tree_if_command_list (void) - : lst () { } + tree_if_command_list (void) { } - tree_if_command_list (tree_if_clause *t) - : lst () { lst.append (t); } + tree_if_command_list (tree_if_clause *t) { append (t); } ~tree_if_command_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_if_clause *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_if_clause *&s) { lst.append (s); } - void append (tree_if_clause * const &s) { lst.append (s); } - - tree_if_clause *&operator () (Pix p) { return lst (p); } - - tree_if_clause * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void eval (void); void accept (tree_walker& tw); private: - // The list of if/elseif clauses. - SLList<tree_if_clause *> lst; - // No copying! tree_if_command_list (const tree_if_command_list&); @@ -230,45 +214,30 @@ }; class -tree_switch_case_list +tree_switch_case_list : public octave_base_list<tree_switch_case *> { public: - tree_switch_case_list (void) - : lst () { } + tree_switch_case_list (void) { } - tree_switch_case_list (tree_switch_case *t) - : lst () { lst.append (t); } + tree_switch_case_list (tree_switch_case *t) { append (t); } ~tree_switch_case_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_switch_case *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_switch_case *&s) { lst.append (s); } - void append (tree_switch_case * const &s) { lst.append (s); } - - tree_switch_case *&operator () (Pix p) { return lst (p); } - - tree_switch_case * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - void eval (const octave_value& val); void accept (tree_walker& tw); private: - // The list of switch cases. - SLList<tree_switch_case *> lst; - // No copying! tree_switch_case_list (const tree_switch_case_list&);
--- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -28,8 +28,6 @@ #include <config.h> #endif -#include <SLList.h> - #include "quit.h" #include "defun.h" @@ -159,9 +157,9 @@ if (error_state) return retval; - for (Pix p = lst.first (); p != 0; lst.next (p)) + for (iterator p = begin (); p != end (); p++) { - tree_statement *elt = lst (p); + tree_statement *elt = *p; if (elt) {
--- a/src/pt-stmt.h +++ b/src/pt-stmt.h @@ -27,8 +27,6 @@ #pragma interface #endif -#include <SLList.h> - class octave_value_list; class tree_command; @@ -36,6 +34,7 @@ class tree_walker; +#include "base-list.h" #include "comment-list.h" // A statement is either a command to execute or an expression to @@ -105,42 +104,26 @@ // A list of statements to evaluate. class -tree_statement_list +tree_statement_list : public octave_base_list<tree_statement *> { public: tree_statement_list (void) - : lst (), function_body (false) { } + : function_body (false) { } tree_statement_list (tree_statement *s) - : lst (), function_body (false) { lst.append (s); } + : function_body (false) { append (s); } ~tree_statement_list (void) { - while (! lst.empty ()) + while (! empty ()) { - tree_statement *t = lst.remove_front (); - delete t; + iterator p = begin (); + delete *p; + erase (p); } } - void append (tree_statement *&s) { lst.append (s); } - void append (tree_statement * const &s) { lst.append (s); } - - tree_statement *&operator () (Pix p) { return lst (p); } - - tree_statement * const &operator () (Pix p) const { return lst (p); } - - Pix first (void) const { return lst.first (); } - - void next (Pix& p) const { return lst.next (p); } - - tree_statement *front (void) { return lst.front (); } - tree_statement *rear (void) { return lst.rear (); } - - const tree_statement *front (void) const { return lst.front (); } - const tree_statement *rear (void) const { return lst.rear (); } - void mark_as_function_body (void) { function_body = true; } octave_value_list eval (bool silent = false, int nargout = 0); @@ -155,9 +138,6 @@ private: - // List of statements to evaluate. - SLList<tree_statement *> lst; - // Does this list of statements make up the body of a function? bool function_body;