@@ -46,7 +46,10 @@ public class RStringVecNativeData implements TruffleObject, ShareableVectorData
4646
4747 /**
4848 * After nativized, the data array degenerates to a reference holder, which prevents the objects
49- * from being GC'ed. If the native code copies data of one string vector to another without
49+ * from being GC'ed. This means that if someone changes the order of the CHARSXP elements on the native
50+ * side, this modification is not reflected in this reference holder array.
51+ *
52+ * If the native code copies data of one string vector to another without
5053 * using the proper API, we are doomed.
5154 */
5255 private final CharSXPWrapper [] data ;
@@ -140,32 +143,32 @@ public RandomAccessIterator randomAccessIterator() {
140143
141144 @ ExportMessage
142145 public String getStringAt (int index ) {
143- return NativeDataAccess .getData (vec , null , index );
146+ return NativeDataAccess .getData (vec , index ). getContents ( );
144147 }
145148
146149 @ ExportMessage
147150 public String getNextString (SeqIterator it ) {
148- return NativeDataAccess .getData (vec , null , it .getIndex ());
151+ return NativeDataAccess .getData (vec , it .getIndex ()). getContents ( );
149152 }
150153
151154 @ ExportMessage
152155 public String getString (@ SuppressWarnings ("unused" ) RandomAccessIterator it , int index ) {
153- return NativeDataAccess .getData (vec , null , index );
156+ return NativeDataAccess .getData (vec , index ). getContents ( );
154157 }
155158
156159 @ ExportMessage
157160 public CharSXPWrapper getCharSXPAt (int index ) {
158- return data [ index ] ;
161+ return NativeDataAccess . getData ( vec , index ) ;
159162 }
160163
161164 @ ExportMessage
162165 public CharSXPWrapper getNextCharSXP (SeqIterator it ) {
163- return data [ it .getIndex ()] ;
166+ return NativeDataAccess . getData ( vec , it .getIndex ()) ;
164167 }
165168
166169 @ ExportMessage
167170 public CharSXPWrapper getCharSXP (@ SuppressWarnings ("unused" ) RandomAccessIterator it , int index ) {
168- return data [ index ] ;
171+ return NativeDataAccess . getData ( vec , index ) ;
169172 }
170173
171174 // Write access to the elements:
@@ -197,16 +200,16 @@ public void setString(@SuppressWarnings("unused") RandomAccessWriteIterator it,
197200
198201 @ ExportMessage
199202 public void setCharSXPAt (int index , CharSXPWrapper value ) {
200- data [ index ] = value ;
203+ NativeDataAccess . setData ( vec , data , index , value ) ;
201204 }
202205
203206 @ ExportMessage
204207 public void setNextCharSXP (SeqWriteIterator it , CharSXPWrapper value ) {
205- data [ it .getIndex ()] = value ;
208+ NativeDataAccess . setData ( vec , data , it .getIndex (), value ) ;
206209 }
207210
208211 @ ExportMessage
209212 public void setCharSXP (@ SuppressWarnings ("unused" ) RandomAccessWriteIterator it , int index , CharSXPWrapper value ) {
210- data [ index ] = value ;
213+ NativeDataAccess . setData ( vec , data , index , value ) ;
211214 }
212215}
0 commit comments