Skip to content
Snippets Groups Projects
Commit 85a20b5d authored by Mick Jordan's avatar Mick Jordan
Browse files

CharSXPWrapper as TruffleObject

parent 59535ef0
No related branches found
No related tags found
No related merge requests found
/*
* 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;
}
}
}
......@@ -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());
......
#
# 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
......
......@@ -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) {
......
......@@ -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
......
......@@ -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()
......
#
# 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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment