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 25
25
*/
26
26
package com .oracle .graal .python .builtins .objects .array ;
27
27
28
+ import com .oracle .graal .python .builtins .objects .common .SequenceStorageNodes ;
29
+ import com .oracle .graal .python .builtins .objects .object .PythonObjectLibrary ;
28
30
import com .oracle .graal .python .runtime .sequence .PMutableSequence ;
29
31
import 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 ;
30
35
import com .oracle .truffle .api .object .DynamicObject ;
31
36
37
+ @ ExportLibrary (PythonObjectLibrary .class )
32
38
public class PArray extends PMutableSequence {
33
39
34
40
private SequenceStorage store ;
@@ -55,4 +61,24 @@ public void setSequenceStorage(SequenceStorage store) {
55
61
public int len () {
56
62
return store .length ();
57
63
}
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
+ }
58
84
}
You can’t perform that action at this time.
0 commit comments