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

make RConnection a TruffleObject for C_ParseRd in NFI/LLVM

parent 41c77839
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.conn.RConnection;
@MessageResolution(receiverType = RConnection.class, language = TruffleRLanguage.class)
public class RConnectionMR {
@CanResolve
public abstract static class RConnection extends Node {
protected static boolean test(TruffleObject receiver) {
return receiver instanceof RConnection;
}
}
}
......@@ -28,6 +28,7 @@ import com.oracle.truffle.api.interop.ForeignAccess;
import com.oracle.truffle.api.interop.MessageResolution;
import com.oracle.truffle.r.engine.TruffleRLanguage;
import com.oracle.truffle.r.runtime.RInternalError;
import com.oracle.truffle.r.runtime.conn.RConnection;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.context.RForeignAccessFactory;
import com.oracle.truffle.r.runtime.data.RDouble;
......@@ -92,6 +93,8 @@ public final class RForeignAccessFactoryImpl implements RForeignAccessFactory {
return RDoubleMRForeign.ACCESS;
} else if (obj instanceof CharSXPWrapper) {
return CharSXPWrapperMRForeign.ACCESS;
} else if (obj instanceof RConnection) {
return RConnectionMRForeign.ACCESS;
} else {
if (obj instanceof RAbstractVector) {
return ForeignAccess.create(RAbstractVector.class, new RAbstractVectorAccessFactory());
......
......@@ -31,12 +31,13 @@ import java.nio.channels.ByteChannel;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.r.runtime.conn.ConnectionSupport.BaseRConnection;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.RTruffleObject;
import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
/**
* Denotes an R {@code connection} instance used in the {@code base} I/O library.
*/
public interface RConnection extends AutoCloseable {
public interface RConnection extends AutoCloseable, RTruffleObject {
static BaseRConnection fromIndex(int con) {
return RContext.getInstance().stateRConnection.getConnection(con, true);
......
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