working build scripts
This commit is contained in:
parent
8d43313512
commit
058f68cffb
6 changed files with 78 additions and 101 deletions
|
|
@ -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;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue