File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/array Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 2525 */
2626package com .oracle .graal .python .builtins .objects .array ;
2727
28+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
29+ import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
2830import com .oracle .graal .python .runtime .sequence .PMutableSequence ;
2931import com .oracle .graal .python .runtime .sequence .storage .SequenceStorage ;
32+ import com .oracle .truffle .api .dsl .Cached ;
33+ import com .oracle .truffle .api .library .ExportLibrary ;
34+ import com .oracle .truffle .api .library .ExportMessage ;
3035import com .oracle .truffle .api .object .DynamicObject ;
3136
37+ @ ExportLibrary (PythonObjectLibrary .class )
3238public class PArray extends PMutableSequence {
3339
3440 private SequenceStorage store ;
@@ -55,4 +61,24 @@ public void setSequenceStorage(SequenceStorage store) {
5561 public int len () {
5662 return store .length ();
5763 }
64+
65+ @ ExportMessage
66+ boolean isBuffer () {
67+ return true ;
68+ }
69+
70+ @ ExportMessage
71+ byte [] getBufferBytes (
72+ @ Cached SequenceStorageNodes .ToByteArrayNode toByteArrayNode ) {
73+ // TODO Implement access to the actual bytes which represent the array in memory.
74+ // This implementation only works for ByteSequenceStorage.
75+ return toByteArrayNode .execute (store );
76+ }
77+
78+ @ ExportMessage
79+ int getBufferLength (
80+ @ Cached SequenceStorageNodes .LenNode lenNode ) {
81+ // TODO This only works for ByteSequenceStorage since its itemsize is 1.
82+ return lenNode .execute (store );
83+ }
5884}
You can’t perform that action at this time.
0 commit comments