mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 19:40:18 +00:00
Update common.h
This commit is contained in:
parent
ea3e64ec8c
commit
2d3abde352
@ -188,15 +188,17 @@ struct PyVar final{
|
|||||||
|
|
||||||
// uninitialized
|
// uninitialized
|
||||||
PyVar() = default;
|
PyVar() = default;
|
||||||
|
|
||||||
|
/* We must initialize all members to allow == operator to work correctly */
|
||||||
// constexpr initialized
|
// constexpr initialized
|
||||||
constexpr PyVar(const const_sso_var&, Type type, int value): type(type), is_sso(true), flags(0), _0(value), _1(0) {}
|
constexpr PyVar(const const_sso_var&, Type type, int value): type(type), is_sso(true), flags(0), _0(value), _1(0) {}
|
||||||
// zero initialized
|
// zero initialized
|
||||||
constexpr PyVar(std::nullptr_t): type(0), is_sso(false), flags(0), _0(0), _1(0) {}
|
constexpr PyVar(std::nullptr_t): type(0), is_sso(false), flags(0), _0(0), _1(0) {}
|
||||||
// PyObject* initialized (is_sso = false)
|
// PyObject* initialized (is_sso = false)
|
||||||
PyVar(Type type, PyObject* p): type(type), is_sso(false), flags(0), _1(reinterpret_cast<i64>(p)) {}
|
PyVar(Type type, PyObject* p): type(type), is_sso(false), flags(0), _0(0), _1(reinterpret_cast<i64>(p)) {}
|
||||||
// SSO initialized (is_sso = true)
|
// SSO initialized (is_sso = true)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
PyVar(Type type, T value): type(type), is_sso(true), flags(0) {
|
PyVar(Type type, T value): type(type), is_sso(true), flags(0), _0(0), _1(0) {
|
||||||
static_assert(sizeof(T) <= 12, "SSO size exceeded");
|
static_assert(sizeof(T) <= 12, "SSO size exceeded");
|
||||||
as<T>() = value;
|
as<T>() = value;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user