C++11 cleanups
This commit is contained in:
@@ -348,17 +348,13 @@ namespace chaiscript
|
|||||||
static std::vector<Boxed_Value> do_return_boxed_value_vector(FunctionType f,
|
static std::vector<Boxed_Value> do_return_boxed_value_vector(FunctionType f,
|
||||||
const dispatch::Proxy_Function_Base *b)
|
const dispatch::Proxy_Function_Base *b)
|
||||||
{
|
{
|
||||||
typedef decltype(std::mem_fn(f)) MemFunType;
|
auto v = (b->*f)();
|
||||||
typedef typename MemFunType::result_type Vector;
|
|
||||||
|
|
||||||
Vector v = (b->*f)();
|
|
||||||
|
|
||||||
std::vector<Boxed_Value> vbv;
|
std::vector<Boxed_Value> vbv;
|
||||||
for (typename Vector::const_iterator itr = v.begin();
|
|
||||||
itr != v.end();
|
for (const auto &o: v)
|
||||||
++itr)
|
|
||||||
{
|
{
|
||||||
vbv.push_back(const_var(*itr));
|
vbv.push_back(const_var(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
return vbv;
|
return vbv;
|
||||||
|
@@ -111,9 +111,7 @@ namespace chaiscript
|
|||||||
|
|
||||||
virtual std::vector<Const_Proxy_Function> get_contained_functions() const
|
virtual std::vector<Const_Proxy_Function> get_contained_functions() const
|
||||||
{
|
{
|
||||||
std::vector<Const_Proxy_Function> fs;
|
return {m_func};
|
||||||
fs.push_back(m_func);
|
|
||||||
return fs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -51,7 +51,7 @@ namespace chaiscript
|
|||||||
/// if the function is variadic or takes no arguments (arity of 0 or -1), the returned
|
/// if the function is variadic or takes no arguments (arity of 0 or -1), the returned
|
||||||
/// value containes exactly 1 Type_Info object: the return type
|
/// value containes exactly 1 Type_Info object: the return type
|
||||||
/// \returns the types of all parameters.
|
/// \returns the types of all parameters.
|
||||||
std::vector<Type_Info> get_param_types() const { return m_types; }
|
const std::vector<Type_Info> &get_param_types() const { return m_types; }
|
||||||
|
|
||||||
virtual bool operator==(const Proxy_Function_Base &) const = 0;
|
virtual bool operator==(const Proxy_Function_Base &) const = 0;
|
||||||
virtual bool call_match(const std::vector<Boxed_Value> &vals) const = 0;
|
virtual bool call_match(const std::vector<Boxed_Value> &vals) const = 0;
|
||||||
@@ -262,7 +262,7 @@ namespace chaiscript
|
|||||||
// For the return type
|
// For the return type
|
||||||
types.push_back(chaiscript::detail::Get_Type_Info<Boxed_Value>::get());
|
types.push_back(chaiscript::detail::Get_Type_Info<Boxed_Value>::get());
|
||||||
|
|
||||||
if (arity >= 0)
|
if (arity > 0)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < arity; ++i)
|
for (int i = 0; i < arity; ++i)
|
||||||
{
|
{
|
||||||
@@ -378,6 +378,7 @@ namespace chaiscript
|
|||||||
const std::vector<Boxed_Value> &t_args)
|
const std::vector<Boxed_Value> &t_args)
|
||||||
{
|
{
|
||||||
assert(t_f->get_arity() < 0 || t_f->get_arity() == static_cast<int>(t_args.size()));
|
assert(t_f->get_arity() < 0 || t_f->get_arity() == static_cast<int>(t_args.size()));
|
||||||
|
|
||||||
if (t_f->get_arity() < 0) { return std::vector<Type_Info>(); }
|
if (t_f->get_arity() < 0) { return std::vector<Type_Info>(); }
|
||||||
|
|
||||||
std::vector<Type_Info> types = t_f->get_param_types();
|
std::vector<Type_Info> types = t_f->get_param_types();
|
||||||
@@ -430,13 +431,11 @@ namespace chaiscript
|
|||||||
return pimpl != 0;
|
return pimpl != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual int get_arity() const
|
virtual int get_arity() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(m_types.size()) - 1;
|
return static_cast<int>(m_types.size()) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual bool call_match(const std::vector<Boxed_Value> &vals) const
|
virtual bool call_match(const std::vector<Boxed_Value> &vals) const
|
||||||
{
|
{
|
||||||
if (int(vals.size()) != get_arity())
|
if (int(vals.size()) != get_arity())
|
||||||
@@ -487,6 +486,7 @@ namespace chaiscript
|
|||||||
{
|
{
|
||||||
const Attribute_Access<T, Class> * aa
|
const Attribute_Access<T, Class> * aa
|
||||||
= dynamic_cast<const Attribute_Access<T, Class> *>(&t_func);
|
= dynamic_cast<const Attribute_Access<T, Class> *>(&t_func);
|
||||||
|
|
||||||
if (aa) {
|
if (aa) {
|
||||||
return m_attr == aa->m_attr;
|
return m_attr == aa->m_attr;
|
||||||
} else {
|
} else {
|
||||||
@@ -537,11 +537,9 @@ namespace chaiscript
|
|||||||
private:
|
private:
|
||||||
static std::vector<Type_Info> param_types()
|
static std::vector<Type_Info> param_types()
|
||||||
{
|
{
|
||||||
std::vector<Type_Info> v;
|
return {user_type<T>(), user_type<Class>()};
|
||||||
v.push_back(user_type<T>());
|
|
||||||
v.push_back(user_type<Class>());
|
|
||||||
return v;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
T Class::* m_attr;
|
T Class::* m_attr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -576,7 +574,7 @@ namespace chaiscript
|
|||||||
* function is found or throw dispatch_error if no matching function is found
|
* function is found or throw dispatch_error if no matching function is found
|
||||||
*/
|
*/
|
||||||
template<typename InItr>
|
template<typename InItr>
|
||||||
Boxed_Value dispatch(InItr begin, InItr end,
|
Boxed_Value dispatch(InItr begin, const InItr &end,
|
||||||
const std::vector<Boxed_Value> &plist)
|
const std::vector<Boxed_Value> &plist)
|
||||||
{
|
{
|
||||||
while (begin != end)
|
while (begin != end)
|
||||||
|
Reference in New Issue
Block a user