Monday, October 30, 2006

GibberMonkey 0.1.0

Yesterday I cut the initial release of my first project leveraging spidermonkey-dotnet. It is called GibberMonkey, and it is a JavaScript scriptable IRC bot, programmable even from the chatroom. Source code, .Net & Mono binaries are available on CodePlex. It is the result of a marriage between the SpiderMonkey engine & the SmartIrc4Net library. SmartIrc4Net is a C# library providing an API for communicating with an IRC server, documentation for this API is here.
Part of the purpose of GibberMonkey is to be the usability testbed for the new generic object embedding in spidermonkey-dotnet (see previous posts).

The SmartIrc4Net API is completely exposed to JavaScript, all done generically without specific embedding code. GibberMonkey itself is quite small because of this. The key feature that was missing in the alpha generic embedder was full support of delegates. What is now possible is for a JavaScript function (JSTYPE_FUNCTION) to be created at runtime and be mapped and stored automatically as any needed delegate type. Later on, managed code can make the callback to the JS engine seamlessly.

This solution was implemented by System.Reflection.Emitting a dynamic method of the necessary delegate type. Inside this method the parameters are moved into an array so we can eventually invoke the user JavaScript function via JS_CallFunction. Hardcore. GibberMonkey wraps dozens of SmartIrc4Net delegate types, and this is the primary method of customizing the bot's behavior.

The alpha version of spidermonkey-dotnet now runs under Mono. Makefiles for Mono compilation and the above features are both in source control.

3 Comments:

Anonymous Anonymous said...

Great stuff. Love the name too!

11/30/2006 3:21 PM  
Blogger Jonah said...

It would appear that the delegate handling is now broken :(

I tried this with the TestFire method of the Shell class in the smnet-shell project, and although stepping through the code shows me that the _xyz event handler is of the correct type, it still does nothing.

I will continue to delve into this issue, but I am desperately hoping that you will provide some words of wisdom that I can use in my efforts to make the callback functions... functional :)

8/10/2007 9:28 PM  
Blogger abstraktmethodz said...

Jonah, let me know what changeset or release your working with. Or send some source to my email address.

8/14/2007 1:24 AM  

Post a Comment

Links to this post:

Create a Link

<< Home