Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the Dart representation of the PROPVARIANT structure #845

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 5.5.0-wip

- Add `BLOB`, `BSTRBLOB`, `CABOOL`, `CABSTR`, `CABSTRBLOB`, `CAC`, `CACLIPDATA`,
`CACLSID`, `CACY`, `CADATE`, `CADBL`, `CAFILETIME`, `CAFLT`, `CAH`, `CAI`,
`CAL`, `CALPSTR`, `CALPWSTR`, `CAPROPVARIANT`, `CASCODE`, `CAUB`, `CAUH`,
`CAUI`, `CAUL`, `CLIPDATA`, and `VERSIONEDSTREAM` structures (#845)
- Add `VARIANT_BOOL` typedef (#845)
- Fix the Dart representation of the `PROPVARIANT` structure (#845)
- Add `PropVariantInit` and `PropVariantClear` APIs (#845)

## 5.4.0

- Fix constant values `ERROR_SERVICE_NOT_ACTIVE`, `KF_FLAG_ALIAS_ONLY`,
Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:dartwindows_lints/analysis_options.yaml
include: package:lints/recommended.yaml

analyzer:
exclude: ['example/explorer/**', 'test_fixes/**']
Expand Down
8 changes: 4 additions & 4 deletions example/wasapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ void main() {
// Check the retrieved device friendly name.
final varName = pVal.ref;
if (varName.vt != VARENUM.VT_EMPTY) {
final ptr = Pointer<Utf16>.fromAddress(varName.val1);
final name = ptr.toDartString();
final bstrVal = varName.bstrVal;
final name = bstrVal.toDartString();
print(" ID: $id Name: $name");
free(ptr);
SysFreeString(bstrVal);
} else {
print(" Unknown device");
print(' Unknown device');
}

free(ppEndpoint);
Expand Down
11 changes: 11 additions & 0 deletions lib/src/macros.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import 'dart:ffi';

import 'package:ffi/ffi.dart';

import 'constants.dart';
import 'enums.g.dart';
import 'inline.dart';
import 'variant.dart';

/// Creates a WORD value by concatenating the specified values.
//
Expand Down Expand Up @@ -111,3 +114,11 @@ int CTL_CODE(int DeviceType, int Function, int Method, int Access) =>
//
// #define GET_SC_WPARAM(wParam) ((int)wParam & 0xFFF0)
int GET_SC_WPARAM(int wParam) => wParam & 0xFFF0;

/// The PropVariantInit function initializes a PROPVARIANT structure.
//
// #define PropVariantInit(pvar) memset ( (pvar), 0, sizeof(PROPVARIANT) )
void PropVariantInit(Pointer<PROPVARIANT> pvar) {
ZeroMemory(pvar, sizeOf<PROPVARIANT>());
pvar.ref.vt = VARENUM.VT_EMPTY;
}
206 changes: 206 additions & 0 deletions lib/src/structs.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ base class BLENDFUNCTION extends Struct {
external int AlphaFormat;
}

/// The BLOB structure, derived from Binary Large Object, contains
/// information about a block of data.
///
/// {@category struct}
base class BLOB extends Struct {
@Uint32()
external int cbSize;

external Pointer<Uint8> pBlobData;
}

/// The BLUETOOTH_ADDRESS structure provides the address of a Bluetooth
/// device.
///
Expand Down Expand Up @@ -742,6 +753,14 @@ base class BSMINFO extends Struct {
external LUID luid;
}

/// {@category struct}
base class BSTRBLOB extends Struct {
@Uint32()
external int cbSize;

external Pointer<Uint8> pData;
}

/// The BTH_DEVICE_INFO structure stores information about a Bluetooth
/// device.
///
Expand Down Expand Up @@ -1180,6 +1199,38 @@ base class BY_HANDLE_FILE_INFORMATION extends Struct {
external int nFileIndexLow;
}

/// {@category struct}
base class CABOOL extends Struct {
@Uint32()
external int cElems;

external Pointer<Int16> pElems;
}

/// {@category struct}
base class CABSTR extends Struct {
@Uint32()
external int cElems;

external Pointer<Pointer<Utf16>> pElems;
}

/// {@category struct}
base class CABSTRBLOB extends Struct {
@Uint32()
external int cElems;

external Pointer<BSTRBLOB> pElems;
}

/// {@category struct}
base class CAC extends Struct {
@Uint32()
external int cElems;

external Pointer<Utf8> pElems;
}

/// Describes the cache attributes.
///
/// {@category struct}
Expand All @@ -1200,6 +1251,150 @@ base class CACHE_DESCRIPTOR extends Struct {
external int Type;
}

/// {@category struct}
base class CACLIPDATA extends Struct {
@Uint32()
external int cElems;

external Pointer<CLIPDATA> pElems;
}

/// {@category struct}
base class CACLSID extends Struct {
@Uint32()
external int cElems;

external Pointer<GUID> pElems;
}

/// {@category struct}
base class CACY extends Struct {
@Uint32()
external int cElems;

external Pointer<CY> pElems;
}

/// {@category struct}
base class CADATE extends Struct {
@Uint32()
external int cElems;

external Pointer<Double> pElems;
}

/// {@category struct}
base class CADBL extends Struct {
@Uint32()
external int cElems;

external Pointer<Double> pElems;
}

/// {@category struct}
base class CAFILETIME extends Struct {
@Uint32()
external int cElems;

external Pointer<FILETIME> pElems;
}

/// {@category struct}
base class CAFLT extends Struct {
@Uint32()
external int cElems;

external Pointer<Float> pElems;
}

/// {@category struct}
base class CAH extends Struct {
@Uint32()
external int cElems;

external Pointer<Int64> pElems;
}

/// {@category struct}
base class CAI extends Struct {
@Uint32()
external int cElems;

external Pointer<Int16> pElems;
}

/// {@category struct}
base class CAL extends Struct {
@Uint32()
external int cElems;

external Pointer<Int32> pElems;
}

/// {@category struct}
base class CALPSTR extends Struct {
@Uint32()
external int cElems;

external Pointer<Pointer<Utf8>> pElems;
}

/// {@category struct}
base class CALPWSTR extends Struct {
@Uint32()
external int cElems;

external Pointer<Pointer<Utf16>> pElems;
}

/// {@category struct}
base class CAPROPVARIANT extends Struct {
@Uint32()
external int cElems;

external Pointer<PROPVARIANT> pElems;
}

/// {@category struct}
base class CASCODE extends Struct {
@Uint32()
external int cElems;

external Pointer<Int32> pElems;
}

/// {@category struct}
base class CAUB extends Struct {
@Uint32()
external int cElems;

external Pointer<Uint8> pElems;
}

/// {@category struct}
base class CAUH extends Struct {
@Uint32()
external int cElems;

external Pointer<Uint64> pElems;
}

/// {@category struct}
base class CAUI extends Struct {
@Uint32()
external int cElems;

external Pointer<Uint16> pElems;
}

/// {@category struct}
base class CAUL extends Struct {
@Uint32()
external int cElems;

external Pointer<Uint32> pElems;
}

/// Contains information passed to a WH_CBT hook procedure, CBTProc, before
/// a window is activated.
///
Expand Down Expand Up @@ -1434,6 +1629,17 @@ base class CLIENT_ID extends Struct {
external int UniqueThread;
}

/// {@category struct}
base class CLIPDATA extends Struct {
@Uint32()
external int cbSize;

@Int32()
external int ulClipFmt;

external Pointer<Uint8> pClipData;
}

/// The COLORADJUSTMENT structure defines the color adjustment values used
/// by the StretchBlt and StretchDIBits functions when the stretch mode is
/// HALFTONE. You can set the color adjustment values by calling the
Expand Down
1 change: 1 addition & 0 deletions lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ typedef ULONG64 = Uint64;
typedef ULONGLONG = Uint64;
typedef ULONG_PTR = IntPtr;
typedef USHORT = Uint16;
typedef VARIANT_BOOL = Int16;
typedef WCHAR = Uint16;
typedef WORD = Uint16;
typedef WPARAM = UINT_PTR;
Loading