Helma Logo
main list history
previous version  overview  next version

Version 4 by hannes on 03. September 2008, 22:16

Since I have gotten a more frustrated with *JSAdapter|http://blogs.sun.com/sundararajan/entry/self_javascript_and_jsadapter* lately, I have started working on a new metaprogramming extension to Rhino which I call Metamethods. It is based on *JOMP|http://www.bias2build.com/thesis/javascript_mop_expanded.html*, but looks for methods in the target object itself rather than a separate meta object. It is also thread-safe and adds a method to controll control behavior of the equals operator (==).

In detail, Metamethods looks for the following methods in a JavaScript object:

* <b>__has__</b>(property): this method is called when checking for a property
* <b>__get__</b>(property): this method is called when getting a property
* <b>__set__</b>(property, value): this method is called when setting a property
* <b>__delete__</b>(property): this method is called when deleting a property
* <b>__getIds__</b>(): this method is called when iterating over property ids
* <b>__hasInstance__</b>(object): this method is called when the instanceof operator is used
* <b>__equals__</b>(object): this method is called when the == operator is used

Currently you have to manually patch and build Rhino to use Metamethods using the patch attached to this page.

<% this.attachments %>

This patch is against the current Rhino CVS snapshot. Let me know if it fails to apply to earlier versions of Rhino.

     removed
     added