-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposed some previously private things for testing.
- Loading branch information
Showing
9 changed files
with
122 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
public struct Testing { | ||
/// Public API for tracking live objects | ||
public struct LiveObjects { | ||
/// All framework objects | ||
public static var framework: [Wrapped] { Array(liveFrameworkObjects.values) } | ||
|
||
/// All user-defined objects | ||
public static var subtyped: [Wrapped] { Array(liveSubtypedObjects.values) } | ||
|
||
/// All objects | ||
public static var all: [Wrapped] { framework + subtyped } | ||
|
||
/// Reset all existing tracked objects | ||
public static func reset() { | ||
liveFrameworkObjects.removeAll() | ||
liveSubtypedObjects.removeAll() | ||
} | ||
} | ||
|
||
public struct ClassNames { | ||
public static func setDuplicateNameCallback(_ callback: @escaping (_ name: StringName, _ type: Wrapped.Type) -> Void) -> DuplicateNameCallback { | ||
let old = duplicateClassNameDetected | ||
duplicateClassNameDetected = callback | ||
return old | ||
} | ||
} | ||
} | ||
|
||
/// Currently contains all instantiated objects, but might want to separate those | ||
/// (or find a way of easily telling appart) framework objects from user subtypes | ||
internal var liveFrameworkObjects: [UnsafeRawPointer: Wrapped] = [:] | ||
internal var liveSubtypedObjects: [UnsafeRawPointer: Wrapped] = [:] | ||
|
||
public typealias DuplicateNameCallback = (StringName, Wrapped.Type) -> Void | ||
var duplicateClassNameDetected: DuplicateNameCallback = { name, type in | ||
preconditionFailure( | ||
""" | ||
Godot already has a class named \(name), so I cannot register \(type) using that name. This is a fatal error because the only way I can tell whether Godot is handing me a pointer to a class I'm responsible for is by checking the class name. | ||
""" | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters