Skip to content

Commit aaf1df1

Browse files
committed
enhanced the calculator app
1 parent af00674 commit aaf1df1

7 files changed

Lines changed: 467 additions & 101 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
12
cmake_minimum_required(VERSION 3.10)
23
project(Pythonic)
34

5+
# Exclude any .cpp file in the REPL directory from build
6+
file(GLOB_RECURSE REPL_CPP_FILES "include/pythonic/REPL/*.cpp")
7+
set_source_files_properties(${REPL_CPP_FILES} PROPERTIES HEADER_FILE_ONLY TRUE)
8+
49
# Require C++20 for concepts, ranges, and other features
510
set(CMAKE_CXX_STANDARD 20)
611
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -130,6 +135,8 @@ endif()
130135

131136
# Create a library
132137
add_library(pythonic src/pythonicDispatchStubs.cpp)
138+
target_compile_definitions(pythonic PUBLIC HAVE_READLINE)
139+
target_link_libraries(pythonic PUBLIC readline)
133140

134141
# Find and require threading support (needed for std::thread in video export)
135142
set(THREADS_PREFER_PTHREAD_FLAG ON)

docs/examples/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ endif()
7070
# --> Replace 'demoapp' with your project executable name
7171
# --> Add all your .cpp files here if you have multiple
7272
add_executable(demoapp demo.cpp)
73+
target_compile_definitions(demoapp PRIVATE HAVE_READLINE)
74+
target_link_libraries(demoapp PRIVATE readline)
7375
# For multi-file projects:
7476
# add_executable(demoapp main.cpp file1.cpp file2.cpp)
7577
# or use file(GLOB SOURCES *.cpp) and then add_executable(demoapp ${SOURCES})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
rm -fr test_calculator &&
3+
g++ -std=c++20 -o test_calculator -DHAVE_READLINE test_calculator.cpp -lreadline -lncurses || exit 1
4+
clear &&
5+
if [[ "$1" == "--test" ]]; then
6+
printf "%s\n" \
7+
"var a = PI*2, b = sin(a) + e" \
8+
"var c = (a^2 + b^2) / (1 + cos(a/2))" \
9+
"var d = sqrt(abs(c - 100)) + log10(b + 1)" \
10+
"sqrt(d) + deg"
11+
./test_calculator <<'EOF'
12+
var a = PI*2, b = sin(a) + e
13+
var c = (a^2 + b^2) / (1 + cos(a/2))
14+
var d = sqrt(abs(c - 100)) + log10(b + 1)
15+
sqrt(d) + deg
16+
EOF
17+
else
18+
./test_calculator
19+
fi

0 commit comments

Comments
 (0)