Allow booleanization of all types

We now allow booleanization of all types. This means that empty versions
of all types now evaluate to false. So a Vector2(0,0), Dictionary(),
etc.

This allows you to write GDScript like:
if not Dictionary():
  print("Empty dict")

Booleanization can now also no longer fail. There is no more valid flag,
this changes Variant and GDNative API.
This commit is contained in:
Hein-Pieter van Braam
2017-09-18 20:02:47 +02:00
parent 85641c545b
commit 833c3917b2
6 changed files with 20 additions and 105 deletions

View File

@@ -480,10 +480,9 @@ godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const g
return self->hash_compare(*other);
}
godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self, godot_bool *r_valid) {
godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self) {
const Variant *self = (const Variant *)p_self;
bool &valid = *r_valid;
return self->booleanize(valid);
return self->booleanize();
}
void GDAPI godot_variant_destroy(godot_variant *p_self) {