From 40fb6c94d90485729f93e4638064fc2a96d0d6fa Mon Sep 17 00:00:00 2001 From: Lukas Stadler <lukas.stadler@oracle.com> Date: Thu, 6 Oct 2016 13:49:03 +0200 Subject: [PATCH] remove unnecessary CapabilitiesFunctions wrapper class --- .../r/nodes/builtin/base/BasePackage.java | 2 +- .../r/nodes/builtin/base/Capabilities.java | 91 ++++++++++++++++++ .../builtin/base/CapabilitiesFunctions.java | 94 ------------------- 3 files changed, 92 insertions(+), 95 deletions(-) create mode 100644 com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Capabilities.java delete mode 100644 com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CapabilitiesFunctions.java diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java index 46def37dbc..d92be87cff 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/BasePackage.java @@ -209,7 +209,7 @@ public class BasePackage extends RBuiltinPackage { add(BrowserFunctions.BrowserSetDebug.class, BrowserFunctionsFactory.BrowserSetDebugNodeGen::create); add(BrowserFunctions.BrowserText.class, BrowserFunctionsFactory.BrowserTextNodeGen::create); add(Call.class, CallNodeGen::create); - add(CapabilitiesFunctions.Capabilities.class, CapabilitiesFunctionsFactory.CapabilitiesNodeGen::create); + add(Capabilities.class, CapabilitiesNodeGen::create); add(Cat.class, CatNodeGen::create); add(Ceiling.class, CeilingNodeGen::create); add(CharMatch.class, CharMatchNodeGen::create); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Capabilities.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Capabilities.java new file mode 100644 index 0000000000..ed3a304e22 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Capabilities.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.nodes.builtin.base; + +import static com.oracle.truffle.r.runtime.builtins.RBehavior.READS_STATE; +import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; + +import com.oracle.truffle.api.dsl.Specialization; +import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.builtins.RBuiltin; +import com.oracle.truffle.r.runtime.context.RContext; +import com.oracle.truffle.r.runtime.data.RDataFactory; +import com.oracle.truffle.r.runtime.data.RLogicalVector; +import com.oracle.truffle.r.runtime.data.RStringVector; + +@RBuiltin(name = "capabilities", kind = INTERNAL, parameterNames = {}, behavior = READS_STATE) +public abstract class Capabilities extends RBuiltinNode { + private enum Capability { + jpeg(false, null), + png(false, null), + tiff(false, null), + tcltk(false, null), + X11(false, null), + aqua(false, null), + http_fttp(true, "http/ftp"), + sockets(true, null), + libxml(false, null), + fifo(false, null), + cledit(false, null), + iconv(false, null), + nls(false, "NLS"), + profmem(false, null), + cairo(false, null); + + private final boolean defValue; + private final String rName; + + Capability(boolean defValue, String nameOverride) { + this.defValue = defValue; + this.rName = nameOverride == null ? name() : nameOverride; + } + + static String[] rNames() { + Capability[] values = values(); + String[] result = new String[values.length]; + for (Capability c : values) { + result[c.ordinal()] = c.rName; + } + return result; + } + + } + + private static final RStringVector NAMES = RDataFactory.createStringVector(Capability.rNames(), RDataFactory.COMPLETE_VECTOR); + + @Specialization + protected RLogicalVector capabilities() { + byte[] data = new byte[NAMES.getLength()]; + for (Capability c : Capability.values()) { + boolean value = c.defValue; + switch (c) { + case cledit: + value = RContext.getInstance().isInteractive() && !RContext.getInstance().getStartParams().getNoReadline(); + break; + } + data[c.ordinal()] = RRuntime.asLogical(value); + } + return RDataFactory.createLogicalVector(data, RDataFactory.COMPLETE_VECTOR, NAMES); + } +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CapabilitiesFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CapabilitiesFunctions.java deleted file mode 100644 index 32cd5b8d61..0000000000 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/CapabilitiesFunctions.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.nodes.builtin.base; - -import static com.oracle.truffle.r.runtime.builtins.RBehavior.READS_STATE; -import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL; - -import com.oracle.truffle.api.dsl.Specialization; -import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; -import com.oracle.truffle.r.runtime.RRuntime; -import com.oracle.truffle.r.runtime.builtins.RBuiltin; -import com.oracle.truffle.r.runtime.context.RContext; -import com.oracle.truffle.r.runtime.data.RDataFactory; -import com.oracle.truffle.r.runtime.data.RLogicalVector; -import com.oracle.truffle.r.runtime.data.RStringVector; - -public class CapabilitiesFunctions { - - @RBuiltin(name = "capabilities", kind = INTERNAL, parameterNames = {}, behavior = READS_STATE) - public abstract static class Capabilities extends RBuiltinNode { - private enum Capability { - jpeg(false, null), - png(false, null), - tiff(false, null), - tcltk(false, null), - X11(false, null), - aqua(false, null), - http_fttp(true, "http/ftp"), - sockets(true, null), - libxml(false, null), - fifo(false, null), - cledit(false, null), - iconv(false, null), - nls(false, "NLS"), - profmem(false, null), - cairo(false, null); - - private final boolean defValue; - private final String rName; - - Capability(boolean defValue, String nameOverride) { - this.defValue = defValue; - this.rName = nameOverride == null ? name() : nameOverride; - } - - static String[] rNames() { - Capability[] values = values(); - String[] result = new String[values.length]; - for (Capability c : values) { - result[c.ordinal()] = c.rName; - } - return result; - } - - } - - private static final RStringVector NAMES = RDataFactory.createStringVector(Capability.rNames(), RDataFactory.COMPLETE_VECTOR); - - @Specialization - protected RLogicalVector capabilities() { - byte[] data = new byte[NAMES.getLength()]; - for (Capability c : Capability.values()) { - boolean value = c.defValue; - switch (c) { - case cledit: - value = RContext.getInstance().isInteractive() && !RContext.getInstance().getStartParams().getNoReadline(); - break; - } - data[c.ordinal()] = RRuntime.asLogical(value); - } - return RDataFactory.createLogicalVector(data, RDataFactory.COMPLETE_VECTOR, NAMES); - } - } -} -- GitLab