mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
some fix
This commit is contained in:
parent
1714195da4
commit
393952d800
@ -219,6 +219,9 @@ struct PyVar final{
|
||||
}
|
||||
|
||||
i64 hash() const { return as<i64>(); }
|
||||
|
||||
template<typename T>
|
||||
T& obj_get();
|
||||
};
|
||||
|
||||
static_assert(sizeof(PyVar) == 16 && is_pod_v<PyVar>);
|
||||
|
@ -165,8 +165,14 @@ StrName _type_name(VM* vm, Type type);
|
||||
template<typename T> T to_void_p(VM*, PyVar);
|
||||
PyVar from_void_p(VM*, void*);
|
||||
|
||||
template<typename T>
|
||||
T& PyVar::obj_get(){
|
||||
static_assert(!std::is_reference_v<T>);
|
||||
if(is_sso) return as<T>();
|
||||
return ((Py_<T>*)(get()))->_value;
|
||||
}
|
||||
|
||||
#define PK_OBJ_GET(T, obj) (is_sso_v<T> ? obj.as<T>() : (((Py_<T>*)(obj.get()))->_value))
|
||||
#define PK_OBJ_GET(T, obj) (obj).obj_get<T>()
|
||||
|
||||
#define PK_OBJ_MARK(obj) \
|
||||
if(!is_tagged(obj) && !(obj)->gc_marked) { \
|
||||
|
Loading…
x
Reference in New Issue
Block a user