output.c 4.96 KB
/*====================================================================
 * output.c
 *
 * Synopsis:
 *
 * Copyright 1993, Silicon Graphics, Inc.
 * All Rights Reserved.
 *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics,
 * Inc.; the contents of this file may not be disclosed to third
 * parties, copied or duplicated in any form, in whole or in part,
 * without the prior written permission of Silicon Graphics, Inc.
 *
 * RESTRICTED RIGHTS LEGEND:
 * Use, duplication or disclosure by the Government is subject to
 * restrictions as set forth in subdivision (c)(1)(ii) of the Rights
 * in Technical Data and Computer Software clause at DFARS
 * 252.227-7013, and/or in similar or successor clauses in the FAR,
 * DOD or NASA FAR Supplement. Unpublished - rights reserved under the
 * Copyright Laws of the United States.
 *====================================================================*/

#include "ic.h"

void doPrint()
{
    Node *obj;
    
    for (obj = objectList->head; obj != 0; obj = obj->next) {
        Decl *declptr = obj->data;
        
        switch (declptr->declclass) {
            case (ICBANK):
                bankPrint((ICBank *)declptr);
                break;

            case (ICINST):
                instPrint((ICInst *)declptr);
                
                break;

            case (ICSOUND):
                soundPrint((ICSound *)declptr);
                break;

            case (ICKEYMAP):
                keyPrint((ICKeyMap *)declptr);
                break;

            case (ICWAVE):
                wavePrint((ICWave *)declptr);
                break;

            case (ICLOOP):
                loopPrint((ICLoop *)declptr);
                break;

            case (ICBANKFILE):
                bankfPrint((ICBankFile *)declptr);
                break;
                
            case (ICENVELOPE):
                envPrint((ICEnvelope *)declptr);
                break;
                
            case (ICBOOK):
                bookPrint((ICBook *)declptr);
                break;
                
            default:
                printf("doPrint: unknown declclass\n");
                break;
        }
    }
}

void doWrite(FILE *f)
{
    Node *obj;
    
    for (obj = objectList->head; obj != 0; obj = obj->next) {
        Decl *declptr = obj->data;
        
        switch (declptr->declclass) {
            case (ICBANK):
                bankWrite((ICBank *)declptr, f);
                break;

            case (ICINST):
                instWrite((ICInst *)declptr, f);
                
                break;

            case (ICSOUND):
                soundWrite((ICSound *)declptr, f);
                break;

            case (ICKEYMAP):
                keyWrite((ICKeyMap *)declptr, f);
                break;

            case (ICWAVE):
                waveWrite((ICWave *)declptr, f);
                break;

            case (ICLOOP):
                loopWrite((ICLoop *)declptr, f);
                break;

            case (ICBANKFILE):
                bankfWrite((ICBankFile *)declptr, f);
                break;
                
            case (ICENVELOPE):
                envWrite((ICEnvelope *)declptr, f);
                break;
                
            case (ICBOOK):
                bookWrite((ICBook *)declptr, f);
                break;
                
            default:
                printf("doWrite: unknown declclass\n");
                break;
        }
    }
}

void doLayOut()
{
    Node *obj = objectList->head;
    int curOffset = 0;
    
    /*
     * allocate a list of ids for layout
     */
    for (obj = objectList->head; obj != 0; obj = obj->next) {
        /*
         * allocate offsets in file image. This is a little bit
         * kludgy.
         */
        Decl *decl   = obj->data;
        decl->offset = (void *)curOffset;
        curOffset   += declSize(decl);
    }
    
    for (obj = objectList->head; obj != 0; obj = obj->next) {

        Decl *decl   = obj->data;

        switch (decl->declclass) {
            case (ICBANK):
                bankLayOut((ICBank *)decl);
                break;

            case (ICINST):
                instLayOut((ICInst *)decl);
                break;

            case (ICSOUND):
                soundLayOut((ICSound *)decl);
                break;

            case (ICKEYMAP):
                keyLayOut((ICKeyMap *)decl);
                break;

            case (ICWAVE):
                waveLayOut((ICWave *)decl);
                break;

            case (ICLOOP):
                loopLayOut((ICLoop *)decl);
                break;

            case (ICBANKFILE):
                bankfLayOut((ICBankFile *)decl);
                break;
                
            case (ICENVELOPE):
                envLayOut((ICEnvelope *)decl);
                break;

            case (ICBOOK):
                bookLayOut((ICBook *)decl);
                break;
                
            default:
                printf("doLayOut: unknown declclass\n");
                break;
        }

    }
}