Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed decimal usability in converter section #1896

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: windows-latest
env:
SONAR_SCANNER_VERSION: 4.7.0.2747
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Download and set up sonar-scanner
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-windows.zip
run: |
New-Item -Force -ItemType directory -Path $HOME\.sonar
curl -sSLo $HOME\.sonar\sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME\.sonar\sonar-scanner.zip -d $HOME\.sonar\
echo "$HOME\.sonar\sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-windows\bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Download and set up build-wrapper
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-win-x86.zip
run: |
curl -sSLo $HOME\.sonar\build-wrapper.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME\.sonar\build-wrapper.zip -d $HOME\.sonar\
echo "$HOME\.sonar\build-wrapper-win-x86" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Run build-wrapper
run: |
build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }}<insert_your_clean_build_command>
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Calculator ships regularly with new features and bug fixes. You can get the late

## Getting started
Prerequisites:
- Your computer must be running Windows 10, version 1809 or newer. Windows 11 is recommended.
- Your computer must be running Windows 11, build 22000 or newer.
- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient).
- Install the "Universal Windows Platform Development" workload.
- Install the optional "C++ Universal Windows Platform tools" component.
Expand Down
12 changes: 12 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sonar.projectKey=DeclanGazil02_calculator
sonar.organization=declangazil02

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=calculator
#sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
3 changes: 1 addition & 2 deletions src/CalcManager/CEngine/Number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ namespace CalcEngine
Number::Number(PNUMBER p) noexcept
: m_sign{ p->sign }
, m_exp{ p->exp }
, m_mantissa{}
{
m_mantissa.reserve(p->cdigit);
copy(p->mant, p->mant + p->cdigit, back_inserter(m_mantissa));
copy_n(p->mant, p->cdigit, back_inserter(m_mantissa));
}

PNUMBER Number::ToPNUMBER() const
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/CEngine/calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ CCalcEngine::CCalcEngine(
{
InitChopNumbers();

m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(m_numwidth);
m_dwWordBitWidth = DwWordBitWidthFromNumWidth(m_numwidth);

m_maxTrigonometricNum = RationalMath::Pow(10, 100);

Expand Down
34 changes: 24 additions & 10 deletions src/CalcManager/CEngine/scicomm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,31 @@ namespace
// 0 is returned. Higher the number, higher the precedence of the operator.
int NPrecedenceOfOp(int nopCode)
{
static uint16_t rgbPrec[] = { 0, 0, IDC_OR, 0, IDC_XOR, 0, IDC_AND, 1, IDC_NAND, 1, IDC_NOR, 1, IDC_ADD, 2, IDC_SUB, 2, IDC_RSHF, 3,
IDC_LSHF, 3, IDC_RSHFL, 3, IDC_MOD, 3, IDC_DIV, 3, IDC_MUL, 3, IDC_PWR, 4, IDC_ROOT, 4, IDC_LOGBASEY, 4 };

for (unsigned int iPrec = 0; iPrec < size(rgbPrec); iPrec += 2)
switch (nopCode)
{
if (nopCode == rgbPrec[iPrec])
{
return rgbPrec[iPrec + 1];
}
default:
case IDC_OR:
case IDC_XOR:
return 0;
case IDC_AND:
case IDC_NAND:
case IDC_NOR:
return 1;
case IDC_ADD:
case IDC_SUB:
return 2;
case IDC_LSHF:
case IDC_RSHF:
case IDC_RSHFL:
case IDC_MOD:
case IDC_DIV:
case IDC_MUL:
return 3;
case IDC_PWR:
case IDC_ROOT:
case IDC_LOGBASEY:
return 4;
}
return 0;
}
}

Expand Down Expand Up @@ -518,7 +532,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)

if (wParam == IDC_OPENP)
{
// if there's an omitted multiplication sign
// if there's an omitted multiplication sign
if (IsDigitOpCode(m_nLastCom) || IsUnaryOpCode(m_nLastCom) || m_nLastCom == IDC_PNT || m_nLastCom == IDC_CLOSEP)
{
ProcessCommand(IDC_MUL);
Expand Down
6 changes: 3 additions & 3 deletions src/CalcManager/CEngine/sciset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt
if (numwidth >= NUM_WIDTH::QWORD_WIDTH && numwidth <= NUM_WIDTH::BYTE_WIDTH)
{
m_numwidth = numwidth;
m_dwWordBitWidth = DwWordBitWidthFromeNumWidth(numwidth);
m_dwWordBitWidth = DwWordBitWidthFromNumWidth(numwidth);
}

// inform ratpak that a change in base or precision has occurred
Expand All @@ -50,7 +50,7 @@ void CCalcEngine::SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidt
DisplayNum();
}

int32_t CCalcEngine::DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth)
int32_t CCalcEngine::DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth)
{
switch (numwidth)
{
Expand Down Expand Up @@ -85,7 +85,7 @@ uint32_t CCalcEngine::NRadixFromRadixType(RadixType radixtype)
// Toggles a given bit into the number representation. returns true if it changed it actually.
bool CCalcEngine::TryToggleBit(CalcEngine::Rational& rat, uint32_t wbitno)
{
uint32_t wmax = DwWordBitWidthFromeNumWidth(m_numwidth);
uint32_t wmax = DwWordBitWidthFromNumWidth(m_numwidth);
if (wbitno >= wmax)
{
return false; // ignore error cant happen
Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/Header Files/CalcEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class CCalcEngine
CalcEngine::Rational SciCalcFunctions(CalcEngine::Rational const& rat, uint32_t op);
CalcEngine::Rational DoOperation(int operation, CalcEngine::Rational const& lhs, CalcEngine::Rational const& rhs);
void SetRadixTypeAndNumWidth(RadixType radixtype, NUM_WIDTH numwidth);
int32_t DwWordBitWidthFromeNumWidth(NUM_WIDTH numwidth);
int32_t DwWordBitWidthFromNumWidth(NUM_WIDTH numwidth);
uint32_t NRadixFromRadixType(RadixType radixtype);
double GenerateRandomNumber();

Expand Down
2 changes: 1 addition & 1 deletion src/CalcManager/Ratpack/CalcErr.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// This format is based loosely on an OLE HRESULT and is compatible with the
// SUCCEEDED and FAILED macros as well as the HRESULT_CODE macro

typedef int32_t ResultCode;
using ResultCode = int32_t;

// CALC_E_DIVIDEBYZERO
//
Expand Down
9 changes: 4 additions & 5 deletions src/CalcManager/UnitConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,12 @@ namespace UnitConversionManager
std::wstring targetCurrencyCode;
};

typedef std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit> CategorySelectionInitializer;
typedef std::unordered_map<
using CategorySelectionInitializer = std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit>;
using UnitToUnitToConversionDataMap = std::unordered_map<
UnitConversionManager::Unit,
std::unordered_map<UnitConversionManager::Unit, UnitConversionManager::ConversionData, UnitConversionManager::UnitHash>,
UnitConversionManager::UnitHash>
UnitToUnitToConversionDataMap;
typedef std::unordered_map<int, std::vector<UnitConversionManager::Unit>> CategoryToUnitVectorMap;
UnitConversionManager::UnitHash>;
using CategoryToUnitVectorMap = std::unordered_map<int, std::vector<UnitConversionManager::Unit>>;

class IViewModelCurrencyCallback
{
Expand Down
2 changes: 1 addition & 1 deletion src/CalcViewModel/Common/LocalizationStringUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace CalculatorApp::ViewModel
{
std::wstring returnString = L"";
const UINT32 length = 1024;
std::unique_ptr<wchar_t[]> spBuffer = std::unique_ptr<wchar_t[]>(new wchar_t[length]);
std::unique_ptr<wchar_t[]> spBuffer = std::make_unique<wchar_t[]>(length);
va_list args = NULL;
va_start(args, pMessage);
DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage->Data(), 0, 0, spBuffer.get(), length, &args);
Expand Down
5 changes: 4 additions & 1 deletion src/CalcViewModel/UnitConverterViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ void UnitConverterViewModel::ResetCategory()
m_isInputBlocked = false;
SetSelectedUnits();

UpdateIsDecimalEnabled();

IsCurrencyLoadingVisible = m_IsCurrencyCurrentCategory && !m_isCurrencyDataLoaded;
IsDropDownEnabled = m_Units->GetAt(0) != EMPTY_UNIT;

Expand Down Expand Up @@ -871,7 +873,8 @@ void UnitConverterViewModel::UpdateCurrencyFormatter()
void UnitConverterViewModel::UpdateIsDecimalEnabled()
{
if (!IsCurrencyCurrentCategory || CurrencyFormatterFrom == nullptr)
return;
IsDecimalEnabled = true;
else
IsDecimalEnabled = CurrencyFormatterFrom->FractionDigits > 0;
}

Expand Down
11 changes: 0 additions & 11 deletions src/CalcViewModel/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,3 @@
#include "winrt/Windows.UI.Xaml.h"
#include "winrt/Windows.Foundation.Metadata.h"
#include "winrt/Windows.Management.Policies.h"

// The following namespaces exist as a convenience to resolve
// ambiguity for Windows types in the Windows::UI::Xaml::Automation::Peers
// namespace that only exist on RS3.
// Once the app switches to min version RS3, the namespaces can be removed.
// TODO - MSFT 12735088
namespace StandardPeers = Windows::UI::Xaml::Automation::Peers;
namespace CalculatorApp::ViewModel::Common::Automation
{
}
namespace CustomPeers = CalculatorApp::ViewModel::Common::Automation;
4 changes: 2 additions & 2 deletions src/Calculator/Calculator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -792,9 +792,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.10</Version>
<Version>6.2.14</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.0" />
<PackageReference Include="Microsoft.UI.Xaml" Version="2.8.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CalcViewModel\CalcViewModel.vcxproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="Appium.WebDriver" Version="4.3.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
</ItemGroup>
</Project>
4 changes: 0 additions & 4 deletions src/CalculatorUITestFramework/WindowsDriverServiceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public WindowsDriverServiceBuilder WithFileInfo(FileInfo fileInfo)

public WindowsDriverServiceBuilder WithStartUpTimeOut(TimeSpan startUpTimeout)
{
if (startUpTimeout == null)
{
throw new ArgumentNullException("A startup timeout should not be NULL");
}
this.StartUpTimeout = startUpTimeout;
return this;
}
Expand Down
8 changes: 4 additions & 4 deletions src/CalculatorUITests/CalculatorUITests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
<PackageReference Include="Appium.WebDriver" Version="4.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="Appium.WebDriver" Version="4.3.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CalculatorUITestFramework\CalculatorUITestFramework.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/GraphingInterfaces/IGraphAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Graphing::Analyzer
{
typedef unsigned int NativeAnalysisType; // PerformAnalysisType
using NativeAnalysisType = unsigned int; // PerformAnalysisType

struct IGraphAnalyzer : public NonCopyable, public NonMoveable
{
Expand Down