Implement CallbackManager

With it users don't have to provide a foreign_method_fn()
function anymore, it's become optional.
This commit is contained in:
King_DuckZ 2022-04-29 18:16:57 +02:00
commit fa0183a3bf
8 changed files with 272 additions and 22 deletions

View file

@ -17,6 +17,7 @@
#include "wrenpp/vm.hpp"
#include "wrenpp/configuration.hpp"
#include "wrenpp/callback_manager.hpp"
#include "dynafunc_maker.hpp"
#include <wren.hpp>
#include <cassert>
@ -152,6 +153,7 @@ namespace wren {
#endif
}
CallbackManager callback_manager;
detail::Callbacks callbacks;
DynafuncMaker dynafunc;
WrenVM* wvm;
@ -316,6 +318,10 @@ namespace wren {
m_local->dynafunc.clear();
}
CallbackManager& VM::callback_manager() {
return m_local->callback_manager;
}
void VM::ensure_slots (int num_slots) {
wrenEnsureSlots(m_local->wvm, num_slots);
}