Skip to content

Commit

Permalink
Fixed #1389.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebattista committed Dec 3, 2022
1 parent 046f75b commit 4e3e060
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 16 deletions.
2 changes: 2 additions & 0 deletions generation/WinSDK/ConstantsScraper.settings.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ FALSE
true
false
NULL
SECURITY_DYNAMIC_TRACKING
SECURITY_STATIC_TRACKING
POWER_PLATFORM_ROLE_V1_MAX
POWER_PLATFORM_ROLE_V2_MAX
IBBM_Last
Expand Down
5 changes: 5 additions & 0 deletions generation/WinSDK/autoTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"Name": "BOOLEAN",
"ValueType": "byte"
},
{
"Namespace": "Windows.Win32.Foundation",
"Name": "VARIANT_BOOL",
"ValueType": "short"
},
{
"Namespace": "Windows.Win32.Foundation",
"Name": "BSTR",
Expand Down
16 changes: 0 additions & 16 deletions generation/WinSDK/enums.json
Original file line number Diff line number Diff line change
Expand Up @@ -35451,22 +35451,6 @@
}
]
},
{
"namespace": "Windows.Win32.Foundation",
"name": "VARIANT_BOOL",
"type": "short",
"members": [
{
"name": "VARIANT_TRUE",
"value": "-1"
},
{
"name": "VARIANT_FALSE",
"value": "0"
}
],
"uses": []
},
{
"name": "HTML_HELP_COMMAND",
"autoPopulate": {
Expand Down
12 changes: 12 additions & 0 deletions generation/WinSDK/manual/Foundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ namespace Windows.Win32.Foundation
{
public static unsafe partial class Apis
{
[NativeTypeName("BOOL")]

This comment has been minimized.

Copy link
@kennykerr

kennykerr Dec 3, 2022

Contributor

What is NativeTypeName? I've not seen this before. It's not clear to me why we need an attribute for this.

This comment has been minimized.

Copy link
@kennykerr

kennykerr Dec 3, 2022

Contributor

It's the same kind of thing as #1337 - we don't need attributes when we can coerce the value/type of constants.

This comment has been minimized.

Copy link
@mikebattista

mikebattista Dec 3, 2022

Author Collaborator

It's used pervasively already. It's taking for TRUE/FALSE but for some reason it doesn't seem to be taking for VARIANT_TRUE/VARIANT_FALSE.

This comment has been minimized.

Copy link
@kennykerr

kennykerr Dec 3, 2022

Contributor

Can you give me an example? I can't find an example of this in the win32 metadata.

This comment has been minimized.

Copy link
@kennykerr

kennykerr Dec 3, 2022

Contributor

I'm guessing this is some kind of implementation detail that doesn't make its way into the final winmd.

This comment has been minimized.

Copy link
@mikebattista

mikebattista Dec 3, 2022

Author Collaborator

As far as the metadata goes, NativeTypeName doesn't show up there. It's used by the build to change the type that's emitted to the type in the NativeTypeName attribute. For example, look at INVALID_HANDLE_VALUE defined right after VARIANT_FALSE. That is typed as HANDLE in the metadata, not as int. TRUE and FALSE as defined will show up as BOOL in the metadata.

For some reason, VARIANT_TRUE/VARIANT_FALSE, defined the same way, are not translating to VARIANT_BOOL in the metadata.

public const int TRUE = 1;

[NativeTypeName("BOOL")]
public const int FALSE = 0;

[NativeTypeName("VARIANT_BOOL")]
public const short VARIANT_TRUE = -1;

[NativeTypeName("VARIANT_BOOL")]
public const short VARIANT_FALSE = 0;

[NativeTypeName("HANDLE")]
public const int INVALID_HANDLE_VALUE = -1;

Expand Down
9 changes: 9 additions & 0 deletions generation/WinSDK/manual/Security.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

namespace Windows.Win32.Security
{
public static unsafe partial class Apis
{
[NativeTypeName("BOOLEAN")]
public const byte SECURITY_DYNAMIC_TRACKING = 1;

[NativeTypeName("BOOLEAN")]
public const byte SECURITY_STATIC_TRACKING = 0;
}

// We need to define this manually because of how it's defined with duplicate typedefs
[UnmanagedFunctionPointer]
[return: NativeTypeName("NTSTATUS")]
Expand Down
12 changes: 12 additions & 0 deletions scripts/ChangesSinceLastRelease.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,15 @@ Windows.Win32.System.Ole.OLEUIBUSYW.dwFlags...System.UInt32 => Windows.Win32.Sys
Windows.Win32.System.Diagnostics.Debug.Apis.ContinueDebugEvent : dwContinueStatus...UInt32 => NTSTATUS
# Fixed #1390.
Windows.Win32.Graphics.Direct2D.ID2D1Resource.GetFactory : factory : [Out] => [ComOutPtr,Out]
# Fixed #1389.
Windows.Win32.Foundation.Apis.FALSE added
Windows.Win32.Foundation.Apis.TRUE added
Windows.Win32.Foundation.Apis.VARIANT_FALSE added
Windows.Win32.Foundation.Apis.VARIANT_TRUE added
Windows.Win32.Foundation.VARIANT_BOOL : => [NativeTypedef]
Windows.Win32.Foundation.VARIANT_BOOL.Value added
Windows.Win32.Foundation.VARIANT_BOOL.value__ removed
Windows.Win32.Foundation.VARIANT_BOOL.VARIANT_FALSE removed
Windows.Win32.Foundation.VARIANT_BOOL.VARIANT_TRUE removed
Windows.Win32.Security.Apis.SECURITY_DYNAMIC_TRACKING added
Windows.Win32.Security.Apis.SECURITY_STATIC_TRACKING added

0 comments on commit 4e3e060

Please sign in to comment.