move some more stuff, don't use both_libraries() in meson

master
Daniel Kolesa 2021-03-23 02:48:14 +01:00
parent b5b0d0adf5
commit 95e0da1fff
4 changed files with 63 additions and 75 deletions

View File

@ -32,7 +32,7 @@ subdir('tools')
pkg = import('pkgconfig')
pkg.generate(
libraries: libcubescript_lib,
libraries: libcubescript_target,
version: meson.project_version(),
name: 'libcubescript',
filebase: 'libcubescript',

View File

@ -175,6 +175,65 @@ cs_state::cs_state(cs_alloc_cb func, void *data):
cs_init_lib_base(*this);
}
LIBCUBESCRIPT_EXPORT cs_state::~cs_state() {
destroy();
}
LIBCUBESCRIPT_EXPORT void cs_state::destroy() {
if (!p_state || !p_owner) {
return;
}
for (auto &p: p_state->idents) {
cs_ident *i = p.second;
cs_alias *a = i->get_alias();
if (a) {
a->get_value().force_none();
static_cast<cs_alias_impl *>(a)->clean_code();
}
p_state->destroy(i->p_impl);
}
p_state->destroy(static_cast<cs_charbuf *>(p_errbuf));
p_state->destroy(p_state);
}
cs_state::cs_state(cs_shared_state *s):
p_state(s), p_owner(false)
{}
LIBCUBESCRIPT_EXPORT cs_state cs_state::new_thread() {
return cs_state{p_state};
}
LIBCUBESCRIPT_EXPORT cs_hook_cb cs_state::set_call_hook(cs_hook_cb func) {
auto hk = std::move(p_callhook);
p_callhook = std::move(func);
return hk;
}
LIBCUBESCRIPT_EXPORT cs_hook_cb const &cs_state::get_call_hook() const {
return p_callhook;
}
LIBCUBESCRIPT_EXPORT cs_hook_cb &cs_state::get_call_hook() {
return p_callhook;
}
LIBCUBESCRIPT_EXPORT cs_vprint_cb cs_state::set_var_printer(
cs_vprint_cb func
) {
auto fn = std::move(p_state->varprintf);
p_state->varprintf = std::move(func);
return fn;
}
LIBCUBESCRIPT_EXPORT cs_vprint_cb const &cs_state::get_var_printer() const {
return p_state->varprintf;
}
LIBCUBESCRIPT_EXPORT void *cs_state::alloc(void *ptr, size_t os, size_t ns) {
return p_state->alloc(ptr, os, ns);
}
LIBCUBESCRIPT_EXPORT void cs_state::init_libs(int libs) {
if (libs & CS_LIB_MATH) {
cs_init_lib_math(*this);

View File

@ -20,73 +20,6 @@ bool cs_check_num(std::string_view s) {
}
}
void cs_init_lib_base(cs_state &cs);
static void *cs_default_alloc(void *, void *p, size_t, size_t ns) {
if (!ns) {
std::free(p);
return nullptr;
}
return std::realloc(p, ns);
}
LIBCUBESCRIPT_EXPORT cs_state::~cs_state() {
destroy();
}
LIBCUBESCRIPT_EXPORT void cs_state::destroy() {
if (!p_state || !p_owner) {
return;
}
for (auto &p: p_state->idents) {
cs_ident *i = p.second;
cs_alias *a = i->get_alias();
if (a) {
a->get_value().force_none();
static_cast<cs_alias_impl *>(a)->clean_code();
}
p_state->destroy(i->p_impl);
}
p_state->destroy(static_cast<cs_charbuf *>(p_errbuf));
p_state->destroy(p_state);
}
cs_state::cs_state(cs_shared_state *s):
p_state(s), p_owner(false)
{}
LIBCUBESCRIPT_EXPORT cs_state cs_state::new_thread() {
return cs_state{p_state};
}
LIBCUBESCRIPT_EXPORT cs_hook_cb cs_state::set_call_hook(cs_hook_cb func) {
auto hk = std::move(p_callhook);
p_callhook = std::move(func);
return hk;
}
LIBCUBESCRIPT_EXPORT cs_hook_cb const &cs_state::get_call_hook() const {
return p_callhook;
}
LIBCUBESCRIPT_EXPORT cs_hook_cb &cs_state::get_call_hook() {
return p_callhook;
}
LIBCUBESCRIPT_EXPORT cs_vprint_cb cs_state::set_var_printer(cs_vprint_cb func) {
auto fn = std::move(p_state->varprintf);
p_state->varprintf = std::move(func);
return fn;
}
LIBCUBESCRIPT_EXPORT cs_vprint_cb const &cs_state::get_var_printer() const {
return p_state->varprintf;
}
LIBCUBESCRIPT_EXPORT void *cs_state::alloc(void *ptr, size_t os, size_t ns) {
return p_state->alloc(ptr, os, ns);
}
LIBCUBESCRIPT_EXPORT void cs_state::clear_override(cs_ident &id) {
if (!(id.get_flags() & CS_IDF_OVERRIDDEN)) {
return;

View File

@ -21,22 +21,18 @@ libcubescript_src = [
'lib_str.cc'
]
libcubescript_lib = both_libraries('cubescript',
libcubescript_target = library('cubescript',
libcubescript_src,
include_directories: libcubescript_includes + [include_directories('.')],
cpp_args: extra_cxxflags,
install: true,
pic: true,
version: meson.project_version()
)
libcubescript = declare_dependency(
include_directories: libcubescript_includes,
link_with: libcubescript_lib.get_shared_lib()
)
libcubescript_static = declare_dependency(
include_directories: libcubescript_includes,
link_with: libcubescript_lib.get_static_lib()
link_with: libcubescript_target
)
install_headers(libcubescript_header_src, install_dir: dir_package_include)