Example #1
0
inline void dfunction_t::Archive( Archiver &arc )
{
    Class::Archive( arc );

    arc.ArchiveInteger( &eventnum );
    arc.ArchiveInteger( &first_statement );
    arc.ArchiveInteger( &parm_start );
    arc.ArchiveInteger( &parm_total );
    arc.ArchiveInteger( &locals );

    arc.ArchiveInteger( &profile );

    arc.ArchiveString( &s_name );
    arc.ArchiveString( &s_file );

    arc.ArchiveInteger( &numparms );
    arc.ArchiveInteger( &minparms );

    if ( arc.Loading() )
    {
        memset( &parm_size, 0, sizeof( parm_size[0] ) * MAX_PARMS );
        memset( &parm_type, 0, sizeof( parm_type[0] ) * MAX_PARMS );
    }

    arc.ArchiveRaw( parm_size, sizeof( parm_size[0] ) * numparms );
    arc.ArchiveRaw( parm_type, sizeof( parm_type[0] ) * numparms );
}
Example #2
0
inline void Program::Archive( Archiver &arc )
{
    int i, num;
    type_t *curtype, *newtype;
    def_t *curdef, *newdef;

    Class::Archive( arc );

    /* // Force all of the defs to have indexes

    forceDefSave = &def_void;
    arc.ArchiveObjectPointer( ( Class ** )&forceDefSave );
    forceDefSave = &def_string;
    arc.ArchiveObjectPointer( ( Class ** )&forceDefSave );
    forceDefSave = &def_float;
    arc.ArchiveObjectPointer( ( Class ** )&forceDefSave );
    forceDefSave = &def_vector;
    arc.ArchiveObjectPointer( ( Class ** )&forceDefSave );
    forceDefSave = &def_entity;
    arc.ArchiveObjectPointer( ( Class ** )&forceDefSave );
    forceDefSave = &def_function;
    arc.ArchiveObjectPointer( ( Class ** )&forceDefSave );

    // Force all of the types to have indexes

    forceTypeSave = &type_void;
    arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave );
    forceTypeSave = &type_string;
    arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave );
    forceTypeSave = &type_float;
    arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave );
    forceTypeSave = &type_vector;
    arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave );
    forceTypeSave = &type_entity;
    arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave );
    forceTypeSave = &type_function;
    arc.ArchiveObjectPointer( ( Class ** )&forceTypeSave ); */

    // NOTE: must archive global data for pointer fixups
    arc.ArchiveObject( &def_void );
    arc.ArchiveObject( &def_string );
    arc.ArchiveObject( &def_float );
    arc.ArchiveObject( &def_vector );
    arc.ArchiveObject( &def_entity );
    arc.ArchiveObject( &def_function );

    arc.ArchiveObject( &def_ret );
    arc.ArchiveObject( &junkdef );

    arc.ArchiveObject( &type_void );
    arc.ArchiveObject( &type_string );
    arc.ArchiveObject( &type_float );
    arc.ArchiveObject( &type_vector );
    arc.ArchiveObject( &type_entity );
    arc.ArchiveObject( &type_function );

    arc.ArchiveInteger( &numpr_globals );

    if ( arc.Loading() )
    {
        memset( pr_globals, 0, sizeof( pr_globals[0] ) * MAX_REGS );
    }

    arc.ArchiveRaw( pr_globals, sizeof( pr_globals[0] ) * numpr_globals );

    arc.ArchiveInteger( &locals_start );
    arc.ArchiveInteger( &locals_end );

    for ( i = 0; i < MAX_STRINGS; i++ )
    {
        arc.ArchiveBool( &strings[i].inuse );

        if ( strings[i].inuse )
        {
            arc.ArchiveString( &strings[i].s );
        }
        else
        {
            strings[i].s = "";
        }
    }

    arc.ArchiveInteger( &numstatements );
    arc.ArchiveRaw( statements, sizeof( statements[0] ) * numstatements );

    arc.ArchiveInteger( &numfunctions );
    for ( i = 0; i < numfunctions; i++ )
        arc.ArchiveObject( ( Class * )&functions[i] );

    // archive types
    if ( arc.Saving() )
    {
        for ( curtype = types, num = 0; curtype; curtype = curtype->next )
        {
            num++;
        }

        // Don't count type_function

        num--;
    }

    arc.ArchiveInteger( &num );

    if ( arc.Saving() )
    {
        for ( curtype = types; curtype; curtype = curtype->next )
        {
            // Skip type_function (we archive it seperately above)

            if ( curtype == &type_function )
                continue;

            arc.ArchiveObject( ( Class * )curtype );
        }
    }
    else
    {
        curtype = types;

        for ( i = 0; i < num; i++ )
        {
            newtype = new type_t;
            arc.ArchiveObject( ( Class * )newtype );
            newtype->next = NULL;

            curtype->next = newtype;
            curtype = newtype;
        }
    }

    // archive defs
    if ( arc.Saving() ) {
        for ( curdef = def_head.next, num = 0; curdef; curdef = curdef->next )
            num++;
    }

    arc.ArchiveInteger( &num );

    if ( arc.Saving() ) {
        for ( curdef = def_head.next; curdef; curdef = curdef->next )
            arc.ArchiveObject( ( Class * )curdef );
    }
    else {
        def_tail = &def_head;
        curdef = def_tail;

        for ( i = 0; i < num; i++ ) {
            newdef = new def_t;
            arc.ArchiveObject( ( Class * )newdef );
            newdef->next = NULL;

            curdef->next = newdef;
            curdef = newdef;
        }
    }

    arc.ArchiveInteger( &pr_error_count );

    filenames.Archive( arc );
    arc.ArchiveString( &s_file );

    if ( arc.Loading() )
    {
        memset( pr_global_defs, 0, sizeof( pr_global_defs ) );
    }

    for ( i = 0; i < numpr_globals; i++ )
    {
        arc.ArchiveObjectPointer( ( Class ** )&pr_global_defs[i] );
    }
}