mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Define common windows data types in win_data_types_cross_platform.h and change #define HRESULT to a typedef in winerror_cross_platform.h
Add cross-platform includes in ratpak.h and define __in_opt in sal_cross_platform.h Define FAILED macro in winerror_cross_platform.h Implement Number::isZero using a traditional for loop since the functional version does not compile with Clang Add more data type declarations and common macros Modify calculator engine includes to use pch.h on Windows and pch_cross_platform.h on other platforms Add other cross platform headers to pch_cross_platform.h
This commit is contained in:
parent
1f704ad0af
commit
14c00f46c7
17 changed files with 108 additions and 2 deletions
|
@ -1,7 +1,12 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
#include "Header Files/CalcUtils.h"
|
#include "Header Files/CalcUtils.h"
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "CalculatorVector.h"
|
#include "CalculatorVector.h"
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/Number.h"
|
#include "Header Files/Number.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -59,6 +64,13 @@ namespace CalcEngine
|
||||||
|
|
||||||
bool Number::IsZero() const
|
bool Number::IsZero() const
|
||||||
{
|
{
|
||||||
return all_of(m_mantissa.begin(), m_mantissa.end(), [](auto &&i) { return i == 0; });
|
for (auto const& digit : Mantissa())
|
||||||
|
{
|
||||||
|
if (digit != 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/Rational.h"
|
#include "Header Files/Rational.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/RationalMath.h"
|
#include "Header Files/RationalMath.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
|
|
||||||
#include "CalculatorResource.h"
|
#include "CalculatorResource.h"
|
||||||
|
|
|
@ -12,7 +12,13 @@
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
#include "Header Files/CalcUtils.h"
|
#include "Header Files/CalcUtils.h"
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,13 @@
|
||||||
*
|
*
|
||||||
* Author:
|
* Author:
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -16,7 +16,13 @@
|
||||||
/*** ***/
|
/*** ***/
|
||||||
/*** ***/
|
/*** ***/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "pch.h"
|
||||||
|
#else
|
||||||
#include "pch_cross_platform.h"
|
#include "pch_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Header Files/CalcEngine.h"
|
#include "Header Files/CalcEngine.h"
|
||||||
|
|
||||||
using namespace CalcEngine;
|
using namespace CalcEngine;
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
*
|
*
|
||||||
\****************************************************************************/
|
\****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include "win_data_types_cross_platform.h"
|
||||||
|
#include "sal_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "CCommand.h"
|
#include "CCommand.h"
|
||||||
#include "EngineStrings.h"
|
#include "EngineStrings.h"
|
||||||
#include "../Command.h"
|
#include "../Command.h"
|
||||||
|
|
|
@ -17,6 +17,13 @@
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include "win_data_types_cross_platform.h"
|
||||||
|
#include "sal_cross_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include "CalcErr.h"
|
#include "CalcErr.h"
|
||||||
|
|
||||||
static constexpr uint32_t BASEXPWR = 31L;// Internal log2(BASEX)
|
static constexpr uint32_t BASEXPWR = 31L;// Internal log2(BASEX)
|
||||||
|
|
|
@ -12,4 +12,7 @@
|
||||||
// #include <intsafe.h>
|
// #include <intsafe.h>
|
||||||
#include <array>
|
#include <array>
|
||||||
// #include <ppltasks.h>
|
// #include <ppltasks.h>
|
||||||
|
|
||||||
#include "winerror_cross_platform.h"
|
#include "winerror_cross_platform.h"
|
||||||
|
#include "win_data_types_cross_platform.h"
|
||||||
|
#include "sal_cross_platform.h"
|
||||||
|
|
|
@ -7,3 +7,4 @@
|
||||||
#define _In_
|
#define _In_
|
||||||
#define _Out_
|
#define _Out_
|
||||||
#define _Inout_
|
#define _Inout_
|
||||||
|
#define __in_opt
|
||||||
|
|
23
src/CalcManager/win_data_types_cross_platform.h
Normal file
23
src/CalcManager/win_data_types_cross_platform.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
typedef uint64_t ULONGLONG;
|
||||||
|
typedef int INT;
|
||||||
|
typedef char CHAR;
|
||||||
|
typedef long LONG;
|
||||||
|
typedef unsigned int UINT_PTR;
|
||||||
|
typedef unsigned long ULONG_PTR;
|
||||||
|
typedef unsigned int ULONG32;
|
||||||
|
typedef unsigned long DWORD;
|
||||||
|
typedef unsigned long ULONG;
|
||||||
|
typedef unsigned short USHORT;
|
||||||
|
typedef wchar_t WCHAR;
|
||||||
|
typedef unsigned short WORD;
|
||||||
|
typedef UINT_PTR WPARAM;
|
||||||
|
typedef ULONG_PTR DWORD_PTR;
|
||||||
|
|
||||||
|
#define LOWORD(dw) ((WORD)(((DWORD_PTR)(dw)) & 0xffff))
|
||||||
|
#define HIWORD(dw) ((WORD)((((DWORD_PTR)(dw)) >> 16) & 0xffff))
|
||||||
|
#define LODWORD(qw) ((DWORD)(qw))
|
||||||
|
#define HIDWORD(qw) ((DWORD)(((qw) >> 32) & 0xffffffff))
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define HRESULT int32_t
|
typedef int32_t HRESULT;
|
||||||
|
|
||||||
#define E_ACCESSDENIED 0x80070005
|
#define E_ACCESSDENIED 0x80070005
|
||||||
#define E_FAIL 0x80004005
|
#define E_FAIL 0x80004005
|
||||||
#define E_INVALIDARG 0x80070057
|
#define E_INVALIDARG 0x80070057
|
||||||
|
@ -14,3 +15,4 @@
|
||||||
#define S_FALSE 0x1
|
#define S_FALSE 0x1
|
||||||
|
|
||||||
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
|
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
|
||||||
|
#define FAILED(hr) (((HRESULT)(hr)) < 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue