Rename function

I think this is the opposite of the code I'm working on
now, ie it's not called by wren to create a c++ object
but from c++ to create a wren object. I'll add an
example for this.
This commit is contained in:
King_DuckZ 2022-05-15 16:19:42 +02:00
parent f67ec7afb1
commit a8cef95cb9

View file

@ -32,9 +32,6 @@
#include <utility> #include <utility>
namespace wren { namespace wren {
namespace detail {
} //namespace detail
template <typename R, typename... Args> template <typename R, typename... Args>
R call (VM& vm, const Handle& object, const Handle& method, const Args&... args); R call (VM& vm, const Handle& object, const Handle& method, const Args&... args);
@ -48,11 +45,11 @@ namespace wren {
R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args); R call (VM& vm, const ModuleAndName& object, const char (&method)[N], const Args&... args);
template <typename T, typename... Args> template <typename T, typename... Args>
T* make_foreign_object(VM& vm, const ModuleAndName& mn, Args&&... args); T* make_wren_object(VM& vm, const ModuleAndName& mn, Args&&... args);
#if defined(WRENPP_WITH_NAME_GUESSING) #if defined(WRENPP_WITH_NAME_GUESSING)
template <typename T, typename... Args> template <typename T, typename... Args>
T* make_foreign_object(VM& vm, const char* module, Args&&... args); T* make_wren_object(VM& vm, const char* module, Args&&... args);
#endif #endif
template <auto V> template <auto V>
@ -172,7 +169,7 @@ namespace wren {
} }
template <typename T, typename... Args> template <typename T, typename... Args>
inline T* make_foreign_object(VM& vm, const ModuleAndName& mn, Args&&... args) { inline T* make_wren_object(VM& vm, const ModuleAndName& mn, Args&&... args) {
variable(vm, mn, 0); variable(vm, mn, 0);
void* const mem = vm.set_slot_new_foreign(0, 0, sizeof(T)); void* const mem = vm.set_slot_new_foreign(0, 0, sizeof(T));
T* const obj = new(mem) T{std::forward<Args>(args)...}; T* const obj = new(mem) T{std::forward<Args>(args)...};
@ -181,8 +178,8 @@ namespace wren {
#if defined(WRENPP_WITH_NAME_GUESSING) #if defined(WRENPP_WITH_NAME_GUESSING)
template <typename T, typename... Args> template <typename T, typename... Args>
inline T* make_foreign_object(VM& vm, const char* module, Args&&... args) { inline T* make_wren_object(VM& vm, const char* module, Args&&... args) {
return make_foreign_object<T>( return make_wren_object<T>(
vm, vm,
ModuleAndName{module, guess_class_name<T>()}, ModuleAndName{module, guess_class_name<T>()},
std::forward<Args>(args)... std::forward<Args>(args)...