wrenpp/src/dynafunc_maker.hpp

45 lines
1.2 KiB
C++
Raw Normal View History

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/>.
*/
#pragma once
2022-05-15 13:41:00 +00:00
#include "wrenpp/detail/wren_types.hpp"
#include <vector>
#include <list>
#include <cstddef>
namespace wren {
class DynafuncMaker {
public:
DynafuncMaker();
~DynafuncMaker() noexcept;
void* make (VM* vm, foreign_method_t cb, const char* mod_name, const char* cls_name);
void clear() noexcept;
std::size_t total_memory() const;
private:
unsigned char* allocate_chunk();
std::list<std::vector<char>> m_string_params;
std::vector<void*> m_pages;
std::size_t m_page_size;
std::size_t m_used_bytes;
};
} //namespace wren