From 9fecb69b842814f0953d73727b2f538281c7e00a Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 4 Mar 2013 16:26:28 +0100 Subject: [PATCH] cppbind: tweaking from_nasal/to_nasal. --- simgear/nasal/cppbind/Ghost.hxx | 6 ++++++ simgear/nasal/cppbind/detail/from_nasal_helper.cxx | 3 +++ 2 files changed, 9 insertions(+) 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)); } -- 2.39.5