Add a very simple test program

Not quite a unit test, it looks more like an example
but still something.
This commit is contained in:
King_DuckZ 2021-02-02 14:04:27 +01:00
commit 3c318d6771
8 changed files with 119 additions and 0 deletions

View file

@ -100,6 +100,10 @@ namespace wren {
m_used_bytes = m_page_size;
}
std::size_t DynafuncMaker::total_memory() const {
return m_pages.size() * m_page_size;
}
unsigned char* DynafuncMaker::allocate_chunk() {
if (m_page_size - m_used_bytes < g_dynafunc_len) {
unique_ptr_free_t page(std::aligned_alloc(m_page_size, m_page_size));

View file

@ -18,6 +18,7 @@
#pragma once
#include <vector>
#include <cstddef>
namespace wren {
class VM;
@ -31,6 +32,8 @@ namespace wren {
void* make (VM* vm, foreign_method_t cb);
void clear() noexcept;
std::size_t total_memory() const;
private:
unsigned char* allocate_chunk();

View file

@ -271,6 +271,10 @@ namespace wren {
return nullptr != m_local->user_data;
}
std::size_t VM::dynafunc_byte_size() const {
return m_local->dynafunc.total_memory();
}
void VM::ensure_slots (int num_slots) {
wrenEnsureSlots(m_local->wvm, num_slots);
}