Skip to content

Commit

Permalink
Fix comments and organize code
Browse files Browse the repository at this point in the history
  • Loading branch information
temeddix committed Sep 12, 2024
1 parent 8dd6db7 commit 8a5ad7a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions flutter_package/lib/src/load_os.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ RustLibrary loadRustLibrary() {
// because of Flutter's `RTLD_LOCAL` behavior.
// Therefore we cannot use the efficient `RustLibraryNew`.
// - https://github.com/dart-lang/native/issues/923
return RustLibraryOld(lib);
return RustLibraryOld(lib: lib);
} else {
// Native library symbols are loaded in global space
// thanks to Flutter's `RTLD_GLOBAL` behavior.
Expand Down Expand Up @@ -129,7 +129,7 @@ abstract class RustLibrary {
/// This is the efficient and ideal way to call native code.
/// `@Native` decorator with `isLeaf` parameter
/// that enables the `Uint8List.address` syntax
/// can only used on global native symbols.
/// can only be used on globally loaded native symbols.
/// - https://github.com/dart-lang/sdk/issues/44589
class RustLibraryNew extends RustLibrary {
void startRustLogic() {
Expand Down Expand Up @@ -167,16 +167,15 @@ class RustLibraryNew extends RustLibrary {
/// This is relatively inefficient because `malloc.allocate` is required.
/// It involves extra memory copy before sending the data to Rust.
class RustLibraryOld extends RustLibrary {
late DynamicLibrary lib;
final DynamicLibrary lib;
late void Function() startRustLogicExtern;
late void Function() stopRustLogicExtern;
late void Function(int) prepareIsolateExtern;
late void Function(PostCObjectPtr) storeDartPostCObjectExtern;
late void Function(int, Pointer<Uint8>, int, Pointer<Uint8>, int)
sendDartSignalExtern;

RustLibraryOld(DynamicLibrary lib) {
this.lib = lib;
RustLibraryOld({required this.lib}) {
this.startRustLogicExtern =
lib.lookupFunction<Void Function(), void Function()>(
'start_rust_logic_extern',
Expand Down

0 comments on commit 8a5ad7a

Please sign in to comment.