mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 18:24:02 +00:00
Add construction of Counter from Java
This commit is contained in:
parent
108f24ebcf
commit
20c82f88e9
@ -50,6 +50,14 @@ public class RunScript3 {
|
|||||||
// Use the Counter class to define a Counter constructor
|
// Use the Counter class to define a Counter constructor
|
||||||
// and prototype in JavaScript.
|
// and prototype in JavaScript.
|
||||||
ScriptableObject.defineClass(scope, Counter.class);
|
ScriptableObject.defineClass(scope, Counter.class);
|
||||||
|
|
||||||
|
// Create an instance of Counter and assign it to
|
||||||
|
// the top-level variable "myCounter". This is
|
||||||
|
// equivalent to the JavaScript code
|
||||||
|
// myCounter = new Counter(7);
|
||||||
|
Object[] arg = { new Integer(7) };
|
||||||
|
Scriptable myCounter = cx.newObject(scope, "Counter", arg);
|
||||||
|
scope.put("myCounter", scope, myCounter);
|
||||||
|
|
||||||
String s = "";
|
String s = "";
|
||||||
for (int i=0; i < args.length; i++)
|
for (int i=0; i < args.length; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user