From 7923c3e0c7a53d77a3becebcf43bf6f3d4053932 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 31 Jan 2016 14:05:44 -0700 Subject: [PATCH 1/2] Add docs on `set_global` --- cheatsheet.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cheatsheet.md b/cheatsheet.md index 25b84694..9b51f2a7 100644 --- a/cheatsheet.md +++ b/cheatsheet.md @@ -107,8 +107,9 @@ chai.add(chaiscript::var(std::ref(somevar), "somevar"); // by reference, shared auto shareddouble = std::make_shared(4.3); chai.add(chaiscript::var(shareddouble), "shareddouble"); // by shared_ptr, shared between c++ and chai chai.add(chaiscript::const_var(somevar), "somevar"); // copied in and made const -chai.add_global_const(chaiscript::const_var(somevar), "somevar"); // global const. Throws if value is non-const -chai.add_global(chaiscript::var(somevar), "somevar"); // global non-const +chai.add_global_const(chaiscript::const_var(somevar), "somevar"); // global const. Throws if value is non-const, throws if object exists +chai.add_global(chaiscript::var(somevar), "somevar"); // global non-const, throws if object exists +chai.set_global(chaiscript::var(somevar), "somevar"); // global non-const, overwrites existing object ``` # Using STL ChaiScript recognize many types from STL, but you have to add specific instantiation yourself. From c438a388d71fa8c186e38fe37389b8af59309d71 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 31 Jan 2016 19:05:37 -0700 Subject: [PATCH 2/2] Add workaround for msvc 2015 update 1 with 1 CPU. --- include/chaiscript/chaiscript_stdlib.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/chaiscript/chaiscript_stdlib.hpp b/include/chaiscript/chaiscript_stdlib.hpp index 4b38f2cd..84797b75 100644 --- a/include/chaiscript/chaiscript_stdlib.hpp +++ b/include/chaiscript/chaiscript_stdlib.hpp @@ -49,7 +49,13 @@ namespace chaiscript #ifndef CHAISCRIPT_NO_THREADS lib->add(standard_library::future_type>("future")); +#ifdef CHAISCRIPT_MSVC + /// this is to work around an issue that seems to only come up on single CPU hosts on MSVC 2015 Update 1 + /// \todo reevaluate this later + lib->add(chaiscript::fun([](const std::function &t_func){ return std::async(std::thread::hardware_concurrency() <= 1 ? std::launch::deferred : std::launch::async, t_func);}), "async"); +#else lib->add(chaiscript::fun([](const std::function &t_func){ return std::async(std::launch::async, t_func);}), "async"); +#endif #endif lib->add(json_wrap::library());