Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-12

importtl - importing typelib

3 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marco van de Voort

Fyi

Recently, a type lib importer was added to FPC, made by Ludo.

I've played a bit, by running them against all TLBs on my, and in some of the larger tlbs there are problems:

in activeds.tlb, there is a fragment that references non existing identifiers that have "internal" naming:

ADSTYPEENUM = __MIDL___MIDL_itf_ads_0000_0000_0001;
     ADS_OCTET_STRING = __MIDL___MIDL_itf_ads_0000_0000_0002;
     P__MIDL___MIDL_itf_ads_0000_0000_0002 =
        ^__MIDL___MIDL_itf_ads_0000_0000_0002;
     __MIDL___MIDL_itf_ads_0000_0000_0002 = packed record
     dwLength : LongWord;
     lpValue : PByte;
 end;

Similarly, the huge mshtml (IE9) html had several failures. The first two were fixable

1. defining true=1 and false=0.
2. Somewhere a pointer type was referenced before definition (one line lower) (same code fragment as (3), see below)
3. same problem as activeds, types that have "internal" names.

//records, unions, aliases
 wireHDC = P_RemotableHandle;             // problem  (2), only defined
						a line lower
 P_RemotableHandle = ^_RemotableHandle;
 _RemotableHandle = packed record
     fContext : Integer;
     u : __MIDL_IWinTypes_0009; // (3) unknown problem.
 end;

Reply by email

Ludo Brands
to Marco van de Voort
Show quoted text 12 lines
in activeds.tlb, there is a fragment that references non existing identifiers that have "internal" naming: ADSTYPEENUM = __MIDL___MIDL_itf_ads_0000_0000_0001; ADS_OCTET_STRING = __MIDL___MIDL_itf_ads_0000_0000_0002; P__MIDL___MIDL_itf_ads_0000_0000_0002 = ^__MIDL___MIDL_itf_ads_0000_0000_0002; __MIDL___MIDL_itf_ads_0000_0000_0002 = packed record dwLength : LongWord; lpValue : PByte; end;

Thank you for testing. Activeds.tbl has another few unhandled particularities I hadn't encountered before.

I've reworked the complete alias/record/union import. The above example is something that C can handle with incomplete typedefs but pascal can't. The approach now is to defer type declarations until all user_types used have been declared, external or internal. In case of circular references, an error message is added to the header so that the user can either solve the circular reference or remove the types.

Show quoted text 19 lines
Similarly, the huge mshtml (IE9) html had several failures. The first two were fixable 1. defining true=1 and false=0. 2. Somewhere a pointer type was referenced before definition (one line lower) (same code fragment as (3), see below) 3. same problem as activeds, types that have "internal" names. //records, unions, aliases wireHDC = P_RemotableHandle; // problem (2), only defined a line lower P_RemotableHandle = ^_RemotableHandle; _RemotableHandle = packed record fContext : Integer; u : __MIDL_IWinTypes_0009; // (3) unknown problem. end;

1. added a check against reserved identifiers in all places. 2,3. same as activeds

Added also support for unions.

Both files compile now.

Patch attached to http://bugs.freepascal.org/view.php?id=20972

Ludo

Reply by email