kopia lustrzana https://github.com/TeamNewPipe/NewPipeExtractor
Fix compile problems in JavaScript class
rodzic
b376539062
commit
470a719861
|
@ -10,31 +10,25 @@ public final class JavaScript {
|
|||
}
|
||||
|
||||
public static void compileOrThrow(final String function) {
|
||||
try {
|
||||
final Context context = Context.enter();
|
||||
context.setOptimizationLevel(-1);
|
||||
try (Context context = Context.enter()) {
|
||||
context.setInterpretedMode(true);
|
||||
|
||||
// If it doesn't compile it throws an exception here
|
||||
context.compileString(function, null, 1, null);
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
|
||||
public static String run(final String function,
|
||||
final String functionName,
|
||||
final String... parameters) {
|
||||
try {
|
||||
final Context context = Context.enter();
|
||||
context.setOptimizationLevel(-1);
|
||||
try (Context context = Context.enter()) {
|
||||
context.setInterpretedMode(true);
|
||||
final ScriptableObject scope = context.initSafeStandardObjects();
|
||||
|
||||
context.evaluateString(scope, function, functionName, 1, null);
|
||||
final Function jsFunction = (Function) scope.get(functionName, scope);
|
||||
final Object result = jsFunction.call(context, scope, scope, parameters);
|
||||
return result.toString();
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue