Fix dispatch for const boost::shared_ptr<> & parameters for functions, add a test to example.cpp and fix some issues with building example.cpp

This commit is contained in:
Jason Turner 2009-08-20 21:35:56 +00:00
parent 8840f06053
commit a136236179
4 changed files with 23 additions and 2 deletions

View File

@ -30,7 +30,7 @@ namespace chaiscript
functor(const std::vector<std::pair<std::string, Proxy_Function > > &funcs)
{
FunctionType *p=0;
return build_function_caller_helper(p, funcs);
return detail::build_function_caller_helper(p, funcs);
}
/**

View File

@ -30,7 +30,7 @@ namespace chaiscript
* value of a build_function_caller
*/
template<typename Ret>
class Function_Caller_Ret
struct Function_Caller_Ret
{
static Ret call(const std::vector<std::pair<std::string, Proxy_Function > > &t_funcs,
const std::vector<Boxed_Value> &params)

View File

@ -106,6 +106,18 @@ namespace chaiscript
}
};
template<typename T>
struct Get_Type_Info<const boost::shared_ptr<T> &>
{
static Type_Info get()
{
return Type_Info(boost::is_const<T>::value, boost::is_reference<T>::value, boost::is_pointer<T>::value,
boost::is_void<T>::value,
&typeid(const boost::shared_ptr<T> &),
&typeid(typename boost::remove_const<typename boost::remove_pointer<typename boost::remove_reference<T>::type>::type>::type));
}
};
template<typename T>
struct Get_Type_Info<boost::reference_wrapper<T> >
{

View File

@ -45,6 +45,10 @@ struct System
}
};
void take_shared_ptr(const boost::shared_ptr<std::string> &p)
{
std::cout << *p << std::endl;
}
int main(int argc, char *argv[]) {
using namespace chaiscript;
@ -59,6 +63,8 @@ int main(int argc, char *argv[]) {
chai.add(fun(&System::add_callback), "add_callback");
chai.add(fun(&System::do_callbacks), "do_callbacks");
chai.add(fun(&take_shared_ptr), "take_shared_ptr");
// Let's use chaiscript to add a new lambda callback to our system.
// The function "{ 'Callback1' + x }" is created in chaiscript and passed into our C++ application
// in the "add_callback" function of struct System the chaiscript function is converted into a
@ -123,5 +129,8 @@ int main(int argc, char *argv[]) {
//mostly supported currently
chai.add(bootstrap::vector_type<std::vector<int> >("IntVector"));
chai("dump_system()");
chai("take_shared_ptr(\"Hello World as a shared_ptr\");");
}