Implementing dictionary operators

This commit is contained in:
Bastiaan Olij
2021-11-18 14:05:14 +11:00
parent 5cacce7a26
commit b008810c01
7 changed files with 46 additions and 9 deletions

View File

@@ -54,7 +54,9 @@ void Example::_bind_methods() {
ClassDB::bind_method(D_METHOD("return_something_const"), &Example::return_something_const);
ClassDB::bind_method(D_METHOD("return_extended_ref"), &Example::return_extended_ref);
ClassDB::bind_method(D_METHOD("extended_ref_checks"), &Example::extended_ref_checks);
ClassDB::bind_method(D_METHOD("test_array"), &Example::test_array);
ClassDB::bind_method(D_METHOD("test_dictionary"), &Example::test_dictionary);
{
MethodInfo mi;
@@ -145,6 +147,15 @@ Array Example::test_array() const {
return arr;
}
Dictionary Example::test_dictionary() const {
Dictionary dict;
dict["hello"] = "world";
dict["foo"] = "bar";
return dict;
}
// Properties.
void Example::set_custom_position(const Vector2 &pos) {
custom_position = pos;

View File

@@ -88,7 +88,9 @@ public:
Ref<ExampleRef> extended_ref_checks(Ref<ExampleRef> p_ref) const;
Variant varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
void emit_custom_signal(const String &name, int value);
Array test_array() const;
Dictionary test_dictionary() const;
// Property.
void set_custom_position(const Vector2 &pos);