cppbind: Use separet Context::to_nasal_vec instead of overload
This commit is contained in:
@@ -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<class... Vals>
|
||||
naRef newVector(Vals ... vals)
|
||||
{
|
||||
return newVector({to_nasal(vals)...});
|
||||
}
|
||||
|
||||
/** Raise a nasal runtime error */
|
||||
template<class... Args>
|
||||
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<class T>
|
||||
naRef to_nasal(std::initializer_list<T> list) const
|
||||
/** Create a nasal vector filled with the given values */
|
||||
template<class... Vals>
|
||||
naRef to_nasal_vec(Vals ... vals)
|
||||
{
|
||||
return nasal::to_nasal(_ctx, list);
|
||||
return newVector({to_nasal(vals)...});
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -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<int>(naVec_get(na_vec, 0)), 1);
|
||||
BOOST_CHECK_EQUAL(ctx.from_nasal<int>(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<int>(naVec_get(vec, 0)), 1);
|
||||
|
||||
Reference in New Issue
Block a user