diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1c70e71 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "dart.lineLength": 120, + "editor.rulers": [ + 120 + ], + "[dart]": { + "editor.rulers": [ + 120 + ], + "editor.formatOnSave": true, + } +} \ No newline at end of file diff --git a/melos.yaml b/melos.yaml index 74f2d0e..91d6bac 100644 --- a/melos.yaml +++ b/melos.yaml @@ -20,13 +20,6 @@ scripts: flutter pub get description: Run `flutter pub get` in all packages. - - analyze: - run: | - melos exec -c 1 -- \ - flutter analyze . - description: - Run `dart analyze` in all packages. generate: run: melos run generate:dart && melos run generate:flutter @@ -58,6 +51,14 @@ scripts: flutter: true dir-exists: test + checkformat: + run: melos exec -c 1 "flutter format --line-length=120 --output=none --set-exit-if-changed ." + description: Check all packages are formatted. + format: - run: melos exec -c 1 "flutter format ." - description: Format all packages using flutter format + run: melos exec -c 1 "flutter format --line-length=120 ." + description: Format all packages. + + analyze: + run: melos exec -c 1 "flutter analyze --fatal-infos ." + description: Run `flutter analyze --fatal-infos` in all packages. diff --git a/packages/_ardera_common_libc_bindings/lib/src/libc.dart b/packages/_ardera_common_libc_bindings/lib/src/libc.dart index 7997f04..51dfedd 100644 --- a/packages/_ardera_common_libc_bindings/lib/src/libc.dart +++ b/packages/_ardera_common_libc_bindings/lib/src/libc.dart @@ -78,8 +78,7 @@ class LibC { final ffi.Pointer Function(String) _lookup; final dynamic _backend; - factory LibC.fromLookup( - ffi.Pointer Function(String) lookup) { + factory LibC.fromLookup(ffi.Pointer Function(String) lookup) { if (Arch.isArm) { final _libcArm = arm.LibCPlatformBackend.fromLookup(lookup); return LibC._internal( @@ -113,21 +112,13 @@ class LibC { return LibC.fromLookup(dylib.lookup); } - late final int Function(int, int, ffi.Pointer) ioctl_ptr = - Arch.isArm || Arch.isI386 - ? (addresses.ioctl as ffi.Pointer) - .cast< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Uint32, ffi.Pointer)>>() - .asFunction)>( - isLeaf: true) - : (addresses.ioctl as ffi.Pointer) - .cast< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Uint64, ffi.Pointer)>>() - .asFunction)>(isLeaf: true); + late final int Function(int, int, ffi.Pointer) ioctl_ptr = Arch.isArm || Arch.isI386 + ? (addresses.ioctl as ffi.Pointer) + .cast)>>() + .asFunction)>(isLeaf: true) + : (addresses.ioctl as ffi.Pointer) + .cast)>>() + .asFunction)>(isLeaf: true); late final int Function(int, int) ioctl = _backend.ioctl; late final int Function(int) epoll_create = _backend.epoll_create; late final int Function(int) epoll_create1 = _backend.epoll_create1; @@ -136,16 +127,12 @@ class LibC { return _backend.epoll_ctl(__epfd, __op, __fd, __event.nativeBacking); } - int epoll_wait( - int __epfd, epoll_event_ptr __events, int __maxevents, int __timeout) { - return _backend.epoll_wait( - __epfd, __events.nativeBacking, __maxevents, __timeout); + int epoll_wait(int __epfd, epoll_event_ptr __events, int __maxevents, int __timeout) { + return _backend.epoll_wait(__epfd, __events.nativeBacking, __maxevents, __timeout); } late final int Function(ffi.Pointer, int) open = - Arch.isArm || Arch.isArm64 - ? (file, oflag) => _backend.open(file.cast(), oflag) - : _backend.open; + Arch.isArm || Arch.isArm64 ? (file, oflag) => _backend.open(file.cast(), oflag) : _backend.open; late final int Function(int) close = _backend.close; late final int Function(int, ffi.Pointer, int) read = _backend.read; @@ -174,30 +161,24 @@ class LibC { return _backend.tcsetattr(__fd, __optional_actions, __termios_p.backing); } - late final int Function(int __fd, int __duration) tcsendbreak = - _backend.tcsendbreak; + late final int Function(int __fd, int __duration) tcsendbreak = _backend.tcsendbreak; late final int Function(int __fd) tcdrain = _backend.tcdrain; - late final int Function(int __fd, int __queue_selector) tcflush = - _backend.tcflush; + late final int Function(int __fd, int __queue_selector) tcflush = _backend.tcflush; late final int Function(int __fd, int __action) tcflow = _backend.tcflow; late final int Function(int __fd) tcgetsid = _backend.tcgetsid; late final addresses = _backend.addresses; - late final ffi.Pointer Function()>> - errno_location_symbol_address = (() { - ffi.Pointer Function()>>? - tryLookup(String name) { + late final ffi.Pointer Function()>> errno_location_symbol_address = (() { + ffi.Pointer Function()>>? tryLookup(String name) { try { - return _lookup Function()>>( - name); + return _lookup Function()>>(name); } on ArgumentError { return null; } } - ffi.Pointer Function()>> - throwStateError() { + ffi.Pointer Function()>> throwStateError() { throw StateError('Couldn\'t resolve the errno location function.'); } @@ -208,8 +189,8 @@ class LibC { tryLookup('__libc_errno') ?? throwStateError(); })(); - ffi.Pointer get errno_location => errno_location_symbol_address - .asFunction Function()>()(); + ffi.Pointer get errno_location => + errno_location_symbol_address.asFunction Function()>()(); int get errno => errno_location.value; } diff --git a/packages/_ardera_common_libc_bindings/lib/src/libc_amd64.g.dart b/packages/_ardera_common_libc_bindings/lib/src/libc_amd64.g.dart index 023b14e..f6536a5 100644 --- a/packages/_ardera_common_libc_bindings/lib/src/libc_amd64.g.dart +++ b/packages/_ardera_common_libc_bindings/lib/src/libc_amd64.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for amd64 class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Int32, ffi.Pointer, ffi.Uint64)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint64)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,24 +291,14 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer> - get ioctl => _library._ioctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer> get ioctl => _library._ioctlPtr; + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Int32, ffi.Pointer, ffi.Uint64)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint64)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_common_libc_bindings/lib/src/libc_arm.g.dart b/packages/_ardera_common_libc_bindings/lib/src/libc_arm.g.dart index 3f5021b..9ab8c01 100644 --- a/packages/_ardera_common_libc_bindings/lib/src/libc_arm.g.dart +++ b/packages/_ardera_common_libc_bindings/lib/src/libc_arm.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for arm class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Uint32)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint32)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,24 +291,14 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer> - get ioctl => _library._ioctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer> get ioctl => _library._ioctlPtr; + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Uint32)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint32)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_common_libc_bindings/lib/src/libc_arm64.g.dart b/packages/_ardera_common_libc_bindings/lib/src/libc_arm64.g.dart index e0e0c9c..99e8830 100644 --- a/packages/_ardera_common_libc_bindings/lib/src/libc_arm64.g.dart +++ b/packages/_ardera_common_libc_bindings/lib/src/libc_arm64.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for arm64 class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Int32, ffi.Pointer, ffi.Uint64)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint64)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,24 +291,14 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer> - get ioctl => _library._ioctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer> get ioctl => _library._ioctlPtr; + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Int32, ffi.Pointer, ffi.Uint64)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint64)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_common_libc_bindings/lib/src/libc_i386.g.dart b/packages/_ardera_common_libc_bindings/lib/src/libc_i386.g.dart index 66ff726..d80416c 100644 --- a/packages/_ardera_common_libc_bindings/lib/src/libc_i386.g.dart +++ b/packages/_ardera_common_libc_bindings/lib/src/libc_i386.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for i386 class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Uint32)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint32)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,24 +291,14 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer> - get ioctl => _library._ioctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer> get ioctl => _library._ioctlPtr; + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Uint32)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint32)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_amd64.g.dart b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_amd64.g.dart index 2f9cf67..f32f555 100644 --- a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_amd64.g.dart +++ b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_amd64.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for amd64 class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Int32, ffi.Pointer, ffi.Uint64)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint64)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,22 +291,13 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Int32, ffi.Pointer, ffi.Uint64)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint64)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm.g.dart b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm.g.dart index 022909d..9f0d5a4 100644 --- a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm.g.dart +++ b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for arm class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Uint32)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint32)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,22 +291,13 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Uint32)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint32)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm64.g.dart b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm64.g.dart index 2f01589..aa1295c 100644 --- a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm64.g.dart +++ b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_arm64.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for arm64 class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int64 Function( - ffi.Int32, ffi.Pointer, ffi.Uint64)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint64)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,22 +291,13 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int64 Function(ffi.Int32, ffi.Pointer, ffi.Uint64)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint64)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_i386.g.dart b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_i386.g.dart index 176adaf..01fb9c7 100644 --- a/packages/_ardera_libc_bindings_generator/example/lib/src/libc_i386.g.dart +++ b/packages/_ardera_libc_bindings_generator/example/lib/src/libc_i386.g.dart @@ -14,17 +14,13 @@ import 'dart:ffi' as ffi; /// libc backend for i386 class LibCPlatformBackend { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) - _lookup; + final ffi.Pointer Function(String symbolName) _lookup; /// The symbols are looked up in [dynamicLibrary]. - LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) - : _lookup = dynamicLibrary.lookup; + LibCPlatformBackend(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - LibCPlatformBackend.fromLookup( - ffi.Pointer Function(String symbolName) - lookup) + LibCPlatformBackend.fromLookup(ffi.Pointer Function(String symbolName) lookup) : _lookup = lookup; int ioctl( @@ -37,11 +33,8 @@ class LibCPlatformBackend { ); } - late final _ioctlPtr = - _lookup>( - 'ioctl'); - late final _ioctl = - _ioctlPtr.asFunction(isLeaf: true); + late final _ioctlPtr = _lookup>('ioctl'); + late final _ioctl = _ioctlPtr.asFunction(isLeaf: true); int epoll_create( int __size, @@ -51,11 +44,8 @@ class LibCPlatformBackend { ); } - late final _epoll_createPtr = - _lookup>( - 'epoll_create'); - late final _epoll_create = - _epoll_createPtr.asFunction(isLeaf: true); + late final _epoll_createPtr = _lookup>('epoll_create'); + late final _epoll_create = _epoll_createPtr.asFunction(isLeaf: true); int epoll_create1( int __flags, @@ -65,11 +55,8 @@ class LibCPlatformBackend { ); } - late final _epoll_create1Ptr = - _lookup>( - 'epoll_create1'); - late final _epoll_create1 = - _epoll_create1Ptr.asFunction(isLeaf: true); + late final _epoll_create1Ptr = _lookup>('epoll_create1'); + late final _epoll_create1 = _epoll_create1Ptr.asFunction(isLeaf: true); int epoll_ctl( int __epfd, @@ -85,13 +72,10 @@ class LibCPlatformBackend { ); } - late final _epoll_ctlPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, - ffi.Pointer)>>('epoll_ctl'); - late final _epoll_ctl = _epoll_ctlPtr - .asFunction)>( - isLeaf: true); + late final _epoll_ctlPtr = + _lookup)>>( + 'epoll_ctl'); + late final _epoll_ctl = _epoll_ctlPtr.asFunction)>(isLeaf: true); int epoll_wait( int __epfd, @@ -107,23 +91,18 @@ class LibCPlatformBackend { ); } - late final _epoll_waitPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, - ffi.Int32)>>('epoll_wait'); - late final _epoll_wait = _epoll_waitPtr - .asFunction, int, int)>( - isLeaf: true); + late final _epoll_waitPtr = + _lookup, ffi.Int32, ffi.Int32)>>( + 'epoll_wait'); + late final _epoll_wait = + _epoll_waitPtr.asFunction, int, int)>(isLeaf: true); ffi.Pointer errno_location() { return _errno_location(); } - late final _errno_locationPtr = - _lookup Function()>>( - '__errno_location'); - late final _errno_location = _errno_locationPtr - .asFunction Function()>(isLeaf: true); + late final _errno_locationPtr = _lookup Function()>>('__errno_location'); + late final _errno_location = _errno_locationPtr.asFunction Function()>(isLeaf: true); int open( ffi.Pointer __file, @@ -135,11 +114,8 @@ class LibCPlatformBackend { ); } - late final _openPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Int32)>>('open'); - late final _open = _openPtr - .asFunction, int)>(isLeaf: true); + late final _openPtr = _lookup, ffi.Int32)>>('open'); + late final _open = _openPtr.asFunction, int)>(isLeaf: true); int close( int __fd, @@ -149,8 +125,7 @@ class LibCPlatformBackend { ); } - late final _closePtr = - _lookup>('close'); + late final _closePtr = _lookup>('close'); late final _close = _closePtr.asFunction(isLeaf: true); int read( @@ -165,12 +140,9 @@ class LibCPlatformBackend { ); } - late final _readPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Uint32)>>('read'); - late final _read = _readPtr - .asFunction, int)>(isLeaf: true); + late final _readPtr = + _lookup, ffi.Uint32)>>('read'); + late final _read = _readPtr.asFunction, int)>(isLeaf: true); int cfgetospeed( ffi.Pointer __termios_p, @@ -180,11 +152,8 @@ class LibCPlatformBackend { ); } - late final _cfgetospeedPtr = - _lookup)>>( - 'cfgetospeed'); - late final _cfgetospeed = _cfgetospeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetospeedPtr = _lookup)>>('cfgetospeed'); + late final _cfgetospeed = _cfgetospeedPtr.asFunction)>(isLeaf: true); int cfgetispeed( ffi.Pointer __termios_p, @@ -194,11 +163,8 @@ class LibCPlatformBackend { ); } - late final _cfgetispeedPtr = - _lookup)>>( - 'cfgetispeed'); - late final _cfgetispeed = _cfgetispeedPtr - .asFunction)>(isLeaf: true); + late final _cfgetispeedPtr = _lookup)>>('cfgetispeed'); + late final _cfgetispeed = _cfgetispeedPtr.asFunction)>(isLeaf: true); int cfsetospeed( ffi.Pointer __termios_p, @@ -210,11 +176,9 @@ class LibCPlatformBackend { ); } - late final _cfsetospeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetospeed'); - late final _cfsetospeed = _cfsetospeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetospeedPtr = + _lookup, ffi.Uint32)>>('cfsetospeed'); + late final _cfsetospeed = _cfsetospeedPtr.asFunction, int)>(isLeaf: true); int cfsetispeed( ffi.Pointer __termios_p, @@ -226,11 +190,9 @@ class LibCPlatformBackend { ); } - late final _cfsetispeedPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Pointer, ffi.Uint32)>>('cfsetispeed'); - late final _cfsetispeed = _cfsetispeedPtr - .asFunction, int)>(isLeaf: true); + late final _cfsetispeedPtr = + _lookup, ffi.Uint32)>>('cfsetispeed'); + late final _cfsetispeed = _cfsetispeedPtr.asFunction, int)>(isLeaf: true); int tcgetattr( int __fd, @@ -242,11 +204,9 @@ class LibCPlatformBackend { ); } - late final _tcgetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer)>>('tcgetattr'); - late final _tcgetattr = _tcgetattrPtr - .asFunction)>(isLeaf: true); + late final _tcgetattrPtr = + _lookup)>>('tcgetattr'); + late final _tcgetattr = _tcgetattrPtr.asFunction)>(isLeaf: true); int tcsetattr( int __fd, @@ -260,12 +220,9 @@ class LibCPlatformBackend { ); } - late final _tcsetattrPtr = _lookup< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Pointer)>>('tcsetattr'); - late final _tcsetattr = _tcsetattrPtr - .asFunction)>(isLeaf: true); + late final _tcsetattrPtr = + _lookup)>>('tcsetattr'); + late final _tcsetattr = _tcsetattrPtr.asFunction)>(isLeaf: true); int tcsendbreak( int __fd, @@ -277,11 +234,8 @@ class LibCPlatformBackend { ); } - late final _tcsendbreakPtr = - _lookup>( - 'tcsendbreak'); - late final _tcsendbreak = - _tcsendbreakPtr.asFunction(isLeaf: true); + late final _tcsendbreakPtr = _lookup>('tcsendbreak'); + late final _tcsendbreak = _tcsendbreakPtr.asFunction(isLeaf: true); int tcdrain( int __fd, @@ -291,8 +245,7 @@ class LibCPlatformBackend { ); } - late final _tcdrainPtr = - _lookup>('tcdrain'); + late final _tcdrainPtr = _lookup>('tcdrain'); late final _tcdrain = _tcdrainPtr.asFunction(isLeaf: true); int tcflush( @@ -305,11 +258,8 @@ class LibCPlatformBackend { ); } - late final _tcflushPtr = - _lookup>( - 'tcflush'); - late final _tcflush = - _tcflushPtr.asFunction(isLeaf: true); + late final _tcflushPtr = _lookup>('tcflush'); + late final _tcflush = _tcflushPtr.asFunction(isLeaf: true); int tcflow( int __fd, @@ -321,11 +271,8 @@ class LibCPlatformBackend { ); } - late final _tcflowPtr = - _lookup>( - 'tcflow'); - late final _tcflow = - _tcflowPtr.asFunction(isLeaf: true); + late final _tcflowPtr = _lookup>('tcflow'); + late final _tcflow = _tcflowPtr.asFunction(isLeaf: true); int tcgetsid( int __fd, @@ -335,10 +282,8 @@ class LibCPlatformBackend { ); } - late final _tcgetsidPtr = - _lookup>('tcgetsid'); - late final _tcgetsid = - _tcgetsidPtr.asFunction(isLeaf: true); + late final _tcgetsidPtr = _lookup>('tcgetsid'); + late final _tcgetsid = _tcgetsidPtr.asFunction(isLeaf: true); late final addresses = _SymbolAddresses(this); } @@ -346,22 +291,13 @@ class LibCPlatformBackend { class _SymbolAddresses { final LibCPlatformBackend _library; _SymbolAddresses(this._library); - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>> + ffi.Pointer)>> get epoll_ctl => _library._epoll_ctlPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>> + ffi.Pointer, ffi.Int32, ffi.Int32)>> get epoll_wait => _library._epoll_waitPtr; - ffi.Pointer Function()>> - get errno_location => _library._errno_locationPtr; - ffi.Pointer< - ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Uint32)>> - get read => _library._readPtr; + ffi.Pointer Function()>> get errno_location => _library._errno_locationPtr; + ffi.Pointer, ffi.Uint32)>> get read => + _library._readPtr; } abstract class EPOLL_EVENTS { diff --git a/packages/_ardera_libc_bindings_generator/lib/src/ffigen_config.dart b/packages/_ardera_libc_bindings_generator/lib/src/ffigen_config.dart index 603b290..5e1f3e9 100644 --- a/packages/_ardera_libc_bindings_generator/lib/src/ffigen_config.dart +++ b/packages/_ardera_libc_bindings_generator/lib/src/ffigen_config.dart @@ -22,19 +22,14 @@ const headerIncludeDirectives = [ //'**if**.h', ]; -List getHeaderEntryPointsForSearchPath( - List entryPoints, Directory searchPath) { +List getHeaderEntryPointsForSearchPath(List entryPoints, Directory searchPath) { return [ for (final entryPoint in entryPoints) searchPath.childFile(entryPoint).path, ]; } -List getHeaderEntryPointsForSearchPaths( - List entryPoints, List searchPaths) { - return [ - for (final searchPath in searchPaths) - ...getHeaderEntryPointsForSearchPath(entryPoints, searchPath) - ]; +List getHeaderEntryPointsForSearchPaths(List entryPoints, List searchPaths) { + return [for (final searchPath in searchPaths) ...getHeaderEntryPointsForSearchPath(entryPoints, searchPath)]; } List getIncludeSearchPaths(Directory sysroot, TargetArch arch) { @@ -43,10 +38,8 @@ List getIncludeSearchPaths(Directory sysroot, TargetArch arch) { final usrLibGcc = usrLib.childDir('gcc'); final usrLibGccTarget = usrLibGcc.childDir(arch.gccDirName); final usrLibGccTargetVersion = usrLibGccTarget.childDir('10'); - final usrLibGccTargetVersionInclude = - usrLibGccTargetVersion.childDir('include'); - final usrLibGccTargetVersionIncludeFixed = - usrLibGccTargetVersion.childDir('include-fixed'); + final usrLibGccTargetVersionInclude = usrLibGccTargetVersion.childDir('include'); + final usrLibGccTargetVersionIncludeFixed = usrLibGccTargetVersion.childDir('include-fixed'); final usrInclude = usr.childDir('include'); final usrIncludeTarget = usrInclude.childDir(arch.targetTriple); diff --git a/packages/_ardera_libc_bindings_generator/lib/src/libc_bindings_generator.dart b/packages/_ardera_libc_bindings_generator/lib/src/libc_bindings_generator.dart index b1c3d97..b0c8880 100644 --- a/packages/_ardera_libc_bindings_generator/lib/src/libc_bindings_generator.dart +++ b/packages/_ardera_libc_bindings_generator/lib/src/libc_bindings_generator.dart @@ -96,8 +96,7 @@ class FrontendLibrary implements Spec { final classes = {}; final structs = >{}; - final constants = - >{}; + final constants = >{}; final enums = >{}; for (final backend in backends) { @@ -123,11 +122,10 @@ class FrontendLibrary implements Spec { } } - final firstBackendWithoutAnFfiClass = - backends.cast().firstWhere( - (backend) => !classes.containsKey(backend), - orElse: () => null, - ); + final firstBackendWithoutAnFfiClass = backends.cast().firstWhere( + (backend) => !classes.containsKey(backend), + orElse: () => null, + ); if (firstBackendWithoutAnFfiClass != null) { throw StateError( @@ -138,8 +136,7 @@ class FrontendLibrary implements Spec { final firstStructWithoutAnElementForEachBackend = structs.entries .cast>?>() .firstWhere( - (entry) => - !backends.every((backend) => entry!.value.containsKey(backend)), + (entry) => !backends.every((backend) => entry!.value.containsKey(backend)), orElse: () => null, ) ?.key; @@ -151,12 +148,9 @@ class FrontendLibrary implements Spec { } final firstConstantWithoutAnElementForEachBackend = constants.entries - .cast< - MapEntry>?>() + .cast>?>() .firstWhere( - (entry) => - !backends.every((backend) => entry!.value.containsKey(backend)), + (entry) => !backends.every((backend) => entry!.value.containsKey(backend)), orElse: () => null, ) ?.key; @@ -170,8 +164,7 @@ class FrontendLibrary implements Spec { final firstEnumWithoutAnElementForEachBackend = enums.entries .cast>?>() .firstWhere( - (entry) => - !backends.every((backend) => entry!.value.containsKey(backend)), + (entry) => !backends.every((backend) => entry!.value.containsKey(backend)), orElse: () => null, ) ?.key; @@ -245,8 +238,7 @@ class LibCPlatformBackendGenerator extends Generator { final Logger _logger; final Map _options; - String get _sevenZipCommand => - _options[_kSevenZipCommand] as String? ?? '7za'; + String get _sevenZipCommand => _options[_kSevenZipCommand] as String? ?? '7za'; String? get _windowsLlvmPath => _options[_kWindowsLlvmPath] as String?; String? get _linuxLlvmPath => _options[_kLinuxLlvmPath] as String?; @@ -260,11 +252,9 @@ class LibCPlatformBackendGenerator extends Generator { } } - Map? get _ffigenOptions => - (_options[_kFfigenOptions] as Map?)?.cast(); + Map? get _ffigenOptions => (_options[_kFfigenOptions] as Map?)?.cast(); - Future _ensureSysrootInstalled( - {required LibCPlatformBackend backend}) async { + Future _ensureSysrootInstalled({required LibCPlatformBackend backend}) async { final cacheDir = getApplicationSupportDirectory(_cacheDirName); if (!await cacheDir.exists()) { @@ -334,8 +324,7 @@ class LibCPlatformBackendGenerator extends Generator { /// Somehow, ffigen sometimes fails when the paths use `\` seperators /// because the globbing library used internally won't accept `\` seperators. - final headerEntryPointsPosix = - headerEntryPoints.map((e) => e.replaceAll(r'\', '/')).toList(); + final headerEntryPointsPosix = headerEntryPoints.map((e) => e.replaceAll(r'\', '/')).toList(); final config = ffigen.Config.fromYaml(YamlMap.wrap({ if (_llvmPath != null) ffigen.llvmPath: [_llvmPath], @@ -343,8 +332,7 @@ class LibCPlatformBackendGenerator extends Generator { ffigen.headers: { ffigen.entryPoints: YamlList.wrap(headerEntryPointsPosix), if (ffigenOptions[ffigen.headers][ffigen.includeDirectives] != null) - ffigen.includeDirectives: ffigenOptions[ffigen.headers] - [ffigen.includeDirectives], + ffigen.includeDirectives: ffigenOptions[ffigen.headers][ffigen.includeDirectives], }, ffigen.compilerOpts: YamlList.wrap([ '--target=${arch.targetTriple}', @@ -472,10 +460,7 @@ class LibCPlatformBackendGenerator extends Generator { var backend = LibCPlatformBackend( TargetArch.forNameOrAlias( - RegExp(r'_([a-zA-Z0-9]+)\.dart$') - .allMatches(buildStep.inputId.pathSegments.last) - .single - .group(1)!, + RegExp(r'_([a-zA-Z0-9]+)\.dart$').allMatches(buildStep.inputId.pathSegments.last).single.group(1)!, ), TargetPlatform.fromName(_options[_kTargetDistro] as String), ); diff --git a/packages/_ardera_libc_bindings_generator/lib/src/sysroot_dict.dart b/packages/_ardera_libc_bindings_generator/lib/src/sysroot_dict.dart index 63cc224..d5cda8c 100644 --- a/packages/_ardera_libc_bindings_generator/lib/src/sysroot_dict.dart +++ b/packages/_ardera_libc_bindings_generator/lib/src/sysroot_dict.dart @@ -29,15 +29,13 @@ class SysrootDict { ); Future> get _json async { - final chromiumJsonString = - await httpGetString(_chromiumSysrootDictUri, base64: true); + final chromiumJsonString = await httpGetString(_chromiumSysrootDictUri, base64: true); final dartJsonString = await httpGetString(_dartSysrootDictUri); final chromiumJson = jsonDecode(chromiumJsonString); final dartJson = jsonDecode(dartJsonString); - return Map.from(chromiumJson as Map) - ..addAll((dartJson as Map).cast()); + return Map.from(chromiumJson as Map)..addAll((dartJson as Map).cast()); } Future lookupForTarget({ diff --git a/packages/_ardera_libc_bindings_generator/lib/src/target_arch.dart b/packages/_ardera_libc_bindings_generator/lib/src/target_arch.dart index d916257..23da658 100644 --- a/packages/_ardera_libc_bindings_generator/lib/src/target_arch.dart +++ b/packages/_ardera_libc_bindings_generator/lib/src/target_arch.dart @@ -53,22 +53,16 @@ class TargetArch { static const arm = TargetArch.smallLong('arm', 'arm-linux-gnueabihf'); static const arm64 = TargetArch.largeLong('arm64', 'aarch64-linux-gnu'); - static const i386 = TargetArch.smallLong('i386', 'i386-linux-gnu', - gccDirName: 'i686-linux-gnu', aliases: ['x86']); - static const amd64 = - TargetArch.largeLong('amd64', 'x86_64-linux-gnu', aliases: ['x64']); - static const mips = - TargetArch.smallLong('mips', 'mipsel-linux-gnu', aliases: ['mipsel']); - static const mips64el = TargetArch.largeLong( - 'mips64el', 'mips64el-linux-gnuabi64', - aliases: ['mips64']); + static const i386 = TargetArch.smallLong('i386', 'i386-linux-gnu', gccDirName: 'i686-linux-gnu', aliases: ['x86']); + static const amd64 = TargetArch.largeLong('amd64', 'x86_64-linux-gnu', aliases: ['x64']); + static const mips = TargetArch.smallLong('mips', 'mipsel-linux-gnu', aliases: ['mipsel']); + static const mips64el = TargetArch.largeLong('mips64el', 'mips64el-linux-gnuabi64', aliases: ['mips64']); static const values = {arm, arm64, i386, amd64, mips, mips64el}; factory TargetArch.forNameOrAlias(String nameOrAlias) { - return values.singleWhere((element) => - element.name == nameOrAlias || - element.aliases.any((alias) => alias == nameOrAlias)); + return values + .singleWhere((element) => element.name == nameOrAlias || element.aliases.any((alias) => alias == nameOrAlias)); } String toString() => 'TargetArch.$name'; diff --git a/packages/_ardera_libc_bindings_generator/lib/src/target_platform.dart b/packages/_ardera_libc_bindings_generator/lib/src/target_platform.dart index cbb17ac..ece5b88 100644 --- a/packages/_ardera_libc_bindings_generator/lib/src/target_platform.dart +++ b/packages/_ardera_libc_bindings_generator/lib/src/target_platform.dart @@ -1,8 +1,7 @@ class TargetPlatform { const TargetPlatform(this.name); - factory TargetPlatform.fromName(String name) => - values.singleWhere((platform) => platform.name == name); + factory TargetPlatform.fromName(String name) => values.singleWhere((platform) => platform.name == name); final String name; diff --git a/packages/_ardera_libc_bindings_generator/lib/src/util.dart b/packages/_ardera_libc_bindings_generator/lib/src/util.dart index ad8047e..1b0d7d2 100644 --- a/packages/_ardera_libc_bindings_generator/lib/src/util.dart +++ b/packages/_ardera_libc_bindings_generator/lib/src/util.dart @@ -15,12 +15,10 @@ import 'package:xdg_directories/xdg_directories.dart' as xdg; Stream> httpGetByteStream(Uri uri) { final client = HttpClient(); - return StreamCompleter.fromFuture( - client.getUrl(uri).then((value) => value.close())); + return StreamCompleter.fromFuture(client.getUrl(uri).then((value) => value.close())); } -Future httpGetString(Uri uri, - {Encoding encoding = utf8, bool base64 = false}) async { +Future httpGetString(Uri uri, {Encoding encoding = utf8, bool base64 = false}) async { final string = await encoding.decodeStream(httpGetByteStream(uri)); if (base64) { @@ -72,14 +70,12 @@ Future dartFormat({ required FileSystemEntity target, required Logger logger, }) async { - final result = - await Process.run('dart', ['format', '-l', '200', target.path]); + final result = await Process.run('dart', ['format', '-l', '200', target.path]); if (result.exitCode == 0) { logger.fine(result.stdout); logger.fine(result.stderr); } else { - logger.warning( - 'Couldn\'t format bindings: ${result.stdout}, ${result.stderr}'); + logger.warning('Couldn\'t format bindings: ${result.stdout}, ${result.stderr}'); } } @@ -99,8 +95,7 @@ Future invoke7Zip({ final exitCode = await process.exitCode; if (exitCode != 0) { - logger.severe( - 'Couldn\'t extract file \"$src\" using 7zip. exit code: $exitCode'); + logger.severe('Couldn\'t extract file \"$src\" using 7zip. exit code: $exitCode'); return false; } @@ -120,8 +115,7 @@ Future tryExtractUsingTar({ final exitCode = await process.exitCode; if (exitCode != 0) { - logger.severe( - 'Couldn\'t extract file \"$tarball\" using tar. exit code: $exitCode'); + logger.severe('Couldn\'t extract file \"$tarball\" using tar. exit code: $exitCode'); return false; } @@ -139,8 +133,7 @@ class DartWriter implements StringSink { void write(Object? object) => buffer.write(object); @override - void writeAll(Iterable objects, [String separator = ""]) => - buffer.writeAll(objects, separator); + void writeAll(Iterable objects, [String separator = ""]) => buffer.writeAll(objects, separator); @override void writeCharCode(int charCode) => buffer.writeCharCode(charCode); @@ -149,10 +142,7 @@ class DartWriter implements StringSink { void writeln([Object? object]) => buffer.writeln(object); void writeComment(String text, {bool doc = false}) { - LineSplitter() - .convert(text) - .map((l) => '//${doc ? '/' : ''} $l') - .forEach(writeln); + LineSplitter().convert(text).map((l) => '//${doc ? '/' : ''} $l').forEach(writeln); } void writeImport(AssetId assetId, {String? importPrefix}) { @@ -201,10 +191,8 @@ Directory getApplicationSupportDirectory(String applicationIdentifier) { } } - var sanitized = applicationIdentifier - .replaceAll(RegExp(r'[<>:"/\\|?*]'), '_') - .trimRight() - .replaceAll(RegExp(r'[.]+$'), ''); + var sanitized = + applicationIdentifier.replaceAll(RegExp(r'[<>:"/\\|?*]'), '_').trimRight().replaceAll(RegExp(r'[.]+$'), ''); const int kMaxComponentLength = 255; if (sanitized.length > kMaxComponentLength) { @@ -219,8 +207,7 @@ Directory getApplicationSupportDirectory(String applicationIdentifier) { } else if (Platform.isLinux) { return xdg.dataHome.childDir(applicationIdentifier); } else { - throw UnsupportedError( - 'Platform ${Platform.operatingSystem} is not supported.'); + throw UnsupportedError('Platform ${Platform.operatingSystem} is not supported.'); } } @@ -243,8 +230,7 @@ Future tryExtractUsing7Zip({ return false; } - final extractedTarFile = - temp.childFile(pathlib.basenameWithoutExtension(tarball.path)); + final extractedTarFile = temp.childFile(pathlib.basenameWithoutExtension(tarball.path)); if (extractedTarFile.existsSync()) { success = await invoke7Zip( src: extractedTarFile, @@ -280,16 +266,12 @@ Future extractTarball({ } logger.info('Trying to extract using 7zip...'); - bool success = await tryExtractUsing7Zip( - tarball: tarball, - dest: dest, - sevenZipCommand: sevenZipCommand, - logger: logger); + bool success = + await tryExtractUsing7Zip(tarball: tarball, dest: dest, sevenZipCommand: sevenZipCommand, logger: logger); if (success == false) { logger.info('Trying to extract using tar...'); - success = - await tryExtractUsingTar(tarball: tarball, dest: dest, logger: logger); + success = await tryExtractUsingTar(tarball: tarball, dest: dest, logger: logger); } if (success == false) { diff --git a/packages/flutter_gpiod/example/lib/main.dart b/packages/flutter_gpiod/example/lib/main.dart index 91ff789..99c0f92 100644 --- a/packages/flutter_gpiod/example/lib/main.dart +++ b/packages/flutter_gpiod/example/lib/main.dart @@ -52,11 +52,9 @@ void main() async { /// Now we're listening for falling and rising edge events /// on BCM 23 and BCM 24. - line1.requestInput( - consumer: "test 1", triggers: {SignalEdge.falling, SignalEdge.rising}); + line1.requestInput(consumer: "test 1", triggers: {SignalEdge.falling, SignalEdge.rising}); - line2.requestInput( - consumer: "test 2", triggers: {SignalEdge.falling, SignalEdge.rising}); + line2.requestInput(consumer: "test 2", triggers: {SignalEdge.falling, SignalEdge.rising}); print("line value: ${line1.getValue()}"); @@ -110,14 +108,12 @@ void main() async { /// memory will fill up with buffered signal events. /// `SingleSubscriptionTransformer` is contained in the `async` package btw. - final bufferingStream = line1.onEvent - .transform(SingleSubscriptionTransformer()); + final bufferingStream = line1.onEvent.transform(SingleSubscriptionTransformer()); // Let's say, if we pulse line 2 (BCM 24) some device connected // to it will pulse line 1 (BCM 23) as an interrupt. line2.release(); - line2.requestOutput( - consumer: 'some device that has interrupts', initialValue: false); + line2.requestOutput(consumer: 'some device that has interrupts', initialValue: false); line2.setValue(true); await Future.delayed(Duration(milliseconds: 500)); line2.setValue(false); diff --git a/packages/flutter_gpiod/lib/src/gpiod.dart b/packages/flutter_gpiod/lib/src/gpiod.dart index 5a999a3..15aeb94 100644 --- a/packages/flutter_gpiod/lib/src/gpiod.dart +++ b/packages/flutter_gpiod/lib/src/gpiod.dart @@ -141,24 +141,19 @@ int _syscall4( return ok < 0 ? -errno : ok; } -typedef native_epoll_wait = ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Int32, ffi.Int32)>; +typedef native_epoll_wait = ffi.NativeFunction; typedef dart_epoll_wait = int Function(int, ffi.Pointer, int, int); -typedef native_epoll_ctl = ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Int32, ffi.Int32, ffi.Pointer)>; +typedef native_epoll_ctl = ffi.NativeFunction; typedef dart_epoll_ctl = int Function(int, int, int, ffi.Pointer); -typedef native_read = ffi.NativeFunction< - ffi.Int32 Function(ffi.Int32, ffi.Pointer, ffi.Uint32)>; +typedef native_read = ffi.NativeFunction, ffi.Uint32)>; typedef dart_read = int Function(int, ffi.Pointer, int); -typedef native_read64 = ffi.NativeFunction< - ffi.Int64 Function(ffi.Int32, ffi.Pointer, ffi.Uint64)>; +typedef native_read64 = ffi.NativeFunction, ffi.Uint64)>; typedef dart_read64 = dart_read; -typedef native_errno_location - = ffi.NativeFunction Function()>; +typedef native_errno_location = ffi.NativeFunction Function()>; typedef dart_errno_location = ffi.Pointer Function(); void _eventIsolateEntry2(List args) { @@ -168,9 +163,7 @@ void _eventIsolateEntry2(List args) { final epollFd = args[1] as int; final epollWaitAddr = args[2] as int; - final epollWaitRaw = ffi.Pointer.fromAddress(epollWaitAddr) - .cast() - .asFunction(); + final epollWaitRaw = ffi.Pointer.fromAddress(epollWaitAddr).cast().asFunction(); int epollWait(int epfd, epoll_event_ptr events, int maxevents, int timeout) { return epollWaitRaw(epfd, events.backing, maxevents, timeout); } @@ -181,23 +174,19 @@ void _eventIsolateEntry2(List args) { if (readAddr != null) { read = ffi.Pointer.fromAddress(readAddr).cast().asFunction(); } else if (readAddr64 != null) { - read = - ffi.Pointer.fromAddress(readAddr64).cast().asFunction(); + read = ffi.Pointer.fromAddress(readAddr64).cast().asFunction(); } else { - throw ArgumentError( - "Either `args[4]` (readAddr) or `args[5]` (readAddr64) must be non-null."); + throw ArgumentError("Either `args[4]` (readAddr) or `args[5]` (readAddr64) must be non-null."); } final getErrnoLocationAddr = args[5] as int; - final getErrnoLocation = ffi.Pointer.fromAddress(getErrnoLocationAddr) - .cast() - .asFunction(); + final getErrnoLocation = + ffi.Pointer.fromAddress(getErrnoLocationAddr).cast().asFunction(); final errnoPtr = getErrnoLocation(); final maxEpollEvents = 64; - final epollEvents = - epoll_event_ptr.allocate(allocator: ffi.calloc, count: maxEpollEvents); + final epollEvents = epoll_event_ptr.allocate(allocator: ffi.calloc, count: maxEpollEvents); final maxEvents = 16; final events = newGpioEventData(count: maxEvents); @@ -232,8 +221,7 @@ void _eventIsolateEntry2(List args) { if (ok < 0) { epollEvents.free(); freeStruct(events); - throw LinuxError( - "Could not read GPIO events from event line fd", "read", -ok); + throw LinuxError("Could not read GPIO events from event line fd", "read", -ok); } else if (ok == 0) { throw LinuxError( 'read(${epollEvent.u64}, ${events}, ${maxEvents * ffi.sizeOf()}) returned 0', @@ -243,12 +231,7 @@ void _eventIsolateEntry2(List args) { final nEventsRead = ok / ffi.sizeOf(); for (var j = 0; j < nEventsRead; j++) { final event = events.elementAt(j).ref; - convertedEvents.add([ - epollEvent.u64, - event.id, - event.timestamp, - DateTime.now().microsecondsSinceEpoch - ]); + convertedEvents.add([epollEvent.u64, event.id, event.timestamp, DateTime.now().microsecondsSinceEpoch]); } nReady--; @@ -295,8 +278,7 @@ class PlatformInterface { if (fd < 0) { chipIndexToFd.values.forEach((fd) => libc.close(fd)); - throw FileSystemException( - 'Could not open GPIO chip $i', '/dev/gpiochip$i'); + throw FileSystemException('Could not open GPIO chip $i', '/dev/gpiochip$i'); } chipIndexToFd[i] = fd; @@ -304,8 +286,7 @@ class PlatformInterface { final epollFd = libc.epoll_create1(0); if (epollFd < 0) { - throw LinuxError( - "Could not create epoll instance", "epoll_create1", libc.errno); + throw LinuxError("Could not create epoll instance", "epoll_create1", libc.errno); } final receivePort = ReceivePort(); @@ -329,8 +310,7 @@ class PlatformInterface { throw RemoteError(message[0], message[1]); }); - return PlatformInterface._construct( - libc, numChips, chipIndexToFd, epollFd, receivePort); + return PlatformInterface._construct(libc, numChips, chipIndexToFd, epollFd, receivePort); } final LibC libc; @@ -365,8 +345,7 @@ class PlatformInterface { } int _lineFdFromLineHandle(int lineHandle) { - return _lineHandleToLineHandleFd[lineHandle] ?? - _lineHandleToLineEventFd[lineHandle]!; + return _lineHandleToLineHandleFd[lineHandle] ?? _lineHandleToLineEventFd[lineHandle]!; } int _chipIndexFromLineHandle(int lineHandle) { @@ -401,15 +380,12 @@ class PlatformInterface { ) .key; - final edge = list[1] == GPIOEVENT_EVENT_RISING_EDGE - ? SignalEdge.rising - : SignalEdge.falling; + final edge = list[1] == GPIOEVENT_EVENT_RISING_EDGE ? SignalEdge.rising : SignalEdge.falling; final timestampNanos = list[2]; final timestamp = Duration(microseconds: timestampNanos ~/ 1000); final time = DateTime.fromMicrosecondsSinceEpoch(list[3]); - return GlobalSignalEvent( - lineHandle, SignalEvent(edge, timestampNanos, timestamp, time)); + return GlobalSignalEvent(lineHandle, SignalEvent(edge, timestampNanos, timestamp, time)); }) .where((event) => event.lineHandle != -1) .asBroadcastStream(); @@ -423,15 +399,13 @@ class PlatformInterface { } Map getChipDetails(int chipIndex) { - final structPtr = - newStruct(elementSize: ffi.sizeOf()); + final structPtr = newStruct(elementSize: ffi.sizeOf()); final struct = structPtr.ref; Map map; try { - _ioctl( - _chipFdFromChipIndex(chipIndex), GPIO_GET_CHIPINFO_IOCTL, structPtr); + _ioctl(_chipFdFromChipIndex(chipIndex), GPIO_GET_CHIPINFO_IOCTL, structPtr); map = { 'name': stringFromInlineArray(32, (i) => struct.name[i]), @@ -453,8 +427,7 @@ class PlatformInterface { final fd = _chipFdFromLineHandle(lineHandle); final offset = _lineIndexFromLineHandle(lineHandle); - final structPtr = - newStruct(elementSize: ffi.sizeOf()); + final structPtr = newStruct(elementSize: ffi.sizeOf()); final struct = structPtr.ref; struct.line_offset = offset; @@ -505,8 +478,7 @@ class PlatformInterface { final isEvent = triggers.isNotEmpty; if (isEvent && !isInput) { - throw ArgumentError( - 'Line must be requested as input when triggers are requested.'); + throw ArgumentError('Line must be requested as input when triggers are requested.'); } if (isInput) { @@ -533,8 +505,7 @@ class PlatformInterface { final offset = _lineIndexFromLineHandle(lineHandle); if (!isEvent) { - final requestPtr = newStruct( - elementSize: ffi.sizeOf()); + final requestPtr = newStruct(elementSize: ffi.sizeOf()); final request = requestPtr.ref; request.lines = 1; @@ -546,9 +517,7 @@ class PlatformInterface { (i, v) => request.consumer_label[i] = v, ); - request.flags = (direction == LineDirection.input - ? GPIOHANDLE_REQUEST_INPUT - : GPIOHANDLE_REQUEST_OUTPUT) | + request.flags = (direction == LineDirection.input ? GPIOHANDLE_REQUEST_INPUT : GPIOHANDLE_REQUEST_OUTPUT) | (outputMode == OutputMode.openDrain ? GPIOHANDLE_REQUEST_OPEN_DRAIN : outputMode == OutputMode.openSource @@ -575,13 +544,11 @@ class PlatformInterface { freeStruct(requestPtr); } } else { - final requestPtr = newStruct( - elementSize: ffi.sizeOf()); + final requestPtr = newStruct(elementSize: ffi.sizeOf()); final request = requestPtr.ref; request.lineoffset = offset; - writeStringToArrayHelper( - consumer, 32, (i, v) => request.consumer_label[i] = v); + writeStringToArrayHelper(consumer, 32, (i, v) => request.consumer_label[i] = v); request.handleflags = GPIOHANDLE_REQUEST_INPUT | (bias == Bias.disable ? GPIOHANDLE_REQUEST_BIAS_DISABLE @@ -606,15 +573,13 @@ class PlatformInterface { final epollEvent = epoll_event_ptr.allocate(); epollEvent.events = EPOLL_EVENTS.EPOLLIN | EPOLL_EVENTS.EPOLLPRI; epollEvent.u64 = request.fd; - final result = - libc.epoll_ctl(_epollFd, EPOLL_CTL_ADD, request.fd, epollEvent); + final result = libc.epoll_ctl(_epollFd, EPOLL_CTL_ADD, request.fd, epollEvent); epollEvent.free(); if (result < 0) { final errno = libc.errno; releaseLine(lineHandle); - throw LinuxError("Could not add GPIO line event fd to epoll instance", - "epoll_ctl", errno); + throw LinuxError("Could not add GPIO line event fd to epoll instance", "epoll_ctl", errno); } } finally { freeStruct(requestPtr); @@ -629,10 +594,7 @@ class PlatformInterface { var ok = libc.close(fd); var errno = libc.errno; if (ok != 0) { - throw LinuxError( - "Couldn't release line by closing line handle file descriptor.", - "close", - errno); + throw LinuxError("Couldn't release line by closing line handle file descriptor.", "close", errno); } _requestedLines.remove(lineHandle); @@ -670,13 +632,10 @@ class PlatformInterface { ArgumentError.checkNotNull(initialValue, 'initialValue'); } - final requestPtr = newStruct( - elementSize: ffi.sizeOf()); + final requestPtr = newStruct(elementSize: ffi.sizeOf()); final request = requestPtr.ref; - request.flags = (direction == LineDirection.input - ? GPIOHANDLE_REQUEST_INPUT - : GPIOHANDLE_REQUEST_OUTPUT) | + request.flags = (direction == LineDirection.input ? GPIOHANDLE_REQUEST_INPUT : GPIOHANDLE_REQUEST_OUTPUT) | (outputMode == OutputMode.openDrain ? GPIOHANDLE_REQUEST_OPEN_DRAIN : outputMode == OutputMode.openSource @@ -696,8 +655,7 @@ class PlatformInterface { } try { - _ioctl(_lineFdFromLineHandle(lineHandle), GPIOHANDLE_SET_CONFIG_IOCTL, - requestPtr); + _ioctl(_lineFdFromLineHandle(lineHandle), GPIOHANDLE_SET_CONFIG_IOCTL, requestPtr); } finally { freeStruct(requestPtr); } @@ -708,8 +666,7 @@ class PlatformInterface { final fd = _lineFdFromLineHandle(lineHandle); - final structPtr = - newStruct(elementSize: ffi.sizeOf()); + final structPtr = newStruct(elementSize: ffi.sizeOf()); final struct = structPtr.ref; bool result; @@ -728,14 +685,12 @@ class PlatformInterface { assert(_requestedLines.contains(lineHandle)); assert(_lineHandleToLineHandleFd.containsKey(lineHandle)); - final structPtr = - newStruct(elementSize: ffi.sizeOf()); + final structPtr = newStruct(elementSize: ffi.sizeOf()); final struct = structPtr.ref; struct.values[0] = value ? 1 : 0; try { - _ioctl(_lineFdFromLineHandle(lineHandle), - GPIOHANDLE_SET_LINE_VALUES_IOCTL, structPtr); + _ioctl(_lineFdFromLineHandle(lineHandle), GPIOHANDLE_SET_LINE_VALUES_IOCTL, structPtr); } finally { freeStruct(structPtr); } @@ -748,8 +703,7 @@ class PlatformInterface { throw StateError("Unsupported OS: ${Platform.operatingSystem}"); } - final matches = RegExp("^Linux (\\d*)\\.(\\d*)") - .firstMatch(Platform.operatingSystemVersion)!; + final matches = RegExp("^Linux (\\d*)\\.(\\d*)").firstMatch(Platform.operatingSystemVersion)!; if (matches.groupCount == 2) { final major = int.parse(matches.group(1)!); final minor = int.parse(matches.group(2)!); @@ -781,8 +735,7 @@ class PlatformInterface { /// Starting-point for querying GPIO chips or lines, /// and finding the line you want to control. class FlutterGpiod { - FlutterGpiod._internal( - this.chips, this.supportsBias, this.supportsLineReconfiguration); + FlutterGpiod._internal(this.chips, this.supportsBias, this.supportsLineReconfiguration); static FlutterGpiod? _instance; @@ -807,15 +760,13 @@ class FlutterGpiod { /// If none exists, one will be constructed. static FlutterGpiod get instance { if (_instance == null) { - final chips = List.generate(PlatformInterface.instance.getNumChips(), - (i) => GpioChip._fromIndex(i), - growable: false); + final chips = + List.generate(PlatformInterface.instance.getNumChips(), (i) => GpioChip._fromIndex(i), growable: false); final bias = PlatformInterface.instance.supportsBias(); final reconfig = PlatformInterface.instance.supportsLineReconfiguration(); - _instance = - FlutterGpiod._internal(List.unmodifiable(chips), bias, reconfig); + _instance = FlutterGpiod._internal(List.unmodifiable(chips), bias, reconfig); } return _instance!; @@ -827,9 +778,7 @@ class FlutterGpiod { } Stream _onSignalEvent(int lineHandle) { - return _onGlobalSignalEvent - .where((e) => e.lineHandle == lineHandle) - .map((e) => e.signalEvent); + return _onGlobalSignalEvent.where((e) => e.lineHandle == lineHandle).map((e) => e.signalEvent); } } @@ -1059,8 +1008,7 @@ class GpioLine { final info = PlatformInterface.instance.getLineInfo(lineHandle); if (info.isRequested) { - return GpioLine._internal(lineHandle, true, info, const {}, - PlatformInterface.instance.getLineValue(lineHandle)); + return GpioLine._internal(lineHandle, true, info, const {}, PlatformInterface.instance.getLineValue(lineHandle)); } else { return GpioLine._internal(lineHandle, false, null, const {}, null); } @@ -1176,8 +1124,7 @@ class GpioLine { void _checkSupportsLineReconfiguration() { if (!FlutterGpiod.instance.supportsLineReconfiguration) { - throw UnsupportedError( - "Can't reconfigure line because that's not supported by " + throw UnsupportedError("Can't reconfigure line because that's not supported by " "the underlying version of libgpiod. " "You need to check `FlutterGpiod.supportsLineReconfiguration` " "to make sure you can reconfigure."); @@ -1194,8 +1141,7 @@ class GpioLine { /// /// You can't specify triggers here because of platform /// limitations. - void reconfigureInput( - {Bias? bias, ActiveState activeState = ActiveState.high}) { + void reconfigureInput({Bias? bias, ActiveState activeState = ActiveState.high}) { ArgumentError.checkNotNull(activeState, "activeState"); _checkSupportsBiasValue(bias); _checkSupportsLineReconfiguration(); @@ -1278,13 +1224,11 @@ class GpioLine { ArgumentError.checkNotNull(value, "value"); if (_requested == false) { - throw StateError( - "Can't set line value because line is not requested and configured as output."); + throw StateError("Can't set line value because line is not requested and configured as output."); } if (_info!.direction != LineDirection.output) { - throw StateError( - "Can't set line value because line is not configured as output."); + throw StateError("Can't set line value because line is not configured as output."); } if (_value == value) return; @@ -1327,8 +1271,7 @@ class GpioLine { /// like this: `rising`, `rising`, `rising`, `falling`, `rising`, /// even though that doesn't seem to make any sense /// at first glance. - Stream get onEvent => - FlutterGpiod.instance._onSignalEvent(_lineHandle); + Stream get onEvent => FlutterGpiod.instance._onSignalEvent(_lineHandle); /// Broadcast stream of signal edges. /// diff --git a/packages/flutter_gpiod/lib/src/linux_error.dart b/packages/flutter_gpiod/lib/src/linux_error.dart index 5868552..2fccaa2 100644 --- a/packages/flutter_gpiod/lib/src/linux_error.dart +++ b/packages/flutter_gpiod/lib/src/linux_error.dart @@ -1,8 +1,7 @@ import 'dart:io'; class LinuxError extends OSError { - LinuxError._private([String? message, int errno = OSError.noErrorCode]) - : super(message ?? "", errno); + LinuxError._private([String? message, int errno = OSError.noErrorCode]) : super(message ?? "", errno); factory LinuxError([String? description, String? method, int? errno]) { final hasErrno = errno != null && errno != OSError.noErrorCode; diff --git a/packages/flutter_gpiod/lib/src/util.dart b/packages/flutter_gpiod/lib/src/util.dart index 2a47649..8ffc33b 100644 --- a/packages/flutter_gpiod/lib/src/util.dart +++ b/packages/flutter_gpiod/lib/src/util.dart @@ -4,8 +4,7 @@ List listFromArrayHelper(int length, T getElement(int index)) { return List.generate(length, getElement, growable: false); } -String stringFromInlineArray(int maxLength, int getElement(int index), - {Encoding codec = utf8}) { +String stringFromInlineArray(int maxLength, int getElement(int index), {Encoding codec = utf8}) { final list = listFromArrayHelper(maxLength, getElement); final indexOfZero = list.indexOf(0); final length = indexOfZero == -1 ? maxLength : indexOfZero; @@ -13,11 +12,8 @@ String stringFromInlineArray(int maxLength, int getElement(int index), return codec.decode(list.sublist(0, length)); } -void writeStringToArrayHelper( - String str, int length, void setElement(int index, int value), - {Encoding codec = utf8}) { - final untruncatedBytes = List.of(codec.encode(str)) - ..addAll(List.filled(length, 0)); +void writeStringToArrayHelper(String str, int length, void setElement(int index, int value), {Encoding codec = utf8}) { + final untruncatedBytes = List.of(codec.encode(str))..addAll(List.filled(length, 0)); untruncatedBytes.take(length).toList().asMap().forEach(setElement); } diff --git a/packages/flutter_gpiod_test_app/integration_test/gpio_matcher.dart b/packages/flutter_gpiod_test_app/integration_test/gpio_matcher.dart index 54d9ac4..11f3985 100644 --- a/packages/flutter_gpiod_test_app/integration_test/gpio_matcher.dart +++ b/packages/flutter_gpiod_test_app/integration_test/gpio_matcher.dart @@ -2,80 +2,70 @@ import 'package:flutter_gpiod/flutter_gpiod.dart'; import 'package:flutter_test/flutter_test.dart'; class _GpioLineHasInfo extends CustomMatcher { - _GpioLineHasInfo(matcher) - : super('GpioLine with info that is', 'info', matcher); + _GpioLineHasInfo(matcher) : super('GpioLine with info that is', 'info', matcher); @override Object? featureValueOf(actual) => (actual as GpioLine).info; } class _LineInfoHasName extends CustomMatcher { - _LineInfoHasName(matcher) - : super("LineInfo with name that is", "name", matcher); + _LineInfoHasName(matcher) : super("LineInfo with name that is", "name", matcher); @override featureValueOf(actual) => (actual as LineInfo).name; } class _LineInfoHasConsumer extends CustomMatcher { - _LineInfoHasConsumer(matcher) - : super('LineInfo with consumer that is', 'consumer', matcher); + _LineInfoHasConsumer(matcher) : super('LineInfo with consumer that is', 'consumer', matcher); @override featureValueOf(actual) => (actual as LineInfo).consumer; } class _LineInfoHasIsUsed extends CustomMatcher { - _LineInfoHasIsUsed(matcher) - : super('LineInfo with isUsed that is', 'isUsed', matcher); + _LineInfoHasIsUsed(matcher) : super('LineInfo with isUsed that is', 'isUsed', matcher); @override featureValueOf(actual) => (actual as LineInfo).isUsed; } class _LineInfoHasIsRequested extends CustomMatcher { - _LineInfoHasIsRequested(matcher) - : super('LineInfo with isRequested that is', 'isRequested', matcher); + _LineInfoHasIsRequested(matcher) : super('LineInfo with isRequested that is', 'isRequested', matcher); @override featureValueOf(actual) => (actual as LineInfo).isRequested; } class _LineInfoHasIsFree extends CustomMatcher { - _LineInfoHasIsFree(matcher) - : super('LineInfo with isFree that is', 'isFree', matcher); + _LineInfoHasIsFree(matcher) : super('LineInfo with isFree that is', 'isFree', matcher); @override featureValueOf(actual) => (actual as LineInfo).isFree; } class _LineInfoHasDirection extends CustomMatcher { - _LineInfoHasDirection(matcher) - : super('LineInfo with direction that is', 'direction', matcher); + _LineInfoHasDirection(matcher) : super('LineInfo with direction that is', 'direction', matcher); @override featureValueOf(actual) => (actual as LineInfo).direction; } class _LineInfoHasOutputMode extends CustomMatcher { - _LineInfoHasOutputMode(matcher) - : super('LineInfo with outputMode that is', 'outputMode', matcher); + _LineInfoHasOutputMode(matcher) : super('LineInfo with outputMode that is', 'outputMode', matcher); @override featureValueOf(actual) => (actual as LineInfo).outputMode; } class _LineInfoHasBias extends CustomMatcher { - _LineInfoHasBias(matcher) - : super('LineInfo with bias that is', 'bias', matcher); + _LineInfoHasBias(matcher) : super('LineInfo with bias that is', 'bias', matcher); @override featureValueOf(actual) => (actual as LineInfo).bias; } class _LineInfoHasActiveState extends CustomMatcher { - _LineInfoHasActiveState(matcher) - : super('LineInfo with activeState that is', 'activeState', matcher); + _LineInfoHasActiveState(matcher) : super('LineInfo with activeState that is', 'activeState', matcher); @override featureValueOf(actual) => (actual as LineInfo).activeState; diff --git a/packages/flutter_gpiod_test_app/integration_test/gpio_test.dart b/packages/flutter_gpiod_test_app/integration_test/gpio_test.dart index d24e1fc..5db3280 100644 --- a/packages/flutter_gpiod_test_app/integration_test/gpio_test.dart +++ b/packages/flutter_gpiod_test_app/integration_test/gpio_test.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:flutter_gpiod/flutter_gpiod.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:integration_test/integration_test.dart'; import 'gpio_matcher.dart'; @@ -20,8 +19,7 @@ Matcher isFreeInputLine(Object? name, [ActiveState? activeState]) { ); } -Matcher isFreeOutputLine(Object? name, - {Object? outputMode, Object? bias, Object? activeState}) { +Matcher isFreeOutputLine(Object? name, {Object? outputMode, Object? bias, Object? activeState}) { return matchGpioLineInfo( name, noConsumer, @@ -35,8 +33,7 @@ Matcher isFreeOutputLine(Object? name, ); } -Matcher isKernelInputLine(Object? name, Object? consumer, - {Object? outputMode, Object? bias, Object? activeState}) { +Matcher isKernelInputLine(Object? name, Object? consumer, {Object? outputMode, Object? bias, Object? activeState}) { return matchGpioLineInfo( name, consumer, @@ -50,8 +47,7 @@ Matcher isKernelInputLine(Object? name, Object? consumer, ); } -Matcher isKernelOutputLine(Object? name, Object? consumer, - {Object? outputMode, Object? bias, Object? activeState}) { +Matcher isKernelOutputLine(Object? name, Object? consumer, {Object? outputMode, Object? bias, Object? activeState}) { return matchGpioLineInfo( name, consumer, @@ -65,8 +61,7 @@ Matcher isKernelOutputLine(Object? name, Object? consumer, ); } -Matcher isOwnedInputLine(Object? name, Object? consumer, - {Object? bias, Object? activeState}) { +Matcher isOwnedInputLine(Object? name, Object? consumer, {Object? bias, Object? activeState}) { return matchGpioLineInfo( name, consumer, @@ -170,10 +165,7 @@ void main() { expect(lines, hasLength(8)); expect(lines[0], isFreeOutputLine('BT_ON')); expect(lines[1], isFreeOutputLine('WL_ON')); - expect( - lines[2], - isKernelOutputLine('PWR_LED_OFF', 'led1', - activeState: ActiveState.low)); + expect(lines[2], isKernelOutputLine('PWR_LED_OFF', 'led1', activeState: ActiveState.low)); expect(lines[3], isFreeOutputLine('GLOBAL_RESET')); expect(lines[4], isKernelOutputLine('VDD_SD_IO_SEL', 'vdd-sd-io')); expect(lines[5], isFreeOutputLine('CAM_GPIO')); @@ -190,8 +182,7 @@ void main() { final lines = chip.lines; expect(lines, hasLength(2)); expect(lines[0], isKernelOutputLine(unnamed, '2.reg_bridge')); - expect(lines[1], - isKernelOutputLine(unnamed, 'reset', activeState: ActiveState.low)); + expect(lines[1], isKernelOutputLine(unnamed, 'reset', activeState: ActiveState.low)); }, tags: ['pi4']); }); @@ -356,18 +347,14 @@ void main() { ActiveState activeState = ActiveState.high, Set triggers = const {}, }) { - try { - line.requestInput( - consumer: consumer, - bias: bias, - activeState: activeState, - triggers: triggers, - ); - - requestedLines.add(line); - } catch (e) { - print('requesting $consumer failed'); - } + line.requestInput( + consumer: consumer, + bias: bias, + activeState: activeState, + triggers: triggers, + ); + + requestedLines.add(line); } void requestOutput( @@ -425,14 +412,11 @@ void main() { final lines = FlutterGpiod.instance.chips[0].lines; // request all the lines - expect( - () => requestInput(lines[0], consumer: 'test0'), returnsNormally); - expect( - () => requestInput(lines[1], consumer: 'test1'), returnsNormally); + expect(() => requestInput(lines[0], consumer: 'test0'), returnsNormally); + expect(() => requestInput(lines[1], consumer: 'test1'), returnsNormally); // already consumed by 'ffe09080.usb3phy' // expect(() => requestInput(lines[2], consumer: 'test2'), returnsNormally); - expect( - () => requestInput(lines[3], consumer: 'test3'), returnsNormally); + expect(() => requestInput(lines[3], consumer: 'test3'), returnsNormally); // expect(() => requestInput(lines[4], consumer: 'test4'), returnsNormally); // expect(() => requestInput(lines[5], consumer: 'test5'), returnsNormally); // already consumed by 'amlsd' @@ -443,13 +427,10 @@ void main() { // expect(() => requestInput(lines[10], consumer: 'test10'), returnsNormally); // already consumed by '?' // expect(() => requestInput(lines[11], consumer: 'test11'), returnsNormally); - expect( - () => requestInput(lines[12], consumer: 'test12'), returnsNormally); + expect(() => requestInput(lines[12], consumer: 'test12'), returnsNormally); // expect(() => requestInput(lines[13], consumer: 'test13'), returnsNormally); - expect( - () => requestInput(lines[14], consumer: 'test14'), returnsNormally); - expect( - () => requestInput(lines[15], consumer: 'test15'), returnsNormally); + expect(() => requestInput(lines[14], consumer: 'test14'), returnsNormally); + expect(() => requestInput(lines[15], consumer: 'test15'), returnsNormally); // check the listing matches what we expect expect(lines[0], isOwnedInputLine(unnamed, 'test0')); @@ -468,13 +449,11 @@ void main() { expect(() => release(lines[15]), returnsNormally); }, tags: ['odroidc4']); - testWidgets('test odroid c4 second gpio chip requesting lines', - (_) async { + testWidgets('test odroid c4 second gpio chip requesting lines', (_) async { final lines = FlutterGpiod.instance.chips[1].lines; // request all the lines - expect( - () => requestInput(lines[0], consumer: 'test0'), returnsNormally); + expect(() => requestInput(lines[0], consumer: 'test0'), returnsNormally); // expect(() => requestInput(lines[1], consumer: 'test1'), returnsNormally); // expect(() => requestInput(lines[2], consumer: 'test2'), returnsNormally); // expect(() => requestInput(lines[3], consumer: 'test3'), returnsNormally); @@ -489,24 +468,18 @@ void main() { // expect(() => requestInput(lines[12], consumer: 'test12'), returnsNormally); // expect(() => requestInput(lines[13], consumer: 'test13'), returnsNormally); // expect(() => requestInput(lines[14], consumer: 'test14'), returnsNormally); - expect( - () => requestInput(lines[15], consumer: 'test15'), returnsNormally); - expect( - () => requestInput(lines[16], consumer: 'test16'), returnsNormally); + expect(() => requestInput(lines[15], consumer: 'test15'), returnsNormally); + expect(() => requestInput(lines[16], consumer: 'test16'), returnsNormally); // expect(() => requestInput(lines[17], consumer: 'test17'), returnsNormally); // expect(() => requestInput(lines[18], consumer: 'test18'), returnsNormally); // expect(() => requestInput(lines[19], consumer: 'test19'), returnsNormally); // expect(() => requestInput(lines[20], consumer: 'test20'), returnsNormally); // already consumed by 'usb_hub' // expect(() => requestInput(lines[21], consumer: 'test'), returnsNormally); - expect( - () => requestInput(lines[22], consumer: 'test22'), returnsNormally); - expect( - () => requestInput(lines[23], consumer: 'test23'), returnsNormally); - expect( - () => requestInput(lines[24], consumer: 'test24'), returnsNormally); - expect( - () => requestInput(lines[25], consumer: 'test25'), returnsNormally); + expect(() => requestInput(lines[22], consumer: 'test22'), returnsNormally); + expect(() => requestInput(lines[23], consumer: 'test23'), returnsNormally); + expect(() => requestInput(lines[24], consumer: 'test24'), returnsNormally); + expect(() => requestInput(lines[25], consumer: 'test25'), returnsNormally); // expect(() => requestInput(lines[26], consumer: 'test26'), returnsNormally); // expect(() => requestInput(lines[27], consumer: 'test27'), returnsNormally); // expect(() => requestInput(lines[28], consumer: 'test28'), returnsNormally); @@ -517,78 +490,46 @@ void main() { // expect(() => requestInput(lines[32], consumer: 'test32'), returnsNormally); // expect(() => requestInput(lines[33], consumer: 'test33'), returnsNormally); // expect(() => requestInput(lines[34], consumer: 'test34'), returnsNormally); - expect( - () => requestInput(lines[35], consumer: 'test35'), returnsNormally); + expect(() => requestInput(lines[35], consumer: 'test35'), returnsNormally); // expect(() => requestInput(lines[36], consumer: 'test36'), returnsNormally); - expect( - () => requestInput(lines[37], consumer: 'test37'), returnsNormally); + expect(() => requestInput(lines[37], consumer: 'test37'), returnsNormally); // already consumed by 'amlsd' // expect(() => requestInput(lines[38], consumer: 'test38'), returnsNormally); // expect(() => requestInput(lines[39], consumer: 'test39'), returnsNormally); - expect( - () => requestInput(lines[40], consumer: 'test40'), returnsNormally); - expect( - () => requestInput(lines[41], consumer: 'test41'), returnsNormally); - expect( - () => requestInput(lines[42], consumer: 'test42'), returnsNormally); - expect( - () => requestInput(lines[43], consumer: 'test43'), returnsNormally); - expect( - () => requestInput(lines[44], consumer: 'test44'), returnsNormally); - expect( - () => requestInput(lines[45], consumer: 'test45'), returnsNormally); - expect( - () => requestInput(lines[46], consumer: 'test46'), returnsNormally); - expect( - () => requestInput(lines[47], consumer: 'test47'), returnsNormally); + expect(() => requestInput(lines[40], consumer: 'test40'), returnsNormally); + expect(() => requestInput(lines[41], consumer: 'test41'), returnsNormally); + expect(() => requestInput(lines[42], consumer: 'test42'), returnsNormally); + expect(() => requestInput(lines[43], consumer: 'test43'), returnsNormally); + expect(() => requestInput(lines[44], consumer: 'test44'), returnsNormally); + expect(() => requestInput(lines[45], consumer: 'test45'), returnsNormally); + expect(() => requestInput(lines[46], consumer: 'test46'), returnsNormally); + expect(() => requestInput(lines[47], consumer: 'test47'), returnsNormally); // already consumed by 'amlsd' // expect(() => requestInput(lines[48], consumer: 'test'), returnsNormally); - expect( - () => requestInput(lines[49], consumer: 'test49'), returnsNormally); - expect( - () => requestInput(lines[50], consumer: 'test50'), returnsNormally); - expect( - () => requestInput(lines[51], consumer: 'test51'), returnsNormally); - expect( - () => requestInput(lines[52], consumer: 'test52'), returnsNormally); - expect( - () => requestInput(lines[53], consumer: 'test53'), returnsNormally); - expect( - () => requestInput(lines[54], consumer: 'test54'), returnsNormally); - expect( - () => requestInput(lines[55], consumer: 'test55'), returnsNormally); - expect( - () => requestInput(lines[56], consumer: 'test56'), returnsNormally); - expect( - () => requestInput(lines[57], consumer: 'test57'), returnsNormally); - expect( - () => requestInput(lines[58], consumer: 'test58'), returnsNormally); - expect( - () => requestInput(lines[59], consumer: 'test59'), returnsNormally); - expect( - () => requestInput(lines[60], consumer: 'test60'), returnsNormally); - expect( - () => requestInput(lines[61], consumer: 'test61'), returnsNormally); - expect( - () => requestInput(lines[62], consumer: 'test62'), returnsNormally); - expect( - () => requestInput(lines[63], consumer: 'test63'), returnsNormally); + expect(() => requestInput(lines[49], consumer: 'test49'), returnsNormally); + expect(() => requestInput(lines[50], consumer: 'test50'), returnsNormally); + expect(() => requestInput(lines[51], consumer: 'test51'), returnsNormally); + expect(() => requestInput(lines[52], consumer: 'test52'), returnsNormally); + expect(() => requestInput(lines[53], consumer: 'test53'), returnsNormally); + expect(() => requestInput(lines[54], consumer: 'test54'), returnsNormally); + expect(() => requestInput(lines[55], consumer: 'test55'), returnsNormally); + expect(() => requestInput(lines[56], consumer: 'test56'), returnsNormally); + expect(() => requestInput(lines[57], consumer: 'test57'), returnsNormally); + expect(() => requestInput(lines[58], consumer: 'test58'), returnsNormally); + expect(() => requestInput(lines[59], consumer: 'test59'), returnsNormally); + expect(() => requestInput(lines[60], consumer: 'test60'), returnsNormally); + expect(() => requestInput(lines[61], consumer: 'test61'), returnsNormally); + expect(() => requestInput(lines[62], consumer: 'test62'), returnsNormally); + expect(() => requestInput(lines[63], consumer: 'test63'), returnsNormally); // expect(() => requestInput(lines[64], consumer: 'test64'), returnsNormally); // expect(() => requestInput(lines[65], consumer: 'test65'), returnsNormally); - expect( - () => requestInput(lines[66], consumer: 'test66'), returnsNormally); - expect( - () => requestInput(lines[67], consumer: 'test67'), returnsNormally); - expect( - () => requestInput(lines[68], consumer: 'test68'), returnsNormally); - expect( - () => requestInput(lines[69], consumer: 'test69'), returnsNormally); - expect( - () => requestInput(lines[70], consumer: 'test70'), returnsNormally); - expect( - () => requestInput(lines[71], consumer: 'test71'), returnsNormally); - expect( - () => requestInput(lines[72], consumer: 'test72'), returnsNormally); + expect(() => requestInput(lines[66], consumer: 'test66'), returnsNormally); + expect(() => requestInput(lines[67], consumer: 'test67'), returnsNormally); + expect(() => requestInput(lines[68], consumer: 'test68'), returnsNormally); + expect(() => requestInput(lines[69], consumer: 'test69'), returnsNormally); + expect(() => requestInput(lines[70], consumer: 'test70'), returnsNormally); + expect(() => requestInput(lines[71], consumer: 'test71'), returnsNormally); + expect(() => requestInput(lines[72], consumer: 'test72'), returnsNormally); // expect(() => requestInput(lines[73], consumer: 'test73'), returnsNormally); // expect(() => requestInput(lines[74], consumer: 'test74'), returnsNormally); // expect(() => requestInput(lines[75], consumer: 'test75'), returnsNormally); @@ -597,15 +538,12 @@ void main() { // expect(() => requestInput(lines[77], consumer: 'test77'), returnsNormally); // expect(() => requestInput(lines[78], consumer: 'test78'), returnsNormally); // expect(() => requestInput(lines[79], consumer: 'test79'), returnsNormally); - expect( - () => requestInput(lines[80], consumer: 'test80'), returnsNormally); - expect( - () => requestInput(lines[81], consumer: 'test81'), returnsNormally); + expect(() => requestInput(lines[80], consumer: 'test80'), returnsNormally); + expect(() => requestInput(lines[81], consumer: 'test81'), returnsNormally); // expect(() => requestInput(lines[82], consumer: 'test82'), returnsNormally); // expect(() => requestInput(lines[83], consumer: 'test83'), returnsNormally); // expect(() => requestInput(lines[84], consumer: 'test84'), returnsNormally); - expect( - () => requestInput(lines[85], consumer: 'test85'), returnsNormally); + expect(() => requestInput(lines[85], consumer: 'test85'), returnsNormally); // check the listing matches what we expect expect(lines[0], isOwnedInputLine(unnamed, 'test0')); @@ -711,8 +649,7 @@ void main() { final gpiox0 = FlutterGpiod.instance.chips[1].lines[476 - 410]; // Now request GPIOX.4 as input and GPIOX.0 as output - requestInput(gpiox4, - consumer: 'test', triggers: const {SignalEdge.rising}); + requestInput(gpiox4, consumer: 'test', triggers: const {SignalEdge.rising}); requestOutput(gpiox0, consumer: 'test', initialValue: false); rerequestGpiox0AsInput = true; @@ -737,14 +674,11 @@ void main() { // wait for some time so the edge event arrives //await tester.pump(const Duration(seconds: 5)); - (TestWidgetsFlutterBinding.ensureInitialized() - as TestWidgetsFlutterBinding) + (TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding) .delayed(const Duration(seconds: 5)) .then((value) { if (!completer.isCompleted) { - completer.completeError(TimeoutException( - 'Waiting for signal edge timed out.', - const Duration(seconds: 5))); + completer.completeError(TimeoutException('Waiting for signal edge timed out.', const Duration(seconds: 5))); } }); diff --git a/packages/flutter_gpiod_test_app/test/test.dart b/packages/flutter_gpiod_test_app/test/test.dart deleted file mode 100644 index 8b13789..0000000 --- a/packages/flutter_gpiod_test_app/test/test.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/packages/linux_serial/example/lib/main.dart b/packages/linux_serial/example/lib/main.dart index 988f65d..8f69d58 100644 --- a/packages/linux_serial/example/lib/main.dart +++ b/packages/linux_serial/example/lib/main.dart @@ -5,8 +5,7 @@ import 'package:linux_serial/linux_serial.dart'; void main() async { print("ports: ${SerialPorts.ports}"); - final port = - SerialPorts.ports.singleWhere((element) => element.name == "ttyS0"); + final port = SerialPorts.ports.singleWhere((element) => element.name == "ttyS0"); final handle = port.open(baudrate: Baudrate.b9600); diff --git a/packages/linux_serial/lib/linux_serial.dart b/packages/linux_serial/lib/linux_serial.dart index 5cddaa3..f13c0d2 100644 --- a/packages/linux_serial/lib/linux_serial.dart +++ b/packages/linux_serial/lib/linux_serial.dart @@ -1,2 +1 @@ -export 'src/linux_serial.dart' - show SerialPorts, SerialPort, SerialPortHandle, Baudrate; +export 'src/linux_serial.dart' show SerialPorts, SerialPort, SerialPortHandle, Baudrate; diff --git a/packages/linux_serial/lib/src/linux_serial.dart b/packages/linux_serial/lib/src/linux_serial.dart index 771131f..896c31d 100644 --- a/packages/linux_serial/lib/src/linux_serial.dart +++ b/packages/linux_serial/lib/src/linux_serial.dart @@ -19,8 +19,7 @@ import 'package:_ardera_common_libc_bindings/_ardera_common_libc_bindings.dart'; extension StringUtf8Pointer on String { ffi.Pointer toNativeUtf8({ffi.Allocator allocator = ffi.malloc}) { final units = utf8.encode(this); - final ffi.Pointer result = - allocator(units.length + 1); + final ffi.Pointer result = allocator(units.length + 1); final Uint8List nativeString = result.asTypedList(units.length + 1); nativeString.setAll(0, units); nativeString[units.length] = 0; @@ -144,8 +143,7 @@ class SynchronousComputer implements Computer { return computer.compute(fn, param: param); }); } else { - throw StateError( - "compute called but Computer is not running and not turning on right now."); + throw StateError("compute called but Computer is not running and not turning on right now."); } } @@ -167,8 +165,7 @@ class SynchronousComputer implements Computer { return onTurnedOn!.then((value) => computer.turnOff()); } else { - throw StateError( - "turnOff called but Computer is not running and not turning on right now."); + throw StateError("turnOff called but Computer is not running and not turning on right now."); } } @@ -179,9 +176,7 @@ class SynchronousComputer implements Computer { } else if (_onTurnedOn != null) { throw StateError("turnOn called but Computer is currently turning on"); } else { - _onTurnedOn = _computer - .turnOn(workersCount: workersCount, verbose: verbose) - .then((_) { + _onTurnedOn = _computer.turnOn(workersCount: workersCount, verbose: verbose).then((_) { _isRunning = true; }).whenComplete(() { _onTurnedOn = null; @@ -202,10 +197,7 @@ int executeWrite(Tuple4 param) { final length = param.item4; final write = ffi.Pointer.fromAddress(writeFuncAddr) - .cast< - ffi.NativeFunction< - ffi.Int32 Function( - ffi.Int32, ffi.Pointer, ffi.Uint32)>>() + .cast, ffi.Uint32)>>() .asFunction, int)>(); final buffer = ffi.Pointer.fromAddress(bufferAddr); @@ -224,8 +216,7 @@ int executeWrite(Tuple4 param) { } class PlatformInterface { - PlatformInterface._construct( - this.dylib, this.libc, this.epollFd, this.onFdReady); + PlatformInterface._construct(this.dylib, this.libc, this.epollFd, this.onFdReady); factory PlatformInterface._private() { final dylib = ffi.DynamicLibrary.open("libc.so.6"); @@ -239,10 +230,7 @@ class PlatformInterface { final epollFd = result; final receivePort = ReceivePort(); Isolate.spawn(epollerEntry, Tuple2(receivePort.sendPort, epollFd)); - final fdReadyStream = receivePort - .cast() - .map((list) => list.cast()) - .asBroadcastStream(); + final fdReadyStream = receivePort.cast().map((list) => list.cast()).asBroadcastStream(); return PlatformInterface._construct(dylib, libc, epollFd, fdReadyStream); } @@ -266,8 +254,7 @@ class PlatformInterface { libc.tcgetattr(fd, ptr); - ptr.c_iflag &= - ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + ptr.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); ptr.c_oflag &= ~OPOST; ptr.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); ptr.c_cflag &= ~(CSIZE | PARENB); @@ -290,8 +277,7 @@ class PlatformInterface { throw OSError("Could not get termios state for serial port. (tcgetattr)"); } - ptr.c_iflag &= - ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + ptr.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); ptr.c_oflag &= ~OPOST; ptr.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); ptr.c_cflag &= ~(CSIZE | PARENB); @@ -308,8 +294,7 @@ class PlatformInterface { result = libc.cfsetospeed(ptr, baudrate.asLinuxValue); if (result < 0) { ptr.free(); - throw OSError( - "Could not set output speed for serial port. (cfsetospeed)"); + throw OSError("Could not set output speed for serial port. (cfsetospeed)"); } result = libc.tcsetattr(fd, TCSANOW, ptr); @@ -324,8 +309,7 @@ class PlatformInterface { int open(String path, {Baudrate? baudrate}) { final allocatedPath = path.toNativeUtf8(); - var result = - libc.open(allocatedPath.cast(), O_RDWR | O_CLOEXEC | O_NONBLOCK); + var result = libc.open(allocatedPath.cast(), O_RDWR | O_CLOEXEC | O_NONBLOCK); ffi.malloc.free(allocatedPath); @@ -348,9 +332,7 @@ class PlatformInterface { final epollEvent = epoll_event_ptr.allocate(allocator: ffi.calloc); - epollEvent.events = EPOLL_EVENTS.EPOLLIN | - EPOLL_EVENTS.EPOLLPRI | - EPOLL_EVENTS.EPOLLONESHOT; + epollEvent.events = EPOLL_EVENTS.EPOLLIN | EPOLL_EVENTS.EPOLLPRI | EPOLL_EVENTS.EPOLLONESHOT; epollEvent.u64 = fd; result = libc.epoll_ctl(epollFd, EPOLL_CTL_ADD, fd, epollEvent); @@ -391,10 +373,8 @@ class PlatformInterface { ptr.free(); - final inputBaudrate = Baudrate.values.singleWhere( - (element) => element.asLinuxValue == inputSpeedAsLinuxValue); - final outputBaudrate = Baudrate.values.singleWhere( - (element) => element.asLinuxValue == outputSpeedAsLinuxValue); + final inputBaudrate = Baudrate.values.singleWhere((element) => element.asLinuxValue == inputSpeedAsLinuxValue); + final outputBaudrate = Baudrate.values.singleWhere((element) => element.asLinuxValue == outputSpeedAsLinuxValue); if (inputBaudrate.inBaudsPerSecond < outputBaudrate.inBaudsPerSecond) { return inputBaudrate; @@ -411,8 +391,7 @@ class PlatformInterface { } void arm(int fd) { - final result = - libc.epoll_ctl(epollFd, EPOLL_CTL_MOD, fd, _epollEventForFd[fd]!); + final result = libc.epoll_ctl(epollFd, EPOLL_CTL_MOD, fd, _epollEventForFd[fd]!); if (result != 0) { throw OSError("Could not arm fd events. (epoll_ctl)"); } @@ -436,8 +415,7 @@ class PlatformInterface { return _computerForFd[fd]! .compute, int>(executeWrite, - param: Tuple4( - fd, dylib.lookup("write").address, buffer.address, bufferSize)) + param: Tuple4(fd, dylib.lookup("write").address, buffer.address, bufferSize)) .then((result) { if (result < 0) { throw OSError("Could not write to serial port. (write)"); @@ -601,9 +579,7 @@ class SerialPorts { return Directory( "/sys/dev/char", ).listSync(followLinks: false).map((element) { - final match = RegExp("^([0-9]*):([0-9]*)\$") - .allMatches(basename(element.path)) - .single; + final match = RegExp("^([0-9]*):([0-9]*)\$").allMatches(basename(element.path)).single; final major = int.parse(match.group(1)!); final minor = int.parse(match.group(2)!); final name = basename(element.resolveSymbolicLinksSync()); @@ -625,8 +601,7 @@ class SerialPorts { final major = e.item2; final minor = e.item3; - return SerialPort("/dev/$name", major, minor, - _getDescriptionForMagicNumbers(major, minor) ?? ""); + return SerialPort("/dev/$name", major, minor, _getDescriptionForMagicNumbers(major, minor) ?? ""); }).toSet(); } } @@ -713,8 +688,7 @@ class _StringReaderImpl extends StringReader { Future read({int? numBytes, int? length}) async { if ((numBytes != null) == (length != null)) { - throw ArgumentError( - "Exactly one of `numBytes` or `length` must be given."); + throw ArgumentError("Exactly one of `numBytes` or `length` must be given."); } final encoding = this.encoding; @@ -772,8 +746,7 @@ int getBytesPerChar(Encoding encoding) { } else if (encoding is Latin1Codec) { return 1; } else { - throw ArgumentError.value(encoding, - "Encoding doesn't have a static number of bytes per character."); + throw ArgumentError.value(encoding, "Encoding doesn't have a static number of bytes per character."); } } @@ -789,17 +762,14 @@ class SerialPortHandle implements StringSink, StringReader { onListen: () { PlatformInterface.instance.flushInput(fd); - fdReadySubscription = - PlatformInterface.instance.onFdReady.listen((fds) { + fdReadySubscription = PlatformInterface.instance.onFdReady.listen((fds) { if (fds.contains(fd)) { - final actuallyRead = - PlatformInterface.instance.read(fd, readBuffer, _bufferSize); + final actuallyRead = PlatformInterface.instance.read(fd, readBuffer, _bufferSize); PlatformInterface.instance.arm(fd); if (actuallyRead > 0) { - final copiedBytes = List.unmodifiable( - Uint8List.fromList(readBuffer.asTypedList(actuallyRead))); + final copiedBytes = List.unmodifiable(Uint8List.fromList(readBuffer.asTypedList(actuallyRead))); inputController.add(copiedBytes); } } @@ -813,12 +783,10 @@ class SerialPortHandle implements StringSink, StringReader { }, sync: true); - return SerialPortHandle._construct( - fd, inputController, ffi.malloc.allocate(_bufferSize)); + return SerialPortHandle._construct(fd, inputController, ffi.malloc.allocate(_bufferSize)); } - SerialPortHandle._construct( - this._fd, this._inputController, this._writeBuffer) + SerialPortHandle._construct(this._fd, this._inputController, this._writeBuffer) : stream = _inputController.stream, byteStream = _inputController.stream.expand((element) => element), _writeBufferAsTypedList = _writeBuffer.asTypedList(_bufferSize); @@ -897,8 +865,7 @@ class SerialPortHandle implements StringSink, StringReader { index++; } - await PlatformInterface.instance - .write(_fd, _writeBuffer, subTransmission.length); + await PlatformInterface.instance.write(_fd, _writeBuffer, subTransmission.length); } }); } @@ -975,9 +942,7 @@ class SerialPortHandle implements StringSink, StringReader { }, onError: (err, stackTrace) { completer.completeError(err, stackTrace); }, onDone: () { - completer.completeError( - StateError("Serial input stream closed prematurely."), - StackTrace.current); + completer.completeError(StateError("Serial input stream closed prematurely."), StackTrace.current); }, cancelOnError: true); return completer.future; @@ -986,8 +951,7 @@ class SerialPortHandle implements StringSink, StringReader { @override Future read({int? length, int? numBytes}) { if ((numBytes != null) == (length != null)) { - throw ArgumentError( - "Exactly one of `numBytes` or `length` must be given."); + throw ArgumentError("Exactly one of `numBytes` or `length` must be given."); } final encoding = this.encoding; @@ -1021,9 +985,7 @@ class SerialPortHandle implements StringSink, StringReader { }, onDone: () { byteSink.close(); stringSink.close(); - completer.completeError( - StateError("Serial input stream closed prematurely."), - StackTrace.current); + completer.completeError(StateError("Serial input stream closed prematurely."), StackTrace.current); }); return completer.future; @@ -1061,16 +1023,13 @@ class SerialPortHandle implements StringSink, StringReader { sub.cancel(); byteSink.close(); stringSink.close(); - completer.completeError( - StateError("Serial input stream closed prematurely."), - StackTrace.current); + completer.completeError(StateError("Serial input stream closed prematurely."), StackTrace.current); }); return completer.future; } StringReader getNewSequentialReader() { - return StringReader(stream.expand((element) => element), - encoding: encoding); + return StringReader(stream.expand((element) => element), encoding: encoding); } } diff --git a/packages/linux_spidev/lib/linux_spidev.dart b/packages/linux_spidev/lib/linux_spidev.dart index 4b1bee0..958c72b 100644 --- a/packages/linux_spidev/lib/linux_spidev.dart +++ b/packages/linux_spidev/lib/linux_spidev.dart @@ -1,11 +1,3 @@ library spidev; -export 'src/spidev.dart' - show - SpiMode, - SpiFlag, - Spidevs, - Spidev, - SpidevHandle, - SpiTransfer, - SpiTransferProperties; +export 'src/spidev.dart' show SpiMode, SpiFlag, Spidevs, Spidev, SpidevHandle, SpiTransfer, SpiTransferProperties; diff --git a/packages/linux_spidev/lib/src/spidev.dart b/packages/linux_spidev/lib/src/spidev.dart index 49e71d2..7636838 100644 --- a/packages/linux_spidev/lib/src/spidev.dart +++ b/packages/linux_spidev/lib/src/spidev.dart @@ -49,12 +49,9 @@ class SpiTransfer { abstract class SpiTransferData { SpiTransferData(); - factory SpiTransferData.fromNativeMem( - {ffi.Pointer? txPointer, ffi.Pointer? rxPointer, required int length}) { + factory SpiTransferData.fromNativeMem({ffi.Pointer? txPointer, ffi.Pointer? rxPointer, required int length}) { return NativeMemSpiTransferData._private( - txPointer: txPointer ?? ffi.nullptr, - rxPointer: rxPointer ?? ffi.nullptr, - length: length); + txPointer: txPointer ?? ffi.nullptr, rxPointer: rxPointer ?? ffi.nullptr, length: length); } factory SpiTransferData.fromTypedData({Uint8List? txBuf, Uint8List? rxBuf}) { @@ -74,8 +71,7 @@ class NativeMemSpiTransferData extends SpiTransferData { final ffi.Pointer rxPointer; final int length; - NativeMemSpiTransferData._private( - {required this.txPointer, required this.rxPointer, required this.length}) + NativeMemSpiTransferData._private({required this.txPointer, required this.rxPointer, required this.length}) : assert(txPointer != ffi.nullptr || rxPointer != ffi.nullptr); @override @@ -100,11 +96,9 @@ class TypedDataSpiTransferData extends SpiTransferData { TypedDataSpiTransferData._private({this.txBuf, this.rxBuf}) : assert(txBuf != null || rxBuf != null), - assert( - (txBuf == null || rxBuf == null) || (txBuf.length == rxBuf.length)); + assert((txBuf == null || rxBuf == null) || (txBuf.length == rxBuf.length)); - Tuple2, Set> - nativeMemFromOverlappingData(Set data) { + Tuple2, Set> nativeMemFromOverlappingData(Set data) { final start = data.map((v) => v.offsetInBytes).reduce(min); final end = data.map((v) => v.offsetInBytes + v.lengthInBytes).reduce(max); @@ -126,14 +120,11 @@ class TypedDataSpiTransferData extends SpiTransferData { bool overlaps(Uint8List a, Uint8List b) { return (a.buffer == b.buffer) && - (((a.offsetInBytes >= b.offsetInBytes) && - (a.offsetInBytes <= b.offsetInBytes + b.lengthInBytes)) || - ((b.offsetInBytes >= a.offsetInBytes) && - (b.offsetInBytes <= a.offsetInBytes + a.lengthInBytes))); + (((a.offsetInBytes >= b.offsetInBytes) && (a.offsetInBytes <= b.offsetInBytes + b.lengthInBytes)) || + ((b.offsetInBytes >= a.offsetInBytes) && (b.offsetInBytes <= a.offsetInBytes + a.lengthInBytes))); } - Tuple2, Set> - nativeMemFromByteDataOfSameBuffer(Set data) { + Tuple2, Set> nativeMemFromByteDataOfSameBuffer(Set data) { final nodes = Set.of(data); final edges = >{}; @@ -173,8 +164,7 @@ class TypedDataSpiTransferData extends SpiTransferData { break; } else { group.add(other); - edges.removeWhere( - (element) => element.item1 == other || element.item2 == other); + edges.removeWhere((element) => element.item1 == other || element.item2 == other); } } @@ -187,8 +177,7 @@ class TypedDataSpiTransferData extends SpiTransferData { return result; } - Tuple2, Set> nativeMemFromByteData( - Set data) { + Tuple2, Set> nativeMemFromByteData(Set data) { final dataWithSameBuffer = >{}; data.forEach((element) { @@ -215,19 +204,15 @@ class TypedDataSpiTransferData extends SpiTransferData { assert(rxBuf!.length == txBuf!.length); } - final nativeMem = nativeMemFromByteData( - {if (rxBuf != null) rxBuf!, if (txBuf != null) txBuf!}); + final nativeMem = nativeMemFromByteData({if (rxBuf != null) rxBuf!, if (txBuf != null) txBuf!}); ffi.Pointer txPtr = ffi.nullptr; ffi.Pointer rxPtr = ffi.nullptr; if (txBuf != null) { - txPtr = nativeMem.item1.entries - .singleWhere((element) => element.key == txBuf) - .value; + txPtr = nativeMem.item1.entries.singleWhere((element) => element.key == txBuf).value; - final txPtrAsBuf = - txPtr.cast().asTypedList(txBuf!.lengthInBytes); + final txPtrAsBuf = txPtr.cast().asTypedList(txBuf!.lengthInBytes); for (var i = 0; i < txPtrAsBuf.length; i++) { txPtrAsBuf[i] = txBuf![i]; @@ -235,15 +220,12 @@ class TypedDataSpiTransferData extends SpiTransferData { } if (rxBuf != null) { - rxPtr = nativeMem.item1.entries - .singleWhere((element) => element.key == rxBuf) - .value; + rxPtr = nativeMem.item1.entries.singleWhere((element) => element.key == rxBuf).value; } final postTransfer = () { if (rxBuf != null) { - final rxPtrAsBuf = - rxPtr.cast().asTypedList(rxBuf!.lengthInBytes); + final rxPtrAsBuf = rxPtr.cast().asTypedList(rxBuf!.lengthInBytes); for (var i = 0; i < rxPtrAsBuf.length; i++) { rxBuf![i] = rxPtrAsBuf[i]; @@ -253,10 +235,8 @@ class TypedDataSpiTransferData extends SpiTransferData { nativeMem.item2.forEach((pointer) => ffi.malloc.free(pointer)); }; - final raw = SpiTransferData.fromNativeMem( - txPointer: txPtr, - rxPointer: rxPtr, - length: txBuf?.length ?? rxBuf!.length); + final raw = + SpiTransferData.fromNativeMem(txPointer: txPtr, rxPointer: rxPtr, length: txBuf?.length ?? rxBuf!.length); return Tuple2(raw as NativeMemSpiTransferData, postTransfer); } @@ -272,8 +252,7 @@ class ByteListSpiTransferData extends SpiTransferData { ByteListSpiTransferData._private({required this.txBuf, required this.rxBuf}) : assert(txBuf != null || rxBuf != null), - assert( - (txBuf == null || rxBuf == null) || (txBuf.length == rxBuf.length)); + assert((txBuf == null || rxBuf == null) || (txBuf.length == rxBuf.length)); @override Tuple2 _toNativeMemTransferData() { @@ -282,8 +261,7 @@ class ByteListSpiTransferData extends SpiTransferData { if (txBuf != null) { txPointer = ffi.malloc.allocate(txBuf!.length); - final txPointerAsBuf = - txPointer.cast().asTypedList(txBuf!.length); + final txPointerAsBuf = txPointer.cast().asTypedList(txBuf!.length); txBuf!.asMap().forEach((key, value) { txPointerAsBuf[key] = value; @@ -296,8 +274,7 @@ class ByteListSpiTransferData extends SpiTransferData { final postTransfer = () { if (rxBuf != null) { - final rxPtrAsBuf = - rxPointer.cast().asTypedList(rxBuf!.length); + final rxPtrAsBuf = rxPointer.cast().asTypedList(rxBuf!.length); rxPtrAsBuf.asMap().forEach((key, value) { rxBuf![key] = value; }); @@ -361,8 +338,7 @@ class SpiTransferProperties { : assert(speedHz == null || (speedHz >= 0 && speedHz <= 0xFFFFFFFF)), assert(delay.inMicroseconds >= 0 && delay.inMicroseconds <= 0xFFFF), assert(bitsPerWord == null || (bitsPerWord >= 0 && bitsPerWord <= 32)), - assert( - wordDelay.inMicroseconds >= 0 && wordDelay.inMicroseconds <= 0xFF); + assert(wordDelay.inMicroseconds >= 0 && wordDelay.inMicroseconds <= 0xFF); int nbitsFromTransferMode(SpiTransferMode? mode) { switch (mode) { @@ -382,10 +358,8 @@ class SpiTransferProperties { struct.delay_usecs = delay.inMicroseconds; struct.bits_per_word = bitsPerWord ?? 0; struct.cs_change = doToggleCS ? 1 : 0; - struct.tx_nbits = - txTransferMode == null ? 0 : nbitsFromTransferMode(txTransferMode); - struct.rx_nbits = - rxTransferMode == null ? 0 : nbitsFromTransferMode(rxTransferMode); + struct.tx_nbits = txTransferMode == null ? 0 : nbitsFromTransferMode(txTransferMode); + struct.rx_nbits = rxTransferMode == null ? 0 : nbitsFromTransferMode(rxTransferMode); struct.word_delay_usecs = wordDelay.inMicroseconds; } } @@ -414,20 +388,16 @@ void spiTransferExecutorEntry(Tuple2 channel) async { try { final watch = Stopwatch()..start(); - SpidevPlatformInterface._staticIoctl( - libc, fd, SPI_IOC_MESSAGE(nTransfers), pointer); + SpidevPlatformInterface._staticIoctl(libc, fd, SPI_IOC_MESSAGE(nTransfers), pointer); watch.stop(); - sendPort - .send(Tuple3(transferId, null, null)); + sendPort.send(Tuple3(transferId, null, null)); } on OSError catch (e) { - sendPort.send(Tuple3( - transferId, e, StackTrace.current)); + sendPort.send(Tuple3(transferId, e, StackTrace.current)); } } else { - throw StateError( - "Invalid packet received from receivePort in SpiTransferExecutor isolate: $untypedTransfer"); + throw StateError("Invalid packet received from receivePort in SpiTransferExecutor isolate: $untypedTransfer"); } } } @@ -514,11 +484,9 @@ class SpiTransferExecutor { assert(error[0] is String); assert(error[1] is String); - final constructedError = - RemoteError(error[0] as String, error[1] as String); + final constructedError = RemoteError(error[0] as String, error[1] as String); - _pendingTransfers.values - .forEach((value) => value.completeError(constructedError)); + _pendingTransfers.values.forEach((value) => value.completeError(constructedError)); _pendingTransfers.clear(); _toExecutorCompleter.completeError(constructedError); _error = constructedError; @@ -534,8 +502,8 @@ class SpiTransferExecutor { } void _onIsolateFinished(dynamic result) { - final error = StateError( - "SPI Transfer Executor Isolate finished prematurely. Transfer may or may not have been completed."); + final error = + StateError("SPI Transfer Executor Isolate finished prematurely. Transfer may or may not have been completed."); _pendingTransfers.values.forEach((transfer) { transfer.completeError(error); @@ -554,8 +522,7 @@ class SpiTransferExecutor { final transferId = _nextTransferId++; final transferCompleter = Completer(); - final pointer = ffi.malloc.allocate( - ffi.sizeOf() * transfers.length); + final pointer = ffi.malloc.allocate(ffi.sizeOf() * transfers.length); transfers.asMap().forEach((key, value) { final struct = pointer.elementAt(key).ref; @@ -565,8 +532,7 @@ class SpiTransferExecutor { _pendingTransfers[transferId] = transferCompleter; - final packet = - Tuple3(transferId, transfers.length, pointer.address); + final packet = Tuple3(transferId, transfers.length, pointer.address); if (_toExecutor != null) { _toExecutor!.send(packet); } else { @@ -622,8 +588,7 @@ class SpidevPlatformInterface { return result; } - int _ioctl(int fd, int request, ffi.Pointer argp) => - _staticIoctl(libc, fd, request, argp); + int _ioctl(int fd, int request, ffi.Pointer argp) => _staticIoctl(libc, fd, request, argp); int open(String path) { final nativePath = path.toNativeUtf8(); @@ -845,8 +810,7 @@ class SpidevPlatformInterface { return result; } - Future transfer( - int fd, List> transfers) { + Future transfer(int fd, List> transfers) { assert(_executorForFd.containsKey(fd)); SpiTransferExecutor? executor; @@ -971,8 +935,7 @@ class SpidevHandle { assert(isOpen); if (value != __modeAndFlags) { - SpidevPlatformInterface.instance - .setModeAndFlags(_fd, value.item1, value.item2); + SpidevPlatformInterface.instance.setModeAndFlags(_fd, value.item1, value.item2); __modeAndFlags = value; } } @@ -1032,8 +995,7 @@ class SpidevHandle { return _maxSpeedHz!; } - Future transferNativeMem( - List> transfers) { + Future transferNativeMem(List> transfers) { assert(isOpen); return SpidevPlatformInterface.instance.transfer(_fd, transfers); } @@ -1044,9 +1006,7 @@ class SpidevHandle { return Tuple3(t.item1, e.properties, t.item2); }).toList(); - final rawTransfers = tuples - .map((e) => SpiTransfer(data: e.item1, properties: e.item2)) - .toList(); + final rawTransfers = tuples.map((e) => SpiTransfer(data: e.item1, properties: e.item2)).toList(); return transferNativeMem(rawTransfers).whenComplete(() { // call the postTransform callbacks for all spi transfers @@ -1055,45 +1015,33 @@ class SpidevHandle { } Future transferSingleNativeMem( - {ffi.Pointer? txBuf, - ffi.Pointer? rxBuf, - required int length, - SpiTransferProperties? transferProperties}) { + {ffi.Pointer? txBuf, ffi.Pointer? rxBuf, required int length, SpiTransferProperties? transferProperties}) { return transferNativeMem([ SpiTransfer( - data: SpiTransferData.fromNativeMem( - txPointer: txBuf, - rxPointer: rxBuf, - length: length) as NativeMemSpiTransferData, - properties: - transferProperties ?? SpiTransferProperties.defaultProperties) + data: SpiTransferData.fromNativeMem(txPointer: txBuf, rxPointer: rxBuf, length: length) + as NativeMemSpiTransferData, + properties: transferProperties ?? SpiTransferProperties.defaultProperties) ]); } Future transferSingleTypedData( - {Uint8List? txBuf, - Uint8List? rxBuf, - SpiTransferProperties? transferProperties}) { + {Uint8List? txBuf, Uint8List? rxBuf, SpiTransferProperties? transferProperties}) { return transfer([ SpiTransfer( data: SpiTransferData.fromTypedData( txBuf: txBuf, rxBuf: rxBuf, ), - properties: - transferProperties ?? SpiTransferProperties.defaultProperties) + properties: transferProperties ?? SpiTransferProperties.defaultProperties) ]); } Future transferSingleByteLists( - {List? txBuf, - List? rxBuf, - SpiTransferProperties? transferProperties}) { + {List? txBuf, List? rxBuf, SpiTransferProperties? transferProperties}) { return transfer([ SpiTransfer( data: SpiTransferData.fromByteLists(txBuf: txBuf, rxBuf: rxBuf), - properties: - transferProperties ?? SpiTransferProperties.defaultProperties) + properties: transferProperties ?? SpiTransferProperties.defaultProperties) ]); } diff --git a/packages/omxplayer_video_player/lib/src/ensure_unique.dart b/packages/omxplayer_video_player/lib/src/ensure_unique.dart index f37e5f8..1d34c3d 100644 --- a/packages/omxplayer_video_player/lib/src/ensure_unique.dart +++ b/packages/omxplayer_video_player/lib/src/ensure_unique.dart @@ -30,13 +30,10 @@ class UniqueRegistry implements ValueListenable<_EnsureUniqueState?> { @override _EnsureUniqueState? get value => _notifier.value; - bool isRegistered(Key key, State state) => - _registry.containsKey(key) && _registry[key]!.contains(state); + bool isRegistered(Key key, State state) => _registry.containsKey(key) && _registry[key]!.contains(state); void register(Key key, State state) { - _registry - .putIfAbsent(key, () => <_EnsureUniqueState>[]) - .insert(0, state as _EnsureUniqueState); + _registry.putIfAbsent(key, () => <_EnsureUniqueState>[]).insert(0, state as _EnsureUniqueState); // don't call this synchronously, since we're probably building widgets right now. _callDeferred(() => _notifier.value = _registry[key]!.first); @@ -59,8 +56,7 @@ class _EnsureUniqueKey extends GlobalObjectKey { } class EnsureUnique extends StatefulWidget { - EnsureUnique( - {this.strict = false, required this.identity, required this.child}); + EnsureUnique({this.strict = false, required this.identity, required this.child}); final bool strict; final Key identity; @@ -103,8 +99,7 @@ class _EnsureUniqueState extends State { @override Widget build(BuildContext context) { if (_lastParent != _parent) { - if (_lastParent != null && - UniqueRegistry.instance.isRegistered(widget.identity, this)) { + if (_lastParent != null && UniqueRegistry.instance.isRegistered(widget.identity, this)) { UniqueRegistry.instance.unregister(widget.identity, this); } diff --git a/packages/omxplayer_video_player/lib/src/omxplayer_video_player.dart b/packages/omxplayer_video_player/lib/src/omxplayer_video_player.dart index 6014a53..5170267 100644 --- a/packages/omxplayer_video_player/lib/src/omxplayer_video_player.dart +++ b/packages/omxplayer_video_player/lib/src/omxplayer_video_player.dart @@ -30,44 +30,35 @@ class OmxplayerVideoPlayer extends VideoPlayerPlatform { Future init() => _PlatformInterface.instance.init(); @override - Future dispose(int textureId) => - _PlatformInterface.instance.dispose(textureId); + Future dispose(int textureId) => _PlatformInterface.instance.dispose(textureId); @override - Future create(DataSource dataSource) => - _PlatformInterface.instance.create(dataSource); + Future create(DataSource dataSource) => _PlatformInterface.instance.create(dataSource); @override - Stream videoEventsFor(int textureId) => - _PlatformInterface.instance.videoEventsFor(textureId); + Stream videoEventsFor(int textureId) => _PlatformInterface.instance.videoEventsFor(textureId); @override - Future setLooping(int textureId, bool looping) => - _PlatformInterface.instance.setLooping(textureId, looping); + Future setLooping(int textureId, bool looping) => _PlatformInterface.instance.setLooping(textureId, looping); @override - Future play(int textureId) => - _PlatformInterface.instance.play(textureId); + Future play(int textureId) => _PlatformInterface.instance.play(textureId); @override - Future pause(int textureId) => - _PlatformInterface.instance.pause(textureId); + Future pause(int textureId) => _PlatformInterface.instance.pause(textureId); @override - Future setVolume(int textureId, double volume) => - _PlatformInterface.instance.setVolume(textureId, volume); + Future setVolume(int textureId, double volume) => _PlatformInterface.instance.setVolume(textureId, volume); @override - Future seekTo(int textureId, Duration position) => - _PlatformInterface.instance.seekTo(textureId, position); + Future seekTo(int textureId, Duration position) => _PlatformInterface.instance.seekTo(textureId, position); /// TODO(ardera): Implement setPlaybackSpeed @override Future setPlaybackSpeed(int textureId, double speed) => Future.value(); @override - Future getPosition(int textureId) => - _PlatformInterface.instance.getPosition(textureId); + Future getPosition(int textureId) => _PlatformInterface.instance.getPosition(textureId); @override @@ -95,6 +86,5 @@ class OmxplayerVideoPlayer extends VideoPlayerPlatform { VideoPlayerPlatform.instance = OmxplayerVideoPlayer._(strictViewBehaviour); } - static bool isPlatformSidePresent() => - _PlatformInterface.instance.isPlatformSidePresent(); + static bool isPlatformSidePresent() => _PlatformInterface.instance.isPlatformSidePresent(); } diff --git a/packages/omxplayer_video_player/lib/src/omxplayer_view.dart b/packages/omxplayer_video_player/lib/src/omxplayer_view.dart index 0b0b4bb..fc41de9 100644 --- a/packages/omxplayer_video_player/lib/src/omxplayer_view.dart +++ b/packages/omxplayer_video_player/lib/src/omxplayer_view.dart @@ -13,8 +13,7 @@ class OmxplayerView extends StatelessWidget { return PlatformViewLink( viewType: 'omxplayer', onCreatePlatformView: _createOmxPlayerView, - surfaceFactory: - (BuildContext context, PlatformViewController controller) { + surfaceFactory: (BuildContext context, PlatformViewController controller) { return PlatformViewSurface( controller: controller, gestureRecognizers: const >{}, @@ -24,10 +23,8 @@ class OmxplayerView extends StatelessWidget { ); } - _OmxPlayerViewController _createOmxPlayerView( - PlatformViewCreationParams params) { - final _OmxPlayerViewController controller = - _OmxPlayerViewController(params.id, playerId); + _OmxPlayerViewController _createOmxPlayerView(PlatformViewCreationParams params) { + final _OmxPlayerViewController controller = _OmxPlayerViewController(params.id, playerId); controller._initialize().then((_) { params.onPlatformViewCreated(params.id); diff --git a/packages/omxplayer_video_player/lib/src/platform_interface.dart b/packages/omxplayer_video_player/lib/src/platform_interface.dart index 591e01c..e721659 100644 --- a/packages/omxplayer_video_player/lib/src/platform_interface.dart +++ b/packages/omxplayer_video_player/lib/src/platform_interface.dart @@ -11,9 +11,7 @@ class _PlatformInterface { final lib = ffi.DynamicLibrary.process(); try { - final isPresent = - lib.lookupFunction( - "omxpvidpp_is_present"); + final isPresent = lib.lookupFunction("omxpvidpp_is_present"); return _PlatformInterface._constructor(isPresent); } on ArgumentError { return _PlatformInterface._constructor(null); @@ -61,8 +59,7 @@ class _PlatformInterface { return VideoEvent( eventType: VideoEventType.initialized, duration: Duration(milliseconds: map['duration']), - size: Size(map['width']?.toDouble() ?? 0.0, - map['height']?.toDouble() ?? 0.0), + size: Size(map['width']?.toDouble() ?? 0.0, map['height']?.toDouble() ?? 0.0), ); case 'completed': return VideoEvent( @@ -86,8 +83,7 @@ class _PlatformInterface { } Future setLooping(int playerId, bool looping) { - return _channel.invokeMethod( - 'setLooping', {'playerId': playerId, 'looping': looping}); + return _channel.invokeMethod('setLooping', {'playerId': playerId, 'looping': looping}); } Future play(int playerId) { @@ -103,29 +99,24 @@ class _PlatformInterface { } Future setVolume(int playerId, double volume) { - return _channel.invokeMethod( - 'setVolume', {'playerId': playerId, 'volume': volume}); + return _channel.invokeMethod('setVolume', {'playerId': playerId, 'volume': volume}); } Future seekTo(int playerId, Duration position) { - return _channel.invokeMethod( - 'seekTo', {'playerId': playerId, 'position': position.inMilliseconds}); + return _channel.invokeMethod('seekTo', {'playerId': playerId, 'position': position.inMilliseconds}); } Future getPosition(int playerId) async { - final result = (await _channel - .invokeMethod('getPosition', {'playerId': playerId}))!; + final result = (await _channel.invokeMethod('getPosition', {'playerId': playerId}))!; return Duration(milliseconds: result); } Future createPlatformView(int playerId, int platformViewId) { - return _channel.invokeMethod('createPlatformView', - {'playerId': playerId, 'platformViewId': platformViewId}); + return _channel.invokeMethod('createPlatformView', {'playerId': playerId, 'platformViewId': platformViewId}); } Future disposePlatformView(int playerId, int platformViewId) { - return _channel.invokeMethod('disposePlatformView', - {'playerId': playerId, 'platformViewId': platformViewId}); + return _channel.invokeMethod('disposePlatformView', {'playerId': playerId, 'platformViewId': platformViewId}); } DurationRange _toDurationRange(dynamic value) {