From 81a4f115e6628a2fdeba5482fc8f175c516767e9 Mon Sep 17 00:00:00 2001 From: Steven Hangger Date: Fri, 26 Apr 2019 13:24:32 +0800 Subject: [PATCH 1/4] fix build --- .gitignore | 2 ++ CMakeLists.txt | 39 +++++++++++++++++++++++++++++++++++++++ TinyJS_MathFunctions.cpp | 4 ++-- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..608b1d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vscode/ +build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e1e84a8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,39 @@ +project (tiny-js) +cmake_minimum_required (VERSION 2.6) + +set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + +if (NOT CMAKE_BUILD_TYPE) + set (CMAKE_BUILD_TYPE "Debug") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") +else() + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") +endif(NOT CMAKE_BUILD_TYPE) + +if (NOT WIN32) + include(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) + if(COMPILER_SUPPORTS_CXX14) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall") + else() + message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++14 support.") + endif() +endif(NOT WIN32) + +FILE(GLOB TINY_JS_HEADER_FILES + ${CMAKE_CURRENT_LIST_DIR}/TinyJS.h +) + +FILE(GLOB TINY_JS_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/TinyJS.cpp + ${CMAKE_CURRENT_LIST_DIR}/TinyJS_Functions.cpp + ${CMAKE_CURRENT_LIST_DIR}/TinyJS_MathFunctions.cpp +) + +add_library(tiny-js STATIC ${TINY_JS_HEADER_FILES} ${TINY_JS_SOURCE_FILES}) + +ADD_EXECUTABLE(tiny-js-cli Script.cpp ${TINY_JS_SOURCE_FILES}) + +ADD_EXECUTABLE(tiny-js-tests run_tests.cpp ${TINY_JS_SOURCE_FILES}) \ No newline at end of file diff --git a/TinyJS_MathFunctions.cpp b/TinyJS_MathFunctions.cpp index 1d79882..c155df2 100755 --- a/TinyJS_MathFunctions.cpp +++ b/TinyJS_MathFunctions.cpp @@ -188,7 +188,7 @@ void scMathSinh(CScriptVar *c, void *userdata) { //Math.asinh(a) - returns trig. hyperbolic arcsine of given angle in radians void scMathASinh(CScriptVar *c, void *userdata) { - scReturnDouble( asinh( scGetDouble("a") ) ); + scReturnDouble( asinh( (long double)scGetDouble("a") ) ); } //Math.cosh(a) - returns trig. hyperbolic cosine of given angle in radians @@ -198,7 +198,7 @@ void scMathCosh(CScriptVar *c, void *userdata) { //Math.acosh(a) - returns trig. hyperbolic arccosine of given angle in radians void scMathACosh(CScriptVar *c, void *userdata) { - scReturnDouble( acosh( scGetDouble("a") ) ); + scReturnDouble( acosh( (long double)scGetDouble("a") ) ); } //Math.tanh(a) - returns trig. hyperbolic tangent of given angle in radians From 6a475e61f708034bb540fcb8521181d848fa8f79 Mon Sep 17 00:00:00 2001 From: Steven Hangger Date: Fri, 26 Apr 2019 13:37:48 +0800 Subject: [PATCH 2/4] add tests content copy --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1e84a8..c045ed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,4 +36,10 @@ add_library(tiny-js STATIC ${TINY_JS_HEADER_FILES} ${TINY_JS_SOURCE_FILES}) ADD_EXECUTABLE(tiny-js-cli Script.cpp ${TINY_JS_SOURCE_FILES}) -ADD_EXECUTABLE(tiny-js-tests run_tests.cpp ${TINY_JS_SOURCE_FILES}) \ No newline at end of file +ADD_EXECUTABLE(tiny-js-tests run_tests.cpp ${TINY_JS_SOURCE_FILES}) + +add_custom_command( + TARGET tiny-js-tests POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/tests + ${CMAKE_CURRENT_BINARY_DIR}/tests) \ No newline at end of file From f4b978049af45a95acca8b5eff2f47a9051485f3 Mon Sep 17 00:00:00 2001 From: Steven Hangger Date: Fri, 26 Apr 2019 19:03:58 +0800 Subject: [PATCH 3/4] fix --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 608b1d4..08c508d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .vscode/ -build/ \ No newline at end of file +build/ +build.*/ \ No newline at end of file From c719761ebd2a4f46a4ff601ae86cd297ac9213a0 Mon Sep 17 00:00:00 2001 From: Steven Hangger Date: Fri, 26 Apr 2019 19:05:58 +0800 Subject: [PATCH 4/4] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e1cb5be --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Gordon Williams + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE.