Skip to content

Commit

Permalink
Adjust scraper expression to capture BYTE constants (#1715)
Browse files Browse the repository at this point in the history
  • Loading branch information
riverar authored Sep 20, 2023
1 parent b5bb920 commit 1e1cd10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
10 changes: 10 additions & 0 deletions scripts/ChangesSinceLastRelease.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2894,3 +2894,13 @@ Windows.Win32.Graphics.GdiPlus.SmoothingMode.SmoothingModeAntiAlias8x8 added
Windows.Win32.Graphics.GdiPlus.Status.ProfileNotFound added
Windows.Win32.Graphics.GdiPlus.Tint added
Windows.Win32.Graphics.GdiPlus.TintParams added
# Add missing BYTE constants
Windows.Win32.Media.Audio.Apis.MEVT_COMMENT added
Windows.Win32.Media.Audio.Apis.MEVT_LONGMSG added
Windows.Win32.Media.Audio.Apis.MEVT_NOP added
Windows.Win32.Media.Audio.Apis.MEVT_SHORTMSG added
Windows.Win32.Media.Audio.Apis.MEVT_TEMPO added
Windows.Win32.Media.Audio.Apis.MEVT_VERSION added
Windows.Win32.NetworkManagement.IpHelper.Apis.FILTER_ICMP_CODE_ANY added
Windows.Win32.NetworkManagement.IpHelper.Apis.FILTER_ICMP_TYPE_ANY added
Windows.Win32.System.SystemServices.Apis.DECIMAL_NEG added
12 changes: 9 additions & 3 deletions sources/MetadataUtils/ConstantsScraper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private class ConstantsScraperImpl : IDisposable

private static readonly Regex DefineConstantRegex =
new Regex(
@"^((_HRESULT_TYPEDEF_|_NDIS_ERROR_TYPEDEF_)\(((?:0x)?[\da-f]+L?)\)|(\(HRESULT\)((?:0x)?[\da-f]+L?))|(-?\d+\.\d+(?:e\+\d+)?f?)|((?:0x[\da-f]+|\-?\d+)(?:UL|L)?)|((\d+)\s*(<<\s*\d+))|(MAKEINTRESOURCE[AW]{0,1}\(\s*(\-?\d+)\s*\))|(\(HWND\)(-?\d+|(?:0x)?[\da-f]+))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*\))|(\{\s*(?:(?:0x)?[\da-f]{4,8}L?,?\s*){3}\s*(?:(?:0x)?[\da-f]{1,2}L?,?\s*){8}\s*\})|(\(UCHAR\)\s*((?:0x)?\d+))|(\(UCHAR\)\s*(-\d+))|(\(BYTE\)((?:0x)?[\da-f]+L?))|([a-z0-9_]+))$", RegexOptions.IgnoreCase);

private static readonly Regex DefineGuidConstRegex =
new Regex(
Expand Down Expand Up @@ -868,10 +868,16 @@ private void ScrapeConstantsFromTraversedFiles(Dictionary<string, string> traver
this.AddConstantValue(currentNamespace, "ushort", name, $"unchecked((ushort){match.Groups[35].Value})");
continue;
}
// SOME_OTHER_CONSTANT
// (BYTE) 0x42
else if (match.Groups[36].Success)
{
string otherName = match.Groups[36].Value;
this.AddConstantValue(currentNamespace, "byte", name, match.Groups[37].Value);
continue;
}
// SOME_OTHER_CONSTANT
else if (match.Groups[38].Success)
{
string otherName = match.Groups[38].Value;

matchedToOtherName = true;

Expand Down

0 comments on commit 1e1cd10

Please sign in to comment.