home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 December
/
Chip_2001-12_cd1.bin
/
zkuste
/
delphi
/
kompon
/
d23456
/
CAJSCRTP.ZIP
/
libraries
/
call
/
ifpsdelphi.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2001-10-03
|
2KB
|
84 lines
unit ifpsdelphi;
interface
uses
ifpscall, ifspas, ifs_utl, ifs_var;
function RegisterDelphiFunction(ScriptEngine: TIfPasScript; const Declaration: String; Address: Pointer): Boolean;
{
Valid types for in Declaration:
Byte
Shortint
Word
Smallint
Cardinal
Longint
Integer
PChar (string with EXT param of TypeRec to 1) (*)
String
Valid calling conventions:
register (default)
stdcall
cdecl
pascal
* Pchar type does not support Var parameter.
Defines for this unit:
D1_DEFCCPPASCAL - Set default calling convention to Pascal.
D1_DEFCCCDECL - Set default calling convention to Cdecl.
D1_DEFCCSTDCALL - Set default calling convention to StdCall.
Else the default Calling Convention is Register.
}
implementation
const
DefaultCallingConvention: TCallingConvention =
{$IFDEF D1_DEFCCPPASCAL}ccPascal;{$ELSE}
{$IFDEF D1_DEFCCCDECL}ccCdecl;{$ELSE}
{$IFDEF D1_DEFCCSTDCALL}ccStdcall;{$ELSE}
ccRegister;
{$ENDIF}
{$ENDIF}
{$ENDIF}
function DProc(Sender: TIFPasScript; ScriptID: Pointer; Proc: PProcedure; Params: PVariableManager; res: PIfVariant): TIfPasScriptError;
begin
if not InnerfuseCall(Sender, Nil, PProcedure(Proc)^._Ext, TCallingConvention(PProcedure(Proc)^._Ext2), Params, Res) then
begin
Sender.RunError2(Sender, ECustomError, 'Could not call function');
DProc := ECustomError;
end else
DPRoc := ENoError;
end;
function RegisterDelphiFunction(ScriptEngine: TIfPasScript; const Declaration: String; Address: Pointer): Boolean;
var
FuncName, FuncParam: string;
cc: TCallingConvention;
P: PProcedure;
begin
if not ReadHeader(ScriptEngine, Declaration, FuncName, FuncParam, CC, DefaultCallingConvention) then
RegisterDelphiFunction := False
else begin
p := ScriptEngine.AddFunction(@dproc, 'procedure '+FuncName+';', Address);
if assigned(p) then
begin
with P^ do
begin
_Ext2 := Pointer(CC);
Decl := FuncParam;
Name := FuncName;
end;
RegisterDelphiFunction := True;
end else
RegisterDelphiFunction := False;
end;
end;
end.