Skip to content

Commit

Permalink
Misc. function signature fixes for UWP (#2270)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcam206 authored Jan 7, 2019
1 parent a9e1f72 commit 6d9afd9
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 45 deletions.
5 changes: 4 additions & 1 deletion source/uwp/PerfApp/MainPage.xaml.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// MainPage.xaml.cpp
// Implementation of the MainPage class.
//
Expand All @@ -11,6 +11,9 @@
#include <iostream>
#include <sstream>

// warning C4691: '...': type referenced was expected in unreferenced assembly '...', type defined in current translation unit used instead
#pragma warning(disable : 4691)

using namespace PerfApp;

using namespace Platform;
Expand Down
12 changes: 6 additions & 6 deletions source/uwp/Renderer/lib/AdaptiveCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace AdaptiveNamespace
std::string adaptiveJsonString;
RETURN_IF_FAILED(HStringToUTF8(adaptiveJson, adaptiveJsonString));

return FromJsonString(adaptiveJsonString, elementParserRegistration, actionParserRegistration, parseResult);
return _FromJsonString(adaptiveJsonString, elementParserRegistration, actionParserRegistration, parseResult);
}
CATCH_RETURN;

Expand All @@ -61,14 +61,14 @@ namespace AdaptiveNamespace
std::string adaptiveJsonString;
RETURN_IF_FAILED(JsonObjectToString(adaptiveJson, adaptiveJsonString));

return FromJsonString(adaptiveJsonString, elementParserRegistration, actionParserRegistration, parseResult);
return _FromJsonString(adaptiveJsonString, elementParserRegistration, actionParserRegistration, parseResult);
}
CATCH_RETURN;

HRESULT AdaptiveCardStaticsImpl::FromJsonString(const std::string jsonString,
_In_ IAdaptiveElementParserRegistration* elementParserRegistration,
_In_ IAdaptiveActionParserRegistration* actionParserRegistration,
_COM_Outptr_ IAdaptiveCardParseResult** parseResult)
HRESULT AdaptiveCardStaticsImpl::_FromJsonString(const std::string& jsonString,
_In_ IAdaptiveElementParserRegistration* elementParserRegistration,
_In_ IAdaptiveActionParserRegistration* actionParserRegistration,
_COM_Outptr_ IAdaptiveCardParseResult** parseResult)
{
std::shared_ptr<ElementParserRegistration> sharedModelElementParserRegistration;
if (elementParserRegistration != nullptr)
Expand Down
8 changes: 4 additions & 4 deletions source/uwp/Renderer/lib/AdaptiveCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ namespace AdaptiveNamespace
_COM_Outptr_ ABI::AdaptiveNamespace::IAdaptiveCardParseResult** parseResult) noexcept;

private:
HRESULT FromJsonString(const std::string jsonString,
_In_ ABI::AdaptiveNamespace::IAdaptiveElementParserRegistration* elementParserRegistration,
_In_ ABI::AdaptiveNamespace::IAdaptiveActionParserRegistration* actionParserRegistration,
_COM_Outptr_ ABI::AdaptiveNamespace::IAdaptiveCardParseResult** parseResult);
HRESULT _FromJsonString(const std::string& jsonString,
_In_ ABI::AdaptiveNamespace::IAdaptiveElementParserRegistration* elementParserRegistration,
_In_ ABI::AdaptiveNamespace::IAdaptiveActionParserRegistration* actionParserRegistration,
_COM_Outptr_ ABI::AdaptiveNamespace::IAdaptiveCardParseResult** parseResult);
};

ActivatableClassWithFactory(AdaptiveCard, AdaptiveCardStaticsImpl);
Expand Down
8 changes: 4 additions & 4 deletions source/uwp/Renderer/lib/AdaptiveHostConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace AdaptiveNamespace

std::string adaptiveJsonString;
RETURN_IF_FAILED(HStringToUTF8(adaptiveJson, adaptiveJsonString));
return FromJsonString(adaptiveJsonString, parseResult);
return _FromJsonString(adaptiveJsonString, parseResult);
}
CATCH_RETURN;

Expand All @@ -43,12 +43,12 @@ namespace AdaptiveNamespace
std::string adaptiveJsonString;
RETURN_IF_FAILED(JsonObjectToString(adaptiveJson, adaptiveJsonString));

return FromJsonString(adaptiveJsonString, parseResult);
return _FromJsonString(adaptiveJsonString, parseResult);
}
CATCH_RETURN;

HRESULT AdaptiveHostConfigStaticsImpl::FromJsonString(const std::string jsonString,
_COM_Outptr_ IAdaptiveHostConfigParseResult** parseResult)
HRESULT AdaptiveHostConfigStaticsImpl::_FromJsonString(const std::string& jsonString,
_COM_Outptr_ IAdaptiveHostConfigParseResult** parseResult)
{
HostConfig sharedHostConfig = HostConfig::DeserializeFromString(jsonString);

Expand Down
4 changes: 2 additions & 2 deletions source/uwp/Renderer/lib/AdaptiveHostConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ namespace AdaptiveNamespace
_COM_Outptr_ ABI::AdaptiveNamespace::IAdaptiveHostConfigParseResult** config) noexcept;

private:
HRESULT FromJsonString(const std::string jsonString,
_COM_Outptr_ ABI::AdaptiveNamespace::IAdaptiveHostConfigParseResult** config);
HRESULT _FromJsonString(const std::string& jsonString,
_COM_Outptr_ ABI::AdaptiveNamespace::IAdaptiveHostConfigParseResult** config);
};

ActivatableClassWithFactory(AdaptiveHostConfig, AdaptiveHostConfigStaticsImpl);
Expand Down
2 changes: 1 addition & 1 deletion source/uwp/Renderer/lib/DateTimeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace AdaptiveNamespace
{
DateTimeParser::DateTimeParser(const std::string& language) { m_languageString = language; }

std::string DateTimeParser::GenerateString(DateTimePreparser text)
std::string DateTimeParser::GenerateString(const DateTimePreparser& text)
{
std::wostringstream parsedostr;

Expand Down
2 changes: 1 addition & 1 deletion source/uwp/Renderer/lib/DateTimeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace AdaptiveNamespace
{
public:
DateTimeParser(const std::string& language);
std::string GenerateString(DateTimePreparser text);
std::string GenerateString(const DateTimePreparser& text);

private:
std::string m_languageString;
Expand Down
10 changes: 5 additions & 5 deletions source/uwp/Renderer/lib/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,9 @@ CATCH_RETURN;

// Get a Color object from color string
// Expected formats are "#AARRGGBB" (with alpha channel) and "#RRGGBB" (without alpha channel)
HRESULT GetColorFromString(std::string colorString, _Out_ ABI::Windows::UI::Color* color) noexcept try
HRESULT GetColorFromString(const std::string& colorString, _Out_ ABI::Windows::UI::Color* color) noexcept try
{
if (colorString._Starts_with("#"))
if (colorString.front() == '#')
{
// Get the pure hex value (without #)
std::string hexColorString = colorString.substr(1, std::string::npos);
Expand Down Expand Up @@ -1041,7 +1041,7 @@ HRESULT GetFontWeight(_In_ ABI::AdaptiveNamespace::IAdaptiveFontWeightsConfig* w
}
CATCH_RETURN;

HRESULT StringToJsonObject(const std::string inputString, _COM_Outptr_ IJsonObject** result)
HRESULT StringToJsonObject(const std::string& inputString, _COM_Outptr_ IJsonObject** result)
{
std::wstring asWstring = StringToWstring(inputString);
return HStringToJsonObject(HStringReference(asWstring.c_str()).Get(), result);
Expand Down Expand Up @@ -1117,7 +1117,7 @@ HRESULT JsonValueToHString(_In_ IJsonValue* inputJsonValue, _Outptr_ HSTRING* re
return (localInputJsonValue->Stringify(result));
}

HRESULT JsonCppToJsonObject(Json::Value jsonCppValue, _COM_Outptr_ IJsonObject** result)
HRESULT JsonCppToJsonObject(const Json::Value& jsonCppValue, _COM_Outptr_ IJsonObject** result)
{
Json::FastWriter fastWriter;
std::string jsonString = fastWriter.write(jsonCppValue);
Expand Down Expand Up @@ -1277,7 +1277,7 @@ HRESULT AdaptiveWarningsToSharedWarnings(_In_ ABI::Windows::Foundation::Collecti
return S_OK;
}

Color GenerateLighterColor(Color originalColor)
Color GenerateLighterColor(const Color& originalColor)
{
const double lightIncrement = 0.25;

Expand Down
8 changes: 4 additions & 4 deletions source/uwp/Renderer/lib/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ inline bool Boolify(const boolean value)
return value > 0 ? true : false;
}

HRESULT GetColorFromString(std::string colorString, _Out_ ABI::Windows::UI::Color* color) noexcept;
HRESULT GetColorFromString(const std::string& colorString, _Out_ ABI::Windows::UI::Color* color) noexcept;

HRESULT GetColorFromAdaptiveColor(_In_ ABI::AdaptiveNamespace::IAdaptiveHostConfig* hostConfig,
ABI::AdaptiveNamespace::ForegroundColor adaptiveColor,
Expand Down Expand Up @@ -155,7 +155,7 @@ HRESULT GenerateSeparatorProjection(std::shared_ptr<AdaptiveSharedNamespace::Sep
HRESULT GenerateSharedSeparator(_In_ ABI::AdaptiveNamespace::IAdaptiveSeparator* separator,
_Out_ std::shared_ptr<AdaptiveSharedNamespace::Separator>* sharedSeparatorOut) noexcept;

HRESULT StringToJsonObject(const std::string inputString, _COM_Outptr_ ABI::Windows::Data::Json::IJsonObject** result);
HRESULT StringToJsonObject(const std::string& inputString, _COM_Outptr_ ABI::Windows::Data::Json::IJsonObject** result);
HRESULT HStringToJsonObject(const HSTRING& inputHString, _COM_Outptr_ ABI::Windows::Data::Json::IJsonObject** result);
HRESULT JsonObjectToHString(_In_ ABI::Windows::Data::Json::IJsonObject* inputJson, _Outptr_ HSTRING* result);
HRESULT JsonObjectToString(_In_ ABI::Windows::Data::Json::IJsonObject* inputJson, std::string& result);
Expand All @@ -165,7 +165,7 @@ HRESULT HStringToJsonValue(const HSTRING& inputHString, _COM_Outptr_ ABI::Window
HRESULT JsonValueToHString(_In_ ABI::Windows::Data::Json::IJsonValue* inputJsonValue, _Outptr_ HSTRING* result);
HRESULT JsonValueToString(_In_ ABI::Windows::Data::Json::IJsonValue* inputJsonValue, std::string& result);

HRESULT JsonCppToJsonObject(Json::Value jsonCppValue, _COM_Outptr_ ABI::Windows::Data::Json::IJsonObject** result);
HRESULT JsonCppToJsonObject(const Json::Value& jsonCppValue, _COM_Outptr_ ABI::Windows::Data::Json::IJsonObject** result);
HRESULT JsonObjectToJsonCpp(_In_ ABI::Windows::Data::Json::IJsonObject* jsonObject, _Out_ Json::Value* jsonCppValue);

HRESULT ProjectedActionTypeToHString(ABI::AdaptiveNamespace::ActionType projectedActionType, _Outptr_ HSTRING* result);
Expand Down Expand Up @@ -210,4 +210,4 @@ HRESULT SharedWarningsToAdaptiveWarnings(
HRESULT AdaptiveWarningsToSharedWarnings(_In_ ABI::Windows::Foundation::Collections::IVector<ABI::AdaptiveNamespace::IAdaptiveWarning*>* adaptiveWarnings,
std::vector<std::shared_ptr<AdaptiveSharedNamespace::AdaptiveCardParseWarning>> sharedWarnings);

ABI::Windows::UI::Color GenerateLighterColor(ABI::Windows::UI::Color originalColor);
ABI::Windows::UI::Color GenerateLighterColor(const ABI::Windows::UI::Color& originalColor);
34 changes: 17 additions & 17 deletions source/uwp/Renderer/lib/XamlBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,11 +1590,11 @@ namespace AdaptiveNamespace
hostConfig);
}

HRESULT SetTextOnXamlTextBlock(_In_ IAdaptiveRenderContext* renderContext,
_In_ HSTRING textIn,
ABI::AdaptiveNamespace::FontStyle fontStyle,
_In_ HSTRING language,
_In_ ITextBlock* textBlock)
static HRESULT SetTextOnXamlTextBlock(_In_ IAdaptiveRenderContext* renderContext,
_In_ HSTRING textIn,
ABI::AdaptiveNamespace::FontStyle fontStyle,
_In_ HSTRING language,
_In_ ITextBlock* textBlock)
{
ComPtr<IVector<ABI::Windows::UI::Xaml::Documents::Inline*>> inlines;
RETURN_IF_FAILED(textBlock->get_Inlines(inlines.GetAddressOf()));
Expand Down Expand Up @@ -2693,7 +2693,7 @@ namespace AdaptiveNamespace
THROW_IF_FAILED(xamlGrid.CopyTo(imageSetControl));
}

std::vector<std::string> GetChoiceSetValueVector(_In_ IAdaptiveChoiceSetInput* adaptiveChoiceSetInput)
static std::vector<std::string> GetChoiceSetValueVector(_In_ IAdaptiveChoiceSetInput* adaptiveChoiceSetInput)
{
HString value;
THROW_IF_FAILED(adaptiveChoiceSetInput->get_Value(value.GetAddressOf()));
Expand All @@ -2712,7 +2712,7 @@ namespace AdaptiveNamespace
return values;
}

bool IsChoiceSelected(std::vector<std::string> selectedValues, _In_ IAdaptiveChoiceInput* choice)
static bool IsChoiceSelected(std::vector<std::string> selectedValues, _In_ IAdaptiveChoiceInput* choice)
{
HString value;
THROW_IF_FAILED(choice->get_Value(value.GetAddressOf()));
Expand Down Expand Up @@ -2856,9 +2856,9 @@ namespace AdaptiveNamespace
THROW_IF_FAILED(stackPanel.CopyTo(choiceInputSet));
}

void AddInputValueToContext(_In_ IAdaptiveRenderContext* renderContext,
_In_ IAdaptiveCardElement* adaptiveCardElement,
_In_ IUIElement* inputUiElement)
static void AddInputValueToContext(_In_ IAdaptiveRenderContext* renderContext,
_In_ IAdaptiveCardElement* adaptiveCardElement,
_In_ IUIElement* inputUiElement)
{
ComPtr<IAdaptiveCardElement> cardElement(adaptiveCardElement);
ComPtr<IAdaptiveInputElement> inputElement;
Expand Down Expand Up @@ -3005,9 +3005,9 @@ namespace AdaptiveNamespace
AddInputValueToContext(renderContext, adaptiveCardElement, *numberInputControl);
}

HRESULT HandleKeydownForInlineAction(_In_ IKeyRoutedEventArgs* args,
_In_ IAdaptiveActionInvoker* actionInvoker,
_In_ IAdaptiveActionElement* inlineAction)
static HRESULT HandleKeydownForInlineAction(_In_ IKeyRoutedEventArgs* args,
_In_ IAdaptiveActionInvoker* actionInvoker,
_In_ IAdaptiveActionElement* inlineAction)
{
ABI::Windows::System::VirtualKey key;
RETURN_IF_FAILED(args->get_Key(&key));
Expand Down Expand Up @@ -3037,10 +3037,10 @@ namespace AdaptiveNamespace
return S_OK;
}

bool WarnForInlineShowCard(_In_ IAdaptiveRenderContext* renderContext,
_In_ IAdaptiveHostConfig* hostConfig,
_In_ IAdaptiveActionElement* action,
std::wstring warning)
static bool WarnForInlineShowCard(_In_ IAdaptiveRenderContext* renderContext,
_In_ IAdaptiveHostConfig* hostConfig,
_In_ IAdaptiveActionElement* action,
const std::wstring& warning)
{
if (action != nullptr)
{
Expand Down

0 comments on commit 6d9afd9

Please sign in to comment.