Showing posts with label c. Show all posts
Showing posts with label c. Show all posts

Sunday, 6 January 2008

Moonshine core interpreter


xkcd rockband


Today I will show you a demonstration of the Mooshine core interpreter running two different Lua programs which utilise the Firefox browser.

The first program as outlined below tests the standard module:


-------------------------------
-- test standard module
-------------------------------
print("\n" .. std.version() .. "\n") -- print version
std.msg("Hello from Moonshine!") -- display message
local ans = std.prompt("Enter number:") -- display prompt

It does the following...

  1. Prints the version of the standard module in the interpreter

  2. Displays a message box in the browser

  3. Displays a prompt for user input


The second program retrieves the latest XKCD comic panel (a example of which is in this post) from the XKCD atom feed and displays it in a new browser window...

----------------------------------
-- display latest xkcd web
-- comic from the xkcd atom feed
-- in a new browser window
----------------------------------
-- make a request for xkcd comic feed
feed = net.httpreq("http://xkcd.com/atom.xml")
-- match comic panel
img = string.match(feed,
"http\:\/\/imgs.xkcd.com\/comics\/[%w%_]+.png")
-- display comic panel in a new window
std.window(img)

The current version of the Moonshine core interpreter is an executable written in C with embedded Lua. Most of the functionality itself comes from the included modules.

To properly work as part of my extension, I will rewrite the core intepreter in C++ as an XPCOM component (which use classes).


See the demonstration (animated GIF)

Image courtesy of xkcd (CC-BY-NC)

Digg This Story

Sunday, 23 December 2007

Moonshine


pa loved his ol' moonshine.

I've been working on a project to integrate Lua with the Firefox web browser, in the form of an extension which adds support for the language to write background services or on-demand applications to run directly in the browser.

I have yet to write more code to get the integration working. I will enter this project into the Mozilla Lab's extend Firefox Contest. So hopefully, I'll have enough implemented by the deadline.

For more information, please see the Google code project page.


Image courtesy of ladyphoenixx_1999 (CC-BY-NC-ND)

Digg This Story