Skip to content

Commit

Permalink
Don't use UINT32 type as it's not defined by dncp
Browse files Browse the repository at this point in the history
  • Loading branch information
jkoritzinsky committed Jan 16, 2024
1 parent 19752b3 commit 2626916
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/interfaces/metadataemit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stack>
#include <algorithm>
#include <utility>
#include <cstring>

#define RETURN_IF_FAILED(exp) \
{ \
Expand All @@ -28,7 +29,7 @@ namespace
char const** name)
{
// Search for the last delimiter.
char* pos = ::strrchr(typeName, '.');
char* pos = std::strrchr(typeName, '.');
if (pos == nullptr)
{
// No namespace is indicated by an empty string.
Expand Down Expand Up @@ -60,7 +61,7 @@ HRESULT MetadataEmit::SetModuleProps(
// Search for a file name in the provided path
// and use that as the module name.
char* modulePath = cvt;
std::size_t len = strlen(modulePath);
std::size_t len = std::strlen(modulePath);
const char* start = modulePath;
for (std::size_t i = len - 1; i >= 0; i--)
{
Expand Down Expand Up @@ -1130,22 +1131,22 @@ HRESULT MetadataEmit::SetMethodProps(
if (!md_token_to_cursor(MetaData(), md, &c))
return CLDB_E_FILE_CORRUPT;

if (dwMethodFlags != std::numeric_limits<UINT32>::max())
if (dwMethodFlags != std::numeric_limits<DWORD>::max())
{
// TODO: Strip the reserved flags from user input and preserve the existing reserved flags.
uint32_t flags = dwMethodFlags;
if (1 != md_set_column_value_as_constant(c, mdtMethodDef_Flags, 1, &flags))
return E_FAIL;
}

if (ulCodeRVA != std::numeric_limits<UINT32>::max())
if (ulCodeRVA != std::numeric_limits<ULONG>::max())
{
uint32_t rva = ulCodeRVA;
if (1 != md_set_column_value_as_constant(c, mdtMethodDef_Rva, 1, &rva))
return E_FAIL;
}

if (dwImplFlags != std::numeric_limits<UINT32>::max())
if (dwImplFlags != std::numeric_limits<DWORD>::max())
{
uint32_t implFlags = dwImplFlags;
if (1 != md_set_column_value_as_constant(c, mdtMethodDef_ImplFlags, 1, &implFlags))
Expand All @@ -1166,15 +1167,15 @@ HRESULT MetadataEmit::SetTypeDefProps(
if (!md_token_to_cursor(MetaData(), td, &c))
return CLDB_E_FILE_CORRUPT;

if (dwTypeDefFlags != std::numeric_limits<UINT32>::max())
if (dwTypeDefFlags != std::numeric_limits<DWORD>::max())
{
// TODO: Strip the reserved flags from user input and preserve the existing reserved flags.
uint32_t flags = dwTypeDefFlags;
if (1 != md_set_column_value_as_constant(c, mdtTypeDef_Flags, 1, &flags))
return E_FAIL;
}

if (tkExtends != std::numeric_limits<UINT32>::max())
if (tkExtends != std::numeric_limits<uint32_t>::max())
{
if (IsNilToken(tkExtends))
tkExtends = mdTypeDefNil;
Expand Down Expand Up @@ -1282,7 +1283,7 @@ HRESULT MetadataEmit::SetEventProps(
if (!md_token_to_cursor(MetaData(), ev, &c))
return CLDB_E_FILE_CORRUPT;

if (dwEventFlags != std::numeric_limits<UINT32>::max())
if (dwEventFlags != std::numeric_limits<DWORD>::max())
{
uint32_t eventFlags = dwEventFlags;
if (1 != md_set_column_value_as_constant(c, mdtEvent_EventFlags, 1, &eventFlags))
Expand Down Expand Up @@ -1651,7 +1652,7 @@ HRESULT MetadataEmit::DefineField(
hasConstant = true;
}

if (dwFieldFlags != std::numeric_limits<UINT32>::max())
if (dwFieldFlags != std::numeric_limits<DWORD>::max())
{
// TODO: Handle reserved flags
uint32_t fieldFlags = dwFieldFlags;
Expand Down Expand Up @@ -1750,7 +1751,7 @@ HRESULT MetadataEmit::DefineProperty(
}

uint32_t propFlags = (uint32_t)dwPropFlags;
if (propFlags != std::numeric_limits<UINT32>::max())
if (propFlags != std::numeric_limits<uint32_t>::max())
{
propFlags &= ~prReservedMask;
}
Expand All @@ -1762,13 +1763,13 @@ HRESULT MetadataEmit::DefineProperty(
(pValue || (pValue == 0 && (dwCPlusTypeFlag == ELEMENT_TYPE_STRING ||
dwCPlusTypeFlag == ELEMENT_TYPE_CLASS))))
{
if (propFlags == std::numeric_limits<UINT32>::max())
if (propFlags == std::numeric_limits<uint32_t>::max())
propFlags = 0;
propFlags |= prHasDefault;
hasConstant = true;
}

if (propFlags != std::numeric_limits<UINT32>::max())
if (propFlags != std::numeric_limits<uint32_t>::max())
{
if (1 != md_set_column_value_as_constant(c, mdtProperty_Flags, 1, &propFlags))
return E_FAIL;
Expand Down Expand Up @@ -1862,7 +1863,7 @@ HRESULT MetadataEmit::DefineParam(
hasConstant = true;
}

if (dwParamFlags != std::numeric_limits<UINT32>::max())
if (dwParamFlags != std::numeric_limits<DWORD>::max())
{
// TODO: Handle reserved flags
uint32_t flags = dwParamFlags;
Expand Down Expand Up @@ -1923,7 +1924,7 @@ HRESULT MetadataEmit::SetFieldProps(
hasConstant = true;
}

if (dwFieldFlags != std::numeric_limits<UINT32>::max())
if (dwFieldFlags != std::numeric_limits<DWORD>::max())
{
// TODO: Handle reserved flags
uint32_t fieldFlags = dwFieldFlags;
Expand Down Expand Up @@ -1970,7 +1971,7 @@ HRESULT MetadataEmit::SetPropertyProps(
if (!md_token_to_cursor(MetaData(), pr, &c))
return CLDB_E_FILE_CORRUPT;

if (dwPropFlags != std::numeric_limits<UINT32>::max())
if (dwPropFlags != std::numeric_limits<DWORD>::max())
{
dwPropFlags &= ~prReservedMask;
}
Expand All @@ -1982,13 +1983,13 @@ HRESULT MetadataEmit::SetPropertyProps(
(pValue || (pValue == 0 && (dwCPlusTypeFlag == ELEMENT_TYPE_STRING ||
dwCPlusTypeFlag == ELEMENT_TYPE_CLASS))))
{
if (dwPropFlags == std::numeric_limits<UINT32>::max())
if (dwPropFlags == std::numeric_limits<DWORD>::max())
dwPropFlags = 0;
dwPropFlags |= prHasDefault;
hasConstant = true;
}

if (dwPropFlags != std::numeric_limits<UINT32>::max())
if (dwPropFlags != std::numeric_limits<DWORD>::max())
{
// TODO: Preserve reserved flags
uint32_t flags = dwPropFlags;
Expand Down Expand Up @@ -2074,7 +2075,7 @@ HRESULT MetadataEmit::SetParamProps(
hasConstant = true;
}

if (dwParamFlags != std::numeric_limits<UINT32>::max())
if (dwParamFlags != std::numeric_limits<DWORD>::max())
{
// TODO: Handle reserved flags
uint32_t flags = dwParamFlags;
Expand Down

0 comments on commit 2626916

Please sign in to comment.