Hi, I'm a GCI student, and recently wrote this document for one of the assignments. 

Embedding the Parrot VM into Mozilla Firefox

 Placing a new interpreter into Firefox is something that, to me, seems very important, but as far as I know has never been attempted before. However, I see a very strait forward way of implementing this as a windowed, scriptable* plug-in. Why a plug-in? For one, it is much simpler for both the developer and the user, because the developer gets to use the API for plug-ins (NPAPI),which is well maintained and well documented on the Mozilla Developer Network here, while not having to search though the source code, edit it, and A. Create a new version of Firefox or B. Try and confince enough people at Mozilla to include it. And, for the user, all they have to worry about is installing a plug-in. Plus, (a very large, encouraging plus) NPAPI is already supported by:

Epiphany, Google Chrome, Safari, Konqueror, Mozilla project applications, Netscape Navigator and Communicator, Opera, and Internet Explorer up to 5.5SP2 (so sad that IE can't seem to properly support much anything standardized, except maybe hyperlinks...)

Also good is that that Parrot itself seems to made out of parrot file types and C/C++ files to interpret those (at least on the windows port),and the NPAPI is C, which should mean only a couple files added to parrot and probably some minor edits.

Now, there are many ways to use a (scriptable) plug-in from a web page, all using the <embed> and <object> tags. To activate from a web page, one could do some thing like this:

<embed type="application/x-parrot-perl" id="perlObj"></embed>
<!--The browser doesn't recognise x-parrot-perl nativly, searchs internally for it-->

<div style="display:none" id="myString">
   <!--some perl code-->
   <!--this is should allow for multiline code-->
</div>

<script type="application/_javascript_">
   var myString = document.getElementById('myString').innerTEXT
   myString.replace('<br />', '\n');
   getElementById("perlObj").code(myString)
   //calls the made-up parrot function code() and passes a string of code to it.
</script>

If I'm right, because it doesn't know it by default, the browser should look internally for a plug-in that accepts this MIME type which shall be, of course, parrot. The code function simply and unsurprisingly would take the string sent to the plug-in and interpret it as, in this case, Perl.(there are different ways to go about the above, but the way I gave seems to be the most effective form what I've looked at)

The plug-in itself another thing indeed. As said in the reference/documentation, Mozilla hosts files that give a starting point as samples for creating a plug-in here. Although I don't know C, they seems very simple to configure and take example from.

Whatever the parrot community chooses to do, I can't wait.

*windowed and scriptable simply mean that the plug-in has a space to draw onto and that it can be accessed via _javascript_
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to