working build scripts

This commit is contained in:
Henry Hiles 2026-01-24 13:44:16 +00:00
commit 5c6440894b
No known key found for this signature in database
6 changed files with 78 additions and 101 deletions

View file

@ -6,6 +6,11 @@ import "package:ffi/ffi.dart";
import "package:nexus/src/third_party/gomuks.g.dart";
extension GomuksBufferToJson on GomuksBorrowedBuffer {
Uint8List toBytes() {
if (base == nullptr || length <= 0) return Uint8List(0);
return base.asTypedList(length);
}
Map<String, dynamic> toJson() {
final bytes = toBytes();
if (bytes.isEmpty) return {};
@ -14,21 +19,21 @@ extension GomuksBufferToJson on GomuksBorrowedBuffer {
}
extension JsonToGomuksBuffer on Map<String, dynamic> {
GomuksBuffer toGomuksBuffer() {
final jsonString = json.encode(this);
final bytes = utf8.encode(jsonString);
// GomuksBorrowedBuffer toGomuksBuffer() {
// final jsonString = json.encode(this);
// final bytes = utf8.encode(jsonString);
final dataPtr = calloc<Uint8>(bytes.length);
dataPtr.asTypedList(bytes.length).setAll(0, bytes);
// final dataPtr = calloc<Uint8>(bytes.length);
// dataPtr.asTypedList(bytes.length).setAll(0, bytes);
final bufPtr = calloc<GomuksBuffer>();
bufPtr.ref.base = dataPtr;
bufPtr.ref.length = bytes.length;
// final bufPtr = calloc<GomuksBuffer>();
// bufPtr.ref.base = dataPtr;
// bufPtr.ref.length = bytes.length;
final bufByValue = bufPtr.ref;
// final bufByValue = bufPtr.ref;
calloc.free(bufPtr);
// calloc.free(bufPtr);
return bufByValue;
}
// return bufByValue;
// }
}