diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/CharSXPWrapperMR.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/CharSXPWrapperMR.java new file mode 100644 index 0000000000000000000000000000000000000000..4e5a73a607ee27689111a5307a3b0b33d95baf1c --- /dev/null +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/CharSXPWrapperMR.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 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.engine.interop; + +import com.oracle.truffle.api.interop.CanResolve; +import com.oracle.truffle.api.interop.MessageResolution; +import com.oracle.truffle.api.interop.TruffleObject; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.r.engine.TruffleRLanguage; +import com.oracle.truffle.r.runtime.ffi.CharSXPWrapper; + +@MessageResolution(receiverType = CharSXPWrapper.class, language = TruffleRLanguage.class) +public class CharSXPWrapperMR { + @CanResolve + public abstract static class CharSXPWrapperCheck extends Node { + + protected static boolean test(TruffleObject receiver) { + return receiver instanceof CharSXPWrapper; + } + } + +} diff --git a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java index 11559c31bc4ad818a8b31b6a04defef4ba89cb84..b2c2a28a826ed7994a44f37c6aac5c3514170fe2 100644 --- a/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java +++ b/com.oracle.truffle.r.engine/src/com/oracle/truffle/r/engine/interop/RForeignAccessFactoryImpl.java @@ -58,6 +58,7 @@ import com.oracle.truffle.r.runtime.data.RTruffleObject; import com.oracle.truffle.r.runtime.data.RUnboundValue; import com.oracle.truffle.r.runtime.data.model.RAbstractVector; import com.oracle.truffle.r.runtime.env.REnvironment; +import com.oracle.truffle.r.runtime.ffi.CharSXPWrapper; import com.oracle.truffle.r.runtime.ffi.DLL; import com.oracle.truffle.r.runtime.ffi.DLL.DLLInfo; import com.oracle.truffle.r.runtime.ffi.DLL.DotSymbol; @@ -104,7 +105,7 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { DLLInfo.class, DotSymbol.class, NativeRawArray.class, NativeCharArray.class, NativeIntegerArray.class, NativeDoubleArray.class, NativeLogicalArray.class, - RDouble.class, RInteger.class}; + RDouble.class, RInteger.class, CharSXPWrapper.class}; private static final class ForeignAccessState { @@ -230,6 +231,8 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory { foreignAccess = RIntegerMRForeign.createAccess(); } else if (RDouble.class.isAssignableFrom(clazz)) { foreignAccess = RDoubleMRForeign.createAccess(); + } else if (CharSXPWrapper.class.isAssignableFrom(clazz)) { + foreignAccess = CharSXPWrapperMRForeign.createAccess(); } else { if (RAbstractVector.class.isAssignableFrom(clazz)) { foreignAccess = ForeignAccess.create(RAbstractVector.class, new RAbstractVectorAccessFactory()); diff --git a/com.oracle.truffle.r.native/fficall/src/jni/Makefile b/com.oracle.truffle.r.native/fficall/src/jni/Makefile index 865ff0f99f45fa2c92003d8bea6faa5e3237bb59..fbbb5f7439dba6a5a6e0c261645d4a25922585f1 100644 --- a/com.oracle.truffle.r.native/fficall/src/jni/Makefile +++ b/com.oracle.truffle.r.native/fficall/src/jni/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 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 diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/CharSXPWrapper.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/CharSXPWrapper.java index 914742898c1751e9a2a333c4070f2a90a87c5575..62f5679c8c57b19df52ece5bb3f5ffcff0a08ffc 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/CharSXPWrapper.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/CharSXPWrapper.java @@ -22,6 +22,8 @@ */ package com.oracle.truffle.r.runtime.ffi; +import com.oracle.truffle.r.runtime.data.RTruffleObject; + /** * Internally GNU R distinguishes "strings" and "vectors of strings" using the {@code CHARSXP} and * {@code STRSXP} types, respectively. Although this difference is invisible at the R level, it @@ -32,7 +34,7 @@ package com.oracle.truffle.r.runtime.ffi; * N.B. Use limited to RFFI implementations. * */ -public final class CharSXPWrapper { +public final class CharSXPWrapper implements RTruffleObject { private final String contents; private CharSXPWrapper(String contents) { diff --git a/mx.fastr/copyrights/overrides b/mx.fastr/copyrights/overrides index 5e0730c8e000a7e849b5ddc7b212b38080ef76e2..9ace1ab1d3a27e419cea334c91beb3be453f17cd 100644 --- a/mx.fastr/copyrights/overrides +++ b/mx.fastr/copyrights/overrides @@ -137,7 +137,6 @@ com.oracle.truffle.r.native/fficall/src/include/Fileio.h,gnu_r_gentleman_ihaka.c com.oracle.truffle.r.native/fficall/src/include/contour-common.h,gnu_r_gentleman_ihaka.copyright com.oracle.truffle.r.native/fficall/src/include/nmath.h,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/include/rlocale.h,gnu_r_gentleman_ihaka.copyright -com.oracle.truffle.r.native/fficall/src/variable_defs/variable_defs.h,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/jni/Memory.c,gnu_r.copyright com.oracle.truffle.r.native/fficall/src/jni/pcre_rffi.c,gnu_r_gentleman_ihaka2.copyright com.oracle.truffle.r.native/fficall/src/jni/Rdynload_fastr.c,gnu_r.copyright diff --git a/mx.fastr/mx_fastr_edinclude.py b/mx.fastr/mx_fastr_edinclude.py index ddac3da1ce94a28fbe956560953fe30d6c91977e..dc211cdd32c068b3fdf4ea24e1b4e0c0c2031209 100644 --- a/mx.fastr/mx_fastr_edinclude.py +++ b/mx.fastr/mx_fastr_edinclude.py @@ -20,13 +20,7 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -import os from os.path import join -import platform -import subprocess -import shutil -import mx -import mx_fastr ''' Handles all the editing of R FFI header files from the GNUR include directory to the @@ -40,7 +34,7 @@ r_internals_vars = ['R_NilValue', 'R_UnboundValue', 'R_MissingArg', 'R_GlobalEnv 'R_LevelsSymbol', 'R_ModeSymbol', 'R_NameSymbol', 'R_NamesSymbol', 'R_NaRmSymbol', 'R_PackageSymbol', 'R_QuoteSymbol', 'R_RowNamesSymbol', 'R_SeedsSymbol', 'R_SourceSymbol', 'R_TspSymbol', 'R_dot_defined', 'R_dot_Method', 'R_dot_target', 'R_SrcrefSymbol', 'R_SrcfileSymbol', 'R_NaString', 'R_BlankString', - 'R_BlankScalarString','R_BaseSymbol', 'R_baseSymbol', 'R_NamespaceEnvSymbol'] + 'R_BlankScalarString', 'R_BaseSymbol', 'R_baseSymbol', 'R_NamespaceEnvSymbol'] interface_vars = ['R_Home', 'R_TempDir',] @@ -81,11 +75,11 @@ SEXP R_PreserveObject(SEXP); ''' def ed_r_internals(gnu_dir): - r_internals_h = join(gnu_dir,'Rinternals.h') + r_internals_h = join(gnu_dir, 'Rinternals.h') with open(r_internals_h) as f: lines = f.readlines() - use_rinternals_count = 0; + use_rinternals_count = 0 with open('Rinternals.h', 'w') as f: for line in lines: if '== USE_RINTERNALS section' in line: @@ -104,7 +98,7 @@ def ed_r_internals(gnu_dir): use_rinternals_count = 1 elif 'macro version of R_CheckStack' in line: f.write(use_internals_end) - f.write(line); + f.write(line) elif 'R_PreserveObject' in line: f.write(preserveObject) f.write(line) @@ -180,7 +174,7 @@ extern char* FASTR_R_Home(); ''' def ed_r_interface(gnu_dir): - r_interface_h = join(gnu_dir,'Rinterface.h') + r_interface_h = join(gnu_dir, 'Rinterface.h') with open(r_interface_h) as f: lines = f.readlines() diff --git a/mx.fastr/mx_fastr_mkgramrd.py b/mx.fastr/mx_fastr_mkgramrd.py index 2018341f3b0ea3afa29db693fe84077a6dc569a8..a951e04a1491d38e3e2bc675e8ac292348565e0b 100644 --- a/mx.fastr/mx_fastr_mkgramrd.py +++ b/mx.fastr/mx_fastr_mkgramrd.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 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