Expose some low level functions and String operators.

This commit is contained in:
bruvzg
2022-11-28 14:47:55 +02:00
parent 69b525494b
commit abca497b72
11 changed files with 623 additions and 1049 deletions

View File

@@ -123,6 +123,8 @@ void Example::_bind_methods() {
ClassDB::bind_method(D_METHOD("test_tarray"), &Example::test_tarray);
ClassDB::bind_method(D_METHOD("test_dictionary"), &Example::test_dictionary);
ClassDB::bind_method(D_METHOD("test_node_argument"), &Example::test_node_argument);
ClassDB::bind_method(D_METHOD("test_string_ops"), &Example::test_string_ops);
ClassDB::bind_method(D_METHOD("test_vector_ops"), &Example::test_vector_ops);
ClassDB::bind_method(D_METHOD("def_args", "a", "b"), &Example::def_args, DEFVAL(100), DEFVAL(200));
@@ -255,6 +257,28 @@ Array Example::test_array() const {
return arr;
}
String Example::test_string_ops() const {
String s = String("A");
s += "B";
s += "C";
s += char32_t(0x010E);
s = s + "E";
return s;
}
int Example::test_vector_ops() const {
PackedInt32Array arr;
arr.push_back(10);
arr.push_back(20);
arr.push_back(30);
arr.push_back(45);
int ret = 0;
for (const int32_t &E : arr) {
ret += E;
}
return ret;
}
void Example::test_tarray_arg(const TypedArray<int64_t> &p_array) {
for (int i = 0; i < p_array.size(); i++) {
UtilityFunctions::print(p_array[i]);