Add definition of File object (FESI compatible).

Minor fix for line numbers in debug output.
This commit is contained in:
hns 2003-06-12 16:09:11 +00:00
parent 0c2ac1d781
commit 1515cc96af

View file

@ -74,6 +74,7 @@ public final class RhinoCore implements WrapHandler {
global = context.initStandardObjects(g); global = context.initStandardObjects(g);
ScriptableObject.defineClass(global, HopObject.class); ScriptableObject.defineClass(global, HopObject.class);
ScriptableObject.defineClass(global, FileObject.class);
putPrototype("hopobject", putPrototype("hopobject",
ScriptableObject.getClassPrototype(global, "HopObject")); ScriptableObject.getClassPrototype(global, "HopObject"));
putPrototype("global", global); putPrototype("global", global);
@ -623,14 +624,14 @@ public final class RhinoCore implements WrapHandler {
try { try {
FileReader fr = new FileReader(file); FileReader fr = new FileReader(file);
updateEvaluator(prototype, fr, funcfile.getSourceName()); updateEvaluator(prototype, fr, funcfile.getSourceName(), 1);
} catch (IOException iox) { } catch (IOException iox) {
app.logEvent("Error updating function file: " + iox); app.logEvent("Error updating function file: " + iox);
} }
} else { } else {
StringReader reader = new StringReader(funcfile.getContent()); StringReader reader = new StringReader(funcfile.getContent());
updateEvaluator(prototype, reader, funcfile.getSourceName()); updateEvaluator(prototype, reader, funcfile.getSourceName(), 1);
} }
} else if (code instanceof ActionFile) { } else if (code instanceof ActionFile) {
ActionFile action = (ActionFile) code; ActionFile action = (ActionFile) code;
@ -638,7 +639,7 @@ public final class RhinoCore implements WrapHandler {
try { try {
updateEvaluator(prototype, new StringReader(fa.function), updateEvaluator(prototype, new StringReader(fa.function),
action.getSourceName()); action.getSourceName(), 0);
} catch (Exception esx) { } catch (Exception esx) {
app.logEvent("Error parsing " + action + ": " + esx); app.logEvent("Error parsing " + action + ": " + esx);
} }
@ -646,7 +647,7 @@ public final class RhinoCore implements WrapHandler {
} }
private synchronized void updateEvaluator(Prototype prototype, Reader reader, private synchronized void updateEvaluator(Prototype prototype, Reader reader,
String sourceName) { String sourceName, int firstline) {
// context = Context.enter(context); // context = Context.enter(context);
try { try {
Scriptable op = getPrototype(prototype.getName()); Scriptable op = getPrototype(prototype.getName());
@ -655,7 +656,7 @@ public final class RhinoCore implements WrapHandler {
Context cx = Context.getCurrentContext(); Context cx = Context.getCurrentContext();
// do the update, evaluating the file // do the update, evaluating the file
cx.evaluateReader(op, reader, sourceName, 1, null); cx.evaluateReader(op, reader, sourceName, firstline, null);
} catch (Throwable e) { } catch (Throwable e) {
app.logEvent("Error parsing function file " + sourceName + ": " + e); app.logEvent("Error parsing function file " + sourceName + ": " + e);
e.printStackTrace(); e.printStackTrace();