use of jdk.nashorn.api.scripting.ScriptObjectMirror in project POL-POM-5 by PhoenicisOrg.
the class WinePrefixContainerController method changeSetting.
public void changeSetting(WinePrefixContainerDTO winePrefix, RegistryParameter setting, Runnable doneCallback, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
final String registryPatch = registryWriter.generateRegFileContent(setting.toRegistryPatch());
LOGGER.info("Updating registry for prefix: " + winePrefix.getPath());
LOGGER.info(registryPatch);
interactiveScriptSession.eval("include([\"Engines\", \"Wine\", \"Engine\", \"Object\"]);", ignored -> interactiveScriptSession.eval("new Wine()", output -> {
final ScriptObjectMirror wine = (ScriptObjectMirror) output;
wine.callMember("prefix", winePrefix.getName());
final ScriptObjectMirror regedit = (ScriptObjectMirror) wine.callMember("regedit");
regedit.callMember("patch", registryPatch);
wine.callMember("wait");
doneCallback.run();
}, errorCallback), errorCallback);
}
use of jdk.nashorn.api.scripting.ScriptObjectMirror in project POL-POM-5 by PhoenicisOrg.
the class GenericContainersManager method deleteContainer.
/**
* {@inheritDoc}
* @param container
* @param errorCallback
*/
@Override
public void deleteContainer(ContainerDTO container, Consumer<Exception> errorCallback) {
try {
this.fileUtilities.remove(new File(container.getPath()));
} catch (IOException e) {
LOGGER.error("Cannot delete container (" + container.getPath() + ")! Exception: " + e.toString());
errorCallback.accept(e);
}
List<ShortcutCategoryDTO> categories = this.libraryManager.fetchShortcuts();
categories.stream().flatMap(shortcutCategoryDTO -> shortcutCategoryDTO.getShortcuts().stream()).forEach(shortcutDTO -> {
final InteractiveScriptSession interactiveScriptSession = this.scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Engines\", \"" + container.getEngine() + "\", \"Shortcuts\", \"Reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> {
final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output;
shortcutReader.callMember("of", shortcutDTO);
final String containerName = (String) shortcutReader.callMember("container");
if (containerName.equals(container.getName())) {
this.shortcutManager.deleteShortcut(shortcutDTO);
}
}, errorCallback), errorCallback);
});
}
use of jdk.nashorn.api.scripting.ScriptObjectMirror in project POL-POM-5 by PhoenicisOrg.
the class ShortcutManager method uninstallFromShortcut.
public void uninstallFromShortcut(ShortcutDTO shortcutDTO, Consumer<Exception> errorCallback) {
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession();
interactiveScriptSession.eval("include([\"Engines\", \"Wine\", \"Shortcuts\", \"Reader\"]);", ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> {
final ScriptObjectMirror shortcutReader = (ScriptObjectMirror) output;
shortcutReader.callMember("of", shortcutDTO);
shortcutReader.callMember("uninstall");
}, errorCallback), errorCallback);
}
use of jdk.nashorn.api.scripting.ScriptObjectMirror in project vue-gwt by Axellience.
the class VueTemplateCompiler method compile.
/**
* Compile the given HTML template to JS functions using vue-template-compiler.
* @param htmlTemplate The HTML Component template to compile
* @return An object containing the render functions
* @throws VueTemplateCompilerException If the compilation fails
*/
public VueTemplateCompilerResult compile(String htmlTemplate) throws VueTemplateCompilerException {
ScriptObjectMirror templateCompilerResult;
try {
templateCompilerResult = (ScriptObjectMirror) engine.invokeFunction("compile", htmlTemplate);
} catch (ScriptException | NoSuchMethodException e) {
e.printStackTrace();
throw new VueTemplateCompilerException("An error occurred while compiling the template: " + htmlTemplate + " -> " + e.getMessage());
}
String renderFunction = (String) templateCompilerResult.get("render");
String[] staticRenderFunctions = ((ScriptObjectMirror) templateCompilerResult.get("staticRenderFns")).to(String[].class);
return new VueTemplateCompilerResult(renderFunction, staticRenderFunctions);
}
use of jdk.nashorn.api.scripting.ScriptObjectMirror in project JSCover by tntim96.
the class BranchInstrumentorIntegrationTest method shouldWrapNonCoalesce.
@Test
public void shouldWrapNonCoalesce() throws Exception {
String source = "function test(a) {\n var x = a > 7;\n }\ntest(3);";
runScript(source, true);
ScriptObjectMirror coverageData = (ScriptObjectMirror) engine.eval("_$jscoverage['test.js'].branchData[2][1]");
assertThat(coverageData.get("evalTrue"), equalTo(0));
assertThat(coverageData.get("evalFalse"), equalTo(1.0));
}
Aggregations