diff options
author | David Snopek <dsnopek@gmail.com> | 2023-07-31 18:31:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-31 18:31:24 -0500 |
commit | 5834e16a221fde8dc0b6ca4b7a6721cc4b258037 (patch) | |
tree | 07fa39958c72b286817c0a7507df1b737f5e150e /test/src/example.cpp | |
parent | 845226d66aa25a34ffbbf63ca8666f36032ec8ec (diff) | |
parent | 8bc1c1dbeb0342ae593c46c97e7032bbc664194c (diff) | |
download | redot-cpp-5834e16a221fde8dc0b6ca4b7a6721cc4b258037.tar.gz |
Merge pull request #1166 from dsnopek/string-resize
Implement `String::resize()` in godot-cpp
Diffstat (limited to 'test/src/example.cpp')
-rw-r--r-- | test/src/example.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/src/example.cpp b/test/src/example.cpp index fb47dd8..af3837a 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -139,6 +139,7 @@ void Example::_bind_methods() { ClassDB::bind_method(D_METHOD("test_string_ops"), &Example::test_string_ops); ClassDB::bind_method(D_METHOD("test_str_utility"), &Example::test_str_utility); 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_bitfield", "flags"), &Example::test_bitfield); @@ -304,6 +305,16 @@ bool Example::test_string_is_fourty_two(const String &p_string) const { return strcmp(p_string.utf8().ptr(), "fourty two") == 0; } +String Example::test_string_resize(String p_string) const { + int orig_len = p_string.length(); + p_string.resize(orig_len + 3); + char32_t *data = p_string.ptrw(); + data[orig_len + 0] = '!'; + data[orig_len + 1] = '?'; + data[orig_len + 2] = '\0'; + return p_string; +} + int Example::test_vector_ops() const { PackedInt32Array arr; arr.push_back(10); |