Skip to content

Commit

Permalink
add comments, fix clone
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Apr 3, 2020
1 parent ccc9f77 commit 2b12f15
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/types/IUiaTraceable.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Module Name:
- IUiaTraceable.hpp
Abstract:
- This module is used for assigning and retrieving IDs to Uia objects
- This module is used for assigning and retrieving IDs to UIA objects
Author(s):
- Carlos Zamora (cazamor) Apr 2020
Expand All @@ -27,6 +27,12 @@ namespace Microsoft::Console::Types
return _id;
}

// Routine Description:
// - assigns an ID to the IUiaTraceable object if it doesn't have one
// Arguments:
// - id - the id value that we are trying to assign
// Return Value:
// - true if the assignment was successful, false otherwise (it already has an id).
bool AssignId(IdType id) noexcept
{
if (_id == InvalidId)
Expand Down
19 changes: 18 additions & 1 deletion src/types/UiaTracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ TRACELOGGING_DEFINE_PROVIDER(g_UiaProviderTraceProvider,
using namespace Microsoft::Console::Types;

// The first valid ID is 1 for each of our traced UIA object types
// ID assignment is handled between UiaTracing and IUiaTraceable to...
// - prevent multiple objects with the same ID
// - only assign IDs if UiaTracing is enabled
// - ensure objects are only assigned an ID once
IdType UiaTracing::_utrId = 1;
IdType UiaTracing::_siupId = 1;

// Routine Description:
// - assign an ID to the UiaTextRange, if it doesn't have one already
// Arguments:
// - utr - the UiaTextRange we are assigning an ID to
// Return Value:
// - N/A
void UiaTracing::_assignId(UiaTextRangeBase& utr) noexcept
{
auto temp = utr.AssignId(_utrId);
Expand All @@ -28,6 +38,12 @@ void UiaTracing::_assignId(UiaTextRangeBase& utr) noexcept
}
}

// Routine Description:
// - assign an ID to the ScreenInfoUiaProvider, if it doesn't have one already
// Arguments:
// - siup - the ScreenInfoUiaProvider we are assigning an ID to
// Return Value:
// - N/A
void UiaTracing::_assignId(ScreenInfoUiaProviderBase& siup) noexcept
{
auto temp = siup.AssignId(_siupId);
Expand Down Expand Up @@ -124,11 +140,12 @@ void UiaTracing::TextRange::Constructor(UiaTextRangeBase& result) noexcept
}
}

void UiaTracing::TextRange::Clone(const UiaTextRangeBase& utr, const UiaTextRangeBase& result) noexcept
void UiaTracing::TextRange::Clone(const UiaTextRangeBase& utr, UiaTextRangeBase& result) noexcept
{
EnsureRegistration();
if (TraceLoggingProviderEnabled(g_UiaProviderTraceProvider, WINEVENT_LEVEL_VERBOSE, 0))
{
_assignId(result);
TraceLoggingWrite(
g_UiaProviderTraceProvider,
"UiaTextRange::Clone",
Expand Down
2 changes: 1 addition & 1 deletion src/types/UiaTracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Microsoft::Console::Types
{
public:
static void Constructor(UiaTextRangeBase& result) noexcept;
static void Clone(const UiaTextRangeBase& base, const UiaTextRangeBase& result) noexcept;
static void Clone(const UiaTextRangeBase& base, UiaTextRangeBase& result) noexcept;
static void Compare(const UiaTextRangeBase& base, const UiaTextRangeBase& other, bool result) noexcept;
static void CompareEndpoints(const UiaTextRangeBase& base, const TextPatternRangeEndpoint endpoint, const UiaTextRangeBase& other, TextPatternRangeEndpoint otherEndpoint, int result) noexcept;
static void ExpandToEnclosingUnit(TextUnit unit, const UiaTextRangeBase& result) noexcept;
Expand Down

0 comments on commit 2b12f15

Please sign in to comment.