[fpc-pascal] typelib.pas

José Mejuto joshyfun at gmail.com
Thu Jun 26 21:22:21 CEST 2014


Hello,

A few days ago I was trying to convert a COM DLL into a *_TLB.pas file 
using the importtl.exe and the result does not compile at all due some 
missing parameter names in some functions/procedures.

After note that typelib.pas is the heart of the importtl.exe file I was 
looking for the reason and fixes the bug and proposed a patch in this 
bug report

http://bugs.freepascal.org/view.php?id=26352

After this patch the code is compilable but some functions fails with a 
SIGSEGV. Looking at code again I found that some function names 
"AddRef", "Invoke" and others that are present in base interface 
(IUnknown and IDispatch) are removed from the generated output.
After comment out this lines the code generated works mostly as expected 
(except another bug explained later) and a function "AddRef" appears in 
the middle of some interface definitions.

So my question is. Is fpc binding interface functions based in its index 
? I think the answer is yes so removing that "reserved" names crash the 
binding when a custom function with that name appears in the middle of 
an interface.

To solve this problem there are 2 solutions from my point of view, one 
is add it as is as (what my internal patch does now) or rename the 
function so it does not clash with inherited "AddRef" in example.

The other bug is that I had found intefaces which export a property_put 
with ByRef parameter, so it can not be mapped to a pascal property, so I 
had changed this conflictive functions to no emit a "property read" code.

Currently tipelib.pas generated code like this interface:

procedure Set_Value(var Param1: Widestring);
function  Get_Value: WideString;
property Value read Get_Value write Set_Value;

Which can not be compiled due the "var" in the Set_* procedure.

I hope that one devel can review and apply the patch in the bug report 
noted above.

Best regards,
	José Mejuto
-- 




More information about the fpc-pascal mailing list