mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 04:20:17 +00:00
Update obj.h
This commit is contained in:
parent
d2410e12b1
commit
0da5644db5
@ -111,6 +111,11 @@ struct PyObject final{
|
||||
bool is_attr_valid() const noexcept { return _attr != nullptr; }
|
||||
void* _value_ptr() noexcept { return (char*)this + FIXED_SIZE; }
|
||||
|
||||
template<typename T> T& as() noexcept {
|
||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||
return *reinterpret_cast<T*>(_value_ptr());
|
||||
}
|
||||
|
||||
NameDict& attr() {
|
||||
PK_DEBUG_ASSERT(is_attr_valid())
|
||||
return *_attr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user