Add additional support for boost::shared_ptr as a return type
This commit is contained in:
@@ -126,7 +126,13 @@ namespace chaiscript
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
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(
|
boost::shared_ptr<Data> data(new Data(
|
||||||
Get_Type_Info<T>::get(),
|
Get_Type_Info<T>::get(),
|
||||||
|
@@ -389,7 +389,8 @@ namespace chaiscript
|
|||||||
*/
|
*/
|
||||||
void dump_object(Boxed_Value o, const Dispatch_Engine &e)
|
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)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -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
|
* Used internally for handling a return value from a Proxy_Function call
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user