|
@@ -39,6 +39,12 @@ interface
|
|
uses
|
|
uses
|
|
Classes, SysUtils,comobj,activex,windows;
|
|
Classes, SysUtils,comobj,activex,windows;
|
|
|
|
|
|
|
|
+// Style of input ref parameters:
|
|
|
|
+Type
|
|
|
|
+ TParamInputRefType = (ParamInputVar, // old delphi [in] becomes VAR, Default
|
|
|
|
+ ParamInputConstRef, // (old) FPC [in] becomes CONSTREF
|
|
|
|
+ ParamInputConstRefDelphi); // XE3+ style CONST [Ref]
|
|
|
|
+
|
|
{
|
|
{
|
|
Reads type information from 'FileName' and converts it in a freepascal binding unit. The
|
|
Reads type information from 'FileName' and converts it in a freepascal binding unit. The
|
|
contents of the unit is returned as the function result.
|
|
contents of the unit is returned as the function result.
|
|
@@ -52,12 +58,12 @@ To load a different type of library resource, append an integer index to 'FileNa
|
|
|
|
|
|
Example: C:\WINDOWS\system32\msvbvm60.dll\3
|
|
Example: C:\WINDOWS\system32\msvbvm60.dll\3
|
|
}
|
|
}
|
|
|
|
+
|
|
function ImportTypelib(FileName: WideString;var sUnitName:string;var slDependencies:TStringList;
|
|
function ImportTypelib(FileName: WideString;var sUnitName:string;var slDependencies:TStringList;
|
|
- bActiveX,bPackage,bRemoveStructTag:boolean;var sPackageSource,sPackageRegUnitSource:String):string;
|
|
|
|
|
|
+ bActiveX,bPackage,bRemoveStructTag:boolean;var sPackageSource,sPackageRegUnitSource:String;inreftype :TParamInputRefType = ParamInputVar):string;
|
|
|
|
|
|
|
|
|
|
Type
|
|
Type
|
|
-
|
|
|
|
{ TTypeLibImporter }
|
|
{ TTypeLibImporter }
|
|
|
|
|
|
TTypeLibImporter = Class(TComponent)
|
|
TTypeLibImporter = Class(TComponent)
|
|
@@ -65,6 +71,7 @@ Type
|
|
FActiveX: Boolean;
|
|
FActiveX: Boolean;
|
|
FAppendVersionNumber: Boolean;
|
|
FAppendVersionNumber: Boolean;
|
|
FCreatePackage: Boolean;
|
|
FCreatePackage: Boolean;
|
|
|
|
+ FInParamRefStyle : TParamInputRefType;
|
|
FDependencies: TStringList;
|
|
FDependencies: TStringList;
|
|
FRemoveStructTag: Boolean;
|
|
FRemoveStructTag: Boolean;
|
|
FUnitSource: TStringList;
|
|
FUnitSource: TStringList;
|
|
@@ -157,6 +164,8 @@ Type
|
|
Property RemoveStructTag : Boolean read FRemoveStructTag write SetRemoveStructTag Default False;
|
|
Property RemoveStructTag : Boolean read FRemoveStructTag write SetRemoveStructTag Default False;
|
|
// Set automatically by OutputFileName or by Execute
|
|
// Set automatically by OutputFileName or by Execute
|
|
Property UnitName : string Read FUnitname Write SetUnitName;
|
|
Property UnitName : string Read FUnitname Write SetUnitName;
|
|
|
|
+ // generate constref for [in] parameters instead of delphi compatible VAR, mantis 30764
|
|
|
|
+ Property InParamRefStyle : TParamInputRefType read fInParamRefStyle write FInParamRefStyle;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -166,7 +175,7 @@ Resourcestring
|
|
SErrInvalidUnitName = 'Invalid unit name : %s';
|
|
SErrInvalidUnitName = 'Invalid unit name : %s';
|
|
|
|
|
|
function ImportTypelib(FileName: WideString;var sUnitName:string;var slDependencies:TStringList;
|
|
function ImportTypelib(FileName: WideString;var sUnitName:string;var slDependencies:TStringList;
|
|
- bActiveX,bPackage,bRemoveStructTag:boolean;var sPackageSource,sPackageRegUnitSource:String):string;
|
|
|
|
|
|
+ bActiveX,bPackage,bRemoveStructTag:boolean;var sPackageSource,sPackageRegUnitSource:String;inreftype :TParamInputRefType = ParamInputVar):string;
|
|
var i:integer;
|
|
var i:integer;
|
|
begin
|
|
begin
|
|
With TTypeLibImporter.Create(Nil) do
|
|
With TTypeLibImporter.Create(Nil) do
|
|
@@ -175,11 +184,13 @@ begin
|
|
ActiveX:=bActiveX;
|
|
ActiveX:=bActiveX;
|
|
CreatePackage:=bPackage;
|
|
CreatePackage:=bPackage;
|
|
RemoveStructTag:=bRemoveStructTag;
|
|
RemoveStructTag:=bRemoveStructTag;
|
|
|
|
+ InParamRefStyle :=inreftype;
|
|
Execute;
|
|
Execute;
|
|
Result:=UnitSource.Text;
|
|
Result:=UnitSource.Text;
|
|
sUnitname:=UnitName;
|
|
sUnitname:=UnitName;
|
|
sPackageSource:=FPackageSource.Text;
|
|
sPackageSource:=FPackageSource.Text;
|
|
sPackageRegUnitSource:=FPackageRegUnitSource.Text;
|
|
sPackageRegUnitSource:=FPackageRegUnitSource.Text;
|
|
|
|
+
|
|
if Assigned(slDependencies) then
|
|
if Assigned(slDependencies) then
|
|
begin //add new dependencies
|
|
begin //add new dependencies
|
|
for i:=0 to Dependencies.Count-1 do
|
|
for i:=0 to Dependencies.Count-1 do
|
|
@@ -643,7 +654,12 @@ begin
|
|
case FD^.lprgelemdescParam[k].paramdesc.wParamFlags and (PARAMFLAG_FIN or PARAMFLAG_FOUT) of
|
|
case FD^.lprgelemdescParam[k].paramdesc.wParamFlags and (PARAMFLAG_FIN or PARAMFLAG_FOUT) of
|
|
PARAMFLAG_FIN or PARAMFLAG_FOUT:sPar:='var ';
|
|
PARAMFLAG_FIN or PARAMFLAG_FOUT:sPar:='var ';
|
|
PARAMFLAG_FOUT:sPar:='out ';
|
|
PARAMFLAG_FOUT:sPar:='out ';
|
|
- PARAMFLAG_FIN:sPar:='var '; //constref in safecall? TBD
|
|
|
|
|
|
+ PARAMFLAG_NONE,
|
|
|
|
+ PARAMFLAG_FIN: case FInParamRefStyle of
|
|
|
|
+ ParamInputVar : sPar:='var '; //constref in safecall? TBD
|
|
|
|
+ ParamInputConstRef : sPar:='constref ';
|
|
|
|
+ ParamInputConstRefDelphi : sPar:='const [ref] ';
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
if not MakeValidId(GetName(k+1),sVarName) then
|
|
if not MakeValidId(GetName(k+1),sVarName) then
|
|
AddToHeader('// Warning: renamed parameter ''%s'' in %s.%s to ''%s''',[GetName(k+1),iname,sMethodName,sVarName],True);
|
|
AddToHeader('// Warning: renamed parameter ''%s'' in %s.%s to ''%s''',[GetName(k+1),iname,sMethodName,sVarName],True);
|