Skip to content

Commit

Permalink
Fix the Dart representation of the VARIANT structure (halildurmus#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
halildurmus authored Jul 24, 2023
1 parent ce8927c commit 56ec1f6
Show file tree
Hide file tree
Showing 4 changed files with 244 additions and 172 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.0.6

- Fix the Dart representation of the `VARIANT` structure (#736)

## 5.0.5

- Add `GetRestrictedErrorInfo` and `IRestrictedErrorInfo` (#732)
Expand Down
29 changes: 16 additions & 13 deletions lib/src/variant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import 'win32/oleaut32.g.dart';

sealed class _VARIANT_Anonymous_3 extends Struct {
external Pointer pvRecord;
external Pointer<COMObject> pRecInfo;
external VTablePointer pRecInfo;
}

sealed class _VARIANT_Anonymous_2 extends Union {
Expand Down Expand Up @@ -63,8 +63,8 @@ sealed class _VARIANT_Anonymous_2 extends Union {
@Double()
external double date;
external Pointer<Utf16> bstrVal;
external Pointer<COMObject> punkVal;
external Pointer<COMObject> pdispVal;
external VTablePointer punkVal;
external VTablePointer pdispVal;
external Pointer/*<SAFEARRAY>*/ parray;
external Pointer<Uint8> pbVal;
external Pointer<Int16> piVal;
Expand Down Expand Up @@ -210,16 +210,18 @@ base class VARIANT extends Struct {
__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.bstrVal = value;

// IUnknown
IUnknown get punkVal =>
IUnknown(__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.punkVal);
IUnknown get punkVal => IUnknown(calloc<COMObject>()
..ref.lpVtbl = __VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.punkVal);
set punkVal(IUnknown value) =>
__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.punkVal = value.ptr;
__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.punkVal =
value.ptr.ref.lpVtbl;

// IDispatch
IDispatch get pdispVal =>
IDispatch(__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.pdispVal);
IDispatch get pdispVal => IDispatch(calloc<COMObject>()
..ref.lpVtbl = __VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.pdispVal);
set pdispVal(IDispatch value) =>
__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.pdispVal = value.ptr;
__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.pdispVal =
value.ptr.ref.lpVtbl;

Pointer get parray =>
__VARIANT_NAME_1.__VARIANT_NAME_2.__VARIANT_NAME_3.parray;
Expand Down Expand Up @@ -393,10 +395,11 @@ base class VARIANT extends Struct {
set pvRecord(Pointer value) => __VARIANT_NAME_1
.__VARIANT_NAME_2.__VARIANT_NAME_3.__VARIANT_NAME_4.pvRecord = value;

Pointer<COMObject> get pRecInfo => __VARIANT_NAME_1
.__VARIANT_NAME_2.__VARIANT_NAME_3.__VARIANT_NAME_4.pRecInfo;
set pRecInfo(Pointer<COMObject> value) => __VARIANT_NAME_1
.__VARIANT_NAME_2.__VARIANT_NAME_3.__VARIANT_NAME_4.pRecInfo = value;
Pointer<COMObject> get pRecInfo => calloc<COMObject>()
..ref.lpVtbl = __VARIANT_NAME_1
.__VARIANT_NAME_2.__VARIANT_NAME_3.__VARIANT_NAME_4.pRecInfo;
set pRecInfo(Pointer<COMObject> value) => __VARIANT_NAME_1.__VARIANT_NAME_2
.__VARIANT_NAME_3.__VARIANT_NAME_4.pRecInfo = value.ref.lpVtbl;
}

/// The PROPVARIANT structure is used in the ReadMultiple and WriteMultiple
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: win32
description: A Dart library for accessing common Win32 APIs using FFI. No C required!
version: 5.0.5
version: 5.0.6
homepage: https://win32.pub
repository: https://github.com/dart-windows/win32
issue_tracker: https://github.com/dart-windows/win32/issues
Expand Down
Loading

0 comments on commit 56ec1f6

Please sign in to comment.