From: Thomas Geymayer Date: Sun, 3 Mar 2013 23:30:05 +0000 (+0100) Subject: cppbind: faster from_nasal for bool and fix VS warning. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0539aa38e54eacfe9322192a1abc230bab8e7dc5;p=simgear.git cppbind: faster from_nasal for bool and fix VS warning. --- diff --git a/simgear/nasal/cppbind/detail/from_nasal_helper.cxx b/simgear/nasal/cppbind/detail/from_nasal_helper.cxx index a094e4fb..2a165102 100644 --- a/simgear/nasal/cppbind/detail/from_nasal_helper.cxx +++ b/simgear/nasal/cppbind/detail/from_nasal_helper.cxx @@ -81,4 +81,10 @@ namespace nasal return String(ref); } + //---------------------------------------------------------------------------- + bool from_nasal_helper(naContext c, naRef ref, const bool*) + { + return naTrue(ref) == 1; + } + } // namespace nasal diff --git a/simgear/nasal/cppbind/detail/from_nasal_helper.hxx b/simgear/nasal/cppbind/detail/from_nasal_helper.hxx index 865bc8d1..00cca4b5 100644 --- a/simgear/nasal/cppbind/detail/from_nasal_helper.hxx +++ b/simgear/nasal/cppbind/detail/from_nasal_helper.hxx @@ -94,6 +94,14 @@ namespace nasal */ String from_nasal_helper(naContext c, naRef ref, const String*); + /** + * Convert a Nasal object to bool. + * + * @return true, if ref is string or ref is number != 0 + * false, else + */ + bool from_nasal_helper(naContext c, naRef ref, const bool*); + /** * Convert a Nasal number to a C++ numeric type */ diff --git a/simgear/nasal/cppbind/detail/functor_templates.hxx b/simgear/nasal/cppbind/detail/functor_templates.hxx index eeb3600a..0d827f40 100644 --- a/simgear/nasal/cppbind/detail/functor_templates.hxx +++ b/simgear/nasal/cppbind/detail/functor_templates.hxx @@ -37,7 +37,7 @@ func, _1 BOOST_PP_COMMA_IF(n) - BOOST_PP_ENUM(n, SG_GHOST_REQUIRE_ARG,) + BOOST_PP_ENUM(n, SG_GHOST_REQUIRE_ARG, 0) )) );