-
Notifications
You must be signed in to change notification settings - Fork 903
Preparation for liveconnect separation #1983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
rPraml
wants to merge
21
commits into
mozilla:master
Choose a base branch
from
FOCONIS:lc-experimental
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8c7f6eb
removed VMBridge
rPraml 244ba37
Remove cycle between EquaObjectGraphs and Native* classes
rPraml 995a864
Global: Do not use reflection for init
rPraml 6f48627
Shell: Do not use reflection for init
rPraml 657ab8f
XMLLib: Do not use reflection for init
rPraml 5b14802
First step to sort out LiveConnect classes
rPraml 5df2617
Resolved somple dependency on LiveConnect classes
rPraml 8ed43b1
Updated current state in decycle
rPraml b922ce4
EqualObjectGraphs fixes
rPraml 152c941
LiveConnect bridge introduced
rPraml b3e4ed8
FIX: wrong class in JavaAdapter
rPraml 19aedd8
Updated cycle-exclusions
rPraml 51b6a55
Introduced LcLib
rPraml 6c259b4
Fix Exceptions in Global
rPraml fe6ffa2
Move Context.jsToJava to LiveConnect.jsToJava
rPraml f80f9ca
Move WrapFactory to lc.java
rPraml 84c54ed
ScriptableObject: replace reflection by lambda
rPraml 769c9b1
Continuation: do not use reflection for init
rPraml c6df71d
jsToJavaString method without liveConnect
rPraml 024d2a7
ShellTest/Environment: Do not use reflection for init
rPraml a8e5809
LiveConnect optional
rPraml File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -11,10 +11,10 @@ | |
| import java.io.InputStreamReader; | ||
| import org.mozilla.javascript.Context; | ||
| import org.mozilla.javascript.EvaluatorException; | ||
| import org.mozilla.javascript.Function; | ||
| import org.mozilla.javascript.JavaScriptException; | ||
| import org.mozilla.javascript.Scriptable; | ||
| import org.mozilla.javascript.ScriptableObject; | ||
| import org.mozilla.javascript.Undefined; | ||
| import org.mozilla.javascript.WrappedException; | ||
|
|
||
| /** | ||
|
|
@@ -53,9 +53,38 @@ public static void main(String args[]) { | |
|
|
||
| // Define some global functions particular to the shell. Note | ||
| // that these functions are not part of ECMA. | ||
| String[] names = {"print", "quit", "version", "load", "help"}; | ||
| shell.defineFunctionProperties(names, Shell.class, ScriptableObject.DONTENUM); | ||
|
|
||
| shell.defineProperty( | ||
| shell, | ||
| "print", | ||
| 0, | ||
| Shell::print, | ||
| ScriptableObject.DONTENUM, | ||
| ScriptableObject.DONTENUM | ScriptableObject.READONLY); | ||
|
|
||
| shell.defineProperty( | ||
| shell, | ||
| "version", | ||
| 0, | ||
| Shell::version, | ||
| ScriptableObject.DONTENUM, | ||
| ScriptableObject.DONTENUM | ScriptableObject.READONLY); | ||
|
|
||
| shell.defineProperty( | ||
| shell, | ||
| "load", | ||
| 0, | ||
| Shell::load, | ||
| ScriptableObject.PERMANENT | ScriptableObject.DONTENUM, | ||
| ScriptableObject.DONTENUM); | ||
|
|
||
| shell.defineProperty( | ||
| shell, | ||
| "help", | ||
| 1, | ||
| Shell::help, | ||
| ScriptableObject.PERMANENT | ScriptableObject.DONTENUM, | ||
| ScriptableObject.DONTENUM); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing |
||
| args = processOptions(cx, args); | ||
|
|
||
| // Set up "arguments" in the global scope to contain the command | ||
|
|
@@ -117,7 +146,7 @@ private static void usage(String s) { | |
| * | ||
| * <p>This method is defined as a JavaScript function. | ||
| */ | ||
| public void help() { | ||
| private static Object help(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { | ||
| p(""); | ||
| p("Command Description"); | ||
| p("======= ==========="); | ||
|
|
@@ -134,6 +163,7 @@ public void help() { | |
| p("quit() Quit the shell. "); | ||
| p("version([number]) Get or set the JavaScript version number."); | ||
| p(""); | ||
| return Undefined.instance; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -146,9 +176,8 @@ public void help() { | |
| * @param cx the current Context for this thread | ||
| * @param thisObj the JavaScript <code>this</code> object | ||
| * @param args the array of arguments | ||
| * @param funObj the function object of the invoked JavaScript function | ||
| */ | ||
| public static void print(Context cx, Scriptable thisObj, Object[] args, Function funObj) { | ||
| private static Object print(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { | ||
| for (int i = 0; i < args.length; i++) { | ||
| if (i > 0) System.out.print(" "); | ||
|
|
||
|
|
@@ -158,6 +187,7 @@ public static void print(Context cx, Scriptable thisObj, Object[] args, Function | |
| System.out.print(s); | ||
| } | ||
| System.out.println(); | ||
| return Undefined.instance; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -167,8 +197,9 @@ public static void print(Context cx, Scriptable thisObj, Object[] args, Function | |
| * | ||
| * <p>This method is defined as a JavaScript function. | ||
| */ | ||
| public void quit() { | ||
| public Object quit(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { | ||
| quitting = true; | ||
| return Undefined.instance; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -179,10 +210,9 @@ public void quit() { | |
| * @param cx the current Context for this thread | ||
| * @param thisObj the JavaScript <code>this</code> object | ||
| * @param args the array of arguments | ||
| * @param funObj the function object of the invoked JavaScript function | ||
| * @return the version no as double | ||
| */ | ||
| public static double version(Context cx, Scriptable thisObj, Object[] args, Function funObj) { | ||
| private static double version(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { | ||
| double result = cx.getLanguageVersion(); | ||
| if (args.length > 0) { | ||
| double d = Context.toNumber(args[0]); | ||
|
|
@@ -199,13 +229,13 @@ public static double version(Context cx, Scriptable thisObj, Object[] args, Func | |
| * @param cx the current Context for this thread | ||
| * @param thisObj the JavaScript <code>this</code> object | ||
| * @param args the array of arguments | ||
| * @param funObj the function object of the invoked JavaScript function | ||
| */ | ||
| public static void load(Context cx, Scriptable thisObj, Object[] args, Function funObj) { | ||
| private static Object load(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { | ||
| Shell shell = (Shell) getTopLevelScope(thisObj); | ||
| for (int i = 0; i < args.length; i++) { | ||
| shell.processSource(cx, Context.toString(args[i])); | ||
| } | ||
| return Undefined.instance; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make a bulk registeration? Like so:
It should be easier to read and maintain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see https://github.com/mozilla/rhino/pull/1993/files
If static import is used, it would match in one line.
but maybe it makes sense to replace
defineProperty(this, "defineClass", 1, Global::defineClass, DONTENUM, DONTENUM | READONLY)by
defineFunctionProperty(this, "defineClass", 1, Global::defineClass)