Skip to content

Commit e6cb2e8

Browse files
committed
Merge pull request #103619 from bruvzg/stdio_binds
Add missing default values to the `read_*_from_stdin` binds.
2 parents dc03cf9 + ff118b6 commit e6cb2e8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

core/core_bind.compat.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Dictionary OS::_execute_with_pipe_bind_compat_94434(const String &p_path, const
5353
}
5454

5555
void OS::_bind_compatibility_methods() {
56+
ClassDB::bind_compatibility_method(D_METHOD("read_string_from_stdin", "buffer_size"), &OS::read_string_from_stdin);
57+
ClassDB::bind_compatibility_method(D_METHOD("read_buffer_from_stdin", "buffer_size"), &OS::read_buffer_from_stdin);
5658
ClassDB::bind_compatibility_method(D_METHOD("read_string_from_stdin"), &OS::_read_string_from_stdin_bind_compat_91201);
5759
ClassDB::bind_compatibility_method(D_METHOD("execute_with_pipe", "path", "arguments"), &OS::_execute_with_pipe_bind_compat_94434);
5860
}

core/core_bind.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,8 @@ void OS::_bind_methods() {
657657
ClassDB::bind_method(D_METHOD("get_system_font_path_for_text", "font_name", "text", "locale", "script", "weight", "stretch", "italic"), &OS::get_system_font_path_for_text, DEFVAL(String()), DEFVAL(String()), DEFVAL(400), DEFVAL(100), DEFVAL(false));
658658
ClassDB::bind_method(D_METHOD("get_executable_path"), &OS::get_executable_path);
659659

660-
ClassDB::bind_method(D_METHOD("read_string_from_stdin", "buffer_size"), &OS::read_string_from_stdin);
661-
ClassDB::bind_method(D_METHOD("read_buffer_from_stdin", "buffer_size"), &OS::read_buffer_from_stdin);
660+
ClassDB::bind_method(D_METHOD("read_string_from_stdin", "buffer_size"), &OS::read_string_from_stdin, DEFVAL(1024));
661+
ClassDB::bind_method(D_METHOD("read_buffer_from_stdin", "buffer_size"), &OS::read_buffer_from_stdin, DEFVAL(1024));
662662
ClassDB::bind_method(D_METHOD("get_stdin_type"), &OS::get_stdin_type);
663663
ClassDB::bind_method(D_METHOD("get_stdout_type"), &OS::get_stdout_type);
664664
ClassDB::bind_method(D_METHOD("get_stderr_type"), &OS::get_stderr_type);

doc/classes/OS.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@
720720
</method>
721721
<method name="read_buffer_from_stdin">
722722
<return type="PackedByteArray" />
723-
<param index="0" name="buffer_size" type="int" />
723+
<param index="0" name="buffer_size" type="int" default="1024" />
724724
<description>
725725
Reads a user input as raw data from the standard input. This operation can be [i]blocking[/i], which causes the window to freeze if [method read_string_from_stdin] is called on the main thread.
726726
- If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing [kbd]Enter[/kbd]).
@@ -732,7 +732,7 @@
732732
</method>
733733
<method name="read_string_from_stdin">
734734
<return type="String" />
735-
<param index="0" name="buffer_size" type="int" />
735+
<param index="0" name="buffer_size" type="int" default="1024" />
736736
<description>
737737
Reads a user input as a UTF-8 encoded string from the standard input. This operation can be [i]blocking[/i], which causes the window to freeze if [method read_string_from_stdin] is called on the main thread.
738738
- If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing [kbd]Enter[/kbd]).

0 commit comments

Comments
 (0)