/***************************************************************************
 *   Copyright (C) 2009 by Juergen Thies                                   *
 *   layout@juergenthies.de                                                *
 *                                                                         *
 ***************************************************************************/
#include "schematic/schematic.h"
#include "schematic/sheetlist.h"


void macro::sheetListHandler_registerKeywords(keywords **keyword_){
  *keyword_= new keywords(*keyword_);
 (*keyword_)->keyword="sheetList";
 (*keyword_)->type=type;
 (*keyword_)->typeHandler=&macro::sheetListHandler_typeHandler;
}

void macro::sheetListHandler_typeHandler(int *counter,keywords **keyword_,bool single){
generalTypeProcessing(counter,keyword_,ptrSheetList,ptrSheetList,single);
}

returnValue macro::sheetListHandler_classHandler(int *counter, keywords *keyword_,returnValue* r,bool left){
 QString s;
 returnValue ret;
 parserValue p;
 if (r->type==ptrSheetList){
   if (checkClassPointer(counter)) {
   }
   else { 
   	if (left) { compute(r,counter,keyword_);return ret;}
     	else return *r;
	}
   }
 sheetList *l= r->getSheetList();
 p=next(counter);
;
 // variables
 if ((p.type==keyword)&&(p.value=="thisSheet")){
 		returnValue r2;
		r2.setType(ptrSheet);
		r2.deleteAfter=false;
		r2.Sheet=(l->thisSheet);
		r2=sheetHandler_classHandler(counter,keyword_,&r2,left);
		return r2;
 	}
 else if ((p.type==keyword)&&(p.value=="nextSheet")){
 		returnValue r2;
		r2.setType(ptrSheetList);
		r2.deleteAfter=false;
		r2.SheetList=(l->nextSheet);
		r2=sheetListHandler_classHandler(counter,keyword_,&r2,left);
		return r2;
 	}
 else {
  	error->addItem(tr("Class sheetList has no member ")+p.value,1,message((*counter)));
	throw 1;
 	}
 if (left)  if (!checkSemicolon(counter)) {throw 15;}  
 return ret;
}

