-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support
WinRTStruct
type arguments in Vectors (#289)
- Loading branch information
1 parent
02c5e79
commit 486f0de
Showing
34 changed files
with
13,080 additions
and
1,427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/windows_devices/lib/src/gpio/gpiochangerecord.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
/// Stores a relative timestap of a general-purpose I/O (GPIO) pin value | ||
/// change, and whether the pin transitioned from low to high or from high | ||
/// to low. | ||
final class GpioChangeRecord implements WinRTStruct { | ||
GpioChangeRecord(this.relativeTime, this.edge); | ||
|
||
final int relativeTime; | ||
final int edge; | ||
|
||
@override | ||
Pointer<NativeGpioChangeRecord> toNative({Allocator allocator = malloc}) { | ||
final nativeStructPtr = allocator<NativeGpioChangeRecord>(); | ||
nativeStructPtr.ref | ||
..relativeTime = relativeTime | ||
..edge = edge; | ||
return nativeStructPtr; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
if (identical(this, other)) return true; | ||
return other is GpioChangeRecord && | ||
relativeTime == other.relativeTime && | ||
edge == other.edge; | ||
} | ||
|
||
@override | ||
int get hashCode => relativeTime.hashCode ^ edge.hashCode; | ||
} | ||
|
||
/// @nodoc | ||
extension PointerNativeGpioChangeRecordConversion | ||
on Pointer<NativeGpioChangeRecord> { | ||
/// Converts this [NativeGpioChangeRecord] to a Dart [GpioChangeRecord]. | ||
GpioChangeRecord toDart() { | ||
final ref = this.ref; | ||
return GpioChangeRecord(ref.relativeTime, ref.edge); | ||
} | ||
|
||
/// Creates a `List<GpioChangeRecord>` from | ||
/// `Pointer<NativeGpioChangeRecord>`. | ||
/// | ||
/// [length] must not be greater than the number of elements stored inside the | ||
/// `Pointer<NativeGpioChangeRecord>`. | ||
List<GpioChangeRecord> toList({int length = 1}) => | ||
[for (var i = 0; i < length; i++) elementAt(i).toDart()]; | ||
} |
100 changes: 100 additions & 0 deletions
100
packages/windows_devices/lib/src/input/pointerdeviceusage.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
/// Identifies the Human Interface Device (HID) usage details for the input | ||
/// device. | ||
final class PointerDeviceUsage implements WinRTStruct { | ||
PointerDeviceUsage( | ||
this.usagePage, | ||
this.usage, | ||
this.minLogical, | ||
this.maxLogical, | ||
this.minPhysical, | ||
this.maxPhysical, | ||
this.unit, | ||
this.physicalMultiplier); | ||
|
||
final int usagePage; | ||
final int usage; | ||
final int minLogical; | ||
final int maxLogical; | ||
final int minPhysical; | ||
final int maxPhysical; | ||
final int unit; | ||
final double physicalMultiplier; | ||
|
||
@override | ||
Pointer<NativePointerDeviceUsage> toNative({Allocator allocator = malloc}) { | ||
final nativeStructPtr = allocator<NativePointerDeviceUsage>(); | ||
nativeStructPtr.ref | ||
..usagePage = usagePage | ||
..usage = usage | ||
..minLogical = minLogical | ||
..maxLogical = maxLogical | ||
..minPhysical = minPhysical | ||
..maxPhysical = maxPhysical | ||
..unit = unit | ||
..physicalMultiplier = physicalMultiplier; | ||
return nativeStructPtr; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
if (identical(this, other)) return true; | ||
return other is PointerDeviceUsage && | ||
usagePage == other.usagePage && | ||
usage == other.usage && | ||
minLogical == other.minLogical && | ||
maxLogical == other.maxLogical && | ||
minPhysical == other.minPhysical && | ||
maxPhysical == other.maxPhysical && | ||
unit == other.unit && | ||
physicalMultiplier == other.physicalMultiplier; | ||
} | ||
|
||
@override | ||
int get hashCode => | ||
usagePage.hashCode ^ | ||
usage.hashCode ^ | ||
minLogical.hashCode ^ | ||
maxLogical.hashCode ^ | ||
minPhysical.hashCode ^ | ||
maxPhysical.hashCode ^ | ||
unit.hashCode ^ | ||
physicalMultiplier.hashCode; | ||
} | ||
|
||
/// @nodoc | ||
extension PointerNativePointerDeviceUsageConversion | ||
on Pointer<NativePointerDeviceUsage> { | ||
/// Converts this [NativePointerDeviceUsage] to a Dart [PointerDeviceUsage]. | ||
PointerDeviceUsage toDart() { | ||
final ref = this.ref; | ||
return PointerDeviceUsage( | ||
ref.usagePage, | ||
ref.usage, | ||
ref.minLogical, | ||
ref.maxLogical, | ||
ref.minPhysical, | ||
ref.maxPhysical, | ||
ref.unit, | ||
ref.physicalMultiplier); | ||
} | ||
|
||
/// Creates a `List<PointerDeviceUsage>` from | ||
/// `Pointer<NativePointerDeviceUsage>`. | ||
/// | ||
/// [length] must not be greater than the number of elements stored inside the | ||
/// `Pointer<NativePointerDeviceUsage>`. | ||
List<PointerDeviceUsage> toList({int length = 1}) => | ||
[for (var i = 0; i < length; i++) elementAt(i).toDart()]; | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/windows_devices/lib/src/pointofservice/sizeuint32.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
/// Defines the height and width of an object in a two-dimensional plane. | ||
final class SizeUInt32 implements WinRTStruct { | ||
SizeUInt32(this.width, this.height); | ||
|
||
final int width; | ||
final int height; | ||
|
||
@override | ||
Pointer<NativeSizeUInt32> toNative({Allocator allocator = malloc}) { | ||
final nativeStructPtr = allocator<NativeSizeUInt32>(); | ||
nativeStructPtr.ref | ||
..width = width | ||
..height = height; | ||
return nativeStructPtr; | ||
} | ||
|
||
@override | ||
bool operator ==(Object other) { | ||
if (identical(this, other)) return true; | ||
return other is SizeUInt32 && | ||
width == other.width && | ||
height == other.height; | ||
} | ||
|
||
@override | ||
int get hashCode => width.hashCode ^ height.hashCode; | ||
} | ||
|
||
/// @nodoc | ||
extension PointerNativeSizeUInt32Conversion on Pointer<NativeSizeUInt32> { | ||
/// Converts this [NativeSizeUInt32] to a Dart [SizeUInt32]. | ||
SizeUInt32 toDart() { | ||
final ref = this.ref; | ||
return SizeUInt32(ref.width, ref.height); | ||
} | ||
|
||
/// Creates a `List<SizeUInt32>` from `Pointer<NativeSizeUInt32>`. | ||
/// | ||
/// [length] must not be greater than the number of elements stored inside the | ||
/// `Pointer<NativeSizeUInt32>`. | ||
List<SizeUInt32> toList({int length = 1}) => | ||
[for (var i = 0; i < length; i++) elementAt(i).toDart()]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.