Skip to content

Commit

Permalink
removed unused call_from_v8_traits::arg_convert
Browse files Browse the repository at this point in the history
...using it only in test_call_from_v8.cpp

Refine in context of #113
  • Loading branch information
pmed committed Jul 21, 2019
1 parent 07f500f commit 08b8027
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 28 deletions.
52 changes: 28 additions & 24 deletions test/test_call_from_v8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,48 +41,52 @@ using v8pp::detail::call_from_v8_traits;
using v8pp::raw_ptr_traits;
using v8pp::shared_ptr_traits;

template<typename F, size_t Index, typename Traits>
using arg_convert = typename call_from_v8_traits<F>::template arg_converter<
typename call_from_v8_traits<F>::template arg_type<Index>, Traits>;

// fundamental type converters
static_assert(std::is_same<call_from_v8_traits<decltype(y)>::arg_convert<0, raw_ptr_traits>, v8pp::convert<int>>::value, "y(int)");
static_assert(std::is_same<call_from_v8_traits<decltype(y)>::arg_convert<0, shared_ptr_traits>, v8pp::convert<int>>::value, "y(int)");
static_assert(std::is_same<arg_convert<decltype(y), 0, raw_ptr_traits>, v8pp::convert<int>>::value, "y(int)");
static_assert(std::is_same<arg_convert<decltype(y), 0, shared_ptr_traits>, v8pp::convert<int>>::value, "y(int)");

static_assert(std::is_same<call_from_v8_traits<decltype(z)>::arg_convert<1, raw_ptr_traits>, v8pp::convert<int>>::value, "y(int)");
static_assert(std::is_same<call_from_v8_traits<decltype(z)>::arg_convert<1, shared_ptr_traits>, v8pp::convert<int>>::value, "y(int)");
static_assert(std::is_same<arg_convert<decltype(z), 1, raw_ptr_traits>, v8pp::convert<int>>::value, "y(int)");
static_assert(std::is_same<arg_convert<decltype(z), 1, shared_ptr_traits>, v8pp::convert<int>>::value, "y(int)");

// cv arg converters
static void s(std::string, std::vector<int>&, std::shared_ptr<int> const&, std::string*, std::string const*) {}

static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<0, raw_ptr_traits>, v8pp::convert<std::string>>::value, "s(string)");
static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<0, shared_ptr_traits>, v8pp::convert<std::string>>::value, "s(string)");
static_assert(std::is_same<arg_convert<decltype(s), 0, raw_ptr_traits>, v8pp::convert<std::string>>::value, "s(string)");
static_assert(std::is_same<arg_convert<decltype(s), 0, shared_ptr_traits>, v8pp::convert<std::string>>::value, "s(string)");

static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<1, raw_ptr_traits>, v8pp::convert<std::vector<int>>>::value, "s(vector<int>&)");
static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<1, shared_ptr_traits>, v8pp::convert<std::vector<int>>>::value, "s(vector<int>&)");
static_assert(std::is_same<arg_convert<decltype(s), 1, raw_ptr_traits>, v8pp::convert<std::vector<int>>>::value, "s(vector<int>&)");
static_assert(std::is_same<arg_convert<decltype(s), 1, shared_ptr_traits>, v8pp::convert<std::vector<int>>>::value, "s(vector<int>&)");

static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<2, raw_ptr_traits>, v8pp::convert<std::shared_ptr<int>>>::value, "s(std::shared_ptr<int> const&)");
static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<2, shared_ptr_traits>, v8pp::convert<std::shared_ptr<int>>>::value, "s(std::shared_ptr<int> const&)");
static_assert(std::is_same<arg_convert<decltype(s), 2, raw_ptr_traits>, v8pp::convert<std::shared_ptr<int>>>::value, "s(std::shared_ptr<int> const&)");
static_assert(std::is_same<arg_convert<decltype(s), 2, shared_ptr_traits>, v8pp::convert<std::shared_ptr<int>>>::value, "s(std::shared_ptr<int> const&)");

static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<3, raw_ptr_traits>, v8pp::convert<std::string*>>::value, "s(std::string*)");
static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<3, shared_ptr_traits>, v8pp::convert<std::string*>>::value, "s(std::string*)");
static_assert(std::is_same<arg_convert<decltype(s), 3, raw_ptr_traits>, v8pp::convert<std::string*>>::value, "s(std::string*)");
static_assert(std::is_same<arg_convert<decltype(s), 3, shared_ptr_traits>, v8pp::convert<std::string*>>::value, "s(std::string*)");

static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<4, raw_ptr_traits>, v8pp::convert<std::string const*>>::value, "s(std::string const*)");
static_assert(std::is_same<call_from_v8_traits<decltype(s)>::arg_convert<4, shared_ptr_traits>, v8pp::convert<std::string const*>>::value, "s(std::string const*)");
static_assert(std::is_same<arg_convert<decltype(s), 4, raw_ptr_traits>, v8pp::convert<std::string const*>>::value, "s(std::string const*)");
static_assert(std::is_same<arg_convert<decltype(s), 4, shared_ptr_traits>, v8pp::convert<std::string const*>>::value, "s(std::string const*)");

// fundamental types cv arg converters
static void t(int, char&, bool const&, float*, char const*) {}

static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<0, raw_ptr_traits>, v8pp::convert<int>>::value, "t(int)");
static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<0, shared_ptr_traits>, v8pp::convert<int>>::value, "t(int)");
static_assert(std::is_same<arg_convert<decltype(t), 0, raw_ptr_traits>, v8pp::convert<int>>::value, "t(int)");
static_assert(std::is_same<arg_convert<decltype(t), 0, shared_ptr_traits>, v8pp::convert<int>>::value, "t(int)");

static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<1, raw_ptr_traits>, v8pp::convert<char>>::value, "t(char&)");
static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<1, shared_ptr_traits>, v8pp::convert<char>>::value, "t(char&)");
static_assert(std::is_same<arg_convert<decltype(t), 1, raw_ptr_traits>, v8pp::convert<char>>::value, "t(char&)");
static_assert(std::is_same<arg_convert<decltype(t), 1, shared_ptr_traits>, v8pp::convert<char>>::value, "t(char&)");

static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<2, raw_ptr_traits>, v8pp::convert<bool>>::value, "t(bool const&)");
static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<2, shared_ptr_traits>, v8pp::convert<bool>>::value, "t(bool const&)");
static_assert(std::is_same<arg_convert<decltype(t), 2, raw_ptr_traits>, v8pp::convert<bool>>::value, "t(bool const&)");
static_assert(std::is_same<arg_convert<decltype(t), 2, shared_ptr_traits>, v8pp::convert<bool>>::value, "t(bool const&)");

static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<3, raw_ptr_traits>, v8pp::convert<float*>>::value, "t(float*)");
static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<3, shared_ptr_traits>, v8pp::convert<float*>>::value, "t(float*)");
static_assert(std::is_same<arg_convert<decltype(t), 3, raw_ptr_traits>, v8pp::convert<float*>>::value, "t(float*)");
static_assert(std::is_same<arg_convert<decltype(t), 3, shared_ptr_traits>, v8pp::convert<float*>>::value, "t(float*)");

static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<4, raw_ptr_traits>, v8pp::convert<char const*>>::value, "t(char const*)");
static_assert(std::is_same<call_from_v8_traits<decltype(t)>::arg_convert<4, shared_ptr_traits>, v8pp::convert<char const*>>::value, "t(char const*)");
static_assert(std::is_same<arg_convert<decltype(t), 4, raw_ptr_traits>, v8pp::convert<char const*>>::value, "t(char const*)");
static_assert(std::is_same<arg_convert<decltype(t), 4, shared_ptr_traits>, v8pp::convert<char const*>>::value, "t(char const*)");

void test_call_from_v8()
{
Expand Down
5 changes: 1 addition & 4 deletions v8pp/call_from_v8.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,11 @@ struct call_from_v8_traits
convert<std::remove_cv_t<T>>
>;

template<size_t Index, typename Traits>
using arg_convert = arg_converter<arg_type<Index>, Traits>;

template<size_t Index, typename Traits>
static decltype(auto) arg_from_v8(v8::FunctionCallbackInfo<v8::Value> const& args)
{
// might be reference
return (arg_convert<Index, Traits>::from_v8(args.GetIsolate(), args[Index - offset]));
return (arg_converter<arg_type<Index>, Traits>::from_v8(args.GetIsolate(), args[Index - offset]));
}
};

Expand Down

0 comments on commit 08b8027

Please sign in to comment.