mirror of
https://github.com/godotengine/godot-cpp.git
synced 2026-01-08 18:10:02 +03:00
Merge pull request #1399 from bruvzg/init_list
[Packed*Array] Add support for initializer lists.
This commit is contained in:
@@ -197,6 +197,7 @@ void Example::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("test_string_is_fourty_two"), &Example::test_string_is_fourty_two);
|
||||
ClassDB::bind_method(D_METHOD("test_string_resize"), &Example::test_string_resize);
|
||||
ClassDB::bind_method(D_METHOD("test_vector_ops"), &Example::test_vector_ops);
|
||||
ClassDB::bind_method(D_METHOD("test_vector_init_list"), &Example::test_vector_init_list);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("test_object_cast_to_node", "object"), &Example::test_object_cast_to_node);
|
||||
ClassDB::bind_method(D_METHOD("test_object_cast_to_control", "object"), &Example::test_object_cast_to_control);
|
||||
@@ -411,6 +412,15 @@ int Example::test_vector_ops() const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Example::test_vector_init_list() const {
|
||||
PackedInt32Array arr = { 10, 20, 30, 45 };
|
||||
int ret = 0;
|
||||
for (const int32_t &E : arr) {
|
||||
ret += E;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Callable Example::test_callable_mp() {
|
||||
return callable_mp(this, &Example::unbound_method1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user