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

@@ -10,14 +10,13 @@
#include <cstdint>
#include <exception>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
#include <iterator>
#include "bad_boxed_cast.hpp"
#include "boxed_cast.hpp"
@@ -53,7 +52,7 @@ namespace chaiscript
}
template<typename T, typename = typename std::enable_if<std::is_array<T>::value>::type >
ModulePtr array(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr array(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
typedef typename std::remove_extent<T>::type ReturnType;
const auto extent = std::extent<T>::value;
@@ -95,7 +94,7 @@ namespace chaiscript
/// \tparam T The type to add a copy constructor for
/// \returns The passed in ModulePtr, or the newly constructed one if the default param is used
template<typename T>
ModulePtr copy_constructor(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr copy_constructor(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(constructor<T (const T &)>(), type);
return m;
@@ -106,7 +105,7 @@ namespace chaiscript
/// \param[in,out] m module to add comparison operators to
/// \returns the passed in ModulePtr or the newly constructed one if the default params are used.
template<typename T>
ModulePtr opers_comparison(ModulePtr m = ModulePtr(new Module()))
ModulePtr opers_comparison(ModulePtr m = std::make_shared<Module>())
{
operators::equal<T>(m);
operators::greater_than<T>(m);
@@ -127,7 +126,7 @@ namespace chaiscript
/// \sa copy_constructor
/// \sa constructor
template<typename T>
ModulePtr basic_constructors(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr basic_constructors(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(constructor<T ()>(), type);
copy_constructor<T>(type, m);
@@ -139,7 +138,7 @@ namespace chaiscript
/// \param[in] type The name of the type
/// \param[in,out] m The Module to add the constructor to
template<typename T>
ModulePtr construct_pod(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr construct_pod(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(fun(&detail::construct_pod<T>), type);
return m;
@@ -170,7 +169,7 @@ namespace chaiscript
/// Add all common functions for a POD type. All operators, and
/// common conversions
template<typename T>
ModulePtr bootstrap_pod_type(const std::string &name, ModulePtr m = ModulePtr(new Module()))
ModulePtr bootstrap_pod_type(const std::string &name, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<T>(), name);
m->add(constructor<T()>(), name);
@@ -251,7 +250,7 @@ namespace chaiscript
/// Add all arithmetic operators for PODs
static void opers_arithmetic_pod(ModulePtr m = ModulePtr(new Module()))
static void opers_arithmetic_pod(ModulePtr m = std::make_shared<Module>())
{
m->add(fun(&Boxed_Number::equals), "==");
m->add(fun(&Boxed_Number::less_than), "<");
@@ -309,16 +308,7 @@ namespace chaiscript
static bool has_guard(const Const_Proxy_Function &t_pf)
{
auto pf = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf)
{
if (pf->get_guard()) {
return true;
} else {
return false;
}
} else {
return false;
}
return pf && pf->get_guard();
}
static Const_Proxy_Function get_guard(const Const_Proxy_Function &t_pf)
@@ -372,12 +362,7 @@ namespace chaiscript
static bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
{
const auto pf = std::dynamic_pointer_cast<const chaiscript::dispatch::Dynamic_Proxy_Function>(t_pf);
if (pf && pf->get_parse_tree())
{
return true;
} else {
return false;
}
return pf && pf->get_parse_tree();
}
static chaiscript::AST_NodePtr get_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
@@ -404,7 +389,7 @@ namespace chaiscript
/// \brief perform all common bootstrap functions for std::string, void and POD types
/// \param[in,out] m Module to add bootstrapped functions to
/// \returns passed in ModulePtr, or newly created one if default argument is used
static ModulePtr bootstrap(ModulePtr m = ModulePtr(new Module()))
static ModulePtr bootstrap(ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<void>(), "void");
m->add(user_type<bool>(), "bool");
@@ -512,7 +497,7 @@ namespace chaiscript
m->add(fun(&print), "print_string");
m->add(fun(&println), "println_string");
m->add(Proxy_Function(new dispatch::Dynamic_Proxy_Function(&bind_function)), "bind");
m->add(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Dynamic_Proxy_Function>(&bind_function), "bind");
m->add(fun(&shared_ptr_unconst_clone<dispatch::Proxy_Function_Base>), "clone");
m->add(fun(&ptr_assign<std::remove_const<dispatch::Proxy_Function_Base>::type>), "=");

View File

@@ -14,10 +14,8 @@
#define CHAISCRIPT_BOOTSTRAP_STL_HPP_
#include <functional>
#include <iterator>
#include <memory>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <vector>
@@ -179,7 +177,7 @@ namespace chaiscript
/// Add Bidir_Range support for the given ContainerType
template<typename Bidir_Type>
ModulePtr input_range_type_impl(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr input_range_type_impl(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<Bidir_Type>(), type + "_Range");
@@ -232,7 +230,7 @@ namespace chaiscript
}
template<typename ContainerType>
ModulePtr input_range_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr input_range_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
detail::input_range_type_impl<Bidir_Range<ContainerType> >(type,m);
detail::input_range_type_impl<Const_Bidir_Range<ContainerType> >("Const_" + type, m);
@@ -243,7 +241,7 @@ namespace chaiscript
/// Add random_access_container concept to the given ContainerType
/// http://www.sgi.com/tech/stl/RandomAccessContainer.html
template<typename ContainerType>
ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
ModulePtr random_access_container_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
{
// cppcheck-suppress syntaxError
typedef typename ContainerType::reference(ContainerType::*indexoper)(size_t);
@@ -266,7 +264,7 @@ namespace chaiscript
/// Add assignable concept to the given ContainerType
/// http://www.sgi.com/tech/stl/Assignable.html
template<typename ContainerType>
ModulePtr assignable_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr assignable_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
copy_constructor<ContainerType>(type, m);
operators::assign<ContainerType>(m);
@@ -277,7 +275,7 @@ namespace chaiscript
/// Add container concept to the given ContainerType
/// http://www.sgi.com/tech/stl/Container.html
template<typename ContainerType>
ModulePtr container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
ModulePtr container_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
{
m->add(fun<size_t (const ContainerType *)>([](const ContainerType *a) { return a->size(); } ), "size");
m->add(fun<bool (const ContainerType *)>([](const ContainerType *a) { return a->empty(); } ), "empty");
@@ -289,7 +287,7 @@ namespace chaiscript
/// Add default constructable concept to the given Type
/// http://www.sgi.com/tech/stl/DefaultConstructible.html
template<typename Type>
ModulePtr default_constructible_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr default_constructible_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(constructor<Type ()>(), type);
return m;
@@ -301,7 +299,7 @@ namespace chaiscript
/// Add sequence concept to the given ContainerType
/// http://www.sgi.com/tech/stl/Sequence.html
template<typename ContainerType>
ModulePtr sequence_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
ModulePtr sequence_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
{
m->add(fun(&detail::insert_at<ContainerType>),
[]()->std::string{
@@ -321,7 +319,7 @@ namespace chaiscript
/// Add back insertion sequence concept to the given ContainerType
/// http://www.sgi.com/tech/stl/BackInsertionSequence.html
template<typename ContainerType>
ModulePtr back_insertion_sequence_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
ModulePtr back_insertion_sequence_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
{
typedef typename ContainerType::reference (ContainerType::*backptr)();
@@ -347,17 +345,17 @@ namespace chaiscript
/// Front insertion sequence
/// http://www.sgi.com/tech/stl/FrontInsertionSequence.html
template<typename ContainerType>
ModulePtr front_insertion_sequence_type(const std::string &, ModulePtr m = ModulePtr(new Module()))
ModulePtr front_insertion_sequence_type(const std::string &, ModulePtr m = std::make_shared<Module>())
{
typedef typename ContainerType::reference (ContainerType::*frontptr)();
typedef typename ContainerType::const_reference (ContainerType::*constfrontptr)() const;
typedef void (ContainerType::*pushptr)(typename ContainerType::const_reference);
typedef void (ContainerType::*popptr)();
typedef typename ContainerType::reference (ContainerType::*front_ptr)();
typedef typename ContainerType::const_reference (ContainerType::*const_front_ptr)() const;
typedef void (ContainerType::*push_ptr)(typename ContainerType::const_reference);
typedef void (ContainerType::*pop_ptr)();
m->add(fun(static_cast<frontptr>(&ContainerType::front)), "front");
m->add(fun(static_cast<constfrontptr>(&ContainerType::front)), "front");
m->add(fun(static_cast<front_ptr>(&ContainerType::front)), "front");
m->add(fun(static_cast<const_front_ptr>(&ContainerType::front)), "front");
m->add(fun(static_cast<pushptr>(&ContainerType::push_front)),
m->add(fun(static_cast<push_ptr>(&ContainerType::push_front)),
[]()->std::string{
if (typeid(typename ContainerType::value_type) == typeid(Boxed_Value)) {
return "push_front_ref";
@@ -366,7 +364,7 @@ namespace chaiscript
}
}());
m->add(fun(static_cast<popptr>(&ContainerType::pop_front)), "pop_front");
m->add(fun(static_cast<pop_ptr>(&ContainerType::pop_front)), "pop_front");
return m;
}
@@ -374,7 +372,7 @@ namespace chaiscript
/// bootstrap a given PairType
/// http://www.sgi.com/tech/stl/pair.html
template<typename PairType>
ModulePtr pair_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr pair_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<PairType>(), type);
@@ -397,7 +395,7 @@ namespace chaiscript
/// http://www.sgi.com/tech/stl/PairAssociativeContainer.html
template<typename ContainerType>
ModulePtr pair_associative_container_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr pair_associative_container_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
pair_type<typename ContainerType::value_type>(type + "_Pair", m);
@@ -408,7 +406,7 @@ namespace chaiscript
/// Add unique associative container concept to the given ContainerType
/// http://www.sgi.com/tech/stl/UniqueAssociativeContainer.html
template<typename ContainerType>
ModulePtr unique_associative_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module()))
ModulePtr unique_associative_container_type(const std::string &/*type*/, ModulePtr m = std::make_shared<Module>())
{
m->add(fun(detail::count<ContainerType>), "count");
@@ -435,13 +433,13 @@ namespace chaiscript
/// Add a MapType container
/// http://www.sgi.com/tech/stl/Map.html
template<typename MapType>
ModulePtr map_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr map_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<MapType>(), type);
typedef typename MapType::mapped_type &(MapType::*elemaccess)(const typename MapType::key_type &);
typedef typename MapType::mapped_type &(MapType::*elem_access)(const typename MapType::key_type &);
m->add(fun(static_cast<elemaccess>(&MapType::operator[])), "[]");
m->add(fun(static_cast<elem_access>(&MapType::operator[])), "[]");
container_type<MapType>(type, m);
default_constructible_type<MapType>(type, m);
@@ -457,7 +455,7 @@ namespace chaiscript
/// hopefully working List type
/// http://www.sgi.com/tech/stl/List.html
template<typename ListType>
ModulePtr list_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr list_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<ListType>(), type);
@@ -476,7 +474,7 @@ namespace chaiscript
/// Create a vector type with associated concepts
/// http://www.sgi.com/tech/stl/Vector.html
template<typename VectorType>
ModulePtr vector_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr vector_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<VectorType>(), type);
@@ -525,7 +523,7 @@ namespace chaiscript
/// Add a String container
/// http://www.sgi.com/tech/stl/basic_string.html
template<typename String>
ModulePtr string_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr string_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<String>(), type);
operators::addition<String>(m);
@@ -575,7 +573,7 @@ namespace chaiscript
/// Add a MapType container
/// http://www.sgi.com/tech/stl/Map.html
template<typename FutureType>
ModulePtr future_type(const std::string &type, ModulePtr m = ModulePtr(new Module()))
ModulePtr future_type(const std::string &type, ModulePtr m = std::make_shared<Module>())
{
m->add(user_type<FutureType>(), type);

View File

@@ -7,10 +7,7 @@
#ifndef CHAISCRIPT_BOXED_CAST_HPP_
#define CHAISCRIPT_BOXED_CAST_HPP_
#include <type_traits>
#include "../chaiscript_defines.hpp"
#include "../chaiscript_threading.hpp"
#include "bad_boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"

View File

@@ -7,7 +7,6 @@
#ifndef CHAISCRIPT_BOXED_CAST_HELPER_HPP_
#define CHAISCRIPT_BOXED_CAST_HELPER_HPP_
#include <functional>
#include <memory>
#include <type_traits>
@@ -34,7 +33,7 @@ namespace chaiscript
template<typename Result>
struct Cast_Helper_Inner
{
typedef typename std::reference_wrapper<typename std::add_const<Result>::type > Result_Type;
typedef std::reference_wrapper<typename std::add_const<Result>::type > Result_Type;
static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *)
{
@@ -112,9 +111,9 @@ namespace chaiscript
/// Cast_Helper_Inner for casting to a std::shared_ptr<> type
template<typename Result>
struct Cast_Helper_Inner<typename std::shared_ptr<Result> >
struct Cast_Helper_Inner<std::shared_ptr<Result> >
{
typedef typename std::shared_ptr<Result> Result_Type;
typedef std::shared_ptr<Result> Result_Type;
static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *)
{
@@ -124,9 +123,9 @@ namespace chaiscript
/// Cast_Helper_Inner for casting to a std::shared_ptr<const> type
template<typename Result>
struct Cast_Helper_Inner<typename std::shared_ptr<const Result> >
struct Cast_Helper_Inner<std::shared_ptr<const Result> >
{
typedef typename std::shared_ptr<const Result> Result_Type;
typedef std::shared_ptr<const Result> Result_Type;
static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *)
{

View File

@@ -26,7 +26,7 @@ namespace chaiscript
{
namespace exception
{
struct arithmetic_error : public std::runtime_error
struct arithmetic_error : std::runtime_error
{
arithmetic_error(const std::string& reason) : std::runtime_error("Arithmetic error: " + reason) {}
arithmetic_error(const arithmetic_error &) = default;
@@ -60,7 +60,7 @@ namespace chaiscript
{
private:
template<typename T>
static void check_divide_by_zero(T t, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
static void check_divide_by_zero(T t, typename std::enable_if<std::is_integral<T>::value>::type* = nullptr)
{
#ifndef CHAISCRIPT_NO_PROTECT_DIVIDEBYZERO
if (t == 0) {
@@ -70,7 +70,7 @@ namespace chaiscript
}
template<typename T>
static void check_divide_by_zero(T, typename std::enable_if<std::is_floating_point<T>::value>::type* = 0)
static void check_divide_by_zero(T, typename std::enable_if<std::is_floating_point<T>::value>::type* = nullptr)
{
}

View File

@@ -7,12 +7,10 @@
#ifndef CHAISCRIPT_BOXED_VALUE_HPP_
#define CHAISCRIPT_BOXED_VALUE_HPP_
#include <functional>
#include <map>
#include <memory>
#include <type_traits>
#include "../chaiscript_threading.hpp"
#include "../chaiscript_defines.hpp"
#include "any.hpp"
#include "type_info.hpp"

View File

@@ -8,10 +8,8 @@
#define CHAISCRIPT_DISPATCHKIT_HPP_
#include <algorithm>
#include <cassert>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
@@ -280,8 +278,8 @@ namespace chaiscript
virtual bool operator==(const dispatch::Proxy_Function_Base &rhs) const CHAISCRIPT_OVERRIDE
{
try {
const auto &dispatchfun = dynamic_cast<const Dispatch_Function &>(rhs);
return m_funcs == dispatchfun.m_funcs;
const auto &dispatch_fun = dynamic_cast<const Dispatch_Function &>(rhs);
return m_funcs == dispatch_fun.m_funcs;
} catch (const std::bad_cast &) {
return false;
}
@@ -1138,12 +1136,7 @@ namespace chaiscript
{
if (dynamic_lhs->get_guard())
{
if (dynamic_rhs->get_guard())
{
return false;
} else {
return true;
}
return dynamic_rhs->get_guard() ? false : true;
} else {
return false;
}

View File

@@ -7,19 +7,11 @@
#ifndef CHAISCRIPT_DYNAMIC_OBJECT_HPP_
#define CHAISCRIPT_DYNAMIC_OBJECT_HPP_
#include <cassert>
#include <map>
#include <memory>
#include <string>
#include <typeinfo>
#include <utility>
#include <vector>
#include "../chaiscript_defines.hpp"
#include "boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Type_Conversions;

View File

@@ -213,12 +213,7 @@ namespace chaiscript
virtual bool operator==(const Proxy_Function_Base &f) const CHAISCRIPT_OVERRIDE
{
const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f);
if (dc)
{
return dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func);
} else {
return false;
}
return dc && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func);
}
virtual bool call_match(const std::vector<Boxed_Value> &vals, const Type_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE

View File

@@ -8,7 +8,6 @@
#define CHAISCRIPT_FUNCTION_CALL_HPP_
#include <functional>
#include <iostream>
#include <string>
#include <vector>

View File

@@ -7,7 +7,6 @@
#ifndef CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_
#define CHAISCRIPT_FUNCTION_CALL_DETAIL_HPP_
#include <algorithm>
#include <functional>
#include <memory>
#include <string>

View File

@@ -9,14 +9,11 @@
#include <functional>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include <type_traits>
#include "boxed_number.hpp"
#include "boxed_value.hpp"
#include "type_info.hpp"
namespace chaiscript {
class Boxed_Number;

View File

@@ -229,231 +229,231 @@ namespace chaiscript
template<typename T>
ModulePtr assign(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign<T &, const T&>), "=");
return m;
}
template<typename T>
ModulePtr assign_bitwise_and(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_bitwise_and(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_bitwise_and<T &, const T&>), "&=");
return m;
}
template<typename T>
ModulePtr assign_xor(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_xor(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_xor<T &, const T&>), "^=");
return m;
}
template<typename T>
ModulePtr assign_bitwise_or(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_bitwise_or(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_bitwise_or<T &, const T&>), "|=");
return m;
}
template<typename T>
ModulePtr assign_difference(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_difference(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_difference<T &, const T&>), "-=");
return m;
}
template<typename T>
ModulePtr assign_left_shift(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_left_shift(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_left_shift<T &, const T&>), "<<=");
return m;
}
template<typename T>
ModulePtr assign_product(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_product(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_product<T &, const T&>), "*=");
return m;
}
template<typename T>
ModulePtr assign_quotient(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_quotient(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_quotient<T &, const T&>), "/=");
return m;
}
template<typename T>
ModulePtr assign_remainder(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_remainder(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_remainder<T &, const T&>), "%=");
return m;
}
template<typename T>
ModulePtr assign_right_shift(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_right_shift(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_right_shift<T &, const T&>), ">>=");
return m;
}
template<typename T>
ModulePtr assign_sum(ModulePtr m = ModulePtr(new Module()))
ModulePtr assign_sum(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::assign_sum<T &, const T&>), "+=");
return m;
}
template<typename T>
ModulePtr prefix_decrement(ModulePtr m = ModulePtr(new Module()))
ModulePtr prefix_decrement(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::prefix_decrement<T &>), "--");
return m;
}
template<typename T>
ModulePtr prefix_increment(ModulePtr m = ModulePtr(new Module()))
ModulePtr prefix_increment(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::prefix_increment<T &>), "++");
return m;
}
template<typename T>
ModulePtr equal(ModulePtr m = ModulePtr(new Module()))
ModulePtr equal(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::equal<const T&, const T&>), "==");
return m;
}
template<typename T>
ModulePtr greater_than(ModulePtr m = ModulePtr(new Module()))
ModulePtr greater_than(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::greater_than<const T&, const T&>), ">");
return m;
}
template<typename T>
ModulePtr greater_than_equal(ModulePtr m = ModulePtr(new Module()))
ModulePtr greater_than_equal(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::greater_than_equal<const T&, const T&>), ">=");
return m;
}
template<typename T>
ModulePtr less_than(ModulePtr m = ModulePtr(new Module()))
ModulePtr less_than(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::less_than<const T&, const T&>), "<");
return m;
}
template<typename T>
ModulePtr less_than_equal(ModulePtr m = ModulePtr(new Module()))
ModulePtr less_than_equal(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::less_than_equal<const T&, const T&>), "<=");
return m;
}
template<typename T>
ModulePtr logical_compliment(ModulePtr m = ModulePtr(new Module()))
ModulePtr logical_compliment(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::logical_compliment<const T &>), "!");
return m;
}
template<typename T>
ModulePtr not_equal(ModulePtr m = ModulePtr(new Module()))
ModulePtr not_equal(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::not_equal<const T &, const T &>), "!=");
return m;
}
template<typename T>
ModulePtr addition(ModulePtr m = ModulePtr(new Module()))
ModulePtr addition(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::addition<const T &, const T &>), "+");
return m;
}
template<typename T>
ModulePtr unary_plus(ModulePtr m = ModulePtr(new Module()))
ModulePtr unary_plus(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::unary_plus<const T &>), "+");
return m;
}
template<typename T>
ModulePtr subtraction(ModulePtr m = ModulePtr(new Module()))
ModulePtr subtraction(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::subtraction<const T &, const T &>), "-");
return m;
}
template<typename T>
ModulePtr unary_minus(ModulePtr m = ModulePtr(new Module()))
ModulePtr unary_minus(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::unary_minus<const T &>), "-");
return m;
}
template<typename T>
ModulePtr bitwise_and(ModulePtr m = ModulePtr(new Module()))
ModulePtr bitwise_and(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::bitwise_and<const T &, const T &>), "&");
return m;
}
template<typename T>
ModulePtr bitwise_compliment(ModulePtr m = ModulePtr(new Module()))
ModulePtr bitwise_compliment(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::bitwise_compliment<const T &>), "~");
return m;
}
template<typename T>
ModulePtr bitwise_xor(ModulePtr m = ModulePtr(new Module()))
ModulePtr bitwise_xor(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::bitwise_xor<const T &, const T &>), "^");
return m;
}
template<typename T>
ModulePtr bitwise_or(ModulePtr m = ModulePtr(new Module()))
ModulePtr bitwise_or(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::bitwise_or<const T &, const T &>), "|");
return m;
}
template<typename T>
ModulePtr division(ModulePtr m = ModulePtr(new Module()))
ModulePtr division(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::division<const T &, const T &>), "/");
return m;
}
template<typename T>
ModulePtr left_shift(ModulePtr m = ModulePtr(new Module()))
ModulePtr left_shift(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::left_shift<const T &, const T &>), "<<");
return m;
}
template<typename T>
ModulePtr multiplication(ModulePtr m = ModulePtr(new Module()))
ModulePtr multiplication(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::multiplication<const T &, const T &>), "*");
return m;
}
template<typename T>
ModulePtr remainder(ModulePtr m = ModulePtr(new Module()))
ModulePtr remainder(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::remainder<const T &, const T &>), "%");
return m;
}
template<typename T>
ModulePtr right_shift(ModulePtr m = ModulePtr(new Module()))
ModulePtr right_shift(ModulePtr m = std::make_shared<Module>())
{
m->add(chaiscript::fun(&detail::right_shift<const T &, const T &>), ">>");
return m;

View File

@@ -9,7 +9,6 @@
#define CHAISCRIPT_PROXY_FUNCTIONS_HPP_
#include <algorithm>
#include <cassert>
#include <functional>
#include <memory>
@@ -20,7 +19,6 @@
#include "../chaiscript_defines.hpp"
#include "boxed_cast.hpp"
#include "boxed_cast_helper.hpp"
#include "boxed_value.hpp"
#include "proxy_functions_detail.hpp"
#include "type_info.hpp"
@@ -582,7 +580,7 @@ namespace chaiscript
}
protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions &t_conversions) const
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
return detail::Do_Call<typename std::function<Func>::result_type>::go(m_f, params, t_conversions);
}
@@ -638,12 +636,12 @@ namespace chaiscript
return m_f.get();
}
virtual void assign(const std::shared_ptr<const Proxy_Function_Base> &t_rhs) {
virtual void assign(const std::shared_ptr<const Proxy_Function_Base> &t_rhs) CHAISCRIPT_OVERRIDE {
m_f.get() = dispatch::functor<Func>(t_rhs, nullptr);
}
protected:
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions &t_conversions) const
virtual Boxed_Value do_call(const std::vector<Boxed_Value> &params, const Type_Conversions &t_conversions) const CHAISCRIPT_OVERRIDE
{
return detail::Do_Call<typename std::function<Func>::result_type>::go(m_f.get(), params, t_conversions);
}

View File

@@ -7,10 +7,8 @@
#ifndef CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_
#define CHAISCRIPT_PROXY_FUNCTIONS_DETAIL_HPP_
#include <algorithm>
#include <functional>
#include <stdexcept>
#include <string>
#include <vector>
#include "../chaiscript_defines.hpp"

View File

@@ -11,7 +11,6 @@
#include <type_traits>
#include "bind_first.hpp"
#include "dispatchkit.hpp"
#include "proxy_functions.hpp"
namespace chaiscript

View File

@@ -7,9 +7,7 @@
#ifndef CHAISCRIPT_TYPE_INFO_HPP_
#define CHAISCRIPT_TYPE_INFO_HPP_
#include <functional>
#include <memory>
#include <string>
#include <type_traits>
#include <typeinfo>
@@ -31,8 +29,8 @@ namespace chaiscript
{
public:
CHAISCRIPT_CONSTEXPR Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bareti)
: m_type_info(t_ti), m_bare_type_info(t_bareti),
bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti)
: m_type_info(t_ti), m_bare_type_info(t_bare_ti),
m_is_const(t_is_const), m_is_reference(t_is_reference), m_is_pointer(t_is_pointer),
m_is_void(t_is_void), m_is_arithmetic(t_is_arithmetic),
m_is_undef(false)

View File

@@ -9,8 +9,6 @@
#include <string>
#include "../dispatchkit/dispatchkit.hpp"
namespace chaiscript
{

View File

@@ -78,7 +78,7 @@ namespace chaiscript
{
/// Errors generated during parsing or evaluation
struct eval_error : public std::runtime_error {
struct eval_error : std::runtime_error {
std::string reason;
File_Position start_position;
File_Position end_position;
@@ -230,8 +230,7 @@ namespace chaiscript
if (f)
{
std::shared_ptr<const dispatch::Dynamic_Proxy_Function> dynfunguard
= std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(f);
auto dynfunguard = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(f);
if (dynfunguard)
{
retval += " : " + format_guard(dynfunguard->get_parse_tree());
@@ -393,7 +392,7 @@ namespace chaiscript
/// Errors generated when loading a file
struct file_not_found_error : public std::runtime_error {
struct file_not_found_error : std::runtime_error {
file_not_found_error(const std::string &t_filename) CHAISCRIPT_NOEXCEPT
: std::runtime_error("File Not Found: " + t_filename)
{ }
@@ -488,8 +487,8 @@ namespace chaiscript
private:
// Copy and assignment explicitly unimplemented
AST_Node(const AST_Node &);
AST_Node& operator=(const AST_Node &);
AST_Node(const AST_Node &) = delete;
AST_Node& operator=(const AST_Node &) = delete;
};

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)
{

View File

@@ -7,8 +7,6 @@
#ifndef CHAISCRIPT_EVAL_HPP_
#define CHAISCRIPT_EVAL_HPP_
#include <assert.h>
#include <cstdlib>
#include <exception>
#include <functional>
#include <limits>
@@ -21,7 +19,6 @@
#include "../chaiscript_defines.hpp"
#include "../dispatchkit/boxed_cast.hpp"
#include "../dispatchkit/boxed_cast_helper.hpp"
#include "../dispatchkit/boxed_number.hpp"
#include "../dispatchkit/boxed_value.hpp"
#include "../dispatchkit/dispatchkit.hpp"
@@ -821,12 +818,12 @@ namespace chaiscript
const auto &lambda_node = this->children.back();
return Boxed_Value(Proxy_Function(new dispatch::Dynamic_Proxy_Function(
return Boxed_Value(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Dynamic_Proxy_Function>(
[&t_ss, lambda_node, param_names, captures](const std::vector<Boxed_Value> &t_params)
{
return detail::eval_function(t_ss, lambda_node, param_names, t_params, captures);
},
static_cast<int>(numparams), lambda_node, param_types)));
static_cast<int>(numparams), lambda_node, param_types));
}
@@ -882,23 +879,23 @@ namespace chaiscript
std::shared_ptr<dispatch::Dynamic_Proxy_Function> guard;
if (guardnode) {
guard = std::shared_ptr<dispatch::Dynamic_Proxy_Function>
(new dispatch::Dynamic_Proxy_Function([&t_ss, guardnode, t_param_names](const std::vector<Boxed_Value> &t_params)
guard = std::make_shared<dispatch::Dynamic_Proxy_Function>
([&t_ss, guardnode, t_param_names](const std::vector<Boxed_Value> &t_params)
{
return detail::eval_function(t_ss, guardnode, t_param_names, t_params);
}, static_cast<int>(numparams), guardnode));
}, static_cast<int>(numparams), guardnode);
}
try {
const std::string & l_function_name = this->children[0]->text;
const std::string & l_annotation = this->annotation?this->annotation->text:"";
const auto & func_node = this->children.back();
t_ss.add(Proxy_Function
(new dispatch::Dynamic_Proxy_Function([&t_ss, guardnode, func_node, t_param_names](const std::vector<Boxed_Value> &t_params)
t_ss.add(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Dynamic_Proxy_Function>
([&t_ss, guardnode, func_node, t_param_names](const std::vector<Boxed_Value> &t_params)
{
return detail::eval_function(t_ss, func_node, t_param_names, t_params);
}, static_cast<int>(numparams), this->children.back(),
param_types, l_annotation, guard)), l_function_name);
param_types, l_annotation, guard), l_function_name);
}
catch (const exception::reserved_word_error &e) {
throw exception::eval_error("Reserved word used as function name '" + e.word() + "'");
@@ -1330,7 +1327,7 @@ namespace chaiscript
end_point = this->children.size() - 1;
}
for (size_t i = 1; i < end_point; ++i) {
chaiscript::eval::detail::Scope_Push_Pop catchscope(t_ss);
chaiscript::eval::detail::Scope_Push_Pop catch_scope(t_ss);
AST_NodePtr catch_block = this->children[i];
if (catch_block->children.size() == 1) {

View File

@@ -10,7 +10,6 @@
#include <cstdint>
#include <cstring>
#include <exception>
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
@@ -257,12 +256,12 @@ namespace chaiscript
for (auto &c : p->children)
{
if (c->identifier == AST_Node_Type::Def && c->children.size() > 0) {
auto &lastchild = c->children.back();
if (lastchild->identifier == AST_Node_Type::Block) {
auto &blocklastchild = lastchild->children.back();
if (blocklastchild->identifier == AST_Node_Type::Return) {
if (blocklastchild->children.size() == 1) {
blocklastchild = blocklastchild->children[0];
auto &last_child = c->children.back();
if (last_child->identifier == AST_Node_Type::Block) {
auto &block_last_child = last_child->children.back();
if (block_last_child->identifier == AST_Node_Type::Return) {
if (block_last_child->children.size() == 1) {
block_last_child = block_last_child->children[0];
}
}
}
@@ -789,30 +788,26 @@ namespace chaiscript
}
/// Reads (and potentially captures) an identifier from input
bool Id(const bool t_capture = false) {
bool Id() {
SkipWS();
if (!t_capture) {
return Id_();
const auto start = m_input_pos;
const auto prev_col = m_col;
const auto prev_line = m_line;
if (Id_()) {
m_match_stack.push_back(chaiscript::make_shared<AST_Node, eval::Id_AST_Node>(
[&]()->std::string{
if (*start == '`') {
//Id Literal
return std::string(start+1, m_input_pos-1);
} else {
return std::string(start, m_input_pos);
}
}(),
m_filename, prev_line, prev_col, m_line, m_col));
return true;
} else {
const auto start = m_input_pos;
const auto prev_col = m_col;
const auto prev_line = m_line;
if (Id_()) {
m_match_stack.push_back(chaiscript::make_shared<AST_Node, eval::Id_AST_Node>(
[&]()->std::string{
if (*start == '`') {
//Id Literal
return std::string(start+1, m_input_pos-1);
} else {
return std::string(start, m_input_pos);
}
}(),
m_filename, prev_line, prev_col, m_line, m_col));
return true;
} else {
return false;
}
return false;
}
}
@@ -821,14 +816,14 @@ namespace chaiscript
const auto prev_stack_top = m_match_stack.size();
SkipWS();
if (!Id(true)) {
if (!Id()) {
return false;
}
SkipWS();
if (t_type_allowed) {
Id(true);
Id();
}
build_match(chaiscript::make_shared<AST_Node, eval::Arg_AST_Node>(), prev_stack_top);
@@ -1426,7 +1421,7 @@ namespace chaiscript
if (Keyword("def")) {
retval = true;
if (!Id(true)) {
if (!Id()) {
throw exception::eval_error("Missing function name in definition", File_Position(m_line, m_col), *m_filename);
}
@@ -1436,7 +1431,7 @@ namespace chaiscript
//We're now a method
is_method = true;
if (!Id(true)) {
if (!Id()) {
throw exception::eval_error("Missing method name in definition", File_Position(m_line, m_col), *m_filename);
}
}
@@ -1609,7 +1604,7 @@ namespace chaiscript
if (Keyword("class")) {
retval = true;
if (!Id(true)) {
if (!Id()) {
throw exception::eval_error("Missing class name in definition", File_Position(m_line, m_col), *m_filename);
}
@@ -1890,7 +1885,7 @@ namespace chaiscript
const auto prev_stack_top = m_match_stack.size();
if (Lambda() || Num(true) || Quoted_String(true) || Single_Quoted_String(true) ||
Paren_Expression() || Inline_Container() || Id(true))
Paren_Expression() || Inline_Container() || Id())
{
retval = true;
bool has_more = true;
@@ -1931,7 +1926,7 @@ namespace chaiscript
}
else if (Symbol(".", true)) {
has_more = true;
if (!(Id(true))) {
if (!(Id())) {
throw exception::eval_error("Incomplete array access", File_Position(m_line, m_col), *m_filename);
}
@@ -1952,7 +1947,7 @@ namespace chaiscript
if (t_class_context && (Keyword("attr") || Keyword("auto") || Keyword("var"))) {
retval = true;
if (!Id(true)) {
if (!Id()) {
throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename);
}
@@ -1960,7 +1955,7 @@ namespace chaiscript
} else if (Keyword("auto") || Keyword("var")) {
retval = true;
if (!(Reference() || Id(true))) {
if (!(Reference() || Id())) {
throw exception::eval_error("Incomplete variable declaration", File_Position(m_line, m_col), *m_filename);
}
@@ -1968,13 +1963,13 @@ namespace chaiscript
} else if (Keyword("attr")) {
retval = true;
if (!Id(true)) {
if (!Id()) {
throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename);
}
if (!Symbol("::", false)) {
throw exception::eval_error("Incomplete attribute declaration", File_Position(m_line, m_col), *m_filename);
}
if (!Id(true)) {
if (!Id()) {
throw exception::eval_error("Missing attribute name in definition", File_Position(m_line, m_col), *m_filename);
}
@@ -2036,7 +2031,7 @@ namespace chaiscript
const auto prev_stack_top = m_match_stack.size();
if (Symbol("&", false)) {
if (!Id(true)) {
if (!Id()) {
throw exception::eval_error("Incomplete '&' expression", File_Position(m_line, m_col), *m_filename);
}
@@ -2071,11 +2066,7 @@ namespace chaiscript
/// Parses any of a group of 'value' style ast_node groups from input
bool Value() {
if (Var_Decl() || Dot_Fun_Array() || Prefix()) {
return true;
} else {
return false;
}
return Var_Decl() || Dot_Fun_Array() || Prefix();
}
bool Operator_Helper(const size_t t_precedence) {

View File

@@ -309,7 +309,7 @@ class Range
/// \brief Moves the front pointer forward one
///
/// \post front() returne the element at front() + 1;
/// \post front() returns the element at front() + 1;
void pop_front();
};
@@ -340,7 +340,7 @@ class Const_Range
/// \brief Moves the front pointer forward one
///
/// \post front() returne the element at front() + 1;
/// \post front() returns the element at front() + 1;
void pop_front();
};

View File

@@ -38,8 +38,8 @@ namespace chaiscript
/// { {fun(&test::function), "function"},
/// {fun(&test::function2), "function2"},
/// {fun(&test::function3), "function3"},
/// {fun(static_cast<std::string(test::*)(double)>(&test::functionoverload)), "functionoverload" },
/// {fun(static_cast<std::string(test::*)(int)>(&test::functionoverload)), "functionoverload" },
/// {fun(static_cast<std::string(test::*)(double)>(&test::function_overload)), "function_overload" },
/// {fun(static_cast<std::string(test::*)(int)>(&test::function_overload)), "function_overload" },
/// {fun(static_cast<test & (test::*)(const test &)>(&test::operator=)), "=" }
/// }
/// );

View File

@@ -35,7 +35,7 @@ class TestBaseType
std::function<int (int)> func_member;
private:
TestBaseType &operator=(const TestBaseType &);
TestBaseType &operator=(const TestBaseType &) = delete;
};
class Type2
@@ -82,7 +82,7 @@ class TestDerivedType : public TestBaseType
int derived_only_func() { return 19; }
private:
TestDerivedType &operator=(const TestDerivedType &);
TestDerivedType &operator=(const TestDerivedType &) = delete;
};
class TestMoreDerivedType : public TestDerivedType

View File

@@ -1,6 +1,5 @@
#include <iostream>
#include <list>
#include <algorithm>
#include <chaiscript/chaiscript.hpp>
@@ -25,7 +24,7 @@ void do_work(chaiscript::ChaiScript &c, int id)
ss.str("");
ss << id;
c.use("multithreaded_work.inc");
c("do_chai_work(40000, " + ss.str() + ");");
c("do_chai_work(4000, " + ss.str() + ");");
} catch (const std::exception &e) {
std::cout << "exception: " << e.what() << " thread: " << id;
}
@@ -74,7 +73,7 @@ int main()
for (int i = 0; i < num_threads; ++i)
{
threads.push_back(std::shared_ptr<std::thread>(new std::thread(do_work, std::ref(chai), i)));
threads.push_back(std::make_shared<std::thread>(do_work, std::ref(chai), i));
}
for (int i = 0; i < num_threads; ++i)