Skip to content

Commit

Permalink
Update libedax.dart (#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
sensuikan1973 authored Oct 17, 2023
1 parent cbc23b3 commit 06e0fcf
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 21 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.0.5 <4.0.0"
dart: ">=3.1.0 <4.0.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: libedax4dart_example
publish_to: none

environment:
sdk: ">=3.0.5 <4.0.0"
sdk: ">=3.1.0 <4.0.0"

dependencies:
ffi: ^2.0.2
Expand Down
18 changes: 1 addition & 17 deletions lib/src/libedax.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:ffi';
import 'dart:io';

import 'package:ffi/ffi.dart';
import 'package:meta/meta.dart';
Expand Down Expand Up @@ -53,24 +52,9 @@ class LibEdax {

/// Close dll.
///
/// FIXME: this is workaround Function.
/// See: https://github.com/dart-lang/sdk/issues/40159
///
/// After you call this, if you use edax command, you have to recreate [LibEdax] instance.
@experimental
void closeDll() => _dlCloseFunc(_dylib.handle);

int Function(Pointer<Void>) get _dlCloseFunc {
final funcName = Platform.isWindows ? 'FreeLibrary' : 'dlclose';
return _stdlib
.lookup<NativeFunction<Int32 Function(Pointer<Void>)>>(funcName)
.asFunction();
}

// See: https://github.com/dart-lang/ffi/blob/f3346299c55669cc0db48afae85b8110088bf8da/lib/src/allocation.dart#L8-L11
DynamicLibrary get _stdlib => Platform.isWindows
? DynamicLibrary.open('kernel32.dll')
: DynamicLibrary.process();
void closeDll() => _dylib.close();

/// Init board.
void edaxInit() => _bindings.edax_init();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -570,4 +570,4 @@ packages:
source: hosted
version: "2.1.1"
sdks:
dart: ">=3.0.5 <4.0.0"
dart: ">=3.1.0 <4.0.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ issue_tracker: https://github.com/sensuikan1973/libedax4dart/issues
repository: https://github.com/sensuikan1973/libedax4dart

environment:
sdk: '>=3.0.5 <4.0.0' # See: https://dart.dev/null-safety#enable-null-safety
sdk: '>=3.1.0 <4.0.0' # See: https://dart.dev/null-safety#enable-null-safety

dependencies:
ffi: ^2.0.2
Expand Down

0 comments on commit 06e0fcf

Please sign in to comment.