Skip to content

Commit

Permalink
Use newly introduced Context.initStandardObjects(), not initStandardO…
Browse files Browse the repository at this point in the history
…bjects(null) in the examples
  • Loading branch information
ibukanov committed Oct 9, 2003
1 parent 6b71bd7 commit 5e08971
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/Control.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static void main(String[] args) {

// Initialize the standard objects (Object, Function, etc.)
// This must be done before scripts can be executed.
Scriptable scope = cx.initStandardObjects(null);
Scriptable scope = cx.initStandardObjects();

// Now we can evaluate a script. Let's create a new object
// using the object literal notation.
Expand Down
2 changes: 1 addition & 1 deletion examples/CounterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void main(String[] args) throws Exception
{
Context cx = Context.enter();
try {
Scriptable scope = cx.initStandardObjects(null);
Scriptable scope = cx.initStandardObjects();
ScriptableObject.defineClass(scope, Counter.class);

Scriptable testCounter = cx.newObject(scope, "Counter");
Expand Down
5 changes: 1 addition & 4 deletions examples/DynamicScopes.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void runScripts(Context cx)
// Initialize the standard objects (Object, Function, etc.)
// This must be done before scripts can be executed. The call
// returns a new scope that we will share.
Scriptable scope = cx.initStandardObjects(null);
Scriptable scope = cx.initStandardObjects();

// Now we can evaluate a script and functions will be compiled to
// use dynamic scope if the Context is so initialized.
Expand Down Expand Up @@ -159,9 +159,6 @@ public void run() {
catch (NotAFunctionException jse) {
// ignore
}
catch (PropertyException jse) {
// ignore
}
catch (JavaScriptException jse) {
// ignore
}
Expand Down
13 changes: 2 additions & 11 deletions examples/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,8 @@ public Object jsFunction_readLines()
v.copyInto(lines);

Scriptable scope = ScriptableObject.getTopLevelScope(this);
Scriptable result;
try {
Context cx = Context.getCurrentContext();
result = cx.newObject(scope, "Array", lines);
} catch (PropertyException e) {
throw Context.reportRuntimeError(e.getMessage());
} catch (NotAFunctionException e) {
throw Context.reportRuntimeError(e.getMessage());
}

return result;
Context cx = Context.getCurrentContext();
return cx.newObject(scope, "Array", lines);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/NervousText.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
</pre>
and the resulting 2 classes, NervousText.class extending java.applet.Applet and implementing java.lang.Runnable and NervousText1.class which represents compiled JavaScript code, are placed in the same directory as NervousText.html.
<p>
The test also assumes that js.jar from Rhino distribution is available in the same directory.
The test also assumes that js.jar from Rhino distribution is available in the same directory.
</body>
</html>
5 changes: 3 additions & 2 deletions examples/PrimitiveWrapFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
* that can be converted to ECMA primitive values.
* So java.lang.String is mapped to ECMA string, all java.lang.Numbers are
* mapped to ECMA numbers, and java.lang.Booleans are mapped to ECMA booleans
* instead of being wrapped as objects. Additionally java.lang.Characters are
* converted to ECMA strings. Other types have the default behavior.
* instead of being wrapped as objects. Additionally java.lang.Character is
* converted to ECMA string with length 1.
* Other types have the default behavior.
* <p>
* Note that calling "new java.lang.String('foo')" in JavaScript with this
* wrap factory enabled will still produce a wrapped Java object since the
Expand Down
2 changes: 1 addition & 1 deletion examples/RunScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static void main(String args[])
// Initialize the standard objects (Object, Function, etc.)
// This must be done before scripts can be executed. Returns
// a scope object that we use in later calls.
Scriptable scope = cx.initStandardObjects(null);
Scriptable scope = cx.initStandardObjects();

// Collect the arguments into a single string.
String s = "";
Expand Down
2 changes: 1 addition & 1 deletion examples/RunScript2.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void main(String args[])
{
Context cx = Context.enter();
try {
Scriptable scope = cx.initStandardObjects(null);
Scriptable scope = cx.initStandardObjects();

// Add a global variable "out" that is a JavaScript reflection
// of System.out
Expand Down
2 changes: 1 addition & 1 deletion examples/RunScript3.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void main(String args[])
{
Context cx = Context.enter();
try {
Scriptable scope = cx.initStandardObjects(null);
Scriptable scope = cx.initStandardObjects();

// Collect the arguments into a single string.
String s = "";
Expand Down
2 changes: 1 addition & 1 deletion examples/RunScript4.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void main(String args[])
{
Context cx = Context.enter();
try {
Scriptable scope = cx.initStandardObjects(null);
Scriptable scope = cx.initStandardObjects();

// Use the Counter class to define a Counter constructor
// and prototype in JavaScript.
Expand Down

0 comments on commit 5e08971

Please sign in to comment.