diff --git a/contrib/codeanalysis/codeanalysis.sh b/contrib/codeanalysis/codeanalysis.sh index 6a32210..3da80b4 100755 --- a/contrib/codeanalysis/codeanalysis.sh +++ b/contrib/codeanalysis/codeanalysis.sh @@ -50,7 +50,7 @@ function run_test # Run multithreaded tests echo "****Building multithreaded test" pushd src - g++ multithreaded.cpp -lboost_thread-mt -ldl -omultithreaded -I../include -O3 + g++ multithreaded.cpp -ldl -omultithreaded -I../include -O3 echo "****Testing 1 thread runtime" /usr/bin/time -p ./multithreaded 1 2> ../../r$1-1threadruntime.out echo "****Testing 2 thread runtime" diff --git a/include/chaiscript/chaiscript.hpp b/include/chaiscript/chaiscript.hpp index 497c9c4..33cf6db 100644 --- a/include/chaiscript/chaiscript.hpp +++ b/include/chaiscript/chaiscript.hpp @@ -74,16 +74,16 @@ ///
/// \subsection compiling Compiling ChaiScript Applications /// -/// ChaiScript is a header only library with only two dependecies. boost::threads (optional) and the +/// ChaiScript is a header only library with only one dependecy: The /// operating system provided dynamic library loader, which has to be specified on some platforms. /// /// \subsubsection compilinggcc Compiling with GCC /// /// To compile the above application on a Unix like operating system (MacOS, Linux) with GCC you need to link -/// both boost::threads and the dynamic loader. For example: +/// the dynamic loader. For example: /// /// \code -/// gcc main.cpp -I/path/to/chaiscript/headers -ldl -lboost_threads +/// gcc main.cpp -I/path/to/chaiscript/headers -ldl /// \endcode /// /// Alternatively, you may compile without threading support. @@ -245,7 +245,9 @@ /// /// std::string append_string_int(const std::string &t_lhs, int t_rhs) /// { -/// return t_lhs + boost::lexical_cast(t_rhs); +/// std::stringstream ss; +/// ss << t_lhs << t_rhs; +/// return ss.str(); /// } /// /// chai.add(fun(append_string_int), "+"); @@ -407,7 +409,7 @@ /// /// Thread safety can be disabled by defining CHAISCRIPT_NO_THREADS when using the library. /// -/// Disabling thread safety increases performance and removes the requirement for boost_threads. +/// Disabling thread safety increases performance in many cases. /// ///
/// @@ -743,6 +745,8 @@ /// \namespace chaiscript::detail /// \brief Classes and functions reserved for internal use. Items in this namespace are not supported. +#include "chaiscript_defines.hpp" + #include "dispatchkit/dispatchkit.hpp" #include "dispatchkit/bootstrap.hpp" #include "dispatchkit/bootstrap_stl.hpp" @@ -750,7 +754,7 @@ #include "dispatchkit/dynamic_object.hpp" #include "dispatchkit/boxed_number.hpp" -#ifdef BOOST_HAS_DECLSPEC +#ifdef CHAISCRIPT_HAS_DECLSPEC #define CHAISCRIPT_MODULE_EXPORT extern "C" __declspec(dllexport) #else #define CHAISCRIPT_MODULE_EXPORT extern "C" diff --git a/include/chaiscript/chaiscript_defines.hpp b/include/chaiscript/chaiscript_defines.hpp new file mode 100644 index 0000000..38cd72b --- /dev/null +++ b/include/chaiscript/chaiscript_defines.hpp @@ -0,0 +1,20 @@ +// This file is distributed under the BSD License. +// See "license.txt" for details. +// Copyright 2009-2011, Jonathan Turner (jonathan@emptycrate.com) +// and Jason Turner (jason@emptycrate.com) +// http://www.chaiscript.com + +#ifndef CHAISCRIPT_DEFINES_HPP_ +#define CHAISCRIPT_DEFINES_HPP_ + +#ifdef _MSC_VER +#define CHAISCRIPT_MSVC _MSC_VER +#define CHAISCRIPT_HAS_DECLSPEc +#endif + +#ifdef _WIN32 +#define CHAISCRIPT_WINDOWS +#endif + +#endif + diff --git a/include/chaiscript/chaiscript_threading.hpp b/include/chaiscript/chaiscript_threading.hpp index bc7ae3c..bce2c3e 100644 --- a/include/chaiscript/chaiscript_threading.hpp +++ b/include/chaiscript/chaiscript_threading.hpp @@ -26,7 +26,7 @@ namespace chaiscript { namespace detail { - /// If threading is enabled, then this namespace contains boost::thread classes. + /// If threading is enabled, then this namespace contains std thread classes. /// If threading is not enabled, then stubbed in wrappers that do nothing are provided. /// This allows us to avoid \#ifdef code in the sections that need thread safety. namespace threading @@ -64,8 +64,10 @@ namespace chaiscript - /// Typesafe thread specific storage. If threading is enabled, this class uses boost::thread_specific_ptr. If + /// Typesafe thread specific storage. If threading is enabled, this class uses a mutex protected map. If /// threading is not enabled, the class always returns the same data, regardless of which thread it is called from. + /// + /// \todo move to thread_local when it exists template class Thread_Storage { diff --git a/include/chaiscript/dispatchkit/boxed_cast.hpp b/include/chaiscript/dispatchkit/boxed_cast.hpp index c8b8e76..b75e06f 100644 --- a/include/chaiscript/dispatchkit/boxed_cast.hpp +++ b/include/chaiscript/dispatchkit/boxed_cast.hpp @@ -7,6 +7,8 @@ #ifndef CHAISCRIPT_BOXED_CAST_HPP_ #define CHAISCRIPT_BOXED_CAST_HPP_ +#include "../chaiscript_defines.hpp" + #include "type_info.hpp" #include "boxed_value.hpp" #include "boxed_cast_helper.hpp" @@ -66,7 +68,7 @@ namespace chaiscript return detail::Cast_Helper::cast(bv); } catch (const chaiscript::detail::exception::bad_any_cast &) { -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC //Thank you MSVC, yes we know that a constant value is being used in the if // statment in THIS VERSION of the template instantiation #pragma warning(push) @@ -88,7 +90,7 @@ namespace chaiscript throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type)); } -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(pop) #endif diff --git a/include/chaiscript/dispatchkit/operators.hpp b/include/chaiscript/dispatchkit/operators.hpp index 343da1e..2686976 100644 --- a/include/chaiscript/dispatchkit/operators.hpp +++ b/include/chaiscript/dispatchkit/operators.hpp @@ -7,6 +7,8 @@ #ifndef CHAISCRIPT_OPERATORS_HPP_ #define CHAISCRIPT_OPERATORS_HPP_ +#include "../chaiscript_defines.hpp" + namespace chaiscript { namespace bootstrap @@ -154,7 +156,7 @@ namespace chaiscript template Ret unary_minus(L l) { -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(push) #pragma warning(disable : 4146) return (-l); diff --git a/include/chaiscript/language/chaiscript_algebraic.hpp b/include/chaiscript/language/chaiscript_algebraic.hpp index fe76359..3d363ce 100644 --- a/include/chaiscript/language/chaiscript_algebraic.hpp +++ b/include/chaiscript/language/chaiscript_algebraic.hpp @@ -7,7 +7,7 @@ #ifndef CHAISCRIPT_ALGEBRAIC_HPP_ #define CHAISCRIPT_ALGEBRAIC_HPP_ -#include +#include "../dispatchkit/dispatchkit.hpp" namespace chaiscript { diff --git a/include/chaiscript/language/chaiscript_common.hpp b/include/chaiscript/language/chaiscript_common.hpp index bc00f5c..5fbb209 100644 --- a/include/chaiscript/language/chaiscript_common.hpp +++ b/include/chaiscript/language/chaiscript_common.hpp @@ -7,7 +7,7 @@ #ifndef CHAISCRIPT_COMMON_HPP_ #define CHAISCRIPT_COMMON_HPP_ -#include +#include "../dispatchkit/dispatchkit.hpp" namespace chaiscript { diff --git a/include/chaiscript/language/chaiscript_engine.hpp b/include/chaiscript/language/chaiscript_engine.hpp index e0816b7..c7ec0bf 100644 --- a/include/chaiscript/language/chaiscript_engine.hpp +++ b/include/chaiscript/language/chaiscript_engine.hpp @@ -10,12 +10,13 @@ #include #include -#include +#include "../chaiscript_defines.hpp" +#include "chaiscript_common.hpp" #ifdef _POSIX_VERSION #include #else -#ifdef BOOST_WINDOWS +#ifdef CHAISCRIPT_WINDOWS #define VC_EXTRA_LEAN #define WIN32_LEAN_AND_MEAN #include @@ -23,8 +24,8 @@ #endif -#include -#include +#include "chaiscript_prelude.hpp" +#include "chaiscript_parser.hpp" #include "../dispatchkit/exception_specification.hpp" namespace chaiscript diff --git a/include/chaiscript/language/chaiscript_eval.hpp b/include/chaiscript/language/chaiscript_eval.hpp index b3b4b0c..2e15afd 100644 --- a/include/chaiscript/language/chaiscript_eval.hpp +++ b/include/chaiscript/language/chaiscript_eval.hpp @@ -9,7 +9,7 @@ #include -#include +#include "chaiscript_common.hpp" namespace chaiscript { diff --git a/readme.txt b/readme.txt index bddc703..6c73989 100644 --- a/readme.txt +++ b/readme.txt @@ -13,7 +13,7 @@ ChaiScript is one of the only embedded scripting language designed from the grou [Requirements] -ChaiScript requires a recent version of Boost (http://www.boost.org) to build. +ChaiScript requires a C++11 compiler to build with support for variadic templates. [Usage] diff --git a/src/main.cpp b/src/main.cpp index 50cb43a..240418c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,7 @@ char* readline(const char* p) std::string retval; std::cout << p ; std::getline(std::cin, retval); -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC return std::cin.eof() ? NULL : _strdup(retval.c_str()); #else return std::cin.eof() ? NULL : strdup(retval.c_str()); @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) std::vector modulepaths; // Disable deprecation warning for getenv call. -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(push) #pragma warning(disable : 4996) #endif @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) const char *usepath = getenv("CHAI_USE_PATH"); const char *modulepath = getenv("CHAI_MODULE_PATH"); -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(pop) #endif diff --git a/src/multithreaded.cpp b/src/multithreaded.cpp index 27e3e66..95c827a 100644 --- a/src/multithreaded.cpp +++ b/src/multithreaded.cpp @@ -14,8 +14,9 @@ void do_work(chaiscript::ChaiScript &c) { // c("use(\"work.chai\"); do_chai_work(num_iterations);"); - std::string name = "MyVar" + boost::lexical_cast(rand()); - c.add(chaiscript::var(5), name); + std::stringstream ss; + ss << "MyVar" << rand(); + c.add(chaiscript::var(5), ss.str()); c("use(\"work.chai\"); do_chai_work(10000);"); } diff --git a/src/reflection.cpp b/src/reflection.cpp index fe8bc3a..2bff528 100644 --- a/src/reflection.cpp +++ b/src/reflection.cpp @@ -6,7 +6,7 @@ // MSVC doesn't like that we are using C++ return types from our C declared module // but this is the best way to do it for cross platform compatibility -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(push) #pragma warning(disable : 4190) #endif @@ -96,6 +96,6 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_reflect } -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(pop) #endif diff --git a/src/stl_extra.cpp b/src/stl_extra.cpp index 59a542a..67e6c27 100644 --- a/src/stl_extra.cpp +++ b/src/stl_extra.cpp @@ -5,7 +5,7 @@ // MSVC doesn't like that we are using C++ return types from our C declared module // but this is the best way to do it for cross platform compatibility -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(push) #pragma warning(disable : 4190) #endif @@ -16,6 +16,6 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extr } -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(pop) #endif diff --git a/src/test_module.cpp b/src/test_module.cpp index 633b9de..b5b5084 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -42,7 +42,7 @@ int *get_new_int() // MSVC doesn't like that we are using C++ return types from our C declared module // but this is the best way to do it for cross platform compatibility -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(push) #pragma warning(disable : 4190) #endif @@ -82,6 +82,6 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo } -#ifdef BOOST_MSVC +#ifdef CHAISCRIPT_MSVC #pragma warning(pop) #endif