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)