# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


import progSpec
import codeDogParser
import pattern_GenSymbols
from progSpec import cdlog, cdErr
                classesToProcess.append(structTypeName)
        if(fldCat=='struct'):
            S="    "+'SRet_ <- SRet_ + indent + dispFieldAsText("'+label+'", 15) + "\\n"\n    SRet_ <- SRet_ + '+valStr+'+ "\\n"\n'
        else:
            ender=''
            starter=''
            if(fldCat=='flag' or fldCat=='bool'):
                starter = 'if('+fieldName+'){'
                ender = '}'
            elif(fldCat=='int' or fldCat=='double'):
                starter = 'if('+fieldName+'!=0){'
                ender = '}'
            S="    "+starter+'SRet_ <- SRet_ + indent + dispFieldAsText("'+label+'", 15) + '+valStr+' + "\\n"\n'+ender
        return S

    def processField(self, fieldName, field, fldCat):
        S=""
        itemName = '_'+fieldName+'_item'
        if fldCat=='func': return ''
        typeSpec=field['typeSpec']
        if progSpec.isAContainer(typeSpec):
            if(progSpec.getDatastructID(typeSpec) == "list"):
                innerFieldType=progSpec.getFieldType(typeSpec)
                #print "ARRAYSPEC:",innerFieldType, field
                fldCatInner=progSpec.innerTypeCategory(innerFieldType)
                itemName = '_'+fieldName+'_item'
                calcdName=fieldName+'["+toString('+itemName+'_key)+"]'
                S+="    withEach "+itemName+" in "+fieldName+"{\n"
                S+="        "+self.displayTextFieldAction(calcdName, itemName, field, fldCatInner)+"    }\n"
            else:

# Path: progSpec.py
# def cdlog(lvl, mesg):
#     global MaxLogLevelToShow
#     global lastLogMesgs
#     global highestLvl
#     highestLvl=lvl
#     resizeLogArray(lvl)
#     lastLogMesgs[lvl]=mesg
#     for i in range(highestLvl+1, len(lastLogMesgs)):
#         lastLogMesgs[i]=''
#     if(lvl<=MaxLogLevelToShow):
#         if(lvl==0): print('')
#         printAtLvl(lvl, mesg, '|    ')
# 
# def cdErr(mesg):
#     global lastLogMesgs
#     global highestLvl
#     highestLvl+=1
#     lastLogMesgs[highestLvl]="\n\nError: "+mesg
#     exit(1)


# Path: pattern_DispData.py
import progSpec
import codeDogParser
import pattern_GenSymbols
from progSpec import cdlog, cdErr

                classesToProcess.append(structTypeName)
        if(fldCat=='struct'):
            S="    "+'SRet_ <- SRet_ + indent + dispFieldAsText("'+label+'", 15) + "\\n"\n    SRet_ <- SRet_ + '+valStr+'+ "\\n"\n'
        else:
            ender=''
            starter=''
            if(fldCat=='flag' or fldCat=='bool'):
                starter = 'if('+fieldName+'){'
                ender = '}'
            elif(fldCat=='int' or fldCat=='double'):
                starter = 'if('+fieldName+'!=0){'
                ender = '}'
            S="    "+starter+'SRet_ <- SRet_ + indent + dispFieldAsText("'+label+'", 15) + '+valStr+' + "\\n"\n'+ender
        return S

    def processField(self, fieldName, field, fldCat):
        S=""
        itemName = '_'+fieldName+'_item'
        if fldCat=='func': return ''
        typeSpec=field['typeSpec']
        if progSpec.isAContainer(typeSpec):
            if(progSpec.getDatastructID(typeSpec) == "list"):
                innerFieldType=progSpec.getFieldType(typeSpec)
                #print "ARRAYSPEC:",innerFieldType, field
                fldCatInner=progSpec.innerTypeCategory(innerFieldType)
                itemName = '_'+fieldName+'_item'
                calcdName=fieldName+'["+toString('+itemName+'_key)+"]'
                S+="    withEach "+itemName+" in "+fieldName+"{\n"
                S+="        "+self.displayTextFieldAction(calcdName, itemName, field, fldCatInner)+"    }\n"
            else:

                cdlog(2, "Map not supported")