#include "llistdic.h"
#include "iterator.h"

@implementation WDCLListOfDictionary

- forward:(SEL)aSel : (arglist_t)argFrame
{
  id currentid, iter, retval;
  if ([[self getContent] respondsTo:aSel])
    {
      iter=[[WDCListIterator alloc] initFrom:self];
      [iter goLast];
      if (!(retval=[[[iter getCurrentObject] 
		     getContent] performv:aSel :argFrame]))
	/* there is problem with the return value from the forwarding
	   mechanism.
	   */
	{
	  while ([iter goPrevious])
	    if (retval=[[[iter getCurrentObject] 
			 getContent] performv:aSel :argFrame])
	      break;
	}
      [iter free]; // **
    }
  else
    [self error:"Content does not responds to forwarding message"];
  return retval;
}


- getDefinitionBlockAtKey:(const char*)aName
{
  id currentid, iter, retval;
  if ([[self getContent] respondsTo:@selector(getDefinitionBlockAtKey:)])
    {
      iter=[[WDCListIterator alloc] initFrom:self];
      [iter goLast];
      if (!(retval=[[[iter getCurrentObject] 
		     getContent] getDefinitionBlockAtKey:aName]))
	{
	  while ([iter goPrevious])
	    if (retval=[[[iter getCurrentObject] 
			 getContent] getDefinitionBlockAtKey:aName])
	      break;
	}
      [iter free];
    }
  else
    [self error:"Content does not responds to forwarding message"];
  return retval;
}

@end

