Skip to content

Commit

Permalink
Absorb new TypeProjector
Browse files Browse the repository at this point in the history
  • Loading branch information
timsneath committed Nov 1, 2021
1 parent 9d57ec4 commit 6d89d00
Show file tree
Hide file tree
Showing 93 changed files with 1,594 additions and 1,271 deletions.
9 changes: 4 additions & 5 deletions example/dynamic_load.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ void main() {
final pGetNativeSystemInfo = GetProcAddress(hModule, ansi);
free(ansi);

if (pGetNativeSystemInfo != NULL) {
if (pGetNativeSystemInfo != nullptr) {
print('GetNativeSystemInfo() is available on this system.');
final funcGetNativeSystemInfo =
Pointer<NativeFunction<getNativeSystemInfoNative>>.fromAddress(
pGetNativeSystemInfo)
.asFunction<getNativeSystemInfoDart>();
final funcGetNativeSystemInfo = pGetNativeSystemInfo
.cast<NativeFunction<getNativeSystemInfoNative>>()
.asFunction<getNativeSystemInfoDart>();

funcGetNativeSystemInfo(systemInfo);
} else {
Expand Down
2 changes: 1 addition & 1 deletion example/network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void main() {
}

final netManager = NetworkListManager.createInstance();
final nlmConnectivity = calloc<Uint32>();
final nlmConnectivity = calloc<Int32>();
final enumPtr = calloc<COMObject>();
final netPtr = calloc<COMObject>();
final descPtr = calloc<Pointer<Utf16>>();
Expand Down
4 changes: 2 additions & 2 deletions example/wmi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void main() {
throw exception;
}

final proxy = calloc<Pointer>();
final proxy = calloc<Pointer<COMObject>>();

// Connect to the root\cimv2 namespace with the
// current user and obtain pointer pSvc
Expand Down Expand Up @@ -110,7 +110,7 @@ void main() {

// Use the IWbemServices pointer to make requests of WMI.

final pEnumerator = calloc<Pointer>();
final pEnumerator = calloc<Pointer<COMObject>>();
IEnumWbemClassObject enumerator;

// For example, query for all the running processes
Expand Down
4 changes: 2 additions & 2 deletions lib/src/advapi32.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ int GetTokenInformation(
late final _GetTokenInformation = _advapi32.lookupFunction<
Int32 Function(
IntPtr TokenHandle,
Uint32 TokenInformationClass,
Int32 TokenInformationClass,
Pointer TokenInformation,
Uint32 TokenInformationLength,
Pointer<Uint32> ReturnLength),
Expand Down Expand Up @@ -1244,7 +1244,7 @@ int RegRestoreKey(int hKey, Pointer<Utf16> lpFile, int dwFlags) =>
_RegRestoreKey(hKey, lpFile, dwFlags);

late final _RegRestoreKey = _advapi32.lookupFunction<
Int32 Function(IntPtr hKey, Pointer<Utf16> lpFile, Uint32 dwFlags),
Int32 Function(IntPtr hKey, Pointer<Utf16> lpFile, Int32 dwFlags),
int Function(
int hKey, Pointer<Utf16> lpFile, int dwFlags)>('RegRestoreKeyW');

Expand Down
11 changes: 6 additions & 5 deletions lib/src/api-ms-win-core-winrt-l1-1-0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ final _api_ms_win_core_winrt_l1_1_0 =
/// );
/// ```
/// {@category winrt}
int RoActivateInstance(int activatableClassId, Pointer<Pointer> instance) =>
int RoActivateInstance(
int activatableClassId, Pointer<Pointer<COMObject>> instance) =>
_RoActivateInstance(activatableClassId, instance);

late final _RoActivateInstance = _api_ms_win_core_winrt_l1_1_0.lookupFunction<
Int32 Function(IntPtr activatableClassId, Pointer<Pointer> instance),
Int32 Function(
IntPtr activatableClassId, Pointer<Pointer<COMObject>> instance),
int Function(int activatableClassId,
Pointer<Pointer> instance)>('RoActivateInstance');
Pointer<Pointer<COMObject>> instance)>('RoActivateInstance');

/// Gets the activation factory for the specified runtime class.
///
Expand Down Expand Up @@ -87,8 +89,7 @@ late final _RoGetApartmentIdentifier =
int RoInitialize(int initType) => _RoInitialize(initType);

late final _RoInitialize = _api_ms_win_core_winrt_l1_1_0.lookupFunction<
Int32 Function(Uint32 initType),
int Function(int initType)>('RoInitialize');
Int32 Function(Int32 initType), int Function(int initType)>('RoInitialize');

/// Closes the Windows Runtime on the current thread.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bthprops.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ late final _BluetoothAuthenticateDeviceEx = _bthprops.lookupFunction<
IntPtr hRadioIn,
Pointer<BLUETOOTH_DEVICE_INFO> pbtdiInout,
Pointer<BLUETOOTH_OOB_DATA_INFO> pbtOobData,
Uint32 authenticationRequirement),
Int32 authenticationRequirement),
int Function(
int hwndParentIn,
int hRadioIn,
Expand Down
21 changes: 12 additions & 9 deletions lib/src/com/IApplicationActivationManager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef _ActivateApplication_Native = Int32 Function(
Pointer obj,
Pointer<Utf16> appUserModelId,
Pointer<Utf16> arguments,
Uint32 options,
Int32 options,
Pointer<Uint32> processId);
typedef _ActivateApplication_Dart = int Function(
Pointer obj,
Expand All @@ -43,25 +43,25 @@ typedef _ActivateApplication_Dart = int Function(
typedef _ActivateForFile_Native = Int32 Function(
Pointer obj,
Pointer<Utf16> appUserModelId,
Pointer itemArray,
Pointer<COMObject> itemArray,
Pointer<Utf16> verb,
Pointer<Uint32> processId);
typedef _ActivateForFile_Dart = int Function(
Pointer obj,
Pointer<Utf16> appUserModelId,
Pointer itemArray,
Pointer<COMObject> itemArray,
Pointer<Utf16> verb,
Pointer<Uint32> processId);

typedef _ActivateForProtocol_Native = Int32 Function(
Pointer obj,
Pointer<Utf16> appUserModelId,
Pointer itemArray,
Pointer<COMObject> itemArray,
Pointer<Uint32> processId);
typedef _ActivateForProtocol_Dart = int Function(
Pointer obj,
Pointer<Utf16> appUserModelId,
Pointer itemArray,
Pointer<COMObject> itemArray,
Pointer<Uint32> processId);

/// {@category Interface}
Expand All @@ -80,17 +80,20 @@ class IApplicationActivationManager extends IUnknown {
.asFunction<_ActivateApplication_Dart>()(
ptr.ref.lpVtbl, appUserModelId, arguments, options, processId);

int ActivateForFile(Pointer<Utf16> appUserModelId, Pointer itemArray,
Pointer<Utf16> verb, Pointer<Uint32> processId) =>
int ActivateForFile(
Pointer<Utf16> appUserModelId,
Pointer<COMObject> itemArray,
Pointer<Utf16> verb,
Pointer<Uint32> processId) =>
ptr.ref.lpVtbl.value
.elementAt(4)
.cast<Pointer<NativeFunction<_ActivateForFile_Native>>>()
.value
.asFunction<_ActivateForFile_Dart>()(
ptr.ref.lpVtbl, appUserModelId, itemArray, verb, processId);

int ActivateForProtocol(Pointer<Utf16> appUserModelId, Pointer itemArray,
Pointer<Uint32> processId) =>
int ActivateForProtocol(Pointer<Utf16> appUserModelId,
Pointer<COMObject> itemArray, Pointer<Uint32> processId) =>
ptr.ref.lpVtbl.value
.elementAt(5)
.cast<Pointer<NativeFunction<_ActivateForProtocol_Native>>>()
Expand Down
62 changes: 32 additions & 30 deletions lib/src/com/IAppxFactory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,40 @@ const IID_IAppxFactory = '{BEB94909-E451-438B-B5A7-D79E767B75D8}';

typedef _CreatePackageWriter_Native = Int32 Function(
Pointer obj,
Pointer outputStream,
Pointer<COMObject> outputStream,
Pointer<APPX_PACKAGE_SETTINGS> settings,
Pointer<Pointer> packageWriter);
Pointer<Pointer<COMObject>> packageWriter);
typedef _CreatePackageWriter_Dart = int Function(
Pointer obj,
Pointer outputStream,
Pointer<COMObject> outputStream,
Pointer<APPX_PACKAGE_SETTINGS> settings,
Pointer<Pointer> packageWriter);
Pointer<Pointer<COMObject>> packageWriter);

typedef _CreatePackageReader_Native = Int32 Function(
Pointer obj, Pointer inputStream, Pointer<Pointer> packageReader);
typedef _CreatePackageReader_Dart = int Function(
Pointer obj, Pointer inputStream, Pointer<Pointer> packageReader);
typedef _CreatePackageReader_Native = Int32 Function(Pointer obj,
Pointer<COMObject> inputStream, Pointer<Pointer<COMObject>> packageReader);
typedef _CreatePackageReader_Dart = int Function(Pointer obj,
Pointer<COMObject> inputStream, Pointer<Pointer<COMObject>> packageReader);

typedef _CreateManifestReader_Native = Int32 Function(
Pointer obj, Pointer inputStream, Pointer<Pointer> manifestReader);
typedef _CreateManifestReader_Dart = int Function(
Pointer obj, Pointer inputStream, Pointer<Pointer> manifestReader);
typedef _CreateManifestReader_Native = Int32 Function(Pointer obj,
Pointer<COMObject> inputStream, Pointer<Pointer<COMObject>> manifestReader);
typedef _CreateManifestReader_Dart = int Function(Pointer obj,
Pointer<COMObject> inputStream, Pointer<Pointer<COMObject>> manifestReader);

typedef _CreateBlockMapReader_Native = Int32 Function(
Pointer obj, Pointer inputStream, Pointer<Pointer> blockMapReader);
typedef _CreateBlockMapReader_Dart = int Function(
Pointer obj, Pointer inputStream, Pointer<Pointer> blockMapReader);
typedef _CreateBlockMapReader_Native = Int32 Function(Pointer obj,
Pointer<COMObject> inputStream, Pointer<Pointer<COMObject>> blockMapReader);
typedef _CreateBlockMapReader_Dart = int Function(Pointer obj,
Pointer<COMObject> inputStream, Pointer<Pointer<COMObject>> blockMapReader);

typedef _CreateValidatedBlockMapReader_Native = Int32 Function(
Pointer obj,
Pointer blockMapStream,
Pointer<COMObject> blockMapStream,
Pointer<Utf16> signatureFileName,
Pointer<Pointer> blockMapReader);
Pointer<Pointer<COMObject>> blockMapReader);
typedef _CreateValidatedBlockMapReader_Dart = int Function(
Pointer obj,
Pointer blockMapStream,
Pointer<COMObject> blockMapStream,
Pointer<Utf16> signatureFileName,
Pointer<Pointer> blockMapReader);
Pointer<Pointer<COMObject>> blockMapReader);

/// {@category Interface}
/// {@category com}
Expand All @@ -70,45 +70,47 @@ class IAppxFactory extends IUnknown {
IAppxFactory(Pointer<COMObject> ptr) : super(ptr);

int CreatePackageWriter(
Pointer outputStream,
Pointer<COMObject> outputStream,
Pointer<APPX_PACKAGE_SETTINGS> settings,
Pointer<Pointer> packageWriter) =>
Pointer<Pointer<COMObject>> packageWriter) =>
ptr.ref.lpVtbl.value
.elementAt(3)
.cast<Pointer<NativeFunction<_CreatePackageWriter_Native>>>()
.value
.asFunction<_CreatePackageWriter_Dart>()(
ptr.ref.lpVtbl, outputStream, settings, packageWriter);

int CreatePackageReader(
Pointer inputStream, Pointer<Pointer> packageReader) =>
int CreatePackageReader(Pointer<COMObject> inputStream,
Pointer<Pointer<COMObject>> packageReader) =>
ptr.ref.lpVtbl.value
.elementAt(4)
.cast<Pointer<NativeFunction<_CreatePackageReader_Native>>>()
.value
.asFunction<_CreatePackageReader_Dart>()(
ptr.ref.lpVtbl, inputStream, packageReader);

int CreateManifestReader(
Pointer inputStream, Pointer<Pointer> manifestReader) =>
int CreateManifestReader(Pointer<COMObject> inputStream,
Pointer<Pointer<COMObject>> manifestReader) =>
ptr.ref.lpVtbl.value
.elementAt(5)
.cast<Pointer<NativeFunction<_CreateManifestReader_Native>>>()
.value
.asFunction<_CreateManifestReader_Dart>()(
ptr.ref.lpVtbl, inputStream, manifestReader);

int CreateBlockMapReader(
Pointer inputStream, Pointer<Pointer> blockMapReader) =>
int CreateBlockMapReader(Pointer<COMObject> inputStream,
Pointer<Pointer<COMObject>> blockMapReader) =>
ptr.ref.lpVtbl.value
.elementAt(6)
.cast<Pointer<NativeFunction<_CreateBlockMapReader_Native>>>()
.value
.asFunction<_CreateBlockMapReader_Dart>()(
ptr.ref.lpVtbl, inputStream, blockMapReader);

int CreateValidatedBlockMapReader(Pointer blockMapStream,
Pointer<Utf16> signatureFileName, Pointer<Pointer> blockMapReader) =>
int CreateValidatedBlockMapReader(
Pointer<COMObject> blockMapStream,
Pointer<Utf16> signatureFileName,
Pointer<Pointer<COMObject>> blockMapReader) =>
ptr.ref.lpVtbl.value
.elementAt(7)
.cast<
Expand Down
25 changes: 13 additions & 12 deletions lib/src/com/IAppxFile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import 'IUnknown.dart';
const IID_IAppxFile = '{91DF827B-94FD-468F-827B-57F41B2F6F2E}';

typedef _GetCompressionOption_Native = Int32 Function(
Pointer obj, Pointer<Uint32> compressionOption);
Pointer obj, Pointer<Int32> compressionOption);
typedef _GetCompressionOption_Dart = int Function(
Pointer obj, Pointer<Uint32> compressionOption);
Pointer obj, Pointer<Int32> compressionOption);

typedef _GetContentType_Native = Int32 Function(
Pointer obj, Pointer<Pointer<Utf16>> contentType);
Expand All @@ -41,8 +41,9 @@ typedef _GetSize_Native = Int32 Function(Pointer obj, Pointer<Uint64> size);
typedef _GetSize_Dart = int Function(Pointer obj, Pointer<Uint64> size);

typedef _GetStream_Native = Int32 Function(
Pointer obj, Pointer<Pointer> stream);
typedef _GetStream_Dart = int Function(Pointer obj, Pointer<Pointer> stream);
Pointer obj, Pointer<Pointer<COMObject>> stream);
typedef _GetStream_Dart = int Function(
Pointer obj, Pointer<Pointer<COMObject>> stream);

/// {@category Interface}
/// {@category com}
Expand All @@ -51,13 +52,13 @@ class IAppxFile extends IUnknown {

IAppxFile(Pointer<COMObject> ptr) : super(ptr);

int GetCompressionOption(Pointer<Uint32> compressionOption) =>
ptr.ref.lpVtbl.value
.elementAt(3)
.cast<Pointer<NativeFunction<_GetCompressionOption_Native>>>()
.value
.asFunction<_GetCompressionOption_Dart>()(
ptr.ref.lpVtbl, compressionOption);
int GetCompressionOption(Pointer<Int32> compressionOption) => ptr
.ref.lpVtbl.value
.elementAt(3)
.cast<Pointer<NativeFunction<_GetCompressionOption_Native>>>()
.value
.asFunction<_GetCompressionOption_Dart>()(
ptr.ref.lpVtbl, compressionOption);

int GetContentType(Pointer<Pointer<Utf16>> contentType) =>
ptr.ref.lpVtbl.value
Expand All @@ -78,7 +79,7 @@ class IAppxFile extends IUnknown {
.value
.asFunction<_GetSize_Dart>()(ptr.ref.lpVtbl, size);

int GetStream(Pointer<Pointer> stream) => ptr.ref.lpVtbl.value
int GetStream(Pointer<Pointer<COMObject>> stream) => ptr.ref.lpVtbl.value
.elementAt(7)
.cast<Pointer<NativeFunction<_GetStream_Native>>>()
.value
Expand Down
8 changes: 5 additions & 3 deletions lib/src/com/IAppxFilesEnumerator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import 'IUnknown.dart';
/// @nodoc
const IID_IAppxFilesEnumerator = '{F007EEAF-9831-411C-9847-917CDC62D1FE}';

typedef _GetCurrent_Native = Int32 Function(Pointer obj, Pointer<Pointer> file);
typedef _GetCurrent_Dart = int Function(Pointer obj, Pointer<Pointer> file);
typedef _GetCurrent_Native = Int32 Function(
Pointer obj, Pointer<Pointer<COMObject>> file);
typedef _GetCurrent_Dart = int Function(
Pointer obj, Pointer<Pointer<COMObject>> file);

typedef _GetHasCurrent_Native = Int32 Function(
Pointer obj, Pointer<Int32> hasCurrent);
Expand All @@ -40,7 +42,7 @@ class IAppxFilesEnumerator extends IUnknown {

IAppxFilesEnumerator(Pointer<COMObject> ptr) : super(ptr);

int GetCurrent(Pointer<Pointer> file) => ptr.ref.lpVtbl.value
int GetCurrent(Pointer<Pointer<COMObject>> file) => ptr.ref.lpVtbl.value
.elementAt(3)
.cast<Pointer<NativeFunction<_GetCurrent_Native>>>()
.value
Expand Down
15 changes: 8 additions & 7 deletions lib/src/com/IAppxManifestApplicationsEnumerator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const IID_IAppxManifestApplicationsEnumerator =
'{9EB8A55A-F04B-4D0D-808D-686185D4847A}';

typedef _GetCurrent_Native = Int32 Function(
Pointer obj, Pointer<Pointer> application);
Pointer obj, Pointer<Pointer<COMObject>> application);
typedef _GetCurrent_Dart = int Function(
Pointer obj, Pointer<Pointer> application);
Pointer obj, Pointer<Pointer<COMObject>> application);

typedef _GetHasCurrent_Native = Int32 Function(
Pointer obj, Pointer<Int32> hasCurrent);
Expand All @@ -43,11 +43,12 @@ class IAppxManifestApplicationsEnumerator extends IUnknown {

IAppxManifestApplicationsEnumerator(Pointer<COMObject> ptr) : super(ptr);

int GetCurrent(Pointer<Pointer> application) => ptr.ref.lpVtbl.value
.elementAt(3)
.cast<Pointer<NativeFunction<_GetCurrent_Native>>>()
.value
.asFunction<_GetCurrent_Dart>()(ptr.ref.lpVtbl, application);
int GetCurrent(Pointer<Pointer<COMObject>> application) =>
ptr.ref.lpVtbl.value
.elementAt(3)
.cast<Pointer<NativeFunction<_GetCurrent_Native>>>()
.value
.asFunction<_GetCurrent_Dart>()(ptr.ref.lpVtbl, application);

int GetHasCurrent(Pointer<Int32> hasCurrent) => ptr.ref.lpVtbl.value
.elementAt(4)
Expand Down

0 comments on commit 6d89d00

Please sign in to comment.