Merge pull request #111135 from m4gr3d/add_emit_signal_overload

[Android] Minor updates to the `GodotPlugin` APIs
This commit is contained in:
Thaddeus Crews 2025-10-21 15:10:55 -05:00
commit 58a64124e8
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
6 changed files with 44 additions and 45 deletions

View file

@ -361,7 +361,7 @@ public abstract class GodotPlugin {
/**
* Emit a registered Godot signal.
* @param signalName Name of the signal to emit. It will be validated against the set of registered signals.
* @param signalArgs Arguments used to populate the emitted signal. The arguments will be validated against the {@link SignalInfo} matching the registered signalName parameter.
* @param signalArgs Arguments used to populate the emitted signal. The arguments will be validated against the registered {@link SignalInfo} matching the signalName parameter.
*/
protected void emitSignal(final String signalName, final Object... signalArgs) {
try {
@ -380,6 +380,15 @@ public abstract class GodotPlugin {
}
}
/**
* Emit a registered Godot signal.
* @param signal Signal to emit. It will be validated against the set of registered signals.
* @param signalArgs Arguments used to populate the emitted signal. The arguments will be validated against the registered {@link SignalInfo} matching the signal parameter.
*/
protected void emitSignal(SignalInfo signal, final Object... signalArgs) {
emitSignal(signal.getName(), signalArgs);
}
/**
* Emit a Godot signal.
* @param godot Godot instance
@ -402,7 +411,8 @@ public abstract class GodotPlugin {
// Validate the argument's types.
for (int i = 0; i < signalParamTypes.length; i++) {
if (!signalParamTypes[i].isInstance(signalArgs[i])) {
Object signalArg = signalArgs[i];
if (signalArg != null && !signalParamTypes[i].isInstance(signalArg)) {
throw new IllegalArgumentException(
"Invalid type for argument #" + i + ". Should be of type " + signalParamTypes[i].getName());
}