From 5cb2360985e7aaf2cdaaf62c2399217dfd5ee170 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Tue, 23 Jan 2018 16:15:56 +0100 Subject: [PATCH] cppbind: Use separet Context::to_nasal_vec instead of overload --- simgear/nasal/cppbind/NasalContext.hxx | 16 ++++------------ simgear/nasal/cppbind/test/cppbind_test.cxx | 4 ++-- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/simgear/nasal/cppbind/NasalContext.hxx b/simgear/nasal/cppbind/NasalContext.hxx index 0ea2907a..b1ba53d7 100644 --- a/simgear/nasal/cppbind/NasalContext.hxx +++ b/simgear/nasal/cppbind/NasalContext.hxx @@ -44,13 +44,6 @@ namespace nasal Hash newHash(); String newString(const char* str); - /** Create a new nasal vector and fill it with the given values */ - template - naRef newVector(Vals ... vals) - { - return newVector({to_nasal(vals)...}); - } - /** Raise a nasal runtime error */ template void runtimeError(const char* fmt, Args ... args) const @@ -70,12 +63,11 @@ namespace nasal return nasal::to_nasal(_ctx, array); } - // Workaround for compilers which can not convert a braced-init-list - // to const T(&)[N] - template - naRef to_nasal(std::initializer_list list) const + /** Create a nasal vector filled with the given values */ + template + naRef to_nasal_vec(Vals ... vals) { - return nasal::to_nasal(_ctx, list); + return newVector({to_nasal(vals)...}); } template diff --git a/simgear/nasal/cppbind/test/cppbind_test.cxx b/simgear/nasal/cppbind/test/cppbind_test.cxx index 8583a304..73b16e41 100644 --- a/simgear/nasal/cppbind/test/cppbind_test.cxx +++ b/simgear/nasal/cppbind/test/cppbind_test.cxx @@ -132,7 +132,7 @@ BOOST_AUTO_TEST_CASE( cppbind_arrays ) { TestContext ctx; - naRef na_vec = ctx.to_nasal({1., 2., 3.42}); + naRef na_vec = ctx.to_nasal_vec(1., 2., 3.42); BOOST_REQUIRE( naIsVector(na_vec) ); BOOST_CHECK_EQUAL(ctx.from_nasal(naVec_get(na_vec, 0)), 1); BOOST_CHECK_EQUAL(ctx.from_nasal(naVec_get(na_vec, 1)), 2); @@ -484,7 +484,7 @@ BOOST_AUTO_TEST_CASE( cppbind_misc_testing ) BOOST_AUTO_TEST_CASE( cppbind_context ) { nasal::Context ctx; - naRef vec = ctx.newVector(1, 2, 3.4, "test"); + naRef vec = ctx.to_nasal_vec(1, 2, 3.4, "test"); BOOST_REQUIRE( naIsVector(vec) ); BOOST_CHECK_EQUAL(ctx.from_nasal(naVec_get(vec, 0)), 1);