Add additional support for boost::shared_ptr as a return type

This commit is contained in:
Jason Turner
2009-07-21 02:00:39 +00:00
parent 72b6647718
commit 00ac8113c0
3 changed files with 28 additions and 3 deletions

View File

@@ -126,7 +126,13 @@ namespace chaiscript
}
template<typename T>
boost::shared_ptr<Data> get(boost::shared_ptr<T> obj)
boost::shared_ptr<Data> get(const boost::shared_ptr<T> *obj)
{
return get(*obj);
}
template<typename T>
boost::shared_ptr<Data> get(const boost::shared_ptr<T> &obj)
{
boost::shared_ptr<Data> data(new Data(
Get_Type_Info<T>::get(),

View File

@@ -389,7 +389,8 @@ namespace chaiscript
*/
void dump_object(Boxed_Value o, const Dispatch_Engine &e)
{
std::cout << e.get_type_name(o.get_type_info()) << std::endl;
Type_Info ti = o.get_type_info();
std::cout << (ti.m_is_const?"const ":"") << e.get_type_name(ti) << std::endl;
}
/**
@@ -397,7 +398,7 @@ namespace chaiscript
*/
void dump_type(const Type_Info &type, const Dispatch_Engine &e)
{
std::cout << e.get_type_name(type);
std::cout << (type.m_is_const?"const ":"") << e.get_type_name(type);
}
/**

View File

@@ -40,6 +40,24 @@ namespace chaiscript
}
};
template<typename Ret>
struct Handle_Return<boost::shared_ptr<Ret> &>
{
Boxed_Value operator()(const boost::function<boost::shared_ptr<Ret> & ()> &f)
{
return Boxed_Value(f());
}
};
template<typename Ret>
struct Handle_Return<const boost::shared_ptr<Ret> &>
{
Boxed_Value operator()(const boost::function<const boost::shared_ptr<Ret> & ()> &f)
{
return Boxed_Value(f());
}
};
/**
* Used internally for handling a return value from a Proxy_Function call
*/