Home > Back-end >  C function structure is transformed into the Delphi
C function structure is transformed into the Delphi

Time:10-14

C + + are defined in the structure,
Struct CObjectInterface
{
Virtual int __stdcall proc1 (void);
Virtual time_t __stdcall proc2 (void);
//- firewall config access
Virtual int __stdcall func1 (const int pos, double * acc);
Virtual int __stdcall func2 (const int pos);
Virtual int __stdcall func3 - a non-class function (const int pos, double * acc);
Virtual int __stdcall func4 (const int pos, const int shift);
}

How to define it in Delphi

CodePudding user response:

Statement directly into the interface or abstract class

CodePudding user response:

This should be the declaration of the interface,,

CodePudding user response:

In Delphi statement into interface seems to be no good, forced to comply with the COM specification, inherited from IUnknown,
If it is an abstract class, struct in c + + and no virtual tables, so...
Providing reference for the following Daniel to the past, look to whether can such definition,
 
The program Project1.

{$APPTYPE CONSOLE}

USES the
Windows;

Type
Int=integer;
Time_t=longint;

Type
CObjectInterface=object
The function proc1 () : int. Virtual; Stdcall; The abstract;
The function proc2 () : time_t; Virtual; Stdcall; The abstract;
//- firewall config access
The function func1 (const pos: int. Acc: Pdouble) : int. Virtual; Stdcall; The abstract;
The function func2 (const pos: int) : int. Virtual; Stdcall; The abstract;
The function func3 - a non-class function (const pos: int. Acc: Pdouble) : int. Virtual; Stdcall; The abstract;
The function func4 (const pos; Const shift: int) : int. Virtual; Stdcall; The abstract;
end;

The begin
{TODO oUser - cConsole Main: Insert code here}
End.

CodePudding user response:

Starting from the D7 (or D5?) Don't have to start from the IUnknown interface inheritance, from IInterface inheritance

CodePudding user response:

The IUnknown is just IInterface waistcoat

CodePudding user response:

C + + Sturct and Class in addition to the members of the public private by default.
Type
//c + + has a switch, Time_t might map for 32-bit integer may also be mapped to a 64 - bit integer. You want to go to see the specific switch how to set the
Time_t=Int64;

CObjectInterface=class
The function proc1 () : Integer; Virtual; Stdcall; The abstract;
The function proc2 () : Time_t; Virtual; Stdcall; The abstract;
//- firewall config access
The function func1 (const pos: Integer; Acc: PDouble) : Integer; Virtual; Stdcall; The abstract;
The function func2 (const pos: Integer) : Integer; Virtual; Stdcall; The abstract;
The function func3 - a non-class function (const pos: Integer; Acc: PDouble) : Integer; Virtual; Stdcall; The abstract;
The function func4 (const pos: Integer; Shift: Integer) : Integer;
Virtual; Stdcall; The abstract;
end;
Above is a c + + object, Delphi invocation encapsulation way, if the object is the Delphi will remove the abstract, their implementation
  • Related