From e729e4e86c883b5f8c2c741de8a22099b3ec0467 Mon Sep 17 00:00:00 2001 From: ninnghazad Date: Tue, 25 Sep 2018 15:02:47 +0200 Subject: [PATCH 01/20] Single typo (Mame -> Name) Fixed a typo (Mame -> Name) i came across. --- cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheatsheet.md b/cheatsheet.md index 907fe329..81758062 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -566,7 +566,7 @@ If both a 2 parameter and a 3 parameter signature match, the 3 parameter functio * `__LINE__` Current file line number * `__FILE__` Full path of current file * `__CLASS__` Name of current class - * `__FUNC__` Mame of current function + * `__FUNC__` Name of current function # Built In Functions From 8d0fc743418385451146bed97c75b27a8e38acdb Mon Sep 17 00:00:00 2001 From: Alek Mosingiewicz Date: Sat, 20 Oct 2018 16:50:08 +0200 Subject: [PATCH 02/20] Ci fix after moving to cpp17 (#455) * Update travis configuration. * Update GCC_VER in travis configuration. * Leave only Visual Studio 15 in Appveyor. * Travis - remove GCC_VER 4.9. * Travis - update clang-xcode. * Travis - update clang compiler. * Travis - downgrade clang compiler to 3.4. * Revert "Travis - downgrade clang compiler to 3.4." This reverts commit bd6698bccea9252dd00e8f28fb31334b0e3ea743. * Travis - clang-6.0 package and compiler. * Travis - remove (perhaps unnecessary) compiler option. * Travis - restore clang compiler option. * Update .travis.yml * Another attempt to fix Travis config for clang. * Another attempt to fix Travis config for clang. * Compiler package for clang. * Compiler package for clang. * Xcode 10. * Remove xcode from equation. * Force install clang-6.0. * Does it install these packages at all???. * Does it install these packages at all???. * Some appveyor fixes. * Update CMakeLists.txt Enforce C++17 standard * Update .travis.yml Restore xcode, block CLANG_VER. * experimental/variant for Apple compilers. * Remove OSX pipeline. * Remove OSX pipeline. * Attempt at fixing AppVeyor pipeline. * Restore proper VS version in AppVeyor configuration. * Revert preprocessor changes in json.hpp. --- .travis.yml | 30 +++++++++++++++++------------- CMakeLists.txt | 3 +++ appveyor.yml | 7 +++---- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7333e3b0..6a103736 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,12 @@ addons: apt: sources: - ubuntu-toolchain-r-test + - llvm-toolchain-trusty-5.0 + - sourceline: 'deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main' + key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key' packages: - - g++-4.9 - - g++-5 - - g++-6 + - g++-7 + - g++-8 coverity_scan: project: name: "ChaiScript/ChaiScript" @@ -22,7 +24,7 @@ matrix: include: - os: linux sudo: false - env: GCC_VER="4.9" + env: GCC_VER="7" compiler: gcc # - os: linux #sudo: false @@ -30,19 +32,20 @@ matrix: #compiler: gcc - os: linux sudo: false - env: GCC_VER="5" CPPCHECK=1 CMAKE_OPTIONS="-D RUN_FUZZY_TESTS:BOOL=TRUE" + env: GCC_VER="7" CPPCHECK=1 CMAKE_OPTIONS="-D RUN_FUZZY_TESTS:BOOL=TRUE" compiler: gcc - os: linux sudo: false - env: GCC_VER="6" CPPCHECK=1 COVERAGE=1 CMAKE_OPTIONS="-D RUN_FUZZY_TESTS:BOOL=TRUE" + env: GCC_VER="8" CPPCHECK=1 COVERAGE=1 CMAKE_OPTIONS="-D RUN_FUZZY_TESTS:BOOL=TRUE" compiler: gcc - - os: osx - compiler: clang - osx_image: xcode8 - - os: osx - compiler: clang - osx_image: xcode8 - env: CMAKE_OPTIONS="-D DYNLOAD_ENABLED:BOOL=FALSE -D MULTITHREAD_SUPPORT_ENABLED:BOOL=FALSE -D USE_STD_MAKE_SHARED:BOOL=TRUE" BUILD_ONLY=1 + #- os: osx + # compiler: clang + # osx_image: xcode10 + # env: CLANG_VER="5.0" + #- os: osx + # compiler: clang + # osx_image: xcode10 + # env: CLANG_VER="5.0" CMAKE_OPTIONS="-D DYNLOAD_ENABLED:BOOL=FALSE -D MULTITHREAD_SUPPORT_ENABLED:BOOL=FALSE -D USE_STD_MAKE_SHARED:BOOL=TRUE" BUILD_ONLY=1 env: global: @@ -52,6 +55,7 @@ env: before_install: - if [ "${GCC_VER}" != "" ]; then export CXX="g++-$GCC_VER" CC="gcc-$GCC_VER" GCOV="gcov-$GCC_VER" ; fi + #- if [ "${CLANG_VER}" != "" ]; then export CXX="clang++-$CLANG_VER"; fi - pip install --user cpp-coveralls script: diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cfec822..2d7dcced 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,9 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.1") cmake_policy(SET CMP0054 NEW) endif() +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + project(chaiscript) option(MULTITHREAD_SUPPORT_ENABLED "Multithreaded Support Enabled" TRUE) diff --git a/appveyor.yml b/appveyor.yml index 19187929..a5528862 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,10 +1,9 @@ version: 6.1.x.{build} -image: - - Visual Studio 2017 +image: + - Visual Studio 2017 environment: matrix: - - VS_VERSION: "Visual Studio 14" - - VS_VERSION: "Visual Studio 15" + - VS_VERSION: "Visual Studio 15" build_script: - cmd: >- mkdir build From 7a67963ca77aa2c092348ebf195fadc54c3467dd Mon Sep 17 00:00:00 2001 From: Yuri Yaryshev Date: Thu, 15 Nov 2018 18:59:18 +0300 Subject: [PATCH 03/20] Fix: added 'static' to thread_local variable in chaiscript/chaiscript_threading.hpp Because it's a singleton and should be one instance per thread, without it will be singleton per call, also it won't compile on VS2017 15.8.9 The error: chaiscript\include\chaiscript\chaiscript_threading.hpp(107): error C2480: 'my_t': 'thread' is only valid for data items of static extent --- include/chaiscript/chaiscript_threading.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/chaiscript/chaiscript_threading.hpp b/include/chaiscript/chaiscript_threading.hpp index 3875f9cf..9bfa44fc 100644 --- a/include/chaiscript/chaiscript_threading.hpp +++ b/include/chaiscript/chaiscript_threading.hpp @@ -107,7 +107,7 @@ namespace chaiscript /// does there is no possible way to recover static std::unordered_map &t() noexcept { - thread_local std::unordered_map my_t; + static thread_local std::unordered_map my_t; return my_t; } }; From cba13f94d675eaea428a00c25c45b5242657cfc5 Mon Sep 17 00:00:00 2001 From: vocaviking Date: Wed, 19 Dec 2018 13:03:30 +0100 Subject: [PATCH 04/20] Updated cheatsheet.md - Simplified the part about ChaiScript initialization - Added a link to the ChaiScriptExtras helper library - Removed the Subsection about built-ins, because they are not longer in the code --- cheatsheet.md | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/cheatsheet.md b/cheatsheet.md index 81758062..350863fa 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -11,13 +11,11 @@ ChaiScript tries to follow the [Semantic Versioning](http://semver.org/) scheme. # Initializing ChaiScript ``` -chaiscript::ChaiScript chai; // loads stdlib from loadable module on file system -chaiscript::ChaiScript chai(chaiscript::Std_Lib::library()); // compiles in stdlib +chaiscript::ChaiScript chai; // initializes ChaiScript, adding the standard ChaiScript types (map, string, ...) ``` Note that ChaiScript cannot be used as a global / static object unless it is being compiled with `CHAISCRIPT_NO_THREADS`. - # Adding Things To The Engine ## Adding a Function / Method / Member @@ -200,6 +198,9 @@ chai.eval(R"_( )_"); ``` +## Adding STL math +ChaiScript itself does not provide a link to the math functions defined in ``. You can either add them yourself, or use the [https://github.com/ChaiScript/ChaiScript_Extras](ChaiScript_Extras) helper library. (Which also provides some additional string functions.) + # Executing Script ## General @@ -571,23 +572,6 @@ If both a 2 parameter and a 3 parameter signature match, the 3 parameter functio # Built In Functions -## Disabling Built-Ins - -When constructing a ChaiScript object, a vector of parameters can be passed in to disable or enable various built-in methods. - -Current options: - -``` -enum class Options -{ - Load_Modules, - No_Load_Modules, - External_Scripts, - No_External_Scripts -}; -``` - - ## Evaluation ``` From c0f217ababf0f5f07da3589159187c8907ae1005 Mon Sep 17 00:00:00 2001 From: vocaviking Date: Fri, 21 Dec 2018 15:43:52 +0100 Subject: [PATCH 05/20] Moved ChaiScript_Extras to the bottom --- cheatsheet.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cheatsheet.md b/cheatsheet.md index 350863fa..80d4b3a8 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -198,9 +198,6 @@ chai.eval(R"_( )_"); ``` -## Adding STL math -ChaiScript itself does not provide a link to the math functions defined in ``. You can either add them yourself, or use the [https://github.com/ChaiScript/ChaiScript_Extras](ChaiScript_Extras) helper library. (Which also provides some additional string functions.) - # Executing Script ## General @@ -587,3 +584,6 @@ Both `use` and `eval_file` search the 'usepaths' passed to the ChaiScript constr * `from_json` converts a JSON string into its strongly typed (map, vector, int, double, string) representations * `to_json` converts a ChaiScript object (either a `Object` or one of map, vector, int, double, string) tree into its JSON string representation + +## Extras +ChaiScript itself does not provide a link to the math functions defined in ``. You can either add them yourself, or use the [https://github.com/ChaiScript/ChaiScript_Extras](ChaiScript_Extras) helper library. (Which also provides some additional string functions.) From 62ccd6d2ff73bec88142c0e3d2597a248666987a Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 31 Jan 2019 09:16:59 -0500 Subject: [PATCH 06/20] docs: Add push_back_ref() note --- cheatsheet.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cheatsheet.md b/cheatsheet.md index 80d4b3a8..8c71ebe4 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -389,11 +389,23 @@ switch (myvalue) { ## Built in Types +There are a number of build-in types that are part of ChaiScript. + +### Vectors and Maps + ``` var v = [1,2,3u,4ll,"16", `+`]; // creates vector of heterogenous values var m = ["a":1, "b":2]; // map of string:value pairs + +// Add a value to the vector by value. +v.push_back(123); + +// Add an object to the vector by reference. +v.push_back_ref(m); ``` +### Numbers + Floating point values default to `double` type and integers default to `int` type. All C++ suffixes such as `f`, `ll`, `u` as well as scientific notation are supported From 57ebd9d4039a3f724e48f909973fe663dac819ee Mon Sep 17 00:00:00 2001 From: medithe <40990424+medithe@users.noreply.github.com> Date: Thu, 25 Apr 2019 23:18:51 +0200 Subject: [PATCH 07/20] Update cheatsheet.md: Adding Lambda correction. Currently, the example where a lambda function was added to chaiscript didn't work for me. I use g++7, g++8,g++9 both with c++14 and c++17 mode. It doesn't work either in clang++-7. If the lambda is wrapped into a std::function<> it will work again! --- cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheatsheet.md b/cheatsheet.md index 80d4b3a8..5e712d4e 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -66,7 +66,7 @@ chai.add(chaiscript::fun(static_cast(&Derived::data)), "data"); ``` chai.add( - chaiscript::fun( + chaiscript::fun>( [](bool type) { if (type) { return "x"; } else { return "y"; } From 273bc4a94aa61ad466f676cf981e8ce28508e9ec Mon Sep 17 00:00:00 2001 From: Vladyslav Tronko Date: Wed, 5 Jun 2019 15:19:31 +0300 Subject: [PATCH 08/20] Fix description of ChaiScriptBasic::use Add missing word --- include/chaiscript/language/chaiscript_engine.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 2a68341c..63f9fc4e 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -386,9 +386,9 @@ namespace chaiscript } - /// \brief Loads and parses a file. If the file is already, it is not reloaded - /// The use paths specified at ChaiScript construction time are searched for the - /// requested file. + /// \brief Loads and parses a file. If the file is already open, it is not + /// reloaded. The use paths specified at ChaiScript construction time are + /// searched for the requested file. /// /// \param[in] t_filename Filename to load and evaluate Boxed_Value use(const std::string &t_filename) From 8e5d4a712c0c047786ed69c722b507fc8edfe669 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 26 Jun 2019 14:51:34 -0400 Subject: [PATCH 09/20] docs: Fix gendering Fixes #491 --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 8323a128..cba11ac4 100644 --- a/readme.md +++ b/readme.md @@ -29,7 +29,7 @@ Introduction ChaiScript is one of the only embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development -techniques, working with the developer like he expects it to work. Being a +techniques, working with the developer how they would expect it to work. Being a native C++ application, it has some advantages over existing embedded scripting languages: From af7a5d7c492992d513537c3b36dd1882f0c5f38d Mon Sep 17 00:00:00 2001 From: Joshua Thompson Date: Thu, 22 Aug 2019 10:00:37 -0400 Subject: [PATCH 10/20] #487: Fix warning for implicit 'this' lambda capture in C++20. --- include/chaiscript/language/chaiscript_engine.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index 63f9fc4e..d7da1257 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -156,7 +156,7 @@ namespace chaiscript m_engine.add(fun( - [=](const dispatch::Proxy_Function_Base &t_fun, const std::vector &t_params) -> Boxed_Value { + [=, this](const dispatch::Proxy_Function_Base &t_fun, const std::vector &t_params) -> Boxed_Value { Type_Conversions_State s(this->m_engine.conversions(), this->m_engine.conversions().conversion_saves()); return t_fun(Function_Params{t_params}, s); }), "call"); @@ -168,7 +168,7 @@ namespace chaiscript m_engine.add(fun([this](const std::string &t_type_name){ return m_engine.get_type(t_type_name, true); }), "type"); m_engine.add(fun( - [=](const Type_Info &t_from, const Type_Info &t_to, const std::function &t_func) { + [=, this](const Type_Info &t_from, const Type_Info &t_to, const std::function &t_func) { m_engine.add(chaiscript::type_conversion(t_from, t_to, t_func)); } ), "add_type_conversion"); From eeda632846b19a0125954594325d60d5f2b22b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20M=C5=82okosiewicz?= Date: Mon, 2 Sep 2019 23:12:57 +0200 Subject: [PATCH 11/20] cheatsheet: fix link to ChaiScript_Extras --- cheatsheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cheatsheet.md b/cheatsheet.md index 805f69a3..32d1c3b5 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -598,4 +598,4 @@ Both `use` and `eval_file` search the 'usepaths' passed to the ChaiScript constr * `to_json` converts a ChaiScript object (either a `Object` or one of map, vector, int, double, string) tree into its JSON string representation ## Extras -ChaiScript itself does not provide a link to the math functions defined in ``. You can either add them yourself, or use the [https://github.com/ChaiScript/ChaiScript_Extras](ChaiScript_Extras) helper library. (Which also provides some additional string functions.) +ChaiScript itself does not provide a link to the math functions defined in ``. You can either add them yourself, or use the [ChaiScript_Extras](https://github.com/ChaiScript/ChaiScript_Extras) helper library. (Which also provides some additional string functions.) From 2de0844616d15f0a75435b7984724b1ed9ec10a3 Mon Sep 17 00:00:00 2001 From: grdowns Date: Fri, 27 Sep 2019 02:16:37 -0700 Subject: [PATCH 12/20] Add vcpkg installation instructions --- readme.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/readme.md b/readme.md index cba11ac4..88f8a516 100644 --- a/readme.md +++ b/readme.md @@ -48,6 +48,19 @@ templates. It has been tested with gcc 4.9 and clang 3.6 (with libcxx). For more information see the build [dashboard](http://chaiscript.com/ChaiScript-BuildResults/index.html). +Installation using vcpkg +======================== + +You can download and install ChaiScript using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager: + + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.sh + ./vcpkg integrate install + vcpkg install chaiscript + +The ChaiScript port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. + Usage ===== From 3e621814143ebc433d2fa90c7765e4a159c2ada3 Mon Sep 17 00:00:00 2001 From: Guo Yunhe Date: Sat, 9 Nov 2019 11:10:45 +0200 Subject: [PATCH 13/20] Use LIBDIR instead of lib In Linux, the library should be installed to /usr/lib64 on 64bit machine --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d7dcced..ff221858 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,7 +426,7 @@ if(BUILD_TESTING) target_link_libraries(multifile_test ${LIBS}) add_test(NAME MultiFile_Test COMMAND multifile_test) - install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION lib/chaiscript) + install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION LIBDIR/chaiscript) endif() endif() @@ -439,7 +439,7 @@ if(BUILD_LIBFUZZ_TESTER) endif() -install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION lib/chaiscript) +install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION LIBDIR/chaiscript) install(DIRECTORY include/chaiscript DESTINATION include PATTERN "*.hpp" @@ -458,8 +458,8 @@ install(DIRECTORY samples DESTINATION share/chaiscript PATTERN "*/.git*" EXCLUDE PATTERN "*~" EXCLUDE) -configure_file(contrib/pkgconfig/chaiscript.pc.in lib/pkgconfig/chaiscript.pc @ONLY) +configure_file(contrib/pkgconfig/chaiscript.pc.in LIBDIR/pkgconfig/chaiscript.pc @ONLY) install(FILES "${chaiscript_BINARY_DIR}/lib/pkgconfig/chaiscript.pc" - DESTINATION lib/pkgconfig) + DESTINATION LIBDIR/pkgconfig) From 741893204aad5f147b0cba257279d98fc3e8bb7e Mon Sep 17 00:00:00 2001 From: Guo Yunhe Date: Sat, 9 Nov 2019 11:19:38 +0200 Subject: [PATCH 14/20] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff221858..897fe3d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -458,7 +458,7 @@ install(DIRECTORY samples DESTINATION share/chaiscript PATTERN "*/.git*" EXCLUDE PATTERN "*~" EXCLUDE) -configure_file(contrib/pkgconfig/chaiscript.pc.in LIBDIR/pkgconfig/chaiscript.pc @ONLY) +configure_file(contrib/pkgconfig/chaiscript.pc.in lib/pkgconfig/chaiscript.pc @ONLY) install(FILES "${chaiscript_BINARY_DIR}/lib/pkgconfig/chaiscript.pc" DESTINATION LIBDIR/pkgconfig) From 63951d06f2af1ff80e97353927be74c73ec984e0 Mon Sep 17 00:00:00 2001 From: Guo Yunhe Date: Sat, 9 Nov 2019 11:36:31 +0200 Subject: [PATCH 15/20] Update CMakeLists.txt --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 897fe3d8..a2ca72e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,7 +426,7 @@ if(BUILD_TESTING) target_link_libraries(multifile_test ${LIBS}) add_test(NAME MultiFile_Test COMMAND multifile_test) - install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION LIBDIR/chaiscript) + install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION ${LIBDIR}/chaiscript) endif() endif() @@ -439,7 +439,7 @@ if(BUILD_LIBFUZZ_TESTER) endif() -install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION LIBDIR/chaiscript) +install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION ${LIBDIR}/chaiscript) install(DIRECTORY include/chaiscript DESTINATION include PATTERN "*.hpp" @@ -460,6 +460,6 @@ install(DIRECTORY samples DESTINATION share/chaiscript configure_file(contrib/pkgconfig/chaiscript.pc.in lib/pkgconfig/chaiscript.pc @ONLY) install(FILES "${chaiscript_BINARY_DIR}/lib/pkgconfig/chaiscript.pc" - DESTINATION LIBDIR/pkgconfig) + DESTINATION ${LIBDIR}/pkgconfig) From 0aa186abbe1ab9d5050bd9fcece88fc1596dd05c Mon Sep 17 00:00:00 2001 From: Guo Yunhe Date: Sat, 9 Nov 2019 11:37:32 +0200 Subject: [PATCH 16/20] Update CMakeLists.txt --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2ca72e5..f04149bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,7 +426,7 @@ if(BUILD_TESTING) target_link_libraries(multifile_test ${LIBS}) add_test(NAME MultiFile_Test COMMAND multifile_test) - install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION ${LIBDIR}/chaiscript) + install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION "${LIBDIR}/chaiscript") endif() endif() @@ -439,7 +439,7 @@ if(BUILD_LIBFUZZ_TESTER) endif() -install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION ${LIBDIR}/chaiscript) +install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION "${LIBDIR}/chaiscript") install(DIRECTORY include/chaiscript DESTINATION include PATTERN "*.hpp" @@ -460,6 +460,6 @@ install(DIRECTORY samples DESTINATION share/chaiscript configure_file(contrib/pkgconfig/chaiscript.pc.in lib/pkgconfig/chaiscript.pc @ONLY) install(FILES "${chaiscript_BINARY_DIR}/lib/pkgconfig/chaiscript.pc" - DESTINATION ${LIBDIR}/pkgconfig) + DESTINATION "${LIBDIR}/pkgconfig") From cb1867dfd160f005425d0878b3758d1fe75072df Mon Sep 17 00:00:00 2001 From: Guo Yunhe Date: Sat, 9 Nov 2019 12:01:50 +0200 Subject: [PATCH 17/20] Update CMakeLists.txt --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f04149bc..7e1e754b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -426,7 +426,7 @@ if(BUILD_TESTING) target_link_libraries(multifile_test ${LIBS}) add_test(NAME MultiFile_Test COMMAND multifile_test) - install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION "${LIBDIR}/chaiscript") + install(TARGETS test_module RUNTIME DESTINATION bin LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/chaiscript") endif() endif() @@ -439,7 +439,7 @@ if(BUILD_LIBFUZZ_TESTER) endif() -install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION "${LIBDIR}/chaiscript") +install(TARGETS chai chaiscript_stdlib-${CHAI_VERSION} ${MODULES} RUNTIME DESTINATION bin LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/chaiscript") install(DIRECTORY include/chaiscript DESTINATION include PATTERN "*.hpp" @@ -460,6 +460,6 @@ install(DIRECTORY samples DESTINATION share/chaiscript configure_file(contrib/pkgconfig/chaiscript.pc.in lib/pkgconfig/chaiscript.pc @ONLY) install(FILES "${chaiscript_BINARY_DIR}/lib/pkgconfig/chaiscript.pc" - DESTINATION "${LIBDIR}/pkgconfig") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") From a7dae37a2320de198923fe8873a9c0d982fe4498 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Sat, 9 Nov 2019 09:44:07 -0500 Subject: [PATCH 18/20] Update release notes for 6.1.1 --- releasenotes.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/releasenotes.md b/releasenotes.md index cdccd888..a622566e 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -5,6 +5,9 @@ Current Version: 6.1.1 ### Changes since 6.1.0 * Handle the returning of `&` to `*` types. This specifically comes up with `std::vector` and similar containers + * Update CMake to use `LIBDIR` instead of `lib` #502 by @guoyunhe + * Add documentation for installing ChaiScript with vcpkg #500 by @grdowns + * Fix warning for implicit 'this' lambda capture in C++20 #495 by @Josh-Thompson ### Changes since 6.0.0 @@ -18,7 +21,6 @@ Current Version: 6.1.1 * Support for C++17 compilers! * Support for UTF8 BOM #439 @AlekMosingiewicz @MarioLiebisch - ### Changes since 5.8.6 *6.0.0 is a massive rework compared to 5.x. It now requires a C++14 enabled compiler* From 85e4598986715233cab31360b5efe3edf25c876c Mon Sep 17 00:00:00 2001 From: Jose Rubio Date: Mon, 13 Jan 2020 16:36:32 +0100 Subject: [PATCH 19/20] =?UTF-8?q?Fix=20for=20warnings:=20by-copy=20capture?= =?UTF-8?q?=20of=20=E2=80=98this=E2=80=99=20and=20unused-local-typedefs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are two warnings when compiling with GCC 7.4.1 or clang 5.0.1. 1. warning: explicit by-copy capture of ‘this’ redundant with by-copy capture default 2. warning: typedef ... locally defined but not used [-Wunused-local-typedefs] This change removes [2] and it compacts the lambda capture clause in [1]. --- include/chaiscript/language/chaiscript_engine.hpp | 4 ++-- include/chaiscript/language/chaiscript_eval.hpp | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index d7da1257..702d5cbc 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -156,7 +156,7 @@ namespace chaiscript m_engine.add(fun( - [=, this](const dispatch::Proxy_Function_Base &t_fun, const std::vector &t_params) -> Boxed_Value { + [this](const dispatch::Proxy_Function_Base &t_fun, const std::vector &t_params) -> Boxed_Value { Type_Conversions_State s(this->m_engine.conversions(), this->m_engine.conversions().conversion_saves()); return t_fun(Function_Params{t_params}, s); }), "call"); @@ -168,7 +168,7 @@ namespace chaiscript m_engine.add(fun([this](const std::string &t_type_name){ return m_engine.get_type(t_type_name, true); }), "type"); m_engine.add(fun( - [=, this](const Type_Info &t_from, const Type_Info &t_to, const std::function &t_func) { + [this](const Type_Info &t_from, const Type_Info &t_to, const std::function &t_func) { m_engine.add(chaiscript::type_conversion(t_from, t_to, t_func)); } ), "add_type_conversion"); diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index 52110bde..d38e5aa3 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -331,7 +331,6 @@ namespace chaiscript Boxed_Value fn(this->children[0]->eval(t_ss)); - using ConstFunctionTypePtr = const dispatch::Proxy_Function_Base *; try { return (*t_ss->boxed_cast(fn))(Function_Params{params}, t_ss.conversions()); } From aa3c4ae797c4e3afd03387bddb3726bf7077a156 Mon Sep 17 00:00:00 2001 From: TankorSmash Date: Fri, 22 May 2020 00:24:43 -0400 Subject: [PATCH 20/20] fix typo in cheatsheet; add cpp highlighting --- cheatsheet.md | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/cheatsheet.md b/cheatsheet.md index 32d1c3b5..27669a23 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -22,7 +22,7 @@ Note that ChaiScript cannot be used as a global / static object unless it is bei ### General -``` +```cpp chai.add(chaiscript::fun(&function_name), "function_name"); chai.add(chaiscript::fun(&Class::method_name), "method_name"); chai.add(chaiscript::fun(&Class::member_name), "member_name"); @@ -30,7 +30,7 @@ chai.add(chaiscript::fun(&Class::member_name), "member_name"); ### Bound Member Functions -``` +```cpp chai.add(chaiscript::fun(&Class::method_name, Class_instance_ptr), "method_name"); chai.add(chaiscript::fun(&Class::member_name, Class_instance_ptr), "member_name"); ``` @@ -39,18 +39,18 @@ chai.add(chaiscript::fun(&Class::member_name, Class_instance_ptr), "member_name" #### Preferred -``` +```cpp chai.add(chaiscript::fun(&function_with_overloads), "function_name"); ``` #### Alternative -``` +```cpp chai.add(chaiscript::fun(std::static_cast(&function_with_overloads)), "function_name"); ``` This overload technique is also used when exposing base member using derived type -``` +```cpp struct Base { int data; @@ -64,7 +64,7 @@ chai.add(chaiscript::fun(static_cast(&Derived::data)), "data"); ### Lambda -``` +```cpp chai.add( chaiscript::fun>( [](bool type) { @@ -75,7 +75,7 @@ chai.add( ### Constructors -``` +```cpp chai.add(chaiscript::constructor(), "MyType"); chai.add(chaiscript::constructor(), "MyType"); ``` @@ -84,7 +84,7 @@ chai.add(chaiscript::constructor(), "MyType"); It's not strictly necessary to add types, but it helps with many things. Cloning, better errors, etc. -``` +```cpp chai.add(chaiscript::user_type(), "MyClass"); ``` @@ -107,27 +107,27 @@ add_type_conversion(type("string"), type("Type_Info"), fun(s) { return type(s); Invoking a C++ type conversion possible with `static_cast` -``` +```cpp chai.add(chaiscript::type_conversion()); ``` Calling a user defined type conversion that takes a lambda -``` +```cpp chai.add(chaiscript::type_conversion([](const TestBaseType &t_bt) { /* return converted thing */ })); ``` ### Class Hierarchies -If you want objects to be convertable between base and derived classes, you must tell ChaiScritp about the relationship. +If you want objects to be convertable between base and derived classes, you must tell ChaiScript about the relationship. -``` +```cpp chai.add(chaiscript::base_class()); ``` If you have multiple classes in your inheritance graph, you will probably want to tell ChaiScript about all relationships. -``` +```cpp chai.add(chaiscript::base_class()); chai.add(chaiscript::base_class()); chai.add(chaiscript::base_class()); @@ -168,7 +168,8 @@ chai.set_global(chaiscript::var(somevar), "somevar"); // global non-const, overw Namespaces will not be populated until `import` is called. This saves memory and computing costs if a namespace is not imported into every ChaiScript instance. -``` + +```cpp chai.register_namespace([](chaiscript::Namespace& math) { math["pi"] = chaiscript::const_var(3.14159); math["sin"] = chaiscript::var(chaiscript::fun([](const double x) { return sin(x); })); }, @@ -184,7 +185,7 @@ print(math.pi) // prints 3.14159 # Using STL ChaiScript recognize many types from STL, but you have to add specific instantiation yourself. -``` +```cpp typedef std::vector> data_list; data_list my_list{ make_pair(0, "Hello"), make_pair(1, "World") }; chai.add(chaiscript::bootstrap::standard_library::vector_type("DataList")); @@ -202,7 +203,7 @@ chai.eval(R"_( ## General -``` +```cpp chai.eval("print(\"Hello World\")"); chai.eval(R"(print("Hello World"))"); ``` @@ -213,13 +214,13 @@ Returns values are of the type `Boxed_Value` which is meant to be opaque to the ### Prefered -``` +```cpp chai.eval("5.3 + 2.1"); // returns 7.4 as a C++ double ``` ### Alternative -``` +```cpp auto v = chai.eval("5.3 + 2.1"); chai.boxed_cast(v); // extracts double value from boxed_value and applies known conversions chaiscript::boxed_cast(v); // free function version, does not know about conversions @@ -227,7 +228,7 @@ chaiscript::boxed_cast(v); // free function version, does not know about ### Converting Between Algebraic Types -``` +```cpp chaiscript::Boxed_Number(chai.eval("5.3 + 2.1")).get_as(); // works with any number type // which is equivalent to, but much more automatic than: static_cast(chai.eval("5.3+2.1")); // this version only works if we know that it's a double @@ -257,7 +258,7 @@ int main() ## Sharing Values -``` +```cpp double &d = chai.eval("var i = 5.2; i"); // d is now a reference to i in the script std::shared_ptr d = chai.eval("var i = 5.2; i"); // same result but reference counted @@ -267,7 +268,7 @@ chai.eval("print(i)"); // prints 3 ## Catching Eval Errors -``` +```cpp try { chai.eval("2.3 + \"String\""); } catch (const chaiscript::exception::eval_error &e) { @@ -277,7 +278,7 @@ try { ## Catching Errors Thrown From Script -``` +```cpp try { chai.eval("throw(runtime_error(\"error\"))", chaiscript::exception_specification()); } catch (const double e) { @@ -292,19 +293,19 @@ try { ## Sharing Functions -``` +```cpp auto p = chai.eval>("to_string"); p(5); // calls chaiscript's 'to_string' function, returning std::string("5") ``` Note: backtick treats operators as normal functions -``` +```cpp auto p = chai.eval>(`+`); p(5, 6); // calls chaiscript's '+' function, returning 11 ``` -``` +```cpp auto p = chai.eval>("fun(x,y) { to_string(x) + to_string(y); }"); p(3,4.2); // evaluates the lambda function, returning the string "34.2" to C++ ```