forked from jeresig/env-js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First step to having an env.js-specific set of Rhino extensions. We now
have a new (although still empty) main/shell Java class based on Rhino's default shell that will be used for executing env.js. This is located in a separate jar so that we can continue to operate with unmodified Rhino release jars.
- Loading branch information
Showing
8 changed files
with
144 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
name: mainforenvjs | ||
Name: mainForEnvjs | ||
version: 0 | ||
implementation.version: mainForEnvjs 0 ${implementation.date} | ||
# ^^^ matches Context#getImplementationVersion() | ||
|
||
build.dir: build | ||
src.dir: mainForEnvjs | ||
this.jar: mainForEnvjs.jar | ||
dist.name: mainforenvjs${version} | ||
dist.dir: ${build.dir}/${dist.name} | ||
|
||
# compilation destionation | ||
classes: ${build.dir}/classes | ||
|
||
# compilation settings | ||
debug: on | ||
target-jvm: 1.5 | ||
source-level: 1.5 | ||
jar-compression: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
<project name="rhino" default="all" basedir="."> | ||
<target name="all"> | ||
<ant antfile="mainForEnvjs/build.xml" target="jar"/> | ||
</target> | ||
</project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* This file is a component of env.js, | ||
* http://github.com/gleneivey/env-js/commits/master/README | ||
* a Pure JavaScript Browser Environment | ||
* Copyright 2009 John Resig, licensed under the MIT License | ||
* http://www.opensource.org/licenses/mit-license.php | ||
*/ | ||
|
||
|
||
import org.mozilla.javascript.*; | ||
|
||
public class EnvjsRhinoGlobal extends | ||
org.mozilla.javascript.tools.shell.Global | ||
{ | ||
public void init(Context cx) | ||
{ | ||
// first, let the Rhino shell base class do its init | ||
super.init(cx); | ||
|
||
// now, we add the JavaScript methods we want to provide for env.js | ||
String[] names = { | ||
"createAGlobalObject", | ||
"getThisScopesGlobalObject", | ||
"setThisScopesGlobalObject" | ||
}; | ||
defineFunctionProperties(names, EnvjsRhinoGlobal.class, | ||
ScriptableObject.DONTENUM); | ||
} | ||
|
||
|
||
/* class methods intended to be called as JavaScript global functions */ | ||
|
||
public static void createAGlobalObject(Context cx, Scriptable thisObj, | ||
Object[] args, Function funObj) | ||
{ | ||
} | ||
|
||
public static void getThisScopesGlobalObject(Context cx, Scriptable thisObj, | ||
Object[] args, Function funObj) | ||
{ | ||
} | ||
|
||
public static void setThisScopesGlobalObject(Context cx, Scriptable thisObj, | ||
Object[] args, Function funObj) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* This file is a component of env.js, | ||
* http://github.com/gleneivey/env-js/commits/master/README | ||
* a Pure JavaScript Browser Environment | ||
* Copyright 2009 John Resig, licensed under the MIT License | ||
* http://www.opensource.org/licenses/mit-license.php | ||
*/ | ||
|
||
|
||
import org.mozilla.javascript.tools.shell.*; | ||
|
||
public class EnvjsRhinoMain extends Main | ||
{ | ||
static | ||
{ // replace the generic Global object with our extended | ||
System.out.println("Hello from EnvjsRhinoMain-static-initializer"); | ||
global = new EnvjsRhinoGlobal(); | ||
// not calling global.initQuitAction() Doesn't matter because env.js | ||
// doesn't call the "quit" JS method provided by the Rhino shell app | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
|
||
<project name="mainForEnvjs" default="jar" basedir=".."> | ||
|
||
<target name="properties"> | ||
<tstamp> | ||
<format property="implementation.date" pattern="yyyy MM dd"/> | ||
</tstamp> | ||
<property file="build.properties"/> | ||
</target> | ||
|
||
<target name="init" depends="properties"> | ||
<mkdir dir="${build.dir}"/> | ||
<mkdir dir="${classes}"/> | ||
<mkdir dir="${dist.dir}"/> | ||
</target> | ||
|
||
<target name="compile" depends="init"> | ||
<javac srcdir="${src.dir}" | ||
destdir="${classes}" | ||
includes="**/*.java" | ||
deprecation="on" | ||
classpath="js.jar" | ||
debug="${debug}" | ||
target="${target-jvm}" | ||
source="${source-level}" | ||
> | ||
</javac> | ||
</target> | ||
|
||
<target name="jar" depends="compile"> | ||
<jar jarfile="${this.jar}" | ||
basedir="${classes}" | ||
manifest="${src.dir}/manifest" | ||
compress="${jar-compression}" | ||
/> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Manifest-Version: 1.0 | ||
Main-Class: EnvjsRhinoMain |