Added missing documentation to the source code in the Playdate bindings target.
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
internal import CPlaydate
|
||||
|
||||
/// The cached `playdate->network->http` C API table.
|
||||
private var httpAPI: UnsafePointer<playdate_http> { Playdate.httpAPI.unsafelyUnwrapped }
|
||||
|
||||
extension Network {
|
||||
/// An HTTP connection to a server. Wraps `HTTPConnection`.
|
||||
///
|
||||
/// The binding stores a back-reference to each wrapper in the
|
||||
/// underlying object's userdata slot so callbacks can recover the
|
||||
/// wrapper; the C userdata slot is therefore reserved by the binding.
|
||||
public final class HTTPConnection {
|
||||
let pointer: OpaquePointer
|
||||
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
internal import CPlaydate
|
||||
|
||||
/// The cached `playdate->network->tcp` C API table.
|
||||
private var tcpAPI: UnsafePointer<playdate_tcp> { Playdate.tcpAPI.unsafelyUnwrapped }
|
||||
|
||||
extension Network {
|
||||
/// A TCP connection to a server. Wraps `TCPConnection`.
|
||||
///
|
||||
/// The binding stores a back-reference to each wrapper in the
|
||||
/// underlying object's userdata slot so callbacks can recover the
|
||||
/// wrapper; the C userdata slot is therefore reserved by the binding.
|
||||
public final class TCPConnection {
|
||||
let pointer: OpaquePointer
|
||||
|
||||
|
||||
@@ -21,8 +21,11 @@ extension Network {
|
||||
case notConnectedToAP = -16
|
||||
case notImplemented = -17
|
||||
case connectionClosed = -18
|
||||
/// An error code not covered by `PDNetErr`.
|
||||
case unknown = 1
|
||||
|
||||
/// Creates an error from the C code, or `.unknown` for
|
||||
/// unrecognized codes.
|
||||
init(_ error: PDNetErr) {
|
||||
self = NetError(rawValue: Int32(error.rawValue)) ?? .unknown
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
internal import CPlaydate
|
||||
|
||||
/// The cached `playdate->network` C API table.
|
||||
private var networkAPI: UnsafePointer<playdate_network> { Playdate.networkAPI.unsafelyUnwrapped }
|
||||
|
||||
/// The network API: wifi status, HTTP, and TCP.
|
||||
@@ -18,6 +19,7 @@ extension Network {
|
||||
error == NET_OK ? nil : NetError(error)
|
||||
}
|
||||
|
||||
/// The device's current wifi status.
|
||||
public static var status: WifiStatus {
|
||||
WifiStatus(rawValue: UInt32(networkAPI.pointee.getStatus.unsafelyUnwrapped().rawValue)) ?? .notConnected
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user