Skip to content

Commit

Permalink
Add missing int→Variant conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Nov 8, 2023
1 parent 2dfe792 commit bcac96c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
14 changes: 13 additions & 1 deletion include/godot_cpp/variant/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,18 @@ class Variant {
Variant(int64_t v);
Variant(int32_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint32_t v) :
Variant(int16_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(int8_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint64_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint32_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint16_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(uint8_t v) :
Variant(static_cast<int64_t>(v)) {}
Variant(double v);
Variant(float v) :
Variant((double)v) {}
Expand Down Expand Up @@ -209,8 +217,12 @@ class Variant {
operator bool() const;
operator int64_t() const;
operator int32_t() const;
operator int16_t() const;
operator int8_t() const;
operator uint64_t() const;
operator uint32_t() const;
operator uint16_t() const;
operator uint8_t() const;
operator double() const;
operator float() const;
operator String() const;
Expand Down
16 changes: 16 additions & 0 deletions src/variant/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ Variant::operator int32_t() const {
return static_cast<int32_t>(operator int64_t());
}

Variant::operator int16_t() const {
return static_cast<int16_t>(operator int64_t());
}

Variant::operator int8_t() const {
return static_cast<int8_t>(operator int64_t());
}

Variant::operator uint64_t() const {
return static_cast<uint64_t>(operator int64_t());
}
Expand All @@ -276,6 +284,14 @@ Variant::operator uint32_t() const {
return static_cast<uint32_t>(operator int64_t());
}

Variant::operator uint16_t() const {
return static_cast<uint16_t>(operator int64_t());
}

Variant::operator uint8_t() const {
return static_cast<uint8_t>(operator int64_t());
}

Variant::operator double() const {
double result;
to_type_constructor[FLOAT](&result, _native_ptr());
Expand Down

0 comments on commit bcac96c

Please sign in to comment.