* Reintroduce defineLibraryScope() because it is still used in various places,

but deprecate and drop second argument (boolean initStandardObjects).
This commit is contained in:
hns 2007-06-20 09:13:52 +00:00
parent 7c8404d57d
commit dd4beb2490

View file

@ -73,7 +73,7 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder {
"encodeXml", "encodeForm", "stripTags", "formatParagraphs",
"getXmlDocument", "getHtmlDocument", "seal",
"getDBConnection", "getURL", "write", "writeln",
"serialize", "deserialize",
"serialize", "deserialize", "defineLibraryScope",
"wrapJavaMap", "unwrapJavaMap", "toJava"
};
@ -367,6 +367,29 @@ public class GlobalObject extends ImporterTopLevel implements PropertyRecorder {
return null;
}
/**
* Creates a libary namespace in the global scope.
*
* @param name the name of the libary namespace
* @deprecated should be implemented in JavaScript instead
*/
public void defineLibraryScope(final String name) {
Object obj = get(name, this);
if (obj != NOT_FOUND) {
// put the property again to fool PropertyRecorder
// into believing it has been renewed
put(name, this, obj);
return;
}
ScriptableObject scope = new NativeObject() {
public String getClassName() {
return name;
}
};
scope.setPrototype(ScriptableObject.getObjectPrototype(this));
put(name, this, scope);
}
/**
* Wrap a java.util.Map so that it looks and behaves like a native JS object
* @param obj a map