2022-04-28 20:56:11 +00:00
|
|
|
/* Copyright 2020-2022, Michele Santullo
|
2020-04-30 21:33:54 +00:00
|
|
|
* This file is part of wrenpp.
|
|
|
|
*
|
|
|
|
* Wrenpp is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Wrenpp is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with wrenpp. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-04-26 15:19:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-05-15 13:41:00 +00:00
|
|
|
#include "wrenpp/detail/wren_types.hpp"
|
2020-04-26 15:19:02 +00:00
|
|
|
#include <vector>
|
2022-05-16 23:00:00 +00:00
|
|
|
#include <list>
|
2021-02-02 13:04:27 +00:00
|
|
|
#include <cstddef>
|
2020-04-26 15:19:02 +00:00
|
|
|
|
|
|
|
namespace wren {
|
|
|
|
class DynafuncMaker {
|
|
|
|
public:
|
|
|
|
DynafuncMaker();
|
|
|
|
~DynafuncMaker() noexcept;
|
|
|
|
|
2022-05-16 23:00:00 +00:00
|
|
|
void* make (VM* vm, foreign_method_t cb, const char* mod_name, const char* cls_name);
|
2020-04-26 15:19:02 +00:00
|
|
|
void clear() noexcept;
|
|
|
|
|
2021-02-02 13:04:27 +00:00
|
|
|
std::size_t total_memory() const;
|
|
|
|
|
2020-04-26 15:19:02 +00:00
|
|
|
private:
|
|
|
|
unsigned char* allocate_chunk();
|
|
|
|
|
2022-05-16 23:00:00 +00:00
|
|
|
std::list<std::vector<char>> m_string_params;
|
2020-04-26 15:19:02 +00:00
|
|
|
std::vector<void*> m_pages;
|
|
|
|
std::size_t m_page_size;
|
|
|
|
std::size_t m_used_bytes;
|
|
|
|
};
|
|
|
|
} //namespace wren
|