This repository has been archived on 2024-05-15. You can view files and clone it, but cannot push or open issues or pull requests.
fugg/fugg-api/src/table.h

30 lines
652 B
C++

#pragma once
#include <client.h>
#include <wasm-rt.h>
namespace fugg {
namespace wasm
{
class Table {
wasm_rt_table_t** table;
public:
explicit Table(wasm_rt_table_t** table) : table(table) { }
wasm_rt_elem_t* element(uintptr_t address) const {
return &(*table)->data[address];
}
};
static auto kTable = Table { &Z_clientZ_table };
}
template<typename T>
static T function_ref(uintptr_t address) {
const auto& element = wasm::kTable.element(address);
return reinterpret_cast<T>(element->func);
}
}