Function ordering is working properly now, just need to add a unit test for it.

This commit is contained in:
Jason Turner 2010-12-11 22:38:08 +00:00
parent 13f53839c9
commit e90d49bb9d
2 changed files with 23 additions and 6 deletions

View File

@ -385,7 +385,7 @@ namespace chaiscript
* Similar to shared_ptr_clone. Used for Proxy_Function. * Similar to shared_ptr_clone. Used for Proxy_Function.
*/ */
template<typename Type> template<typename Type>
Boxed_Value ptr_assign(Boxed_Value lhs, const boost::shared_ptr<typename boost::add_const<Type>::type> &rhs) Boxed_Value ptr_assign(Boxed_Value lhs, const boost::shared_ptr<Type> &rhs)
{ {
if (lhs.is_undef() if (lhs.is_undef()
|| (!lhs.get_type_info().is_const() && lhs.get_type_info().bare_equal(chaiscript::detail::Get_Type_Info<Type>::get()))) || (!lhs.get_type_info().is_const() && lhs.get_type_info().bare_equal(chaiscript::detail::Get_Type_Info<Type>::get())))
@ -618,7 +618,8 @@ namespace chaiscript
"bind"); "bind");
m->add(fun(&shared_ptr_unconst_clone<Proxy_Function_Base>), "clone"); m->add(fun(&shared_ptr_unconst_clone<Proxy_Function_Base>), "clone");
m->add(fun(&ptr_assign<Proxy_Function_Base>), "="); m->add(fun(&ptr_assign<boost::remove_const<Proxy_Function_Base>::type>), "=");
m->add(fun(&ptr_assign<boost::add_const<Proxy_Function_Base>::type>), "=");
m->add(Proxy_Function(new Dynamic_Proxy_Function(boost::bind(&call_exists, _1))), m->add(Proxy_Function(new Dynamic_Proxy_Function(boost::bind(&call_exists, _1))),
"call_exists"); "call_exists");

View File

@ -811,6 +811,10 @@ namespace chaiscript
const int lhssize = lhsparamtypes.size(); const int lhssize = lhsparamtypes.size();
const int rhssize = rhsparamtypes.size(); const int rhssize = rhsparamtypes.size();
const Type_Info boxed_type = user_type<Boxed_Value>();
const Type_Info boxed_pod_type = user_type<Boxed_POD_Value>();
for (int i = 1; i < lhssize && i < rhssize; ++i) for (int i = 1; i < lhssize && i < rhssize; ++i)
{ {
const Type_Info lt = lhsparamtypes[i]; const Type_Info lt = lhsparamtypes[i];
@ -824,16 +828,14 @@ namespace chaiscript
// const is after non-const for the same type // const is after non-const for the same type
if (lt.bare_equal(rt) && lt.is_const() && !rt.is_const()) if (lt.bare_equal(rt) && lt.is_const() && !rt.is_const())
{ {
return true; return false;
} }
if (lt.bare_equal(rt) && !lt.is_const()) if (lt.bare_equal(rt) && !lt.is_const())
{ {
return false; return true;
} }
const Type_Info boxed_type = user_type<Boxed_Value>();
// boxed_values are sorted last // boxed_values are sorted last
if (lt.bare_equal(boxed_type)) if (lt.bare_equal(boxed_type))
{ {
@ -841,6 +843,20 @@ namespace chaiscript
} }
if (rt.bare_equal(boxed_type)) if (rt.bare_equal(boxed_type))
{
if (lt.bare_equal(boxed_pod_type))
{
return true;
}
return true;
}
if (lt.bare_equal(boxed_pod_type))
{
return false;
}
if (rt.bare_equal(boxed_pod_type))
{ {
return true; return true;
} }