COM support in FPC - partial implementation (patch)
Original Reporter info from Mantis: mspiller
-
Reporter name:
Original Reporter info from Mantis: mspiller
- Reporter name:
Description:
I have created a sample inside delphi according to:
http://delphi.about.com/library/weekly/aa121404b.htm
It also explaines how IClassFactory should work.
I have created a derived class from TComServerObject into a comserv and created a minimal subset to get sample from first link working.
Attachment contains replacements for comobj.pp and comserv.pp. Inside an attachement is also a test how app should work.
Partially implemented TTypedComObject (still don't know how to load type library).
0010569 - TTypedComObject
Another example about safecall exceptions not working:
0014807 - SafeCall exceptions
Some reference links:
http://delphi.about.com/library/weekly/aa121404b.htm
http://www.codeproject.com/KB/atl/udtdemo.aspx
http://edndoc.esri.com/arcobjects/9.1/ExtendingArcObjects/Ch02/TypeLibrariesAndIDL.htm
http://delphi.about.com/library/weekly/aa121404a.htm
http://www.codeproject.com/KB/atl/udtdemo.aspx
http://www.codeproject.com/KB/atl/com_atl.aspx
http://www.codeproject.com/KB/atl/RegistryMap.aspx
http://www.techvanguards.com/stepbystep/comdelphi/server.asp
http://www.techvanguards.com/com/tutorials/tips.asp
http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/delphivclwin32/ComObj.html
http://docs.embarcadero.com/products/rad_studio/radstudio2007/RS2007_helpupdates/HUpdate4/EN/html/delphivclwin32/ComServ.html
Currently I didn't match the method names accordingly to the last two links (besides the existing ones). I just wanted to get my sample running.
Changes comobj.pp:
- added debug define
- added a list to TComClassManager (with add/remove Factory methods)
- implemented trivial getters GetFactoryFromClassID, GetFactoryFromClass, ForEachFactory (just a couple of iterators)
- implemented TComObjectFactory.QueryInterface, AddRef, Release (copied from TComObject)
- implemented TComObjectFactory.Create, Destroy (just settings variables and calling AddObjectFactory, RemoveObjectFactory)
- TComObjectFactory.CreateComObject (just create an instance from TClass)
Changes ComServ.pp:
- created comserv.pp
- created DllGetClassObject, DllCanUnloadNow, DllRegisterServer, DllUnregisterServer
- overrided all TComServerObject virtual functions
- DllRegisterServer - call each factory updateregistry
- DllUnregisterServer - call each factory updateregistry
- DllCanUnloadNow - counting objects and checking if they are null (some counting error)
- DllGetClassObject - just return for specific class IClassFactory
TODO:
- reference counting is not working (DllCanUnloadClass returns 1)
- load/register typelib
- register/unregister (incomplete implementation from visual studio RGS sample file)
- integrate WIDL.exe (wine version of MIDL)
- finish TTypedComObject
- create TAutoObject
- implement tlbimp.exe
- port to linux as NPAPI wrapper (just partially kidding ;)
as base you can us my updated NPAPI scripting code (https://www.mozdev.org/bugs/show_bug.cgi?id=8708) - already working with FPC (similar entry point functions as in COM) :)
Mantis conversion info:
- Mantis ID: 14822
- OS: Windows
- OS Build: XP
- Build: lazarus20091014 nighly build
- Platform: Win32
- Version: 2.5.1
- Fixed in version: 2.4.2
- Fixed in revision: 14669 (#8885f124)
- Monitored by: » thierrybo (thierrybo)