Ensure that non-shared_ptr, non-boxed_value, non-reference return types

are treated as const.
This commit is contained in:
Jason Turner
2011-03-26 09:03:36 -06:00
parent 92c836c58a
commit 87c29ebc91
3 changed files with 25 additions and 1 deletions

View File

@@ -23,6 +23,7 @@
namespace chaiscript
{
/// \internal
namespace detail
{
namespace threading

View File

@@ -27,7 +27,7 @@ namespace chaiscript
{
static Boxed_Value handle(const Ret &r)
{
return Boxed_Value(r);
return const_var(r);
}
};
@@ -40,6 +40,15 @@ namespace chaiscript
}
};
template<typename Ret>
struct Handle_Return<boost::shared_ptr<Ret> >
{
static Boxed_Value handle(const boost::shared_ptr<Ret> &r)
{
return Boxed_Value(r);
}
};
template<typename Ret>
struct Handle_Return<const boost::shared_ptr<Ret> &>
{
@@ -88,6 +97,18 @@ namespace chaiscript
}
};
/**
* Used internally for handling a return value from a Proxy_Function call
*/
template<>
struct Handle_Return<const Boxed_Value>
{
static Boxed_Value handle(const Boxed_Value &r)
{
return r;
}
};
/**
* Used internally for handling a return value from a Proxy_Function call
*/

View File

@@ -0,0 +1,2 @@
assert_throws("Mismatched types in equation, lhs is const.", fun() { 1 = 2 } );
assert_throws("Mismatched types in equation, lhs is const.", fun() { 1 + 2 = 2 } );