use of com.oracle.truffle.api.interop.InvalidBufferOffsetException in project graal by oracle.
the class PolyglotHostObjectPartialEvaluationTest method readBufferByte.
@Test
public void readBufferByte() {
for (final Buffer buffer : ValueAPITest.makeTestBuffers()) {
getContext().initialize(ProxyLanguage.ID);
final Object bufferHostObject = LanguageContext.get(null).getEnv().asGuestValue(buffer);
final RootNode node = new RootNode(null) {
@Child
InteropLibrary interop = InteropLibrary.getFactory().createDispatched(1);
@Override
public Object execute(VirtualFrame frame) {
try {
return interop.readBufferByte(bufferHostObject, 0);
} catch (UnsupportedMessageException | InvalidBufferOffsetException e) {
throw new RuntimeException(e);
}
}
};
assertPartialEvalNoInvokes(node);
}
}
use of com.oracle.truffle.api.interop.InvalidBufferOffsetException in project graal by oracle.
the class PolyglotHostObjectPartialEvaluationTest method writeBufferByte.
@Test
public void writeBufferByte() {
for (final Buffer buffer : ValueAPITest.makeTestBuffers()) {
if (buffer.isReadOnly()) {
continue;
}
getContext().initialize(ProxyLanguage.ID);
final Object bufferHostObject = LanguageContext.get(null).getEnv().asGuestValue(buffer);
final RootNode node = new RootNode(null) {
@Child
InteropLibrary interop = InteropLibrary.getFactory().createDispatched(1);
@Override
public Object execute(VirtualFrame frame) {
try {
interop.writeBufferByte(bufferHostObject, 0, (byte) 42);
} catch (UnsupportedMessageException | InvalidBufferOffsetException e) {
throw new RuntimeException(e);
}
return null;
}
};
assertPartialEvalNoInvokes(node);
}
}
Aggregations