sdedic commented on a change in pull request #1011: Enhanced wrapper for Scripting API URL: https://github.com/apache/incubator-netbeans/pull/1011#discussion_r239109472
########## File path: platform/api.scripting/src/org/netbeans/modules/scripting/GraalEngineFactory.java ########## @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.scripting; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineFactory; +import org.graalvm.polyglot.Language; + +final class GraalEngineFactory implements ScriptEngineFactory { + + final String id; + final Language language; + final GraalContext ctx; + + GraalEngineFactory(GraalContext ctx, String id, Language language) { + this.id = id; + this.language = language; + this.ctx = ctx; + } + + @Override + public String getEngineName() { + return "GraalVM:" + language.getId(); + } + + @Override + public String getEngineVersion() { + return language.getVersion(); + } + + @Override + public List<String> getExtensions() { + return Collections.singletonList(id); + } + + @Override + public List<String> getMimeTypes() { + return new ArrayList<>(language.getMimeTypes()); + } + + @Override + public List<String> getNames() { + return Arrays.asList(language.getName()); + } + + @Override + public String getLanguageName() { + return language.getName(); + } + + @Override + public String getLanguageVersion() { + return language.getVersion(); + } + + @Override + public Object getParameter(String arg0) { + return null; + } + + @Override + public String getMethodCallSyntax(String arg0, String arg1, String... arg2) { + return null; Review comment: Something which would allow to satisfy contract of [ScriptEngineFactory](https://docs.oracle.com/javase/7/docs/api/javax/script/ScriptEngineFactory.html#getMethodCallSyntax(java.lang.String,%20java.lang.String,%20java.lang.String...) ) in a lang-independent way so it can be bridged to standard Scripting APIs here, like the Polyglot Context eval* methods are. Also note the other get* code construction helper methods in the scripting API. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
