Category : Files from Magazines
Archive   : V12N02.ZIP
Filename : NEWOBJBY.PAS

 
Output of file : NEWOBJBY.PAS contained in archive : V12N02.ZIP
UNIT NewObjByType;
{.$define ObjectProfessional}

{$ifNdef WINDOWS}
{$ifNdef VER60}
{$ifNdef VER55}
!CRASH! This unit requires Turbo Pascal
Version 5.5 or 6.0 or Windows
{$endif}
{$endif}
{$else}
{$ifNdef VER10}
!! This unit requires Turbo Pascal Windows Version 1.0
{$endif}
{$endif}

{$ifdef VER60}
{$define SYMBOLIC_ASM}
{$endif}
{$ifdef WINDOWS}
{$define SYMBOLIC_ASM}
{$endif}

(**) INTERFACE (**)

USES
{$ifdef WINDOWS}
WObjects; { Needed to get definition of object type TObject }
{$endif}
{$ifdef VER55}
OPRoot; { Needed to get definition of object type Root }
{$define ROOT}
{$endif}
{$ifdef VER60}
{$ifdef ObjectProfessional}
OPRoot; { Needed to get definition of object type Root }
{$define ROOT}
{$else}
Objects; { Needed to get definition of object type TObject }
{$endif}
{$endif}

FUNCTION NewByType(VMT : Pointer; { Returned by TypeOf }
ConsAddr : Pointer; { @MyConstructor }
var Data) { Data for constructor }
{$ifdef ROOT}
: RootPtr; { Returns new obj. pointer }
{$else}
: PObject; { Returns new obj. pointer }
{$endif}

(**) IMPLEMENTATION (**)

FUNCTION pNewByType(VMTOfs : Word; { Only the VMT's DS offset}
ConsAddr : Pointer;{ Pass through parameter }
var Data) { Pass through parameter }
{$ifdef ROOT}
: RootPtr; { Returns new obj. pointer }
{$else}
: PObject; { Returns new obj. pointer }
{$endif}
BEGIN
{$ifdef SYMBOLIC_ASM}
ASM
Push word [Data+2] { Push address of untyped }
Push word [Data] { var parameter Data }
Push VMTOfs { Push value of VMT offset in DS }
Xor AX,AX { Get ready for a nil 'Self' }
Push AX { parameter so constructor will }
Push AX { allocate a new instance }
Call [ConsAddr] { call the constructor }
Mov word [BP-4],AX { transfer the function return }
Mov word [BP-2],DX { to place Turbo expects it. }
END;
{$else}
Inline(
$FF/$76/ $FF/$76/ $FF/$76/ $31/$C0/ { Xor AX,AX }
$50/ { Push AX }
$50/ { Push AX }
$FF/$5E/ $89/$46/$FC/ { Mov word [BP-4],AX }
$89/$56/$FE); { Mov word [BP-2],DX }
{$endif}
END; { pNewByType }

FUNCTION NewByType(VMT : Pointer; { Returned by TypeOf }
ConsAddr : Pointer; { @MyConstructor }
var Data) { Data for constructor }
{$ifdef ROOT}
: RootPtr; { Returns new obj. pointer }
{$else}
: PObject; { Returns new obj. pointer }
{$endif}
TYPE
PointerRecord = RECORD
Offset,
Segment : Word;
END; { PointerRecord}
BEGIN
NewByType := pNewByType(PointerRecord(VMT).Offset,
ConsAddr,
Data);
END; { NewByType }

END. { NewObjByType }


  3 Responses to “Category : Files from Magazines
Archive   : V12N02.ZIP
Filename : NEWOBJBY.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/