* importtl (type library import program) from Ludo Brands (bug 20958)

git-svn-id: trunk@19888 -
This commit is contained in:
michael 2011-12-26 16:37:38 +00:00
parent 4c8800c253
commit 48b314928b
5 changed files with 2120 additions and 0 deletions

4
.gitattributes vendored
View File

@ -13072,6 +13072,10 @@ utils/h2pas/scan.pas svneol=native#text/plain
utils/h2pas/testit.h -text
utils/h2pas/yylex.cod -text
utils/h2pas/yyparse.cod -text
utils/importtl/Makefile svneol=native#text/plain
utils/importtl/Makefile.fpc svneol=native#text/plain
utils/importtl/importtl.lpi svneol=native#text/plain
utils/importtl/importtl.pas svneol=native#text/plain
utils/instantfpc/Makefile svneol=native#text/plain
utils/instantfpc/Makefile.fpc svneol=native#text/plain
utils/instantfpc/README.txt svneol=native#text/plain

1956
utils/importtl/Makefile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
#
# Makefile.fpc for h2pas
#
[target]
programs=importtl
[default]
fpcdir=../..

View File

@ -0,0 +1,79 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<UseDefaultCompilerOptions Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Type Library Import progral"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<UseVersionInfo Value="True"/>
<MajorVersionNr Value="1"/>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<CommandLineParams Value="C:\Programs\Acroread\Reader\acrord32.dll"/>
</local>
</RunParams>
<Units Count="1">
<Unit0>
<Filename Value="importtl.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="importtl"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,71 @@
program importtl;
{$mode objfpc}{$H+}
{$apptype console}
uses
classes,typelib,sysutils;
var
unitname:string;
sTL,sOutDir:string;
F:text;
slDep:TStringList;
i:integer;
bNoRecurse,bHelp:boolean;
begin
slDep:=TStringList.Create;
bNoRecurse:=false;
bHelp:=false;
i:=1;
while i<=Paramcount do
begin
if pos('-n',ParamStr(i))>0 then bNoRecurse:=true
else if pos('-h',ParamStr(i))>0 then bHelp:=true
else if pos('-d',ParamStr(i))>0 then
begin
sOutDir:=trim(copy(ParamStr(i), pos('-d',ParamStr(i))+2, 260)); // windows MAX_PATH
if sOutDir='' then
if i<Paramcount-1 then
begin
i:=i+1;
sOutDir:=trim(ParamStr(i));
end
else
begin
bHelp:=true;
sOutDir:='\';
end;
if not (sOutDir[length(sOutDir)] in [':','\']) then
sOutDir:=sOutDir+'\';
end;
i:=i+1;
end;
if bHelp or (Paramcount=0) or (pos('-',paramstr(Paramcount))=1) then
begin
writeln('Usage: importtl [options] file');
writeln('Reads type information from "file" and converts it into a freepascal binding');
writeln('units.');
writeln('Options.');
writeln(' -h : displays this text.');
writeln(' -d dir: set output directory. Default: current directory.');
writeln(' -n : do not recurse typelibs. Default: create bindingss for all');
writeln(' dependencies.');
exit;
end;
slDep.Add(paramstr(Paramcount));
i:=0;
repeat
writeln('Reading typelib from '+slDep[i]+ ' ...');
sTL:=ImportTypelib(slDep[i],unitname,slDep);
unitname:=sOutDir+unitname;
writeln('Writing to '+unitname);
AssignFile(F,unitname);
Rewrite(F);
Write(F,sTL);
CloseFile(F);
i:=i+1;
until bNoRecurse or (i=slDep.Count);
slDep.Destroy;
end.