A Fantom / COM Automation bridge for the JVM Runtime
A utility class that emulates a COM Collection object.
Handles the tricky business of COM threading.
Communicates to COM objects.
A Flag represents many states by setting and clearing bits on a Int.
A multi-format data type used for all COM communications.
As thrown by Fancom.
Thrown when a Dispatch call returns an
Thrown when a Dispatch call returns an invalid
Fancom is a Fantom / COM Automation bridge for Fantom programs running on a JVM. It uses JACOB to make native calls to COM libraries via JNI. Fancom features:
- Runs on x86 and x64 environments supporting 32 bit and 64 bit JVMs.
- Supports COM Events
- COM encapsulation through surrogates
- Clean and simple API
Dispatch wraps a COM object (the IDispatch interface) and allows you to get / set properties and call methods on the component.
All parameters to and from Dispatch objects are encapsulated in
Variant objects. A Variant holds a standard Fantom object (
Bool etc...) and converts it for usage by the COM object.
A simple example:
Dispatch outlook := Dispatch.makeFromProgId("Outlook.Application") Str version := outlook.getProperty(Variant("Version")).asStr
For ease of use, Fancom will convert all standard Fantom literals to Variants for you, so the last line could be written as:
version := outlook.getProperty("Version").asStr
(You can actually pass in any Fantom object as long as it looks like a Variant Surrogate.)
Variants that reference other COM objects may be converted to
Dispatch objects allowing chaining:
Dispatch objWord := Dispatch.makeFromProgId("Word.Application") Dispatch documents := objWord.getProperty("Documents").asDispatch documents.call("Open", "myEssay.doc")
You can register any class to receive events from a COM object by calling:
Then when the COM object fires an event Fancom will look for a matching method on your event sink. The method is the name of the event, prefixed with
on. For example, if the event is called FalseRecognition your handler method should be called
To run, Fancom requires the JACOB file to be part of your Fantom installation. In particular:
afFancom.pod/lib/java/jacob-XXX.zipneeds to be copied to the
FAN_HOME/lib/java/ext/folder and renamed to
afFancom.pod/lib/dotnet/jacob-XXX.dllneeds to be copied to the
TODO: write a simple install script to copy the pod files
- Fixed an issue with method param matching. May have affected some surrogate classes.
- Added support for
- Added support for more (lesser used) VT types
Dispatch.callnow throws a FandocErr if a
VT_ERRORor an invalid
- Added serialization ctor to
Dispatch.callparams could get mixed up if
nullwas passed in
- Surrogate diagnostics checks for typos and common ctor / static factory mixups
- Initial release.