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

make RConnection RAttributable

parent 61f31378
No related branches found
No related tags found
No related merge requests found
......@@ -249,11 +249,6 @@ public class ConnectionSupport implements RContext.StateFactory {
*/
private OpenMode openMode;
/**
* The classes of the connection, which always includes "connection".
*/
private final RStringVector classHr;
/**
* The actual connection, if delegated.
*/
......@@ -295,7 +290,7 @@ public class ConnectionSupport implements RContext.StateFactory {
String[] classes = new String[2];
classes[0] = conClass.printName;
classes[1] = "connection";
this.classHr = RDataFactory.createStringVector(classes, RDataFactory.COMPLETE_VECTOR);
getAttributes().put(RRuntime.CLASS_ATTR_KEY, RDataFactory.createStringVector(classes, RDataFactory.COMPLETE_VECTOR));
}
protected void openNonLazyConnection() throws IOException {
......@@ -549,7 +544,7 @@ public class ConnectionSupport implements RContext.StateFactory {
}
public RStringVector getClassHr() {
return classHr;
return (RStringVector) getAttributes().get(RRuntime.CLASS_ATTR_KEY);
}
public boolean isClosed() {
......
......@@ -36,10 +36,23 @@ import com.oracle.truffle.r.runtime.data.model.*;
*
* TODO Refactor the pushBack code into ConnectionsSupport
*/
public abstract class RConnection implements RClassHierarchy, RTypedValue, AutoCloseable {
public abstract class RConnection implements RClassHierarchy, RAttributable, RTypedValue, AutoCloseable {
private LinkedList<String> pushBack;
/**
* Connections always have at least a class attribute.
*/
private RAttributes attributes = RAttributes.create();
public RAttributes initAttributes() {
return attributes;
}
public RAttributes getAttributes() {
return attributes;
}
public abstract String[] readLinesInternal(int n) throws IOException;
public RType getRType() {
......
......@@ -69,7 +69,7 @@ public final class RAttributes implements Iterable<RAttributes.RAttribute> {
private static final ConditionProfile statsProfile = ConditionProfile.createBinaryProfile();
static RAttributes create() {
public static RAttributes create() {
return new RAttributes();
}
......
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