You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/extension/gdextension_interface.h
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -551,6 +551,7 @@ typedef struct {
551
551
552
552
GDExtensionVariantPtr (*array_operator_index)(GDExtensionTypePtrp_self, GDExtensionIntp_index); // p_self should be an Array ptr
553
553
GDExtensionVariantPtr (*array_operator_index_const)(GDExtensionConstTypePtrp_self, GDExtensionIntp_index); // p_self should be an Array ptr
554
+
void (*array_ref)(GDExtensionTypePtrp_self, GDExtensionConstTypePtrp_from); // p_self should be an Array ptr
554
555
void (*array_set_typed)(GDExtensionTypePtrp_self, uint32_tp_type, GDExtensionConstStringNamePtrp_class_name, GDExtensionConstVariantPtrp_script); // p_self should be an Array ptr
ERR_FAIL_MSG(vformat(R"(Unable to convert array index %i from "%s" to "%s".)", i, Variant::get_type_name(element.get_type()), Variant::get_type_name(typed.type)));
233
223
}
224
+
}
225
+
_p->array = p_array._p->array;
226
+
return;
227
+
}
234
228
235
-
_p->array = new_array;
229
+
Vector<Variant> array;
230
+
array.resize(size);
231
+
Variant *data = array.ptrw();
232
+
233
+
if (source_typed.type == Variant::NIL && typed.type != Variant::OBJECT) {
234
+
// from variants to primitives
235
+
for (int i = 0; i < size; i++) {
236
+
const Variant *value = source + i;
237
+
if (value->get_type() == typed.type) {
238
+
data[i] = *value;
239
+
continue;
240
+
}
241
+
if (!Variant::can_convert_strict(value->get_type(), typed.type)) {
242
+
ERR_FAIL_MSG("Unable to convert array index " + itos(i) + " from '" + Variant::get_type_name(value->get_type()) + "' to '" + Variant::get_type_name(typed.type) + "'.");
ERR_FAIL_COND_MSG(ce.error, vformat(R"(Unable to convert array index %i from "%s" to "%s".)", i, Variant::get_type_name(value->get_type()), Variant::get_type_name(typed.type)));
ERR_FAIL_COND_MSG(ce.error, vformat(R"(Unable to convert array index %i from "%s" to "%s".)", i, Variant::get_type_name(value->get_type()), Variant::get_type_name(typed.type)));
236
255
}
237
-
} elseif (_p->typed.can_reference(p_array._p->typed)) { //same type or compatible
238
-
_ref(p_array);
239
256
} else {
240
-
ERR_FAIL_V_MSG(false, "Assignment of arrays of incompatible types.");
257
+
ERR_FAIL_MSG(vformat(R"(Cannot assign contents of "Array[%s]" to "Array[%s]".)", Variant::get_type_name(source_typed.type), Variant::get_type_name(typed.type)));
0 commit comments