Merge branch 'master' into ChaiScript_5_0_CPP_11
Conflicts: include/chaiscript/dispatchkit/bind_first.hpp include/chaiscript/dispatchkit/bootstrap_stl.hpp include/chaiscript/dispatchkit/boxed_cast.hpp include/chaiscript/dispatchkit/function_call_detail.hpp include/chaiscript/dispatchkit/proxy_functions_detail.hpp
This commit is contained in:
commit
57c6d72a79
@ -148,82 +148,6 @@ namespace chaiscript
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
int return_int_impl(const std::function<typename T::size_type (const T *)> &t_func, const T *t_obj)
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4267)
|
||||
#endif
|
||||
return t_func(t_obj);
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::function<int (const T *)> return_int(size_t (T::*t_func)() const)
|
||||
{
|
||||
return std::bind(&return_int_impl<T>, std::function<size_t (const T *)>(std::mem_fn(t_func)), std::placeholders::_1);
|
||||
}
|
||||
|
||||
template<typename T, typename P1>
|
||||
int return_int_impl(const std::function<typename T::size_type (const T *, P1)> &t_func, const T *t_obj, P1 p1)
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4267)
|
||||
#endif
|
||||
return t_func(t_obj, p1);
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T, typename P1>
|
||||
int return_int_impl_non_const(const std::function<typename T::size_type (T *, P1)> &t_func, T *t_obj, P1 p1)
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4267)
|
||||
#endif
|
||||
return t_func(t_obj, p1);
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T, typename P1>
|
||||
std::function<int (const T *, P1)> return_int(size_t (T::*t_func)(P1) const)
|
||||
{
|
||||
return std::bind(&return_int_impl<T, P1>, std::function<size_t (const T *, P1)>(std::mem_fn(t_func)), std::placeholders::_1, std::placeholders::_2);
|
||||
}
|
||||
|
||||
template<typename T, typename P1>
|
||||
std::function<int (T *, P1)> return_int(size_t (T::*t_func)(P1) )
|
||||
{
|
||||
return std::bind(&return_int_impl_non_const<T, P1>, std::function<size_t (T*, P1)>(std::mem_fn(t_func)), std::placeholders::_1, std::placeholders::_2);
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename P1, typename P2>
|
||||
int return_int_impl(const std::function<typename T::size_type (const T *, P1, P2)> &t_func, const T *t_obj, P1 p1, P2 p2)
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4267)
|
||||
#endif
|
||||
return t_func(t_obj, p1, p2);
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T, typename P1, typename P2>
|
||||
std::function<int (const T *, P1, P2)> return_int(size_t (T::*t_func)(P1, P2) const)
|
||||
{
|
||||
return std::bind(&return_int_impl<T, P1, P2>, std::function<size_t (const T *, P1, P2)>(std::mem_fn(t_func)), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void insert(T &t_target, const T &t_other)
|
||||
@ -483,11 +407,9 @@ namespace chaiscript
|
||||
{
|
||||
m->add(fun<int (const ContainerType *, const typename ContainerType::key_type &)>(&ContainerType::count), "count");
|
||||
|
||||
typedef size_t (ContainerType::*erase_ptr)(const typename ContainerType::key_type &);
|
||||
|
||||
typedef size_t (ContainerType::*erase)(const typename ContainerType::key_type &);
|
||||
erase eraseptr(&ContainerType::erase);
|
||||
|
||||
m->add(fun(std::function<int (ContainerType *, const typename ContainerType::key_type &)>(detail::return_int(eraseptr))), "erase");
|
||||
m->add(fun<int (ContainerType *, const typename ContainerType::key_type &)>(static_cast<erase_ptr>(&ContainerType::erase)), "erase");
|
||||
|
||||
m->add(fun(&detail::insert<ContainerType>), "insert");
|
||||
|
||||
@ -621,6 +543,7 @@ namespace chaiscript
|
||||
|
||||
typedef std::function<int (const String *, const String &, int)> find_func;
|
||||
|
||||
|
||||
m->add(fun(find_func( [](const String *s, const String &f, int pos) { return s->find(f, pos); } )), "find");
|
||||
m->add(fun(find_func( [](const String *s, const String &f, int pos) { return s->rfind(f, pos); } ) ), "rfind");
|
||||
m->add(fun(find_func( [](const String *s, const String &f, int pos) { return s->find_first_of(f, pos); } ) ), "find_first_of");
|
||||
@ -630,7 +553,7 @@ namespace chaiscript
|
||||
|
||||
m->add(fun( std::function<const char *(const String *)>( [](const String *s) { return s->c_str(); } ) ), "c_str");
|
||||
m->add(fun( std::function<const char *(const String *)>( [](const String *s) { return s->data(); } ) ), "data");
|
||||
|
||||
m->add(fun( std::function<String (const String *, int, int)>( [](const String *s, int pos, int len) { return s->substr(pos, len); } ) ), "substr");
|
||||
|
||||
return m;
|
||||
}
|
||||
|
@ -143,7 +143,6 @@ namespace chaiscript
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
11
unittests/number_suffixes.chai
Normal file
11
unittests/number_suffixes.chai
Normal file
@ -0,0 +1,11 @@
|
||||
assert_equal(true, int_type.bare_equal(1.get_type_info()))
|
||||
assert_equal(true, unsigned_int_type.bare_equal(1u.get_type_info()))
|
||||
assert_equal(true, unsigned_long_type.bare_equal(1lu.get_type_info()))
|
||||
assert_equal(true, long_type.bare_equal(1l.get_type_info()))
|
||||
assert_equal(true, int64_t_type.bare_equal(1ll.get_type_info()))
|
||||
assert_equal(true, uint64_t_type.bare_equal(1ull.get_type_info()))
|
||||
|
||||
assert_equal(true, double_type.bare_equal(1.6.get_type_info()))
|
||||
assert_equal(true, float_type.bare_equal(1.6f.get_type_info()))
|
||||
assert_equal(true, long_double_type.bare_equal(1.6l.get_type_info()))
|
||||
|
1
unittests/string_substr.chai
Normal file
1
unittests/string_substr.chai
Normal file
@ -0,0 +1 @@
|
||||
assert_equal("3ab", "123abab".substr(2,3))
|
Loading…
x
Reference in New Issue
Block a user