Merge branch 'develop' into smaller_make_shared

And also apply cleanups suggested from resharper

Conflicts:
	include/chaiscript/language/chaiscript_parser.hpp
This commit is contained in:
Jason Turner
2015-04-27 11:55:12 -06:00
26 changed files with 168 additions and 242 deletions

View File

@@ -8,8 +8,6 @@
#define CHAISCRIPT_ENGINE_HPP_
#include <cassert>
#include <cstring>
#include <algorithm>
#include <exception>
#include <fstream>
#include <functional>
@@ -18,7 +16,6 @@
#include <mutex>
#include <set>
#include <stdexcept>
#include <string>
#include <vector>
#include "../chaiscript_defines.hpp"
@@ -166,11 +163,11 @@ namespace chaiscript
static std::string get_error_message(DWORD t_err)
{
typedef LPTSTR StringType;
#if defined(_UNICODE) || defined(UNICODE)
typedef LPWSTR StringType;
std::wstring retval = L"Unknown Error";
#else
typedef LPSTR StringType;
std::string retval = "Unknown Error";
#endif
StringType lpMsgBuf = nullptr;
@@ -182,7 +179,7 @@ namespace chaiscript
NULL,
t_err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(StringType)&lpMsgBuf,
reinterpret_cast<StringType>(&lpMsgBuf),
0, NULL ) != 0 && lpMsgBuf)
{
retval = lpMsgBuf;
@@ -264,8 +261,8 @@ namespace chaiscript
std::map<std::string, detail::Loadable_Module_Ptr> m_loaded_modules;
std::set<std::string> m_active_loaded_modules;
std::vector<std::string> m_modulepaths;
std::vector<std::string> m_usepaths;
std::vector<std::string> m_module_paths;
std::vector<std::string> m_use_paths;
chaiscript::detail::Dispatch_Engine m_engine;
@@ -299,7 +296,7 @@ namespace chaiscript
/// Evaluates the given file and looks in the 'use' paths
const Boxed_Value internal_eval_file(const std::string &t_filename) {
for (const auto &path : m_usepaths)
for (const auto &path : m_use_paths)
{
try {
const auto appendedpath = path + t_filename;
@@ -363,10 +360,10 @@ namespace chaiscript
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::function_exists, std::ref(m_engine)), "function_exists");
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::get_function_objects, std::ref(m_engine)), "get_functions");
m_engine.add(fun(&chaiscript::detail::Dispatch_Engine::get_scripting_objects, std::ref(m_engine)), "get_objects");
m_engine.add(Proxy_Function(new dispatch::Dynamic_Proxy_Function(
m_engine.add(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Dynamic_Proxy_Function>(
[this](const std::vector<Boxed_Value> &t_params) {
return m_engine.call_exists(t_params);
})), "call_exists");
}), "call_exists");
// m_engine.add(fun<Boxed_Value (const dispatch::Proxy_Function_Base *, const std::vector<Boxed_Value> &)>(std::bind(&chaiscript::dispatch::Proxy_Function_Base::operator(), std::placeholders::_1, std::placeholders::_2, std::ref(m_engine.conversions()))), "call");
//
@@ -441,16 +438,16 @@ namespace chaiscript
ChaiScript(const ModulePtr &t_lib,
std::vector<std::string> t_modulepaths = std::vector<std::string>(),
std::vector<std::string> t_usepaths = std::vector<std::string>())
: m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths))
: m_module_paths(std::move(t_modulepaths)), m_use_paths(std::move(t_usepaths))
{
if (m_modulepaths.empty())
if (m_module_paths.empty())
{
m_modulepaths.push_back("");
m_module_paths.push_back("");
}
if (m_usepaths.empty())
if (m_use_paths.empty())
{
m_usepaths.push_back("");
m_use_paths.push_back("");
}
build_eval_system(t_lib);
@@ -465,16 +462,16 @@ namespace chaiscript
/// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file
ChaiScript( std::vector<std::string> t_modulepaths = std::vector<std::string>(),
std::vector<std::string> t_usepaths = std::vector<std::string>())
: m_modulepaths(std::move(t_modulepaths)), m_usepaths(std::move(t_usepaths))
: m_module_paths(std::move(t_modulepaths)), m_use_paths(std::move(t_usepaths))
{
if (m_modulepaths.empty())
if (m_module_paths.empty())
{
m_modulepaths.push_back("");
m_module_paths.push_back("");
}
if (m_usepaths.empty())
if (m_use_paths.empty())
{
m_usepaths.push_back("");
m_use_paths.push_back("");
}
#if defined(_POSIX_VERSION) && !defined(__CYGWIN__)
@@ -507,7 +504,7 @@ namespace chaiscript
dllpath = std::string(&buf.front(), pathlen);
}
m_modulepaths.insert(m_modulepaths.begin(), dllpath+"/");
m_module_paths.insert(m_module_paths.begin(), dllpath+"/");
}
#endif
@@ -559,7 +556,7 @@ namespace chaiscript
/// \param[in] t_filename Filename to load and evaluate
Boxed_Value use(const std::string &t_filename)
{
for (const auto &path : m_usepaths)
for (const auto &path : m_use_paths)
{
try {
const auto appendedpath = path + t_filename;
@@ -758,7 +755,7 @@ namespace chaiscript
std::vector<std::string> postfixes{".dll", ".so", ".bundle", ""};
for (auto & elem : m_modulepaths)
for (auto & elem : m_module_paths)
{
for (auto & prefix : prefixes)
{