|
@@ -43,467 +43,6 @@ and procedures.
|
|
|
</p>
|
|
|
</descr>
|
|
|
|
|
|
-<topic name="integertypes">
|
|
|
-<short>Integer Types</short>
|
|
|
-<descr>
|
|
|
-<p>
|
|
|
-The following integer types are defined in the System unit:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-Shortint = -128..127;
|
|
|
-SmallInt = -32768..32767;
|
|
|
-Longint = $80000000..$7fffffff;
|
|
|
-byte = 0..255;
|
|
|
-word = 0..65535;
|
|
|
-dword = longword;
|
|
|
-cardinal = longword;
|
|
|
-Integer = smallint;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The following types are used for the functions that need compiler magic
|
|
|
-such as <link id="Val"/> or <link id="Str"/>:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-StrLenInt = LongInt;
|
|
|
-ValSInt = Longint;
|
|
|
-ValUInt = Cardinal;
|
|
|
-ValReal = Extended;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The <var>Real48</var> type is defined to emulate the old Turbo Pascal <var>Real</var> type:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-Real48 = Array[0..5] of byte;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The assignment operator has been overloaded so this type can be assigned
|
|
|
-to the Free Pascal native <var>Double</var> and <var>Extended</var> types.
|
|
|
-<link id="Real2Double"/>.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-The following character types are defined for Delphi compatibility:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-TAnsiChar = Char;
|
|
|
-AnsiChar = TAnsiChar;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-And the following pointer types as well:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- PChar = ^char;
|
|
|
- pPChar = ^PChar;
|
|
|
- PAnsiChar = PChar;
|
|
|
- PQWord = ^QWord;
|
|
|
- PInt64 = ^Int64;
|
|
|
- pshortstring = ^shortstring;
|
|
|
- plongstring = ^longstring;
|
|
|
- pansistring = ^ansistring;
|
|
|
- pwidestring = ^widestring;
|
|
|
- pextended = ^extended;
|
|
|
- ppointer = ^pointer;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-For the <link id="SetJmp"/> and <link id="LongJmp"/> calls, the following jump bufer
|
|
|
-type is defined (for the I386 processor):
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- jmp_buf = record
|
|
|
- ebx,esi,edi : Longint;
|
|
|
- bp,sp,pc : Pointer;
|
|
|
- end;
|
|
|
- PJmp_buf = ^jmp_buf;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The following records and pointers can be used to scan the
|
|
|
-entries in the string message handler tables:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- tmsgstrtable = record
|
|
|
- name : pshortstring;
|
|
|
- method : pointer;
|
|
|
- end;
|
|
|
- pmsgstrtable = ^tmsgstrtable;
|
|
|
-
|
|
|
- tstringmessagetable = record
|
|
|
- count : dword;
|
|
|
- msgstrtable : array[0..0] of tmsgstrtable;
|
|
|
- end;
|
|
|
- pstringmessagetable = ^tstringmessagetable;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The base class for all classes is defined as:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-Type
|
|
|
- TObject = Class
|
|
|
- Public
|
|
|
- constructor create;
|
|
|
- destructor destroy;virtual;
|
|
|
- class function newinstance : tobject;virtual;
|
|
|
- procedure freeinstance;virtual;
|
|
|
- function safecallexception(exceptobject : tobject;
|
|
|
- exceptaddr : pointer) : longint;virtual;
|
|
|
- procedure defaulthandler(var message);virtual;
|
|
|
- procedure free;
|
|
|
- class function initinstance(instance : pointer) : tobject;
|
|
|
- procedure cleanupinstance;
|
|
|
- function classtype : tclass;
|
|
|
- class function classinfo : pointer;
|
|
|
- class function classname : shortstring;
|
|
|
- class function classnameis(const name : string) : boolean;
|
|
|
- class function classparent : tclass;
|
|
|
- class function instancesize : longint;
|
|
|
- class function inheritsfrom(aclass : tclass) : boolean;
|
|
|
- class function inheritsfrom(aclass : tclass) : boolean;
|
|
|
- class function stringmessagetable : pstringmessagetable;
|
|
|
- procedure dispatch(var message);
|
|
|
- procedure dispatchstr(var message);
|
|
|
- class function methodaddress(const name : shortstring) : pointer;
|
|
|
- class function methodname(address : pointer) : shortstring;
|
|
|
- function fieldaddress(const name : shortstring) : pointer;
|
|
|
- procedure AfterConstruction;virtual;
|
|
|
- procedure BeforeDestruction;virtual;
|
|
|
- procedure DefaultHandlerStr(var message);virtual;
|
|
|
- end;
|
|
|
- TClass = Class Of TObject;
|
|
|
- PClass = ^TClass;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-Unhandled exceptions can be treated using a constant of the
|
|
|
-<var>TExceptProc</var> type:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-TExceptProc = Procedure (Obj : TObject; Addr,Frame: Pointer);
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-<var>Obj</var> is the exception object that was used to raise the exception,
|
|
|
-<var>Addr</var> and <var>Frame</var> contain the exact address and stack frame
|
|
|
-where the exception was raised.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-The <var>TVarRec</var> type is used to access the elements passed in a \var{Array
|
|
|
-of Const} argument to a function or procedure:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-Type
|
|
|
- PVarRec = ^TVarRec;
|
|
|
- TVarRec = record
|
|
|
- case VType : Longint of
|
|
|
- vtInteger : (VInteger: Longint);
|
|
|
- vtBoolean : (VBoolean: Boolean);
|
|
|
- vtChar : (VChar: Char);
|
|
|
- vtExtended : (VExtended: PExtended);
|
|
|
- vtString : (VString: PShortString);
|
|
|
- vtPointer : (VPointer: Pointer);
|
|
|
- vtPChar : (VPChar: PChar);
|
|
|
- vtObject : (VObject: TObject);
|
|
|
- vtClass : (VClass: TClass);
|
|
|
- vtAnsiString : (VAnsiString: Pointer);
|
|
|
- vtWideString : (VWideString: Pointer);
|
|
|
- vtInt64 : (VInt64: PInt64);
|
|
|
- end;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The heap manager uses the <var>TMemoryManager</var> type:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- PMemoryManager = ^TMemoryManager;
|
|
|
- TMemoryManager = record
|
|
|
- Getmem : Function(Size:Longint):Pointer;
|
|
|
- Freemem : Function(var p:pointer):Longint;
|
|
|
- FreememSize : Function(var p:pointer;Size:Longint):Longint;
|
|
|
- AllocMem : Function(Size:longint):Pointer;
|
|
|
- ReAllocMem : Function(var p:pointer;Size:longint):Pointer;
|
|
|
- MemSize : function(p:pointer):Longint;
|
|
|
- HeapSize : Function:Longint;
|
|
|
- end;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-More information on using this record can be found in \progref.
|
|
|
-</p>
|
|
|
-</descr>
|
|
|
-</topic>
|
|
|
-
|
|
|
-<topic name="Constants">
|
|
|
-<short>Constants</short>
|
|
|
-<descr>
|
|
|
-<p>
|
|
|
-The following constants define the maximum values that can be used with
|
|
|
-various types:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- MaxSIntValue = High(ValSInt);
|
|
|
- MaxUIntValue = High(ValUInt);
|
|
|
- maxint = maxsmallint;
|
|
|
- maxLongint = $7fffffff;
|
|
|
- maxSmallint = 32767;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The following constants for file-handling are defined in the system unit:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-Const
|
|
|
- fmclosed = $D7B0;
|
|
|
- fminput = $D7B1;
|
|
|
- fmoutput = $D7B2;
|
|
|
- fminout = $D7B3;
|
|
|
- fmappend = $D7B4;
|
|
|
- filemode : byte = 2;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The <var>filemode</var> variable is used when a non-text file is opened using
|
|
|
-<var>Reset</var>. It indicates how the file will be opened. <var>filemode</var> can have one of
|
|
|
-the following values:
|
|
|
-</p>
|
|
|
-<dl>
|
|
|
-<dt>0</dt><dd> The file is opened for reading.
|
|
|
-</dd><dt>1</dt><dd> The file is opened for writing.
|
|
|
-</dd><dt>2</dt><dd> The file is opened for reading and writing.
|
|
|
-</dd>
|
|
|
-</dl>
|
|
|
-<p>
|
|
|
-The default value is 2. Other values are possible but are operating system specific.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-Further, the following non processor specific general-purpose constants
|
|
|
-are also defined:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-const
|
|
|
- erroraddr : pointer = nil;
|
|
|
- errorcode : word = 0;
|
|
|
- { max level in dumping on error }
|
|
|
- max_frame_dump : word = 20;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-</p>
|
|
|
-<remark>
|
|
|
-Processor specific global constants are named Testxxxx where xxxx
|
|
|
-represents the processor number (such as Test8086, Test68000),
|
|
|
-and are used to determine on what generation of processor the program
|
|
|
-is running on.
|
|
|
-</remark>
|
|
|
-<p>
|
|
|
-The following constants are defined to access VMT entries:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- vmtInstanceSize = 0;
|
|
|
- vmtParent = 8;
|
|
|
- vmtClassName = 12;
|
|
|
- vmtDynamicTable = 16;
|
|
|
- vmtMethodTable = 20;
|
|
|
- vmtFieldTable = 24;
|
|
|
- vmtTypeInfo = 28;
|
|
|
- vmtInitTable = 32;
|
|
|
- vmtAutoTable = 36;
|
|
|
- vmtIntfTable = 40;
|
|
|
- vmtMsgStrPtr = 44;
|
|
|
- vmtMethodStart = 48;
|
|
|
- vmtDestroy = vmtMethodStart;
|
|
|
- vmtNewInstance = vmtMethodStart+4;
|
|
|
- vmtFreeInstance = vmtMethodStart+8;
|
|
|
- vmtSafeCallException = vmtMethodStart+12;
|
|
|
- vmtDefaultHandler = vmtMethodStart+16;
|
|
|
- vmtAfterConstruction = vmtMethodStart+20;
|
|
|
- vmtBeforeDestruction = vmtMethodStart+24;
|
|
|
- vmtDefaultHandlerStr = vmtMethodStart+28;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The constant names should be used, and never their values, because
|
|
|
-the VMT table can change, breaking code that uses direct values.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-The following constants will be used for the planned <var>variant</var> support:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- varEmpty = $0000;
|
|
|
- varNull = $0001;
|
|
|
- varSmallint = $0002;
|
|
|
- varInteger = $0003;
|
|
|
- varSingle = $0004;
|
|
|
- varDouble = $0005;
|
|
|
- varCurrency = $0006;
|
|
|
- varDate = $0007;
|
|
|
- varOleStr = $0008;
|
|
|
- varDispatch = $0009;
|
|
|
- varError = $000A;
|
|
|
- varBoolean = $000B;
|
|
|
- varVariant = $000C;
|
|
|
- varUnknown = $000D;
|
|
|
- varByte = $0011;
|
|
|
- varString = $0100;
|
|
|
- varAny = $0101;
|
|
|
- varTypeMask = $0FFF;
|
|
|
- varArray = $2000;
|
|
|
- varByRef = $4000;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The following constants are used in the <var>TVarRec</var> record:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-vtInteger = 0;
|
|
|
-vtBoolean = 1;
|
|
|
-vtChar = 2;
|
|
|
-vtExtended = 3;
|
|
|
-vtString = 4;
|
|
|
-vtPointer = 5;
|
|
|
-vtPChar = 6;
|
|
|
-vtObject = 7;
|
|
|
-vtClass = 8;
|
|
|
-vtWideChar = 9;
|
|
|
-vtPWideChar = 10;
|
|
|
-vtAnsiString = 11;
|
|
|
-vtCurrency = 12;
|
|
|
-vtVariant = 13;
|
|
|
-vtInterface = 14;
|
|
|
-vtWideString = 15;
|
|
|
-vtInt64 = 16;
|
|
|
-vtQWord = 17;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The <var>ExceptProc</var> is called when an unhandled exception occurs:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-Const
|
|
|
- ExceptProc : TExceptProc = Nil;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-It is set in the <file>objpas</file> unit, but it can be set by the programmer
|
|
|
-to change the default exception handling.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-The following constants are defined to describe the operating system's file
|
|
|
-system:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-LineEnding = #10;
|
|
|
-LFNSupport = true;
|
|
|
-DirectorySeparator = '/';
|
|
|
-DriveSeparator = ':';
|
|
|
-PathSeparator = ':';
|
|
|
-FileNameCaseSensitive : Boolean = True;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The shown values are for unix platforms, but will be different on other
|
|
|
-platforms.
|
|
|
-The meaning of the constants is the following:
|
|
|
-</p>
|
|
|
-<dl>
|
|
|
-<dt>LineEnding</dt>
|
|
|
-<dd> End of line marker. This constant is used when writing end
|
|
|
-of lines to text files.
|
|
|
-</dd>
|
|
|
-<dt>LFNSupport</dt>
|
|
|
-<dd> This is <var>True</var> if the system supports long file names,
|
|
|
-i.e. filenames that are not restricted to 8.3 characters.
|
|
|
-</dd>
|
|
|
-<dt>DirectorySeparator</dt>
|
|
|
-<dd> The character that is used as a directory
|
|
|
-separator, i.e. it appears between various parts of a path to a file.
|
|
|
-</dd>
|
|
|
-<dt>DriveSeparator</dt>
|
|
|
-<dd> On systems that support drive letters, this character
|
|
|
-separates the drive indication from the rest of a filename.
|
|
|
-</dd>
|
|
|
-<dt>PathSeparator</dt>
|
|
|
-<dd> This character can be found between elements in a
|
|
|
-series of paths (such as the contents of the <var>PATH</var> environment
|
|
|
-variable.
|
|
|
-</dd>
|
|
|
-<dt>FileNameCaseSensitive</dt>
|
|
|
-<dd> Indicates whether filenames are case sensitive.
|
|
|
-</dd>
|
|
|
-</dl>
|
|
|
-<p>
|
|
|
-When programming cross-platform, use these constants instead of hard-coded
|
|
|
-characters. This will enhance portability of an application.
|
|
|
-</p>
|
|
|
-</descr>
|
|
|
-</topic>
|
|
|
-
|
|
|
-<topic name="variables">
|
|
|
-<short>Variables</short>
|
|
|
-<descr>
|
|
|
-<p>
|
|
|
-The following variables are defined and initialized in the system unit:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-var
|
|
|
- output,input,stderr : text;
|
|
|
- exitproc : pointer;
|
|
|
- exitcode : word;
|
|
|
- stackbottom : Cardinal;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The variables <var>ExitProc</var>, <var>exitcode</var> are used in the Free Pascal exit
|
|
|
-scheme. It works similarly to the one in Turbo Pascal:
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-When a program halts (be it through the call of the <var>Halt</var> function or
|
|
|
-<var>Exit</var> or through a run-time error), the exit mechanism checks the value
|
|
|
-of <var>ExitProc</var>. If this one is non-<var>Nil</var>, it is set to <var>Nil</var>, and
|
|
|
-the procedure is called. If the exit procedure exits, the value of ExitProc
|
|
|
-is checked again. If it is non-<var>Nil</var> then the above steps are repeated.
|
|
|
-So when an exit procedure must be installed, the old value of <var>ExitProc</var>
|
|
|
-should be saved (it may be non-<var>Nil</var>, since other units could have set
|
|
|
-it). In the exit procedure the value of <var>ExitProc</var> should be restored to
|
|
|
-the previous value, such that if it was non-<var>Nil</var> the exit-procedure can be
|
|
|
-called.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-The <var>ErrorAddr</var> and <var>ExitCode</var> can be used to check for
|
|
|
-error-conditions. If <var>ErrorAddr</var> is non-<var>Nil</var>, a run-time error has
|
|
|
-occurred. If so, <var>ExitCode</var> contains the error code. If <var>ErrorAddr</var> is
|
|
|
-<var>Nil</var>, then {ExitCode} contains the argument to <var>Halt</var> or 0 if the
|
|
|
-program terminated normally.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-<var>ExitCode</var> is always passed to the operating system as the exit-code of
|
|
|
-the current process.
|
|
|
-</p>
|
|
|
-<remark>
|
|
|
-The maximum error code under linux and unix like operating systems is 127.
|
|
|
-</remark>
|
|
|
-<p>
|
|
|
-Under <file>GO32</file>, the following constants are also defined :
|
|
|
-</p>
|
|
|
-<code>
|
|
|
-const
|
|
|
- seg0040 = $0040;
|
|
|
- segA000 = $A000;
|
|
|
- segB000 = $B000;
|
|
|
- segB800 = $B800;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-These constants allow easy access to the bios/screen segment via mem/absolute.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-The randomize function uses a seed stored in the <var>RandSeed</var> variable:
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- RandSeed : Cardinal;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-This variable is initialized in the initialization code of the system unit.
|
|
|
-</p>
|
|
|
-<p>
|
|
|
-Other variables indicate the state of the application.
|
|
|
-</p>
|
|
|
-<code>
|
|
|
- IsLibrary : boolean;
|
|
|
- IsMultiThread : boolean;
|
|
|
-</code>
|
|
|
-<p>
|
|
|
-The <var>IsLibrary</var> variable is set to true if this module is a
|
|
|
-shared library instead of an application. The <var>IsMultiThread</var>
|
|
|
-variable is set to True if the application has spawned other
|
|
|
-threads, otherwise, and by default, it is set to False.
|
|
|
-</p>
|
|
|
-</descr>
|
|
|
-<example file="refex/ex98"/>
|
|
|
-</topic>
|
|
|
-
|
|
|
<topic name="FileFunctions">
|
|
|
<short>File handling functions</short>
|
|
|
<descr>
|