How It All Fits Together Core Language Implementation Language / FFI-specific ‘glue’ ActiveX Substrate
How an ActiveX Object Looks At Runtime Language implementation value type Substrate-provided thread-safe wrapper object 32-bit raw, un-thread-safe object pointer
How Event / Notification Queues Work At Runtime Language Runtime Implementation Non-blocking (but polling) Notifications Events Obj, Data Choose event style to fit impl. model Asynchronous (languages with such support) Win32 Event Handles (signaled on new entries)
Problem? Research Languages Can’t ‘Do Anything’ Substrate provides: Simple, C-based wrappers for Raw ActiveX objects creation / manipulation Event / Notification handlers Type information Thread safety A way to avoid spending months learning to implement IDispatch
What do researchers (minimally) write? VARIANT-to-<langtype> wrapper, and back Substrate calls this change data types upon function calls and returns Addition of a storage class or subtype for ‘ActiveX handles’ Simple wrappers for C functions (creation, etc.)
What else can researchers wrap? Asynchronous or non-blocking (polling-based) event handling Handles both dynamic [source] interfaces and IPropertyNotifySink Type library information Coclasses with all interfaces, not just [default] Interfaces and all of their methods Constant information
Driving IE from Scheme (define ie (create-object “InternetExplorer.Application”)) (define ie-source-iid "{EAB22AC2-30C1-11CF-A7EB-0000C05BAE0B}") (invoke ie "Navigate" "http://www.lars.com/") (register-object-event-handler! ie ie-source-iid "BeforeNavigate" (lambda (a b c d e f) (format #t "The user left lars.com! How *rude*!~%"))) (put ie "Visible" #t)
Making the Agent Say Something More Interesting (define agent-control (create-object "Agent.Control.1")) (put agent-control "Connected" #t) (define agent-characters (get agent-control "Characters")) (invoke agent-characters "Load" "clippit" "C:/program files/microsoft \ office/office/clippit.acs") (define clip-it (invoke agent-characters "Character“ "clippit")) ;; Mua-ha-ha! (invoke clip-it "Show") (invoke clip-it "Speak" "I'm a twisted, evil piece of metal... but at least I don't have to write C code!")