Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/core/Array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class Object;
class Array {
godot_array _godot_array;

friend class Variant;
inline explicit Array(const godot_array &other) {
_godot_array = other;
}

public:
Array();
Array(const Array &other);
Expand Down
5 changes: 5 additions & 0 deletions include/core/Dictionary.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace godot {
class Dictionary {
godot_dictionary _godot_dictionary;

friend Variant::operator Dictionary() const;
inline explicit Dictionary(const godot_dictionary &other) {
_godot_dictionary = other;
}

public:
Dictionary();
Dictionary(const Dictionary &other);
Expand Down
6 changes: 2 additions & 4 deletions src/core/Variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,12 @@ Variant::operator RID() const {
}

Variant::operator Dictionary() const {
Dictionary ret;
*(godot_dictionary *)&ret = godot::api->godot_variant_as_dictionary(&_godot_variant);
Dictionary ret(godot::api->godot_variant_as_dictionary(&_godot_variant));
return ret;
}

Variant::operator Array() const {
Array ret;
*(godot_array *)&ret = godot::api->godot_variant_as_array(&_godot_variant);
Array ret(godot::api->godot_variant_as_array(&_godot_variant));
return ret;
}

Expand Down