cppbind: tweaking from_nasal/to_nasal.

This commit is contained in:
Thomas Geymayer 2013-03-04 16:26:28 +01:00
parent 0539aa38e5
commit 9fecb69b84
2 changed files with 9 additions and 0 deletions

View File

@ -166,6 +166,12 @@ namespace nasal
return (*from_nasal_ptr<T>::get())(c, args[index]); return (*from_nasal_ptr<T>::get())(c, args[index]);
} }
template<class T>
naRef to_nasal(T arg) const
{
return nasal::to_nasal(c, arg);
}
naContext c; naContext c;
size_t argc; size_t argc;
naRef *args; naRef *args;

View File

@ -53,6 +53,9 @@ namespace nasal
std::string from_nasal_helper(naContext c, naRef ref, const std::string*) std::string from_nasal_helper(naContext c, naRef ref, const std::string*)
{ {
naRef na_str = naStringValue(c, ref); naRef na_str = naStringValue(c, ref);
if( !naIsString(na_str) )
throw bad_nasal_cast("Not convertible to string");
return std::string(naStr_data(na_str), naStr_len(na_str)); return std::string(naStr_data(na_str), naStr_len(na_str));
} }