Mathieu Fenniak's Weblog

2002/11/28

XPCOM Enabled MOO

Filed under: moo, programming — admin @ 6:22 pm

On April 29th, 2002, I began to look at integrating the standalone XPCOM with the LambdaMOO server.

XPCOM is a lightweight cross-platform implementation of the concepts behind Microsoft’s COM. It has been implemented in the process of the development of Mozilla. XPCOM is essentially COM, but cross-platform, hence the XP.

The integration inside the MOO server is not necessarily for any specific purpose, but I have a few plans in mind for what this integration will permit:

  • XPCOM can be used to allow builtin functions to be compiled into shared modules and dropped into the MOO ‘components’. These builtin functions will be registered with the ‘regxpcom’ program, and be accessible from inside the MOO instantly. There are multiple advantages over doing this rather than the traditional way of modifying the MOO server to add builtin functions. The most major advantage is that XPCOM components can be written in languages other than C. It’s useful to program in an object-oriented language like C++ when you’re programming a builtin function that will be used in an object-oriented environment in the first place. Additionally, plug-in DLLs can be isolated in such a way that the crash of a builtin function will not affect the running of the MOO server.

    This has been implemented and is currently undergoing testing. The implementation involved the creation of an ‘IBuiltinFunction’ interface. The plug-in DLL exports an IBuiltinFunction derived interface. The MOO server allows access to its data to the XPCOM component via a set of ‘IMOOData’-derived interfaces.

    structure diagram of xpcom interfaces in the moo

  • Another possible use for XPCOM inside the MOO is to allow MOO-code to access XPCOM objects. I expect that originally this will be implemented by creating an XPCOM plug-in DLL that exports builtin functions providing xpcom_createinstance(), xpcom_queryinterface(), xpcom_callfunction(), xpcom_get_attribute(), xpcom_set_attribute(), xpcom_releaseinstance(), and xpcom_isvalidinstance().

    xpcom_createinstance() will create an instance of a given contract id, if possible, and return a hash string that represents that instance. Eg:

    ;xpcom_createinstance("@mozilla.org/file/directory_service;1")
    => "##XPCOM#bbf8cab0-d43a-11d3-8cc2-00609792278c#59e7e77a##"

    The string representing that interface is a concationation of the CID, and a pointer address to it to make it unique for each instance. A hash table of these strings will be stored in the server so that implementation of the other xpcom_*() functions is relatively efficient.

    Implementation of this idea is pending further thought.

  • The MOOzilla MOO client is written in JavaScript using Mozilla, and utilizes XPCOM heavily. It should be possible to create a plug-in architecture for MOOzilla, using some kind of common interfaces that the MOO server is aware of. Using an implementation of SOAP, (implemented as an XPCOM module, of course), it should be possible for the MOO server to ’script’ MOOzilla, or vice-versa, using out-of-band binary SOAP communication streams. Woo! The purpose? … Well, why not create an XPCOM module that wraps Gtk+, and then an interface for it on the client side and an interface for message handling on the server side could allow a Gtk+ application to be MOO-server-driven. Of course, this doesn’t apply just to Gtk+, it could be used for any toolkit… theoretically.

My efforts of XPCOM integration have yield a MOO which can successfully use XPCOM component builtin functions. My work has been based upon the MOO Canada server source, which is a rather hacked up LambdaMOO 1.8.1. The source has some unfortunate usability problems. It is basically customised just for my building and use of it. It should be possible to adapt it to build on your machine. The Makefile-xpcom-lao file is my Makefile. The automake and autoconf sources are not up to date. With some modifications to the Makefile, it should be possible to get it to build for you. Currently, I don’t have any example modules that are fit for publication.

The XPCOM enabled MOO server source can also be accessed by Subversion clients, or browsed with a web browser, at http://stompstompstomp.com/svn/moo/mc/xpcom-enabled-branch.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URL

Sorry, the comment form is closed at this time.

Powered by WordPress