Skip to content

Commit

Permalink
Introduce .clang-format into UWP project (microsoft#2012)
Browse files Browse the repository at this point in the history
* Introduce .clang-format, delete unneeded AdaptiveCards.Uwp_h.h, append semicolons to some directives

* Add reformatted CPP and H files
  • Loading branch information
paulcam206 authored Oct 9, 2018
1 parent 71bdf00 commit 65e9359
Show file tree
Hide file tree
Showing 184 changed files with 4,590 additions and 25,363 deletions.
70 changes: 70 additions & 0 deletions source/uwp/Renderer/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Note: directives below have been commented out to support Visual Studio, which currently only supports up to
# clang-format 5.0
Language: Cpp
Standard: Cpp11
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: DontAlign
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
#AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
#BreakInheritanceList: AfterColon
BreakStringLiterals: false
ColumnLimit: 120
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: true
FixNamespaceComments: false
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakComment: 40
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 50
#PenaltyBreakTemplateDeclaration: 100
PenaltyExcessCharacter: 1
PenaltyReturnTypeOnItsOwnLine: 100
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
#SpaceBeforeCpp11BracedList : false
#SpaceBeforeCtorInitializerColon: true
#SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
#SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
UseTab: Never
20,561 changes: 0 additions & 20,561 deletions source/uwp/Renderer/AdaptiveCards.Uwp_h.h

This file was deleted.

6 changes: 3 additions & 3 deletions source/uwp/Renderer/dll/dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ using namespace Microsoft::WRL;

WrlCreatorMapIncludePragma(AdaptiveCardRenderer);

STDAPI DllGetActivationFactory(_In_ HSTRING activatableClassId, _COM_Outptr_ IActivationFactory **factory)
STDAPI DllGetActivationFactory(_In_ HSTRING activatableClassId, _COM_Outptr_ IActivationFactory** factory)
{
return Module<ModuleType::InProc>::GetModule().GetActivationFactory(activatableClassId, factory);
}

STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _COM_Outptr_ void **ppv)
STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _COM_Outptr_ void** ppv)
{
return Module<ModuleType::InProc>::GetModule().GetClassObject(rclsid, riid, ppv);
}
Expand All @@ -31,7 +31,7 @@ STDAPI DllCanUnloadNow()
return hr;
}

STDAPI_(BOOL) DllMain(_In_ HINSTANCE hInstance, _In_ DWORD dwReason, _In_ void * /*lpReserved*/)
STDAPI_(BOOL) DllMain(_In_ HINSTANCE hInstance, _In_ DWORD dwReason, _In_ void* /*lpReserved*/)
{
switch (dwReason)
{
Expand Down
37 changes: 10 additions & 27 deletions source/uwp/Renderer/lib/AdaptiveActionElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ using namespace ABI::Windows::Foundation::Collections;
using namespace ABI::Windows::UI::Xaml;
using namespace ABI::Windows::UI::Xaml::Controls;

namespace AdaptiveNamespace {
namespace AdaptiveNamespace
{
HRESULT AdaptiveActionElementBase::InitializeBaseElement(const std::shared_ptr<AdaptiveSharedNamespace::BaseActionElement>& sharedModel)
{
RETURN_IF_FAILED(UTF8ToHString(sharedModel->GetId(), m_id.GetAddressOf()));
Expand All @@ -23,34 +24,20 @@ namespace AdaptiveNamespace {
return S_OK;
}

IFACEMETHODIMP AdaptiveActionElementBase::get_Title(HSTRING* title)
{
return m_title.CopyTo(title);
}
IFACEMETHODIMP AdaptiveActionElementBase::get_Title(HSTRING* title) { return m_title.CopyTo(title); }

IFACEMETHODIMP AdaptiveActionElementBase::put_Title(HSTRING title)
{
return m_title.Set(title);
}
IFACEMETHODIMP AdaptiveActionElementBase::put_Title(HSTRING title) { return m_title.Set(title); }

IFACEMETHODIMP AdaptiveActionElementBase::get_Id(HSTRING* id)
{
return m_id.CopyTo(id);
}
IFACEMETHODIMP AdaptiveActionElementBase::get_Id(HSTRING* id) { return m_id.CopyTo(id); }

IFACEMETHODIMP AdaptiveActionElementBase::put_Id(HSTRING id)
{
return m_id.Set(id);
}
IFACEMETHODIMP AdaptiveActionElementBase::put_Id(HSTRING id) { return m_id.Set(id); }

_Use_decl_annotations_
HRESULT AdaptiveActionElementBase::get_IconUrl(HSTRING* iconUrl)
_Use_decl_annotations_ HRESULT AdaptiveActionElementBase::get_IconUrl(HSTRING* iconUrl)
{
return m_iconUrl.CopyTo(iconUrl);
}

_Use_decl_annotations_
HRESULT AdaptiveActionElementBase::put_IconUrl(HSTRING iconUrl)
_Use_decl_annotations_ HRESULT AdaptiveActionElementBase::put_IconUrl(HSTRING iconUrl)
{
return m_iconUrl.Set(iconUrl);
}
Expand All @@ -66,10 +53,7 @@ namespace AdaptiveNamespace {
return S_OK;
}

IFACEMETHODIMP AdaptiveActionElementBase::get_ActionTypeString(HSTRING* type)
{
return m_typeString.CopyTo(type);
}
IFACEMETHODIMP AdaptiveActionElementBase::get_ActionTypeString(HSTRING* type) { return m_typeString.CopyTo(type); }

IFACEMETHODIMP AdaptiveActionElementBase::ToJson(ABI::Windows::Data::Json::IJsonObject** result)
{
Expand All @@ -79,8 +63,7 @@ namespace AdaptiveNamespace {
return StringToJsonObject(sharedModel->Serialize(), result);
}

HRESULT AdaptiveActionElementBase::SetSharedElementProperties(
std::shared_ptr<AdaptiveSharedNamespace::BaseActionElement> sharedCardElement)
HRESULT AdaptiveActionElementBase::SetSharedElementProperties(std::shared_ptr<AdaptiveSharedNamespace::BaseActionElement> sharedCardElement)
{
sharedCardElement->SetId(HStringToUTF8(m_id.Get()));
sharedCardElement->SetTitle(HStringToUTF8(m_title.Get()));
Expand Down
6 changes: 3 additions & 3 deletions source/uwp/Renderer/lib/AdaptiveActionElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include <windows.foundation.h>
#include "Enums.h"

namespace AdaptiveNamespace {
namespace AdaptiveNamespace
{
class DECLSPEC_UUID("CDCCC115-7C53-4A04-9F5B-754BBC00C80E") AdaptiveActionElementBase : public IUnknown
{
protected:

HRESULT InitializeBaseElement(const std::shared_ptr<AdaptiveSharedNamespace::BaseActionElement>& sharedModel);

IFACEMETHODIMP get_ActionTypeString(_Out_ HSTRING* value);
Expand All @@ -19,7 +19,7 @@ namespace AdaptiveNamespace {
IFACEMETHODIMP get_Id(_Out_ HSTRING* id);
IFACEMETHODIMP put_Id(_In_ HSTRING id);

IFACEMETHODIMP get_IconUrl(_Out_ HSTRING *iconUrl);
IFACEMETHODIMP get_IconUrl(_Out_ HSTRING* iconUrl);
IFACEMETHODIMP put_IconUrl(_In_ HSTRING iconUrl);

IFACEMETHODIMP get_AdditionalProperties(_Out_ ABI::Windows::Data::Json::IJsonObject** result);
Expand Down
20 changes: 7 additions & 13 deletions source/uwp/Renderer/lib/AdaptiveActionEventArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,22 @@ using namespace Microsoft::WRL;
using namespace ABI::AdaptiveNamespace;
using namespace ABI::Windows::Data::Json;

namespace AdaptiveNamespace {
HRESULT AdaptiveActionEventArgs::RuntimeClassInitialize()
{
return S_OK;
}
namespace AdaptiveNamespace
{
HRESULT AdaptiveActionEventArgs::RuntimeClassInitialize() { return S_OK; }

_Use_decl_annotations_
HRESULT AdaptiveActionEventArgs::RuntimeClassInitialize(IAdaptiveActionElement* action, IAdaptiveInputs* inputs)
_Use_decl_annotations_ HRESULT AdaptiveActionEventArgs::RuntimeClassInitialize(IAdaptiveActionElement* action,
IAdaptiveInputs* inputs)
{
m_action = action;
m_inputs = inputs;
return S_OK;
}

_Use_decl_annotations_
HRESULT AdaptiveActionEventArgs::get_Action(IAdaptiveActionElement** action)
_Use_decl_annotations_ HRESULT AdaptiveActionEventArgs::get_Action(IAdaptiveActionElement** action)
{
return m_action.CopyTo(action);
}

IFACEMETHODIMP AdaptiveActionEventArgs::get_Inputs(IAdaptiveInputs** inputs)
{
return m_inputs.CopyTo(inputs);
}
IFACEMETHODIMP AdaptiveActionEventArgs::get_Inputs(IAdaptiveInputs** inputs) { return m_inputs.CopyTo(inputs); }
}
14 changes: 7 additions & 7 deletions source/uwp/Renderer/lib/AdaptiveActionEventArgs.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#pragma once
#include "AdaptiveCards.Rendering.Uwp.h"

namespace AdaptiveNamespace {
class AdaptiveActionEventArgs :
public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::WinRt>,
ABI::AdaptiveNamespace::IAdaptiveActionEventArgs>
namespace AdaptiveNamespace
{
class AdaptiveActionEventArgs
: public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::WinRt>, ABI::AdaptiveNamespace::IAdaptiveActionEventArgs>
{
AdaptiveRuntime(AdaptiveActionEventArgs)
AdaptiveRuntime(AdaptiveActionEventArgs);

public:
HRESULT RuntimeClassInitialize();
HRESULT RuntimeClassInitialize(_In_ ABI::AdaptiveNamespace::IAdaptiveActionElement* action, _In_ ABI::AdaptiveNamespace::IAdaptiveInputs* inputs);
HRESULT RuntimeClassInitialize(_In_ ABI::AdaptiveNamespace::IAdaptiveActionElement* action,
_In_ ABI::AdaptiveNamespace::IAdaptiveInputs* inputs);

// IAdaptiveActionEventArgs
IFACEMETHODIMP get_Action(_Outptr_ ABI::AdaptiveNamespace::IAdaptiveActionElement** action);
Expand Down
17 changes: 7 additions & 10 deletions source/uwp/Renderer/lib/AdaptiveActionInvoker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,18 @@ using namespace ABI::AdaptiveNamespace;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Xaml;

namespace AdaptiveNamespace {
HRESULT AdaptiveActionInvoker::RuntimeClassInitialize() noexcept
{
return S_OK;
}
namespace AdaptiveNamespace
{
HRESULT AdaptiveActionInvoker::RuntimeClassInitialize() noexcept { return S_OK; }

HRESULT AdaptiveActionInvoker::RuntimeClassInitialize(
RenderedAdaptiveCard* renderResult) noexcept try
HRESULT AdaptiveActionInvoker::RuntimeClassInitialize(RenderedAdaptiveCard* renderResult) noexcept try
{
m_renderResult = renderResult;
return S_OK;
} CATCH_RETURN;
}
CATCH_RETURN;

_Use_decl_annotations_
HRESULT AdaptiveActionInvoker::SendActionEvent(IAdaptiveActionElement* actionElement)
_Use_decl_annotations_ HRESULT AdaptiveActionInvoker::SendActionEvent(IAdaptiveActionElement* actionElement)
{
return m_renderResult->SendActionEvent(actionElement);
}
Expand Down
11 changes: 5 additions & 6 deletions source/uwp/Renderer/lib/AdaptiveActionInvoker.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#include "AdaptiveCards.Rendering.Uwp.h"
#include "RenderedAdaptiveCard.h"

namespace AdaptiveNamespace {
class AdaptiveActionInvoker :
public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::WinRtClassicComMix>,
ABI::AdaptiveNamespace::IAdaptiveActionInvoker>
namespace AdaptiveNamespace
{
class AdaptiveActionInvoker
: public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::WinRtClassicComMix>, ABI::AdaptiveNamespace::IAdaptiveActionInvoker>
{
AdaptiveRuntime(AdaptiveActionInvoker)
AdaptiveRuntime(AdaptiveActionInvoker);

public:
HRESULT RuntimeClassInitialize() noexcept;
Expand Down
40 changes: 22 additions & 18 deletions source/uwp/Renderer/lib/AdaptiveActionParserRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ using namespace Microsoft::WRL::Wrappers;
using namespace ABI::AdaptiveNamespace;
using namespace ABI::Windows::UI;

namespace AdaptiveNamespace {
AdaptiveActionParserRegistration::AdaptiveActionParserRegistration()
{
}
namespace AdaptiveNamespace
{
AdaptiveActionParserRegistration::AdaptiveActionParserRegistration() {}

HRESULT AdaptiveActionParserRegistration::RuntimeClassInitialize() noexcept try
{
m_sharedParserRegistration = std::make_shared<ActionParserRegistration>();
m_registration = std::make_shared<RegistrationMap>();

return S_OK;
} CATCH_RETURN;

}
CATCH_RETURN;

HRESULT AdaptiveActionParserRegistration::RuntimeClassInitialize(
std::shared_ptr<AdaptiveSharedNamespace::ActionParserRegistration> sharedParserRegistration) noexcept try
Expand All @@ -31,10 +30,10 @@ namespace AdaptiveNamespace {
m_sharedParserRegistration = sharedParserRegistration;

return S_OK;
} CATCH_RETURN;
}
CATCH_RETURN;

_Use_decl_annotations_
HRESULT AdaptiveActionParserRegistration::Set(HSTRING type, IAdaptiveActionParser* Parser)
_Use_decl_annotations_ HRESULT AdaptiveActionParserRegistration::Set(HSTRING type, IAdaptiveActionParser* Parser)
{
std::string typeString = HStringToUTF8(type);

Expand All @@ -46,8 +45,7 @@ namespace AdaptiveNamespace {
return S_OK;
}

_Use_decl_annotations_
HRESULT AdaptiveActionParserRegistration::Get(HSTRING type, IAdaptiveActionParser** result)
_Use_decl_annotations_ HRESULT AdaptiveActionParserRegistration::Get(HSTRING type, IAdaptiveActionParser** result)
{
*result = nullptr;

Expand All @@ -59,8 +57,7 @@ namespace AdaptiveNamespace {
return S_OK;
}

_Use_decl_annotations_
HRESULT AdaptiveActionParserRegistration::Remove(_In_ HSTRING type)
_Use_decl_annotations_ HRESULT AdaptiveActionParserRegistration::Remove(_In_ HSTRING type)
{
std::string typeString = HStringToUTF8(type);

Expand Down Expand Up @@ -88,18 +85,25 @@ namespace AdaptiveNamespace {
ComPtr<IAdaptiveActionParser> parser;
THROW_IF_FAILED(m_parserRegistration->Get(typeAsHstring.Get(), &parser));

ComPtr<ABI::Windows::Data::Json::IJsonObject>jsonObject;
ComPtr<ABI::Windows::Data::Json::IJsonObject> jsonObject;
THROW_IF_FAILED(JsonCppToJsonObject(value, &jsonObject));

ComPtr<IAdaptiveElementParserRegistration> adaptiveElementParserRegistration;
MakeAndInitialize<AdaptiveNamespace::AdaptiveElementParserRegistration>(&adaptiveElementParserRegistration, elementParserRegistration);
MakeAndInitialize<AdaptiveNamespace::AdaptiveElementParserRegistration>(&adaptiveElementParserRegistration,
elementParserRegistration);

ComPtr<IAdaptiveActionParserRegistration> adaptiveActionParserRegistration;
MakeAndInitialize<AdaptiveNamespace::AdaptiveActionParserRegistration>(&adaptiveActionParserRegistration, actionParserRegistration);
MakeAndInitialize<AdaptiveNamespace::AdaptiveActionParserRegistration>(&adaptiveActionParserRegistration,
actionParserRegistration);

ComPtr<IAdaptiveActionElement> actionElement;
ComPtr<ABI::Windows::Foundation::Collections::IVector<IAdaptiveWarning*>> adaptiveWarnings = Make<Vector<IAdaptiveWarning*>>();
THROW_IF_FAILED(parser->FromJson(jsonObject.Get(), adaptiveElementParserRegistration.Get(), adaptiveActionParserRegistration.Get(), adaptiveWarnings.Get(), &actionElement));
ComPtr<ABI::Windows::Foundation::Collections::IVector<IAdaptiveWarning*>> adaptiveWarnings =
Make<Vector<IAdaptiveWarning*>>();
THROW_IF_FAILED(parser->FromJson(jsonObject.Get(),
adaptiveElementParserRegistration.Get(),
adaptiveActionParserRegistration.Get(),
adaptiveWarnings.Get(),
&actionElement));

THROW_IF_FAILED(AdaptiveWarningsToSharedWarnings(adaptiveWarnings.Get(), warnings));

Expand Down
Loading

0 comments on commit 65e9359

Please sign in to comment.