Add overload for Handle
This commit is contained in:
parent
97514085cb
commit
4843ddd95e
1 changed files with 12 additions and 1 deletions
|
@ -33,6 +33,9 @@ namespace wren {
|
|||
template <typename R, typename... Args>
|
||||
R call (VM& vm, const ModuleAndName& object, const Handle& method, const Args&... args);
|
||||
|
||||
template <typename R, std::size_t N, typename... Args>
|
||||
R call (VM& vm, const Handle& object, const char (&method)[N], const Args&... args);
|
||||
|
||||
template <typename R, std::size_t N, typename... Args>
|
||||
R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args);
|
||||
|
||||
|
@ -165,7 +168,7 @@ namespace wren {
|
|||
}
|
||||
|
||||
template <typename R, std::size_t N, typename... Args>
|
||||
inline R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args) {
|
||||
inline R call (VM& vm, const Handle& object, const char (&method)[N], const Args&... args) {
|
||||
const constexpr char dummy_name_buff[N] = {0};
|
||||
const constexpr auto params = dhandy::bt::string<N, char>(dummy_name_buff) +
|
||||
dhandy::bt::make_string("(") +
|
||||
|
@ -177,4 +180,12 @@ namespace wren {
|
|||
std::copy(params.data() + N - 1, params.data() + params.size() + 1, cat_buff + N - 1);
|
||||
return call<R, Args...>(vm, object, vm.make_call_handle(cat_buff), args...);
|
||||
}
|
||||
|
||||
template <typename R, std::size_t N, typename... Args>
|
||||
inline R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args) {
|
||||
vm.ensure_slots(sizeof...(args) + 1);
|
||||
variable(vm, object, 0);
|
||||
Handle obj_handle = vm.slot_handle(0);
|
||||
return call<R, N, Args...>(vm, obj_handle, method, args...);
|
||||
}
|
||||
} //namespace wren
|
||||
|
|
Loading…
Reference in a new issue