list.c File Reference

List Object Type. More...

#include "pm.h"

Defines

#define __FILE_ID__   0x0B

Functions

PmReturn_t list_append (pPmObj_t plist, pPmObj_t pobj)
PmReturn_t list_getItem (pPmObj_t plist, int16_t index, pPmObj_t *r_pobj)
PmReturn_t list_insert (pPmObj_t plist, int16_t index, pPmObj_t pobj)
PmReturn_t list_new (pPmObj_t *r_pobj)
PmReturn_t list_copy (pPmObj_t pobj, pPmObj_t *r_pobj)
PmReturn_t list_replicate (pPmObj_t psrclist, int16_t n, pPmObj_t *r_pnewlist)
PmReturn_t list_setItem (pPmObj_t plist, int16_t index, pPmObj_t pobj)
PmReturn_t list_remove (pPmObj_t plist, pPmObj_t item)
PmReturn_t list_index (pPmObj_t plist, pPmObj_t pitem, uint16_t *r_index)
PmReturn_t list_delItem (pPmObj_t plist, int16_t index)
PmReturn_t list_clear (pPmObj_t plist)


Detailed Description

List Object Type.

List object type operations.


Function Documentation

PmReturn_t list_append ( pPmObj_t  plist,
pPmObj_t  pobj 
)

Appends the given obj to the end of the given list.

Allocate the memory for the node. Do not copy obj, just reuse ptr.

Parameters:
plist Ptr to list
pobj Ptr to item to append
Returns:
Return status

PmReturn_t list_clear ( pPmObj_t  plist  ) 

Removes all items from the list and zeroes the length.

Parameters:
pobj List to clear
Returns:
Return status

PmReturn_t list_copy ( pPmObj_t  pobj,
pPmObj_t r_pobj 
)

Makes a copy of the given list.

Allocate the necessary memory for root and nodes. Duplicate ptrs to objs.

Parameters:
pobj Ptr to source list
r_pobj Return; Addr of ptr to return obj
Returns:
Return status

PmReturn_t list_delItem ( pPmObj_t  plist,
int16_t  index 
)

Removes the item at the given index. Raises a TypeError if the first argument is not a list. Raises an IndexError if the index is out of bounds.

Parameters:
plist Ptr to list obj
index Index of item to remove
Returns:
Return status

PmReturn_t list_getItem ( pPmObj_t  plist,
int16_t  index,
pPmObj_t r_pobj 
)

Gets the object in the list at the index.

Parameters:
pobj Ptr to list obj
index Index into list
r_pobj Return; ptr to return obj
Returns:
Return status

PmReturn_t list_index ( pPmObj_t  plist,
pPmObj_t  pitem,
uint16_t *  r_index 
)

Finds the first index of the item that matches pitem. Returns an ValueError Exception if the item is not found.

Parameters:
plist Ptr to list obj
item Ptr to object to be removed
r_index Addr of the variable for index
Returns:
Return status

PmReturn_t list_insert ( pPmObj_t  plist,
int16_t  index,
pPmObj_t  pobj 
)

Inserts the object into the list at the desired index.

Parameters:
plist Ptr to list obj
pobj Ptr to obj to insert
index Index of where to insert obj
Returns:
Return status

PmReturn_t list_new ( pPmObj_t r_pobj  ) 

Allocates a new List object.

If there is not enough memory to allocate the List, the return status will indicate an OutOfMemoryError that must be passed up to the interpreter. Otherwise, a ptr to the list is returned by reference and the return status is OK.

Parameters:
r_pobj Return; addr of ptr to obj
Returns:
Return status

PmReturn_t list_remove ( pPmObj_t  plist,
pPmObj_t  item 
)

Removes a given object from the list.

Parameters:
plist Ptr to list obj
item Ptr to object to be removed
Returns:
Return status

PmReturn_t list_replicate ( pPmObj_t  psrclist,
int16_t  n,
pPmObj_t r_pnewlist 
)

Creates a new list with the contents of psrclist copied pint number of times. This implements the python code "[0,...] * N" where the list can be any list and N is an integer.

Parameters:
psrclist The source list to replicate
n The integer number of times to replicate it
r_pnewlist Return; new list with its contents set.
Returns:
Return status

PmReturn_t list_setItem ( pPmObj_t  plist,
int16_t  index,
pPmObj_t  pobj 
)

Sets the item in the list at the index.

Parameters:
pobj1 Ptr to list
index Index int
pobj2 Ptr to obj
Returns:
Return status


Generated on Wed Feb 24 13:37:02 2010 for Python-on-a-chip by  doxygen 1.5.9