Lisp from .NET using COM

Here’s another silly example.

Calling a Lisp COM-server from .NET(use RDNZL to load compiled assembly into Lisp and call LispCOM.Foo)

using System;
using System.Runtime.InteropServices;

namespace LispCOM
{
    [Guid("F9210244-38D1-49C0-A848-684EDD3DBFF0"),
     InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    interface IHelloWorld
    {
        void HelloWorld([In, MarshalAs(UnmanagedType.LPWStr)] string message);
    }

    [ComImport, Guid("DF748DA7-BCB9-4F67-8D32-F9AA1AAA3ABF")]
    class HelloWorld
    {
    }

    public class LispCOM
    {
        public static void Foo()
        {
            try
            {
                IHelloWorld helloWorld = (IHelloWorld)(new HelloWorld());
                helloWorld.HelloWorld("Hello from .NET!");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: {0}", e.Message);
            }
        }
    }
}

Current status of the library is as follows(tested under Windows 2000 and Windows 7 on x86):

clisp – works

SBCL – works. But, you’ll need to use patched version of SBCL(Which you can obtain here: sources and binaries) to work with COM. Anton Kovalenko(a developer, who is currently working on improving SBCL port for Windows) has recently added support for stdcall callbacks(which is a vital thing for COM interop) to Dmitry Kalyanov’s fork of SBCL. Oh, and, here’s the patch for CFFI.

Clozure CL – COM interop works only partially. Some problems with callbacks. I will try to fix them, though.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: