Rename hks_object to hks_reference
This commit is contained in:
parent
5b67a53e9c
commit
f98f7ad781
@ -6,22 +6,22 @@
|
|||||||
|
|
||||||
namespace ui_scripting
|
namespace ui_scripting
|
||||||
{
|
{
|
||||||
hks_object::hks_object(const game::hks::HksObject& value)
|
hks_reference::hks_reference(const game::hks::HksObject& value)
|
||||||
{
|
{
|
||||||
this->assign(value);
|
this->assign(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
hks_object::hks_object(const hks_object& other) noexcept
|
hks_reference::hks_reference(const hks_reference& other) noexcept
|
||||||
{
|
{
|
||||||
this->operator=(other);
|
this->operator=(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
hks_object::hks_object(hks_object&& other) noexcept
|
hks_reference::hks_reference(hks_reference&& other) noexcept
|
||||||
{
|
{
|
||||||
this->operator=(std::move(other));
|
this->operator=(std::move(other));
|
||||||
}
|
}
|
||||||
|
|
||||||
hks_object& hks_object::operator=(const hks_object& other) noexcept
|
hks_reference& hks_reference::operator=(const hks_reference& other) noexcept
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ namespace ui_scripting
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
hks_object& hks_object::operator=(hks_object&& other) noexcept
|
hks_reference& hks_reference::operator=(hks_reference&& other) noexcept
|
||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
@ -44,17 +44,17 @@ namespace ui_scripting
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
hks_object::~hks_object()
|
hks_reference::~hks_reference()
|
||||||
{
|
{
|
||||||
this->release();
|
this->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
const game::hks::HksObject& hks_object::get() const
|
const game::hks::HksObject& hks_reference::get() const
|
||||||
{
|
{
|
||||||
return this->value_;
|
return this->value_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hks_object::assign(const game::hks::HksObject& value)
|
void hks_reference::assign(const game::hks::HksObject& value)
|
||||||
{
|
{
|
||||||
this->value_ = value;
|
this->value_ = value;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace ui_scripting
|
|||||||
state->m_apistack.top = top;
|
state->m_apistack.top = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hks_object::release()
|
void hks_reference::release()
|
||||||
{
|
{
|
||||||
if (this->ref_)
|
if (this->ref_)
|
||||||
{
|
{
|
||||||
@ -222,7 +222,7 @@ namespace ui_scripting
|
|||||||
bool script_value::is<int>() const
|
bool script_value::is<int>() const
|
||||||
{
|
{
|
||||||
const auto number = this->get_raw().v.number;
|
const auto number = this->get_raw().v.number;
|
||||||
return this->get_raw().t == game::hks::TNUMBER && static_cast<int>(number) == number;
|
return this->get_type() == game::hks::TNUMBER && static_cast<int>(number) == number;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -250,7 +250,7 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<long long>() const
|
bool script_value::is<long long>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TUI64;
|
return this->get_type() == game::hks::TUI64;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -278,7 +278,7 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<bool>() const
|
bool script_value::is<bool>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TBOOLEAN;
|
return this->get_type() == game::hks::TBOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -294,7 +294,7 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<float>() const
|
bool script_value::is<float>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TNUMBER;
|
return this->get_type() == game::hks::TNUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -322,7 +322,7 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<const char*>() const
|
bool script_value::is<const char*>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TSTRING;
|
return this->get_type() == game::hks::TSTRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -350,7 +350,7 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<lightuserdata>() const
|
bool script_value::is<lightuserdata>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TLIGHTUSERDATA;
|
return this->get_type() == game::hks::TLIGHTUSERDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -366,7 +366,7 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<userdata>() const
|
bool script_value::is<userdata>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TUSERDATA;
|
return this->get_type() == game::hks::TUSERDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -382,7 +382,7 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<table>() const
|
bool script_value::is<table>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TTABLE;
|
return this->get_type() == game::hks::TTABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -398,20 +398,25 @@ namespace ui_scripting
|
|||||||
template <>
|
template <>
|
||||||
bool script_value::is<function>() const
|
bool script_value::is<function>() const
|
||||||
{
|
{
|
||||||
return this->get_raw().t == game::hks::TIFUNCTION
|
return this->get_type() == game::hks::TIFUNCTION
|
||||||
|| this->get_raw().t == game::hks::TCFUNCTION;
|
|| this->get_type() == game::hks::TCFUNCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
function script_value::get() const
|
function script_value::get() const
|
||||||
{
|
{
|
||||||
return {this->get_raw().v.cClosure, this->get_raw().t};
|
return {this->get_raw().v.cClosure, this->get_type()};
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************
|
/***************************************************************
|
||||||
*
|
*
|
||||||
**************************************************************/
|
**************************************************************/
|
||||||
|
|
||||||
|
const game::hks::HksObjectType script_value::get_type() const
|
||||||
|
{
|
||||||
|
return this->value_.get().t;
|
||||||
|
}
|
||||||
|
|
||||||
const game::hks::HksObject& script_value::get_raw() const
|
const game::hks::HksObject& script_value::get_raw() const
|
||||||
{
|
{
|
||||||
return this->value_.get();
|
return this->value_.get();
|
||||||
@ -419,12 +424,12 @@ namespace ui_scripting
|
|||||||
|
|
||||||
bool script_value::operator==(const script_value& other) const
|
bool script_value::operator==(const script_value& other) const
|
||||||
{
|
{
|
||||||
if (this->get_raw().t != other.get_raw().t)
|
if (this->get_type() != other.get_type())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->get_raw().t == game::hks::TSTRING)
|
if (this->get_type() == game::hks::TSTRING)
|
||||||
{
|
{
|
||||||
return this->get<std::string>() == other.get<std::string>();
|
return this->get<std::string>() == other.get<std::string>();
|
||||||
}
|
}
|
||||||
|
@ -62,18 +62,18 @@ namespace ui_scripting
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class hks_object
|
class hks_reference
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
hks_object() = default;
|
hks_reference() = default;
|
||||||
hks_object(const game::hks::HksObject& value);
|
hks_reference(const game::hks::HksObject& value);
|
||||||
hks_object(const hks_object& other) noexcept;
|
hks_reference(const hks_reference& other) noexcept;
|
||||||
hks_object(hks_object&& other) noexcept;
|
hks_reference(hks_reference&& other) noexcept;
|
||||||
|
|
||||||
hks_object& operator=(const hks_object& other) noexcept;
|
hks_reference& operator=(const hks_reference& other) noexcept;
|
||||||
hks_object& operator=(hks_object&& other) noexcept;
|
hks_reference& operator=(hks_reference&& other) noexcept;
|
||||||
|
|
||||||
~hks_object();
|
~hks_reference();
|
||||||
|
|
||||||
const game::hks::HksObject& get() const;
|
const game::hks::HksObject& get() const;
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ namespace ui_scripting
|
|||||||
{
|
{
|
||||||
if (!this->is<T>())
|
if (!this->is<T>())
|
||||||
{
|
{
|
||||||
const auto hks_typename = game::hks::s_compilerTypeName[this->get_raw().t + 2];
|
const auto hks_typename = game::hks::s_compilerTypeName[this->get_type() + 2];
|
||||||
const auto typename_ = get_typename<T>();
|
const auto typename_ = get_typename<T>();
|
||||||
|
|
||||||
throw std::runtime_error(utils::string::va("%s expected, got %s",
|
throw std::runtime_error(utils::string::va("%s expected, got %s",
|
||||||
@ -196,9 +196,10 @@ namespace ui_scripting
|
|||||||
return this->as<T>();
|
return this->as<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const game::hks::HksObjectType get_type() const;
|
||||||
const game::hks::HksObject& get_raw() const;
|
const game::hks::HksObject& get_raw() const;
|
||||||
|
|
||||||
hks_object value_{};
|
hks_reference value_{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user