next up previous contents
Next: Creating ppufiles Up: Anatomy of a unit Previous: The Header

The sections

After this header follow the sections. All sections work the same! A section contains of entries and is ended with also an entry, but containing the specific ibend constant (see ppu.pas for a list).

Each entry starts with an entryheader.

  tppuentry=packed record                                                       
    id   : byte;                                                                
    nr   : byte;                                                                
    size : longint;                                                             
  end;

field Description
id this is 1 or 2 and can be check if it the entry is correctly found. 1 means its a main entry, which says that it is part of the basic layout as explained before. 2 toggles that it it a sub entry of a record or object
nr contains the ib constant number which determines what kind of entry it is
size size of this entry without the header, can be used to skip entries very easily.

To read an entry you can simply call ppufile.readentry:byte, it returns the tppuentry.nr field, which holds the type of the entry. A common way how this works is (example is for the symbols):

  repeat
    b:=ppufile.readentry;
    case b of
   ib<etc> : begin
             end;
 ibendsyms : break;
    end;
  until false;

Then you can parse each entry type yourself. ppufile.readentry will take care of skipping unread bytes in the entry an read the next entry correctly! A special function is skipuntilentry(untilb:byte):boolean; which will read the ppufile until it finds entry untilb in the main entries.

Parsing an entry can be done with ppufile.getxxx functions. The available functions are:

procedure ppufile.getdata(var b;len:longint);
function  getbyte:byte;                                                     
function  getword:word;                                                     
function  getlongint:longint;                                               
function  getreal:ppureal;                                                  
function  getstring:string;

To check if you're at the end of an entry you can use the following function:

function  EndOfEntry:boolean;
notes:
  1. ppureal is the best real that exists for the cpu where the unit is created for. Currently it is extended for i386 and single for m68k.
  2. the ibobjectdef and ibrecorddef have stored a definition and symbol section for themselves. So you'll need a recursive call. See ppudump.pp for a correct implementation.

A complete list of entries and what their fields contain can be found in ppudump.pp.


next up previous contents
Next: Creating ppufiles Up: Anatomy of a unit Previous: The Header

Michael Van Canneyt
Thu Sep 10 14:04:11 CEST 1998