get rid of some more pointers in API

master
Daniel Kolesa 2021-04-24 23:50:06 +02:00
parent 3e8db1042a
commit f19fd57549
6 changed files with 15 additions and 21 deletions

View File

@ -86,17 +86,11 @@ struct LIBCUBESCRIPT_EXPORT alias_local {
/** @brief Local handlers are not move assignable */
alias_local &operator=(alias_local &&v) = delete;
/** @brief Get the contained alias
*
* @return the alias or `nullptr` if none set
*/
alias *get_alias() noexcept { return p_alias; }
/** @brief Get the contained alias */
alias &get_alias() noexcept { return *p_alias; }
/** @brief Get the contained alias
*
* @return the alias or `nullptr` if none set
*/
alias const *get_alias() const noexcept { return p_alias; }
/** @brief Get the contained alias */
alias const &get_alias() const noexcept { return *p_alias; }
/** @brief Set the contained alias's value
*

View File

@ -339,7 +339,7 @@ struct LIBCUBESCRIPT_EXPORT any_value {
* performed, so after main thread destruction this may become
* dangling (and unsafe to use).
*/
void set_ident(ident *val);
void set_ident(ident &val);
/** @brief Get the value as a string reference.
*

View File

@ -88,7 +88,7 @@ void var_changed(thread_state &ts, ident *id) {
}
auto *cimp = static_cast<command_impl *>(cid);
any_value val{};
val.set_ident(id);
val.set_ident(*id);
cimp->call(ts, span_type<any_value>{&val, 1}, val);
}

View File

@ -165,10 +165,10 @@ void any_value::set_code(bcode_ref const &val) {
csv_get<bcode *>(&p_stor) = p;
}
void any_value::set_ident(ident *val) {
void any_value::set_ident(ident &val) {
csv_cleanup(p_type, &p_stor);
p_type = value_type::IDENT;
csv_get<ident *>(&p_stor) = val;
csv_get<ident *>(&p_stor) = &val;
}
void any_value::force_none() {
@ -270,7 +270,7 @@ ident &any_value::force_ident(state &cs) {
auto &id = state_p{cs}.ts().istate->new_ident(
cs, get_string(cs), IDENT_FLAG_UNKNOWN
);
set_ident(&id);
set_ident(id);
return id;
}

View File

@ -154,7 +154,7 @@ void exec_command(
if (rep) {
break;
}
args[i].set_ident(ts.istate->id_dummy);
args[i].set_ident(*ts.istate->id_dummy);
fakeargs++;
} else {
args[i].force_ident(*ts.pstate);
@ -162,7 +162,7 @@ void exec_command(
break;
case '$':
i += 1;
args[i].set_ident(self);
args[i].set_ident(*self);
break;
case 'N':
i += 1;
@ -734,7 +734,7 @@ std::uint32_t *vm_exec(
ts.get_astack(a).push(ts.idstack.emplace_back());
ts.callstack->usedargs[a->get_index()] = true;
}
args.emplace_back().set_ident(a);
args.emplace_back().set_ident(*a);
continue;
}
case BC_INST_IDENT_U: {
@ -750,7 +750,7 @@ std::uint32_t *vm_exec(
ts.get_astack(a).push(ts.idstack.emplace_back());
ts.callstack->usedargs[id->get_index()] = true;
}
arg.set_ident(id);
arg.set_ident(*id);
continue;
}

View File

@ -157,7 +157,7 @@ LIBCUBESCRIPT_EXPORT void std_init_base(state &gcs) {
new_cmd_quiet(gcs, "pushif", "rte", [](auto &cs, auto args, auto &res) {
alias_local st{cs, args[0]};
if (st.get_alias()->is_arg()) {
if (st.get_alias().is_arg()) {
throw error{cs, "cannot push an argument"};
}
if (args[1].get_bool()) {
@ -317,7 +317,7 @@ end:
new_cmd_quiet(gcs, "push", "rte", [](auto &cs, auto args, auto &res) {
alias_local st{cs, args[0]};
if (st.get_alias()->is_arg()) {
if (st.get_alias().is_arg()) {
throw error{cs, "cannot push an argument"};
}
st.set(args[1]);