//====START_GENERATED_PROLOG======================================
//
//
//   COMPONENT_NAME: odutils
//
//   CLASSES: none
//
//   ORIGINS: 81,82,27
//
//
//   (C) COPYRIGHT International Business Machines Corp. 1995,1996
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//   	
//   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
//   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
//   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
//   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
//   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
//   OR PERFORMANCE OF THIS SOFTWARE.
//
//====END_GENERATED_PROLOG========================================
//
// @(#) 1.2 nt/src/utils/tpllitr.cpp, odutils, od96nt, odnt9712d 11/1/96 19:08:07 [ 3/21/97 17:37:36 ]
//
//   Copyright © 1988 Apple Computer, Inc. All rights reserved.

/* WIN16PORT ADD3 */
#ifdef _WIN16
#pragma data_seg("_DATA")
#endif


#define somf_TPrimitiveLinkedListIterator_Class_Source
#include "tpllitr.xih"

/* Defines to take the place of PrimitiveTypes.h */
#define SOMF_NIL 0
#define Boolean boolean
#include "tpll.fnd"

/*
 * -- Original Instance Data (this is a comment -- actual defn in TPLLItr.xih)
 */
/*
typedef struct {
	somf_TPrimitiveLinkedList *fList;
	somf_MLinkable *fCurrent;
	somf_MLinkable *fSentinel;
} somf_TPrimitiveLinkedListIteratorData;
*/

/*
 * -- Method Procedures for somf_TPrimitiveLinkedListIterator
 */

/*
 *  There is no such thing as a constructor in SOM, the closest thing is
 *  somInit, which doesn't take arguments.  This means the following
 *  initialization can not be done through a SOM constructor.  Create an
 *  instance of the somf_TPrimitiveLinkedListIterator class, and call
 *  somfTPrimitiveLinkedListIteratorInit to initialize it.
 *
 *    somf_TPrimitiveLinkedListIterator(somf_TPrimitiveLinkedList* list);
 */

/*
 *  Initialize somf_TPrimitiveLinkedListIterator using somf_TPrimitiveLinkedList list.
 */


/*
 * SOM_Scope somf_TPrimitiveLinkedListIterator *  SOMLINK somfTPrimitiveLinkedListIteratorInit(somf_TPrimitiveLinkedListIterator *somSelf,
 *              somf_TPrimitiveLinkedList *list)
 */

/*
 * The prototype for somfTPrimitiveLinkedListIteratorInit was replaced by the following prototype:
 */
SOM_Scope somf_TPrimitiveLinkedListIterator*  SOMLINK somfTPrimitiveLinkedListIteratorInit(somf_TPrimitiveLinkedListIterator *somSelf, Environment *ev,
		somf_TPrimitiveLinkedList* list)
{
    somf_TPrimitiveLinkedListIteratorData *somThis = somf_TPrimitiveLinkedListIteratorGetData(somSelf);
    somf_TPrimitiveLinkedListData *listPtr = somf_TPrimitiveLinkedListGetData(list);
    somf_TPrimitiveLinkedListIteratorMethodDebug("somf_TPrimitiveLinkedListIterator","somfTPrimitiveLinkedListIteratorInit");

   somThis->fList = list;
   somThis->fCurrent = SOMF_NIL;
   somThis->fSentinel = listPtr->fSentinel;

    return (somSelf);
}

/*
 *  This is the closest SOM has to a destructor, the original pink reference
 *  is below:
 *    ~somf_TPrimitiveLinkedListIterator();
 */

SOM_Scope void   SOMLINK somUninit(somf_TPrimitiveLinkedListIterator *somSelf)
{
    somf_TPrimitiveLinkedListIteratorData *somThis = somf_TPrimitiveLinkedListIteratorGetData(somSelf);
    somf_TPrimitiveLinkedListIteratorMethodDebug("somf_TPrimitiveLinkedListIterator","somUninit");

    parent_SOMObject_somUninit(somSelf);
}

/*
 *    somf_MLinkable* somfFirst();
 */

/*
 *  Reset the iterator and return the first element of the list.
 */


/*
 * SOM_Scope somf_MLinkable *  SOMLINK somfFirst(somf_TPrimitiveLinkedListIterator *somSelf)
 */

/*
 * The prototype for somfFirst was replaced by the following prototype:
 */
SOM_Scope somf_MLinkable*  SOMLINK somfFirst(somf_TPrimitiveLinkedListIterator *somSelf, Environment *ev)
{
    somf_TPrimitiveLinkedListIteratorData *somThis = somf_TPrimitiveLinkedListIteratorGetData(somSelf);
    somf_TPrimitiveLinkedListIteratorMethodDebug("somf_TPrimitiveLinkedListIterator","somfFirst");

   somThis->fCurrent = (somThis->fList)->somfFirst(ev);
   if (somThis->fCurrent == somThis->fSentinel)
      somThis->fCurrent = SOMF_NIL;
   return somThis->fCurrent;
}

/*
 *    somf_MLinkable* somfNext();
 */

/*
 *  Retrieve the next object in the list and return it.
 */


/*
 * SOM_Scope somf_MLinkable *  SOMLINK somfNext(somf_TPrimitiveLinkedListIterator *somSelf)
 */

/*
 * The prototype for somfNext was replaced by the following prototype:
 */
SOM_Scope somf_MLinkable*  SOMLINK somfNext(somf_TPrimitiveLinkedListIterator *somSelf, Environment *ev)
{
    somf_TPrimitiveLinkedListIteratorData *somThis = somf_TPrimitiveLinkedListIteratorGetData(somSelf);
    somf_TPrimitiveLinkedListIteratorMethodDebug("somf_TPrimitiveLinkedListIterator","somfNext");

   if (somThis->fCurrent)
      somThis->fCurrent = (somThis->fCurrent)->somfGetNext(ev);
   if (somThis->fCurrent == somThis->fSentinel)
      somThis->fCurrent = SOMF_NIL;
   return somThis->fCurrent;
}

/*
 *    somf_MLinkable* somfLast();
 */

/*
 *  Retrieve the last object in the list and return it.
 */


/*
 * SOM_Scope somf_MLinkable *  SOMLINK somfLast(somf_TPrimitiveLinkedListIterator *somSelf)
 */

/*
 * The prototype for somfLast was replaced by the following prototype:
 */
SOM_Scope somf_MLinkable*  SOMLINK somfLast(somf_TPrimitiveLinkedListIterator *somSelf, Environment *ev)
{
    somf_TPrimitiveLinkedListIteratorData *somThis = somf_TPrimitiveLinkedListIteratorGetData(somSelf);
    somf_TPrimitiveLinkedListIteratorMethodDebug("somf_TPrimitiveLinkedListIterator","somfLast");

   somThis->fCurrent = (somThis->fList)->somfLast(ev);
   if (somThis->fCurrent == somThis->fSentinel)
      somThis->fCurrent = SOMF_NIL;
   return somThis->fCurrent;
}

/*
 *    somf_MLinkable* somfPrevious();
 */

/*
 *  Retrieve the previous object in the list and return it.
 */


/*
 * SOM_Scope somf_MLinkable *  SOMLINK somfPrevious(somf_TPrimitiveLinkedListIterator *somSelf)
 */

/*
 * The prototype for somfPrevious was replaced by the following prototype:
 */
SOM_Scope somf_MLinkable*  SOMLINK somfPrevious(somf_TPrimitiveLinkedListIterator *somSelf, Environment *ev)
{
    somf_TPrimitiveLinkedListIteratorData *somThis = somf_TPrimitiveLinkedListIteratorGetData(somSelf);
    somf_TPrimitiveLinkedListIteratorMethodDebug("somf_TPrimitiveLinkedListIterator","somfPrevious");

   if (somThis->fCurrent)
      somThis->fCurrent = (somThis->fCurrent)->somfGetPrevious(ev);
   if (somThis->fCurrent == somThis->fSentinel)
      somThis->fCurrent = SOMF_NIL;
   return somThis->fCurrent;
//    return (somf_MLinkable*) 0;
}
