implementation overview of OLE/SML#
Example.
Source type library (in pseudo MIDL).
interface Interface1 : IDispatch {
[id(1)] BSTR method1 ([in] VARIANT_BOOL b);
[id(2)] int propGet1 ();
[id(3)] void propPut ([in] IDispatch* d);
};
library Lib1
{
coclass Coclass1 {
[default] interface Interface1;
};
};
From this type library, generates following SML# code.
signature LIB1 =
sig
type Coclass1 =
{
method1 : bool -> OLE.OLEString.string,
getpropGet1 : unit -> int,
setpropPut1 : OLE.object -> unit,
addRef : unit -> OLE.ULONG,
release : unit -> OLE.ULONG,
this : OLE.object
}
val createCoclass1 : unit -> Coclass1
val wrapCoclass1 : OLE.object -> Coclass1
end
structure Lib1 : LIB1 =
struct
type Coclass1 = ...
fun Coclass1 dispatch =
let
fun method1 p1 =
case #invokeByDISPID dispatch 1 [OLE.BOOL p1]
of SOME(OLE.BSTR x) => x
fun getpropGet1 () =
case #getByDISPID dispatch 2 ()
of OLE.I4 x => x
fun setpropPut1 p1 =
#setByDISPID dispatch 3 (OLE.DISPATCH p1)
in
{
method1 = method1,
getpropGet1 = getpropGet1,
setpropPut1 = setpropPut1,
addRef = #addRef dispatch,
release = #release dispatch,
this = #this dispatch
}
end
fun newCoclass1 () =
let
val dispatch =
OLE.createInstance
(OLE.OLEString.fromAsciiString "Lib1.Coclass1")
in Coclass1 dispatch
end
end
Keyword(s):
References:[mapping COM and SML#] [Oveview of OLE/SML#] [COM in 3 minutes] [OLE/SML#] [implementation overview of OLE/SML#]