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 6720e2f6346a5a024521b1aea106227d27423c65..7d4472033f6520900409cbccebb4933a2633da1d 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 @@ -94,6 +94,8 @@ import com.oracle.truffle.r.nodes.builtin.fastr.FastRContext; import com.oracle.truffle.r.nodes.builtin.fastr.FastRContextFactory; import com.oracle.truffle.r.nodes.builtin.fastr.FastRDebug; import com.oracle.truffle.r.nodes.builtin.fastr.FastRDebugNodeGen; +import com.oracle.truffle.r.nodes.builtin.fastr.FastRHelp; +import com.oracle.truffle.r.nodes.builtin.fastr.FastRHelpNodeGen; import com.oracle.truffle.r.nodes.builtin.fastr.FastRIdentity; import com.oracle.truffle.r.nodes.builtin.fastr.FastRIdentityNodeGen; import com.oracle.truffle.r.nodes.builtin.fastr.FastRInspect; @@ -408,6 +410,7 @@ public class BasePackage extends RBuiltinPackage { add(FastrDqrls.class, FastrDqrlsNodeGen::create); add(FastRDebug.class, FastRDebugNodeGen::create); add(FastRSetBreakpoint.class, FastRSetBreakpointNodeGen::create); + add(FastRHelp.class, FastRHelpNodeGen::create); add(FastRIdentity.class, FastRIdentityNodeGen::create); add(FastRTry.class, FastRTryNodeGen::create); add(FastRInspect.class, FastRInspectNodeGen::create); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRHelp.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRHelp.java new file mode 100644 index 0000000000000000000000000000000000000000..8019291682105af7925cc0c27fd1cfa013e23f6c --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRHelp.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2015, 2017, 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.fastr; + +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; +import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX; +import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; + +import com.oracle.truffle.api.dsl.Specialization; +import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.singleElement; +import static com.oracle.truffle.r.nodes.builtin.CastBuilder.Predef.stringValue; +import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; +import com.oracle.truffle.r.runtime.RError; +import static com.oracle.truffle.r.runtime.RVisibility.ON; +import com.oracle.truffle.r.runtime.builtins.RBuiltin; +import com.oracle.truffle.r.runtime.data.RNull; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +@RBuiltin(name = ".fastr.interop.getHelpRd", visibility = ON, kind = PRIMITIVE, parameterNames = {"builtinName"}, behavior = COMPLEX) +public abstract class FastRHelp extends RBuiltinNode.Arg1 { + + static { + Casts casts = new Casts(FastRHelp.class); + casts.arg("builtinName").mustBe(stringValue()).asStringVector().mustBe(singleElement()).findFirst(); + } + + @Specialization() + @TruffleBoundary + public Object isExternal(String builtinName) { + InputStream in = getClass().getResourceAsStream("/com/oracle/truffle/r/nodes/builtin/fastr/Rd/" + builtinName + ".Rd"); + if (in != null) { + try (BufferedReader r = new BufferedReader(new InputStreamReader(in))) { + StringBuilder sb = new StringBuilder(); + String line; + while ((line = r.readLine()) != null) { + sb.append(line).append("\n"); + } + return sb.toString(); + } catch (IOException ex) { + RError.warning(this, RError.Message.GENERIC, "problems while reading " + builtinName + ".Rd", ex.getMessage()); + } + } + return RNull.instance; + } + +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.byte.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.byte.Rd new file mode 100644 index 0000000000000000000000000000000000000000..5411a6b93d1f9809becca8d3a5ce784bbd4a894f --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.byte.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{as.external.byte} +\alias{as.external.byte} +\title{Marks a R value to be converted to byte when passed over to a foreign language.} +\usage{ +as.external.byte(value) +} +\arguments{ +\item{value}{a R value which can be converted to byte} +} +\value{ +An interop byte value. Error in case the given value can't be converted to a byte. +} +\description{ +Marks a R value to be converted to byte when passed over to a foreign language. +} +\examples{ +as.external.byte(123) +} +\seealso{ +\code{\link{as.external.char}}, \code{\link{as.external.float}}, \code{\link{as.external.long}}, \code{\link{as.external.short}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.char.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.char.Rd new file mode 100644 index 0000000000000000000000000000000000000000..589ff22fb5756d1ad62cfe9a13598e9868f54587 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.char.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{as.external.char} +\alias{as.external.char} +\title{Marks a R value to be converted to char when passed over to a foreign language.} +\usage{ +as.external.char(value) +} +\arguments{ +\item{value}{a R value which can be converted to char} +} +\value{ +An interop char value. Error in case the given value can't be converted to a char. +} +\description{ +Marks a R value to be converted to char when passed over to a foreign language. +} +\examples{ +as.external.char('a') +} +\seealso{ +\code{\link{as.external.byte}}, \code{\link{as.external.float}}, \code{\link{as.external.long}}, \code{\link{as.external.short}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.float.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.float.Rd new file mode 100644 index 0000000000000000000000000000000000000000..10d7248d16a2713f82150b99c9ed45c5800ea8a8 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.float.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{as.external.float} +\alias{as.external.float} +\title{Marks a R value to be converted to float when passed over to a foreign language.} +\usage{ +as.external.float(value) +} +\arguments{ +\item{value}{a R value which can be converted to float} +} +\value{ +An interop float value. Error in case the given value can't be converted to a float. +} +\description{ +Marks a R value to be converted to float when passed over to a foreign language. +} +\examples{ +as.external.float(1.1) +} +\seealso{ +\code{\link{as.external.byte}}, \code{\link{as.external.char}}, \code{\link{as.external.long}}, \code{\link{as.external.short}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.long.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.long.Rd new file mode 100644 index 0000000000000000000000000000000000000000..600f2746f3a7d84908cec829fe6b566e92362707 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.long.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{as.external.long} +\alias{as.external.long} +\title{Marks a R value to be converted to long when passed over to a foreign language.} +\usage{ +as.external.long(value) +} +\arguments{ +\item{value}{a R value which can be converted to long} +} +\value{ +An interop long value. Error in case the given value can't be converted to a long. +} +\description{ +Marks a R value to be converted to long when passed over to a foreign language. +} +\examples{ +as.external.long(123) +} +\seealso{ +\code{\link{as.external.byte}}, \code{\link{as.external.char}}, \code{\link{as.external.float}}, \code{\link{as.external.short}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.short.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.short.Rd new file mode 100644 index 0000000000000000000000000000000000000000..fd96b53ac77c43169ae7ef39d5a41412aa511353 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.external.short.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{as.external.short} +\alias{as.external.short} +\title{Marks a R value to be converted to short when passed over to a foreign language.} +\usage{ +as.external.short(value) +} +\arguments{ +\item{value}{a R value which can be converted to short} +} +\value{ +An interop short value. Error in case the given value can't be converted to a short. +} +\description{ +Marks a R value to be converted to short when passed over to a foreign language. +} +\examples{ +as.external.short(123) +} +\seealso{ +\code{\link{as.external.byte}}, \code{\link{as.external.char}}, \code{\link{as.external.short}}, \code{\link{as.external.long}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.java.array.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.java.array.Rd new file mode 100644 index 0000000000000000000000000000000000000000..0b6f195c8d6ed2e08070697d570c9e1a2d8744e2 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/as.java.array.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{as.java.array} +\alias{as.java.array} +\title{Converts a R vector or list to a java array.} +\usage{ +as.java.array(x, className) +} +\arguments{ +\item{x}{a vector or list} + +\item{className}{Optional. Determines the java array component type.} +} +\value{ +An external object representing a java array. Error in case the array could not be created. +} +\description{ +Converts a R vector or list to a java array. +} +\examples{ +as.java.array(c(1, 2, 3), 'java.lang.Double') +} +\seealso{ +\code{\link{new.java.array}}, \code{\link{is.external.array}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.Rd new file mode 100644 index 0000000000000000000000000000000000000000..3912ef157cb6b5af02d16b2d52eae2b667e2fc20 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{is.external} +\alias{is.external} +\title{Determines whether the given object is an external object or not.} +\usage{ +is.external(obj) +} +\arguments{ +\item{obj}{an external object} +} +\value{ +TRUE in case the given value is executable, otherwise FALSE. +} +\description{ +Determines whether the given object is an external object or not. +} +\examples{ +javaClass <- new.java.class('java.util.ArrayList') +is.external(javaClass) +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.array.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.array.Rd new file mode 100644 index 0000000000000000000000000000000000000000..ddd27ee8ec3bdd962b9f77e10d9d08d3d9974618 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.array.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{is.external.array} +\alias{is.external.array} +\title{Determines whether the given external object has a size. If an external object has a size, it is expected it represents an array-like structure. +Note that even if an e.g. java ArrayList has a "size", the returned value still would be false, because it will be recognised as an array-like structure.} +\usage{ +is.external.array(obj) +} +\arguments{ +\item{obj}{an external object} +} +\value{ +TRUE in case the given value is an array-like structure, otherwise FALSE. +} +\description{ +Determines whether the given external object has a size. If an external object has a size, it is expected it represents an array-like structure. +Note that even if an e.g. java ArrayList has a "size", the returned value still would be false, because it will be recognised as an array-like structure. +} +\examples{ +javaClass <- new.java.class('java.util.ArrayList') +is.external.array(javaClass) +} +\seealso{ +\code{\link{new.java.array}}, \code{\link{as.java.array}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.executable.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.executable.Rd new file mode 100644 index 0000000000000000000000000000000000000000..f1a066cd72df154e880c236ecb38ced1245f08c6 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.executable.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{is.external.executable} +\alias{is.external.executable} +\title{Determines whether the passed external object can be executed.} +\usage{ +is.external.executable(value) +} +\arguments{ +\item{value}{an external object} +} +\value{ +TRUE in case the given value is executable, otherwise FALSE. +} +\description{ +Determines whether the passed external object can be executed. +} +\examples{ +javaClass <- new.java.class('java.util.Collections') +is.external.executable(javaClass$addAll()) +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.null.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.null.Rd new file mode 100644 index 0000000000000000000000000000000000000000..7bfbf3054ca46617b52166108346538ca907b7d6 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/is.external.null.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{is.external.null} +\alias{is.external.null} +\title{Determines whether the given object (external object, or not) represents a Null value.} +\usage{ +is.external.null(value) +} +\arguments{ +\item{value}{an external object} +} +\value{ +TRUE in case the given value is Null, otherwise FALSE. +} +\description{ +Determines whether the given object (external object, or not) represents a Null value. +} +\examples{ +javaClass <- new.java.class('java.util.Collections') +is.external.null(javaClass) +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/java.addToClasspath.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/java.addToClasspath.Rd new file mode 100644 index 0000000000000000000000000000000000000000..71bbd9225971a399b6d82e9b14a40aa7292dac24 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/java.addToClasspath.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{java.addToClasspath} +\alias{java.addToClasspath} +\title{Adds a class path entry to the class path.} +\usage{ +java.addToClasspath(value, silent = FALSE) +} +\arguments{ +\item{value}{character vector. The class path entry or entries to be added to the FastR interop class path.} + +\item{silent}{logical, default FALSE. Determines whether errors should be reported or not.} +} +\description{ +Adds a class path entry to the class path. +} +\examples{ +java.addClasspathEntry('/foo/bar.jar') +} +\seealso{ +\code{\link{new.java.class}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/java.class.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/java.class.Rd new file mode 100644 index 0000000000000000000000000000000000000000..cc69669f516f6e00d66ab3d82006141d39a9387a --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/java.class.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{java.class} +\alias{java.class} +\title{Returns the fully qualified class name for the given external object representing a java class.} +\usage{ +java.class(class) +} +\arguments{ +\item{class}{an external object representing a java class.} +} +\value{ +fully qualified class name if the given value is an external object representing a java class. +} +\description{ +Returns the fully qualified class name for the given external object representing a java class. +} +\examples{ +javaClass <- new.java.class('java.util.ArrayList') +javaObject <- new.external(javaClass) +java.class(javaObject) +} +\seealso{ +\code{\link{new.external}}, \code{\link{new.java.class}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.external.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.external.Rd new file mode 100644 index 0000000000000000000000000000000000000000..e1f12eec9348c0007c0f047db87c4c8db7c62bda --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.external.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{new.external} +\alias{new.external} +\title{Creates a new external object from the given class.} +\usage{ +new.external(class) +} +\arguments{ +\item{class}{an external object representing a class} +} +\value{ +An external object created from the given class. Error in case the object could not be created. +} +\description{ +Creates a new external object from the given class. +} +\examples{ +javaClass <- new.java.class('java.util.ArrayList') +new.external(javaClass) +} +\seealso{ +\code{\link{java.class}}, \code{\link{new.java.class}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.java.array.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.java.array.Rd new file mode 100644 index 0000000000000000000000000000000000000000..36a31df71e804dae545d1791048c6f8576263930 --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.java.array.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{new.java.array} +\alias{new.java.array} +\title{Creates a new java array given by the class name and length or dimensions.} +\usage{ +new.java.array(class, dim) +} +\arguments{ +\item{class}{a fully qualified class name} + +\item{dim}{the array length or dimensions} +} +\value{ +An external object representing a java array. Error in case the array could not be created. +} +\description{ +Creates a new java array given by the class name and length or dimensions. +} +\examples{ +new.java.array('java.lang.Double', 10) +new.java.array('java.lang.Double', c(2, 3)) +} +\seealso{ +\code{\link{as.java.array}}, \code{\link{is.external.array}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.java.class.Rd b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.java.class.Rd new file mode 100644 index 0000000000000000000000000000000000000000..afc718272f49952b390b27cdaabb8326060bf8af --- /dev/null +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/Rd/new.java.class.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/fastrInteropt.R +\name{new.java.class} +\alias{new.java.class} +\title{Creates a java class given by the fully qualified java class name. The class must be available on FastR`s interop classpath.} +\usage{ +new.java.class(class, silent = FALSE) +} +\arguments{ +\item{class}{a fully qualified java class name} + +\item{silent}{logical, default FALSE. Determines whether errors should be reported or not.} +} +\value{ +An external object representing a java class. Otherwise either NULL if silent is set to TRUE, or error in case the class name could not be determined. +} +\description{ +Creates a java class given by the fully qualified java class name. The class must be available on FastR`s interop classpath. +} +\examples{ +new.java.class('java.util.ArrayList') +} +\seealso{ +\code{\link{java.addClasspathEntry}}, \code{\link{new.external}}, \code{\link{java.class}} +} diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/utils/R/utils_overrides.R b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/utils/R/utils_overrides.R index 690fa8cf1384a1e6349532f93838cf094cd5777f..df486f304a0ee9154e4e48361833d3b1d83ebdff 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/utils/R/utils_overrides.R +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/utils/R/utils_overrides.R @@ -32,3 +32,74 @@ setBreakpoint <- function (srcfile, line, nameonly = TRUE, envir = parent.frame( } }), asNamespace("utils")) + +eval(expression({ +help <- function (topic, package = NULL, lib.loc = NULL, verbose = getOption("verbose"), try.all.packages = getOption("help.try.all.packages"), help_type = getOption("help_type")) { + types <- c("text", "html", "pdf") + if (!missing(package)) + if (is.name(y <- substitute(package))) + package <- as.character(y) + if (missing(topic)) { + if (!is.null(package)) { + help_type <- if (!length(help_type)) + "text" + else match.arg(tolower(help_type), types) + if (interactive() && help_type == "html") { + port <- tools::startDynamicHelp(NA) + if (port <= 0L) + return(library(help = package, lib.loc = lib.loc, character.only = TRUE)) + browser <- if (.Platform$GUI == "AQUA") { + get("aqua.browser", envir = as.environment("tools:RGUI")) + } + else getOption("browser") + browseURL(paste0("http://127.0.0.1:", port, "/library/", package, "/html/00Index.html"), browser) + return(invisible()) + } + else return(library(help = package, lib.loc = lib.loc, character.only = TRUE)) + } + if (!is.null(lib.loc)) + return(library(lib.loc = lib.loc)) + topic <- "help" + package <- "utils" + lib.loc <- .Library + } + ischar <- tryCatch(is.character(topic) && length(topic) == 1L, error = identity) + if (inherits(ischar, "error")) + ischar <- FALSE + if (!ischar) { + reserved <- c("TRUE", "FALSE", "NULL", "Inf", "NaN", "NA", "NA_integer_", "NA_real_", "NA_complex_", "NA_character_") + stopic <- deparse(substitute(topic)) + if (!is.name(substitute(topic)) && !stopic %in% reserved) + stop("'topic' should be a name, length-one character vector or reserved word") + topic <- stopic + } + # Fastr >>>> + fastrHelpRd <- .fastr.interop.getHelpRd(topic) + if (!is.null(fastrHelpRd)) { + fastrHelpRd <- tools::parse_Rd(textConnection(fastrHelpRd)) + cat("==== R Help on ‘", topic, "’ ====\n", sep = "") + return(tools::Rd2txt(fastrHelpRd)) + } + # Fastr <<<< + help_type <- if (!length(help_type)) + "text" + else match.arg(tolower(help_type), types) + paths <- index.search(topic, find.package(if (is.null(package)) + loadedNamespaces() + else package, lib.loc, verbose = verbose)) + tried_all_packages <- FALSE + if (!length(paths) && is.logical(try.all.packages) && !is.na(try.all.packages) && try.all.packages && is.null(package) && is.null(lib.loc)) { + for (lib in .libPaths()) { + packages <- .packages(TRUE, lib) + packages <- packages[is.na(match(packages, .packages()))] + paths <- c(paths, index.search(topic, file.path(lib, packages))) + } + paths <- paths[nzchar(paths)] + tried_all_packages <- TRUE + } + paths <- unique(paths) + attributes(paths) <- list(call = match.call(), topic = topic, tried_all_packages = tried_all_packages, type = help_type) + class(paths) <- "help_files_with_topic" + paths +} +}), asNamespace("utils")) \ No newline at end of file