Initial work towards function variables. Existing dispatch works, but lookup of function variables is still untested
This commit is contained in:
@@ -206,6 +206,16 @@ struct Cast_Helper<Result &>
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Result>
|
||||
struct Cast_Helper<typename boost::shared_ptr<Result> >
|
||||
{
|
||||
typename boost::shared_ptr<Result> operator()(Boxed_Value ob)
|
||||
{
|
||||
return boost::any_cast<boost::shared_ptr<Result> >(ob.get());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct Cast_Helper<Boxed_Value>
|
||||
{
|
||||
|
@@ -116,12 +116,26 @@ class BoxedCPP_System
|
||||
return std::vector<Type_Name_Map::value_type>(m_types.begin(), m_types.end());
|
||||
}
|
||||
|
||||
std::vector<Function_Map::value_type> get_function(const std::string &t_name) const
|
||||
std::vector<std::pair<std::string, Function_Map::mapped_type> >
|
||||
get_function(const std::string &t_name) const
|
||||
{
|
||||
std::vector<std::pair<std::string, Function_Map::mapped_type> > funcs;
|
||||
|
||||
try {
|
||||
funcs.insert(funcs.end(),
|
||||
Function_Map::value_type(
|
||||
t_name,
|
||||
Cast_Helper<Function_Map::mapped_type>()(get_object(t_name)))
|
||||
);
|
||||
} catch (const std::bad_cast &) {
|
||||
} catch (const std::range_error &) {
|
||||
}
|
||||
|
||||
std::pair<Function_Map::const_iterator, Function_Map::const_iterator> range
|
||||
= m_functions.equal_range(t_name);
|
||||
|
||||
return std::vector<Function_Map::value_type>(range.first, range.second);
|
||||
funcs.insert(funcs.end(), range.first, range.second);
|
||||
return funcs;
|
||||
}
|
||||
|
||||
std::vector<Function_Map::value_type> get_functions() const
|
||||
|
@@ -178,10 +178,10 @@ class Proxy_Function_Impl : public Proxy_Function
|
||||
Func m_f;
|
||||
};
|
||||
|
||||
Boxed_Value dispatch(const std::vector<std::pair<const std::string, boost::shared_ptr<Proxy_Function> > > &funcs,
|
||||
Boxed_Value dispatch(const std::vector<std::pair<std::string, boost::shared_ptr<Proxy_Function> > > &funcs,
|
||||
const std::vector<Boxed_Value> &plist)
|
||||
{
|
||||
for (std::vector<std::pair<const std::string, boost::shared_ptr<Proxy_Function> > >::const_iterator itr = funcs.begin();
|
||||
for (std::vector<std::pair<std::string, boost::shared_ptr<Proxy_Function> > >::const_iterator itr = funcs.begin();
|
||||
itr != funcs.end();
|
||||
++itr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user