From: Thomas Geymayer Date: Mon, 4 Mar 2013 15:26:28 +0000 (+0100) Subject: cppbind: tweaking from_nasal/to_nasal. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9fecb69b842814f0953d73727b2f538281c7e00a;p=simgear.git cppbind: tweaking from_nasal/to_nasal. --- diff --git a/simgear/nasal/cppbind/Ghost.hxx b/simgear/nasal/cppbind/Ghost.hxx index 6cf37b63..c1d2dae2 100644 --- a/simgear/nasal/cppbind/Ghost.hxx +++ b/simgear/nasal/cppbind/Ghost.hxx @@ -166,6 +166,12 @@ namespace nasal return (*from_nasal_ptr::get())(c, args[index]); } + template + naRef to_nasal(T arg) const + { + return nasal::to_nasal(c, arg); + } + naContext c; size_t argc; naRef *args; diff --git a/simgear/nasal/cppbind/detail/from_nasal_helper.cxx b/simgear/nasal/cppbind/detail/from_nasal_helper.cxx index 2a165102..cbac3558 100644 --- a/simgear/nasal/cppbind/detail/from_nasal_helper.cxx +++ b/simgear/nasal/cppbind/detail/from_nasal_helper.cxx @@ -53,6 +53,9 @@ namespace nasal std::string from_nasal_helper(naContext c, naRef ref, const std::string*) { 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)); }