From 0539aa38e54eacfe9322192a1abc230bab8e7dc5 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 4 Mar 2013 00:30:05 +0100 Subject: [PATCH] cppbind: faster from_nasal for bool and fix VS warning. --- simgear/nasal/cppbind/detail/from_nasal_helper.cxx | 6 ++++++ simgear/nasal/cppbind/detail/from_nasal_helper.hxx | 8 ++++++++ simgear/nasal/cppbind/detail/functor_templates.hxx | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) 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) )) ); -- 2.39.5