hide internal_state from all public headers
parent
3ed7b59d0b
commit
e644674724
|
@ -127,6 +127,8 @@ struct LIBCUBESCRIPT_EXPORT state {
|
||||||
private:
|
private:
|
||||||
friend struct state_p;
|
friend struct state_p;
|
||||||
|
|
||||||
|
LIBCUBESCRIPT_LOCAL state(void *is);
|
||||||
|
|
||||||
hook_func set_call_hook(hook_func func);
|
hook_func set_call_hook(hook_func func);
|
||||||
|
|
||||||
command &new_command(
|
command &new_command(
|
||||||
|
@ -139,8 +141,6 @@ private:
|
||||||
return static_cast<state *>(data)->alloc(p, os, ns);
|
return static_cast<state *>(data)->alloc(p, os, ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
LIBCUBESCRIPT_LOCAL state(internal_state *s);
|
|
||||||
|
|
||||||
void *alloc(void *ptr, size_t olds, size_t news);
|
void *alloc(void *ptr, size_t olds, size_t news);
|
||||||
|
|
||||||
struct thread_state *p_tstate = nullptr;
|
struct thread_state *p_tstate = nullptr;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
namespace cubescript {
|
namespace cubescript {
|
||||||
|
|
||||||
struct internal_state;
|
|
||||||
struct ident;
|
struct ident;
|
||||||
|
|
||||||
struct LIBCUBESCRIPT_EXPORT bcode_ref {
|
struct LIBCUBESCRIPT_EXPORT bcode_ref {
|
||||||
|
@ -42,7 +41,6 @@ struct LIBCUBESCRIPT_EXPORT string_ref {
|
||||||
friend struct string_pool;
|
friend struct string_pool;
|
||||||
|
|
||||||
string_ref() = delete;
|
string_ref() = delete;
|
||||||
string_ref(internal_state *cs, std::string_view str);
|
|
||||||
string_ref(state &cs, std::string_view str);
|
string_ref(state &cs, std::string_view str);
|
||||||
|
|
||||||
string_ref(string_ref const &ref);
|
string_ref(string_ref const &ref);
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
namespace cubescript {
|
namespace cubescript {
|
||||||
|
|
||||||
|
struct internal_state;
|
||||||
|
|
||||||
struct bcode {
|
struct bcode {
|
||||||
std::uint32_t init;
|
std::uint32_t init;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ ident &internal_state::new_ident(state &cs, std::string_view name, int flags) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
auto *inst = create<alias_impl>(
|
auto *inst = create<alias_impl>(
|
||||||
cs, string_ref{this, name}, flags
|
cs, string_ref{cs, name}, flags
|
||||||
);
|
);
|
||||||
id = add_ident(inst, inst);
|
id = add_ident(inst, inst);
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,8 @@ LIBCUBESCRIPT_EXPORT void state::destroy() {
|
||||||
p_tstate = nullptr;
|
p_tstate = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
state::state(internal_state *s) {
|
state::state(void *is) {
|
||||||
|
auto *s = static_cast<internal_state *>(is);
|
||||||
p_tstate = s->create<thread_state>(s);
|
p_tstate = s->create<thread_state>(s);
|
||||||
p_tstate->pstate = this;
|
p_tstate->pstate = this;
|
||||||
p_tstate->istate = s;
|
p_tstate->istate = s;
|
||||||
|
@ -422,8 +423,7 @@ LIBCUBESCRIPT_EXPORT integer_var &state::new_ivar(
|
||||||
std::string_view n, integer_type v, bool read_only, var_type vtp
|
std::string_view n, integer_type v, bool read_only, var_type vtp
|
||||||
) {
|
) {
|
||||||
auto *iv = p_tstate->istate->create<ivar_impl>(
|
auto *iv = p_tstate->istate->create<ivar_impl>(
|
||||||
string_ref{p_tstate->istate, n}, v,
|
string_ref{*this, n}, v, var_flags(read_only, vtp)
|
||||||
var_flags(read_only, vtp)
|
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var_name_check(*this, p_tstate->istate->get_ident(n), n);
|
var_name_check(*this, p_tstate->istate->get_ident(n), n);
|
||||||
|
@ -439,8 +439,7 @@ LIBCUBESCRIPT_EXPORT float_var &state::new_fvar(
|
||||||
std::string_view n, float_type v, bool read_only, var_type vtp
|
std::string_view n, float_type v, bool read_only, var_type vtp
|
||||||
) {
|
) {
|
||||||
auto *fv = p_tstate->istate->create<fvar_impl>(
|
auto *fv = p_tstate->istate->create<fvar_impl>(
|
||||||
string_ref{p_tstate->istate, n}, v,
|
string_ref{*this, n}, v, var_flags(read_only, vtp)
|
||||||
var_flags(read_only, vtp)
|
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var_name_check(*this, p_tstate->istate->get_ident(n), n);
|
var_name_check(*this, p_tstate->istate->get_ident(n), n);
|
||||||
|
@ -456,8 +455,7 @@ LIBCUBESCRIPT_EXPORT string_var &state::new_svar(
|
||||||
std::string_view n, std::string_view v, bool read_only, var_type vtp
|
std::string_view n, std::string_view v, bool read_only, var_type vtp
|
||||||
) {
|
) {
|
||||||
auto *sv = p_tstate->istate->create<svar_impl>(
|
auto *sv = p_tstate->istate->create<svar_impl>(
|
||||||
string_ref{p_tstate->istate, n}, string_ref{p_tstate->istate, v},
|
string_ref{*this, n}, string_ref{*this, v}, var_flags(read_only, vtp)
|
||||||
var_flags(read_only, vtp)
|
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
var_name_check(*this, p_tstate->istate->get_ident(n), n);
|
var_name_check(*this, p_tstate->istate->get_ident(n), n);
|
||||||
|
@ -517,7 +515,7 @@ LIBCUBESCRIPT_EXPORT void state::set_alias(
|
||||||
throw error{*this, "cannot alias invalid name '%s'", name.data()};
|
throw error{*this, "cannot alias invalid name '%s'", name.data()};
|
||||||
} else {
|
} else {
|
||||||
auto *a = p_tstate->istate->create<alias_impl>(
|
auto *a = p_tstate->istate->create<alias_impl>(
|
||||||
*this, string_ref{p_tstate->istate, name}, std::move(v),
|
*this, string_ref{*this, name}, std::move(v),
|
||||||
p_tstate->ident_flags
|
p_tstate->ident_flags
|
||||||
);
|
);
|
||||||
p_tstate->istate->add_ident(a, a);
|
p_tstate->istate->add_ident(a, a);
|
||||||
|
@ -588,7 +586,8 @@ LIBCUBESCRIPT_EXPORT command &state::new_command(
|
||||||
}
|
}
|
||||||
auto &is = *p_tstate->istate;
|
auto &is = *p_tstate->istate;
|
||||||
auto *cmd = is.create<command_impl>(
|
auto *cmd = is.create<command_impl>(
|
||||||
string_ref{&is, name}, string_ref{&is, args}, nargs, std::move(func)
|
string_ref{*this, name}, string_ref{*this, args},
|
||||||
|
nargs, std::move(func)
|
||||||
);
|
);
|
||||||
/* we can set these builtins */
|
/* we can set these builtins */
|
||||||
command **bptrs[] = {
|
command **bptrs[] = {
|
||||||
|
|
|
@ -122,12 +122,6 @@ std::string_view str_managed_view(char const *str) {
|
||||||
|
|
||||||
/* strref implementation */
|
/* strref implementation */
|
||||||
|
|
||||||
LIBCUBESCRIPT_EXPORT string_ref::string_ref(
|
|
||||||
internal_state *cs, std::string_view str
|
|
||||||
) {
|
|
||||||
p_str = cs->strman->add(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
LIBCUBESCRIPT_EXPORT string_ref::string_ref(state &cs, std::string_view str) {
|
LIBCUBESCRIPT_EXPORT string_ref::string_ref(state &cs, std::string_view str) {
|
||||||
p_str = state_p{cs}.ts().istate->strman->add(str);
|
p_str = state_p{cs}.ts().istate->strman->add(str);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue