Skip to content

Commit 7010d2a

Browse files
committed
Implement CStringWrapper#readBuffer to address Truffle warning
1 parent 50fc6a0 commit 7010d2a

File tree

1 file changed

+11
-0
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common

1 file changed

+11
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/CArrayWrappers.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,17 @@ float readBufferFloat(ByteOrder byteOrder, long byteOffset,
307307
@CachedLibrary("this") InteropLibrary thisLib) throws UnsupportedMessageException, InvalidBufferOffsetException {
308308
return Double.longBitsToDouble(thisLib.readBufferLong(this, byteOrder, byteOffset));
309309
}
310+
311+
@ExportMessage
312+
void readBuffer(long byteOffset, byte[] destination, int destinationOffset, int length,
313+
@CachedLibrary("this") InteropLibrary thisLib) throws UnsupportedMessageException, InvalidBufferOffsetException {
314+
if (length < 0) {
315+
throw InvalidBufferOffsetException.create(byteOffset, length);
316+
}
317+
for (int i = 0; i < length; i++) {
318+
destination[destinationOffset + i] = thisLib.readBufferByte(this, byteOffset + i);
319+
}
320+
}
310321
}
311322

312323
/**

0 commit comments

Comments
 (0)