mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Add basic CMake support, update README and create cross-platform pch header
Add -fms-extensions flag to the CalculatorEngine CMake target to support some MS extensions Add windows error codes Add SAL cross platform header and define E_BOUNDS error code Add missing <string> and <vector> includes in CalculatorVector.h Add SUCCEEDED macro in winerror_cross_platform.h Add _Inout_ to sal_cross_platform.h
This commit is contained in:
parent
af41a183a7
commit
1f704ad0af
22 changed files with 100 additions and 13 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -23,6 +23,7 @@ bld/
|
|||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Cc]make_build/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
|
@ -291,4 +292,10 @@ __pycache__/
|
|||
Generated Files/
|
||||
!/build/config/TRexDefs/**
|
||||
!src/Calculator/TemporaryKey.pfx
|
||||
!src/CalculatorUnitTests/CalculatorUnitTests_TemporaryKey.pfx
|
||||
!src/CalculatorUnitTests/CalculatorUnitTests_TemporaryKey.pfx
|
||||
|
||||
# macOS specific
|
||||
.DS_Store
|
||||
|
||||
# VSCode
|
||||
.vscode
|
||||
|
|
5
CMakeLists.txt
Normal file
5
CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
project(calculator)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
add_subdirectory(src)
|
11
README.md
11
README.md
|
@ -18,6 +18,17 @@ Calculator ships regularly with new features and bug fixes. You can get the late
|
|||
- Currency conversion based on data retrieved from [Bing](https://www.bing.com).
|
||||
|
||||
## Getting started
|
||||
|
||||
### On macOS
|
||||
Prerequisites:
|
||||
- CMake
|
||||
- macOS
|
||||
|
||||
- Create a new directory named `cmake_build` in the repository folder
|
||||
- Run `cmake .. -GXcode` from `cmake_build`
|
||||
- Run `cmake --build cmake_build` from the repository folder to build the project
|
||||
|
||||
### On Windows
|
||||
Prerequisites:
|
||||
- Your computer must be running Windows 10, version 1803 or newer.
|
||||
- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient).
|
||||
|
|
1
src/CMakeLists.txt
Normal file
1
src/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
add_subdirectory(CalcManager)
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Header Files/CalcUtils.h"
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Command.h"
|
||||
#include "CalculatorVector.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/Number.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/Rational.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/RationalMath.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
#include "CalculatorResource.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* Author:
|
||||
\****************************************************************************/
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
#include "Header Files/CalcUtils.h"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*
|
||||
* Author:
|
||||
\****************************************************************************/
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
/*** ***/
|
||||
/*** ***/
|
||||
/**************************************************************************/
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace CalcEngine;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
#include "pch_cross_platform.h"
|
||||
#include "Header Files/CalcEngine.h"
|
||||
|
||||
using namespace CalcEngine;
|
||||
|
|
16
src/CalcManager/CMakeLists.txt
Normal file
16
src/CalcManager/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
add_library(CalculatorEngine
|
||||
CEngine/calc.cpp
|
||||
CEngine/CalcInput.cpp
|
||||
CEngine/CalcUtils.cpp
|
||||
CEngine/History.cpp
|
||||
CEngine/Number.cpp
|
||||
CEngine/Rational.cpp
|
||||
CEngine/RationalMath.cpp
|
||||
CEngine/scicomm.cpp
|
||||
CEngine/scidisp.cpp
|
||||
CEngine/scifunc.cpp
|
||||
CEngine/scioper.cpp
|
||||
CEngine/sciset.cpp
|
||||
)
|
||||
target_compile_options(CalculatorEngine PRIVATE "-fms-extensions")
|
||||
target_include_directories(CalculatorEngine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
@ -4,6 +4,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "Ratpack/CalcErr.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include "winerror_cross_platform.h"
|
||||
#include "sal_cross_platform.h"
|
||||
#endif
|
||||
|
||||
template <typename TType>
|
||||
class CalculatorVector
|
||||
|
|
1
src/CalcManager/pch_cross_platform.cpp
Normal file
1
src/CalcManager/pch_cross_platform.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "pch_cross_platform.h"
|
15
src/CalcManager/pch_cross_platform.h
Normal file
15
src/CalcManager/pch_cross_platform.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <limits>
|
||||
#include <regex>
|
||||
#include <unordered_map>
|
||||
// #include <intsafe.h>
|
||||
#include <array>
|
||||
// #include <ppltasks.h>
|
||||
#include "winerror_cross_platform.h"
|
9
src/CalcManager/sal_cross_platform.h
Normal file
9
src/CalcManager/sal_cross_platform.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
// Empty macro definitions for source annotations
|
||||
|
||||
#define _In_opt_
|
||||
#define _Out_opt_
|
||||
#define _In_
|
||||
#define _Out_
|
||||
#define _Inout_
|
16
src/CalcManager/winerror_cross_platform.h
Normal file
16
src/CalcManager/winerror_cross_platform.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#define HRESULT int32_t
|
||||
#define E_ACCESSDENIED 0x80070005
|
||||
#define E_FAIL 0x80004005
|
||||
#define E_INVALIDARG 0x80070057
|
||||
#define E_OUTOFMEMORY 0x8007000E
|
||||
#define E_POINTER 0x80004003
|
||||
#define E_UNEXPECTED 0x8000FFFF
|
||||
#define E_BOUNDS 0x8000000B
|
||||
#define S_OK 0x0
|
||||
#define S_FALSE 0x1
|
||||
|
||||
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
|
Loading…
Add table
Add a link
Reference in a new issue