mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-07-31 00:37:02 +08:00
Address review: remove const_override, set const flag directly on Type_Info
Replace the m_const_override bool on Boxed_Value::Data with a Type_Info::make_const() method that sets the const bit in m_flags directly. This ensures constness is visible everywhere consistently, including places that check get_type_info().is_const() directly. Requested by @lefticus in PR #643 review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e1e0cc96a7
commit
d288e0ba10
@ -47,7 +47,6 @@ namespace chaiscript {
|
||||
m_data_ptr = rhs.m_data_ptr;
|
||||
m_const_data_ptr = rhs.m_const_data_ptr;
|
||||
m_return_value = rhs.m_return_value;
|
||||
m_const_override = rhs.m_const_override;
|
||||
|
||||
if (rhs.m_attrs) {
|
||||
m_attrs = std::make_unique<std::map<std::string, std::shared_ptr<Data>>>(*rhs.m_attrs);
|
||||
@ -68,7 +67,6 @@ namespace chaiscript {
|
||||
std::unique_ptr<std::map<std::string, std::shared_ptr<Data>>> m_attrs;
|
||||
bool m_is_ref;
|
||||
bool m_return_value;
|
||||
bool m_const_override{false};
|
||||
};
|
||||
|
||||
struct Object_Data {
|
||||
@ -157,10 +155,13 @@ namespace chaiscript {
|
||||
/// return true if the object is uninitialized
|
||||
bool is_undef() const noexcept { return m_data->m_type_info.is_undef(); }
|
||||
|
||||
bool is_const() const noexcept { return m_data->m_type_info.is_const() || m_data->m_const_override; }
|
||||
bool is_const() const noexcept { return m_data->m_type_info.is_const(); }
|
||||
|
||||
/// Mark this Boxed_Value as const (used for script-level const declarations)
|
||||
void make_const() noexcept { m_data->m_const_override = true; }
|
||||
void make_const() noexcept {
|
||||
m_data->m_type_info.make_const();
|
||||
m_data->m_data_ptr = nullptr;
|
||||
}
|
||||
|
||||
bool is_type(const Type_Info &ti) const noexcept { return m_data->m_type_info.bare_equal(ti); }
|
||||
|
||||
|
||||
@ -85,6 +85,8 @@ namespace chaiscript {
|
||||
|
||||
constexpr const std::type_info *bare_type_info() const noexcept { return m_bare_type_info; }
|
||||
|
||||
void make_const() noexcept { m_flags |= (1 << is_const_flag); }
|
||||
|
||||
private:
|
||||
struct Unknown_Type {
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user