Closed craiglabenz closed 9 months ago
A Dart
Uint8List
<-> A nativePointer<Char>
.
This is not entirely safe. The char
type behaves as int8
on some platforms and as uint8
on other platforms. You can notice differences once using the indexed access operator in Dart for values 128-255 (or -128 to -1). Depending on the use case this might or might not be an issue. ByteBuffer
and ByteData
are classes that just passes around a piece of memory and does not promise a specific layout. The latter being able to pass around views with a non-zero offset. Again, it probably depends on the use case what solution makes sense.
We have a tracking issue for .asTypedList
on Pointer<T extends AbiSpecificInteger>
:
This is not entirely safe. The char type behaves as int8 on some platforms and as uint8 on other platforms.
A Dart
Uint8List
<-> A nativePointer<Char>
.This is not entirely safe. The
char
type behaves asint8
on some platforms and asuint8
on other platforms. You can notice differences once using the indexed access operator in Dart for values 128-255 (or -128 to -1). Depending on the use case this might or might not be an issue.ByteBuffer
andByteData
are classes that just passes around a piece of memory and does not promise a specific layout. The latter being able to pass around views with a non-zero offset. Again, it probably depends on the use case what solution makes sense.We have a tracking issue for
.asTypedList
onPointer<T extends AbiSpecificInteger>
:
Do you have any estimates on the tracking issue? It doesn't seem about to land, given that you haven't gotten any responses to your questions.
Absent that catch-all implementation, I'd love to quickly sync on the edge cases here to make sure I'm properly handling everything. Even with your helpful answer, I'm not sure how to exhaustively handle these edge cases.
This PR is being replaced.
Adds helpers for converting between Dart and native memory for the following scenarios:
Uint8List
<-> A nativePointer<Char>
.Additionally, I would like to submit the function
Uint8List toUint8List(Pointer<Char> val, {int? length})
for code review, even though it was committed previously.--
The context for this PR is work around Embeddings, which are currently emitting random results on sequential runs, and for which I want to rule out these low level memory mapping helpers.
cc @Piinks