diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..08c508d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.vscode/ +build/ +build.*/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c045ed4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +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}) + +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 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. 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