Skip to content

Commit

Permalink
Fix for variant changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
samdeane committed Nov 22, 2024
1 parent dece74a commit 2f33b90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Sources/SwiftGodot/Core/GenericSignal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public class GenericSignal<each T: VariantStorable> {
args.append(Variant(arg))
}
let result = target.emitSignalWithArguments(args)
return GodotError(rawValue: Int64(result)!)!
guard let result else { return .ok }
guard let errorCode = Int(result) else { return .ok }
return GodotError(rawValue: Int64(errorCode))!
}

/// You can await this property to wait for the signal to be emitted once.
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftGodot/Core/RawCall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extension Object {
/// All input arguments must be marshaled into `Variant`s.
/// The result is a `Variant` that must be unmarshaled into the expected type.
@discardableResult /* discardable per discardableList: Object, emit_signal */
final func rawCall(_ p_method_bind: GDExtensionMethodBindPtr, arguments: [Variant]) -> Variant {
final func rawCall(_ p_method_bind: GDExtensionMethodBindPtr, arguments: [Variant]) -> Variant? {
var _result: Variant.ContentType = Variant.zero
// A temporary allocation containing pointers to `Variant.ContentType` of marshaled arguments
withUnsafeTemporaryAllocation(of: UnsafeRawPointer?.self, capacity: arguments.count) { pArgsBuffer in
Expand All @@ -33,12 +33,12 @@ extension Object {
}
}

return Variant(copying: _result)
return Variant(takingOver: _result)
}

/// Non-variadic variation on the emitSignal method.
/// Used by GenericSignal.
public final func emitSignalWithArguments(_ arguments: [Variant]) -> Variant {
public final func emitSignalWithArguments(_ arguments: [Variant]) -> Variant? {
return rawCall(Object.method_emit_signal, arguments: arguments)
}

Expand Down

0 comments on commit 2f33b90

Please sign in to comment.