Skip to content

Commit fd2bb79

Browse files
committed
Fix rpc's with named parameters
Add __print helper method for C++
1 parent 3acf2f8 commit fd2bb79

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/cpp/dart_bindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ void dart_print(Dart_NativeArguments args) {
710710
Dart_Handle arg = Dart_GetNativeArgument(args, 1);
711711
DART_CHECK(result, Dart_StringToCString(arg, &cstring), "Error getting printable string.");
712712

713-
__print_verbose(cstring);
713+
__print(cstring);
714714
}
715715

716716
void bind_class(Dart_NativeArguments args) {

src/cpp/dart_helpers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ inline bool is_print_verbose_enabled() {
1212
return false;
1313
}
1414

15+
inline void __print(const char* msg) {
16+
godot::String godot_msg(msg);
17+
godot::UtilityFunctions::print(msg);
18+
}
19+
1520
inline void __print_verbose(const char *msg) {
1621
if (is_print_verbose_enabled()) {
1722
godot::String godot_msg(msg);

src/dart/godot_dart_build/lib/src/godot_script_generator.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,14 @@ class GodotScriptAnnotationGenerator
329329

330330
for (final method in rpcMethods) {
331331
var methodSignature = method.getDisplayString(withNullability: true);
332-
var withIdParam =
333-
'${methodSignature.substring(0, methodSignature.length - 1)}, {int? peerId})';
332+
String withIdParam;
333+
if (method.parameters.where((p) => p.isNamed).isNotEmpty) {
334+
withIdParam =
335+
'${methodSignature.substring(0, methodSignature.length - 2)}, int? peerId})';
336+
} else {
337+
withIdParam =
338+
'${methodSignature.substring(0, methodSignature.length - 1)}, {int? peerId})';
339+
}
334340
buffer.write(withIdParam);
335341
buffer.writeln('{');
336342
buffer.writeln(' final args = [');

0 commit comments

Comments
 (0)