mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
46b8e5185c
I'm working on a project which uses rhino. I wanted to have finer control over class generation and saving so I've done some patching and clean up on the current rhino tip. The biggest change I've made is the replacement of ClassOutput with ClassRepository that has the single method: public boolean storeClass(String className, byte[] classBytes, boolean isTopLevel) throws IOException; This interface allows any arbitary storage method, such as a Hashtable/Map. In addition it also allows you to specify whether a class should be loaded, via returning true or false. You can still use ClassOutput as I've coded an internal wrapper. With this interface it has also been possible to strip out the file saving code from Codegen and OptClassNameHelper. The file saving code is now an inner class FileClassRepository in Context. As a consequence of this I've stripped out some methods from ClassNameHelper. The resulting code is much more cleaner then before hand and everything still works as per usual. Other small additions are: o Annonymous functions are now named class$1 instead of class1 o get/setClassName added to ClassNameHelper exposed in Context. My final thoughts are, since all methods in ClassNameHelper except reset() are now exposed whould n't it be much more "cleaner" to simply to some how work around to eliminate reset() and provide getClassNameHelper() via Context? You could then remove the numerous ClassNameHelper shadow methods from Context. Likewise, FileClassRepository could be made a public class very easily and combined with the above result in a dozen or so less public methods in Context. Anyway, the changes can be found on http://www.cins.co.uk/rhino.zip Hope it is of use to some Kemal Bayram <rhino@cins.co.uk>
<html> <!-- - The contents of this file are subject to the Netscape Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/NPL/ - - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. - - The Original Code is Rhino code, released - May 6, 1999. - - The Initial Developer of the Original Code is Netscape - Communications Corporation. Portions created by Netscape are - Copyright (C) 1998-1999 Netscape Communications Corporation. All - Rights Reserved. - - Contributor(s): - Norris Boyd - - Alternatively, the contents of this file may be used under the - terms of the GNU Public License (the "GPL"), in which case the - provisions of the GPL are applicable instead of those above. - If you wish to allow use of your version of this file only - under the terms of the GPL and not to allow others to use your - version of this file under the NPL, indicate your decision by - deleting the provisions above and replace them with the notice - and other provisions required by the GPL. If you do not delete - the provisions above, a recipient may use your version of this - file under either the NPL or the GPL. --> <body> <h1> <span CLASS=LXRSHORTDESC> Rhino: JavaScript in Java<p> </span> </h1> <span CLASS=LXRLONGDESC> Rhino is an implementation of JavaScript in Java. Documentation can be found <a href="http://www.mozilla.org/js/rhino/rhino.html">here</a>. </span> </body> </html>