Annotation of sbbs/javascript/include/mozilla/js/jsclist.h, revision 1.1.1.1

1.1       root        1: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
                      2: /*
                      3:  * The contents of this file are subject to the Netscape Public
                      4:  * License Version 1.1 (the "License"); you may not use this file
                      5:  * except in compliance with the License. You may obtain a copy of
                      6:  * the License at http://www.mozilla.org/NPL/
                      7:  *
                      8:  * Software distributed under the License is distributed on an "AS
                      9:  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
                     10:  * implied. See the License for the specific language governing
                     11:  * rights and limitations under the License.
                     12:  *
                     13:  * The Original Code is Mozilla Communicator client code, released
                     14:  * March 31, 1998.
                     15:  *
                     16:  * The Initial Developer of the Original Code is Netscape
                     17:  * Communications Corporation.  Portions created by Netscape are
                     18:  * Copyright (C) 1998 Netscape Communications Corporation. All
                     19:  * Rights Reserved.
                     20:  *
                     21:  * Contributor(s): 
                     22:  *
                     23:  * Alternatively, the contents of this file may be used under the
                     24:  * terms of the GNU Public License (the "GPL"), in which case the
                     25:  * provisions of the GPL are applicable instead of those above.
                     26:  * If you wish to allow use of your version of this file only
                     27:  * under the terms of the GPL and not to allow others to use your
                     28:  * version of this file under the NPL, indicate your decision by
                     29:  * deleting the provisions above and replace them with the notice
                     30:  * and other provisions required by the GPL.  If you do not delete
                     31:  * the provisions above, a recipient may use your version of this
                     32:  * file under either the NPL or the GPL.
                     33:  */
                     34: 
                     35: #ifndef jsclist_h___
                     36: #define jsclist_h___
                     37: 
                     38: #include "jstypes.h"
                     39: 
                     40: /*
                     41: ** Circular linked list
                     42: */
                     43: typedef struct JSCListStr {
                     44:     struct JSCListStr *next;
                     45:     struct JSCListStr *prev;
                     46: } JSCList;
                     47: 
                     48: /*
                     49: ** Insert element "_e" into the list, before "_l".
                     50: */
                     51: #define JS_INSERT_BEFORE(_e,_l)     \
                     52:     JS_BEGIN_MACRO      \
                     53:    (_e)->next = (_l);   \
                     54:    (_e)->prev = (_l)->prev; \
                     55:    (_l)->prev->next = (_e); \
                     56:    (_l)->prev = (_e);   \
                     57:     JS_END_MACRO
                     58: 
                     59: /*
                     60: ** Insert element "_e" into the list, after "_l".
                     61: */
                     62: #define JS_INSERT_AFTER(_e,_l)  \
                     63:     JS_BEGIN_MACRO      \
                     64:    (_e)->next = (_l)->next; \
                     65:    (_e)->prev = (_l);   \
                     66:    (_l)->next->prev = (_e); \
                     67:    (_l)->next = (_e);   \
                     68:     JS_END_MACRO
                     69: 
                     70: /*
                     71: ** Return the element following element "_e"
                     72: */
                     73: #define JS_NEXT_LINK(_e)    \
                     74:        ((_e)->next)
                     75: /*
                     76: ** Return the element preceding element "_e"
                     77: */
                     78: #define JS_PREV_LINK(_e)    \
                     79:        ((_e)->prev)
                     80: 
                     81: /*
                     82: ** Append an element "_e" to the end of the list "_l"
                     83: */
                     84: #define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l)
                     85: 
                     86: /*
                     87: ** Insert an element "_e" at the head of the list "_l"
                     88: */
                     89: #define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l)
                     90: 
                     91: /* Return the head/tail of the list */
                     92: #define JS_LIST_HEAD(_l) (_l)->next
                     93: #define JS_LIST_TAIL(_l) (_l)->prev
                     94: 
                     95: /*
                     96: ** Remove the element "_e" from it's circular list.
                     97: */
                     98: #define JS_REMOVE_LINK(_e)        \
                     99:     JS_BEGIN_MACRO            \
                    100:    (_e)->prev->next = (_e)->next; \
                    101:    (_e)->next->prev = (_e)->prev; \
                    102:     JS_END_MACRO
                    103: 
                    104: /*
                    105: ** Remove the element "_e" from it's circular list. Also initializes the
                    106: ** linkage.
                    107: */
                    108: #define JS_REMOVE_AND_INIT_LINK(_e)    \
                    109:     JS_BEGIN_MACRO            \
                    110:    (_e)->prev->next = (_e)->next; \
                    111:    (_e)->next->prev = (_e)->prev; \
                    112:    (_e)->next = (_e);         \
                    113:    (_e)->prev = (_e);         \
                    114:     JS_END_MACRO
                    115: 
                    116: /*
                    117: ** Return non-zero if the given circular list "_l" is empty, zero if the
                    118: ** circular list is not empty
                    119: */
                    120: #define JS_CLIST_IS_EMPTY(_l) \
                    121:     ((_l)->next == (_l))
                    122: 
                    123: /*
                    124: ** Initialize a circular list
                    125: */
                    126: #define JS_INIT_CLIST(_l)  \
                    127:     JS_BEGIN_MACRO    \
                    128:    (_l)->next = (_l); \
                    129:    (_l)->prev = (_l); \
                    130:     JS_END_MACRO
                    131: 
                    132: #define JS_INIT_STATIC_CLIST(_l) \
                    133:     {(_l), (_l)}
                    134: 
                    135: #endif /* jsclist_h___ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.