Skip to content

Commit 8468b9b

Browse files
committed
Rebuild docs
1 parent 4cf279c commit 8468b9b

File tree

434 files changed

+5677
-5225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

434 files changed

+5677
-5225
lines changed

.jazzy.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ code_host_file_url: https://github.com/johnfairh/swift-steamworks/blob/main
1010
clean: true
1111
sdk: macosx
1212
theme: fw2020
13-
#deployment_url: https://johnfairh.github.io/swift-steamworks/
13+
deployment_url: https://johnfairh.github.io/swift-steamworks/
1414
build_tool: spm
1515
modules:
1616
- Steamworks
@@ -47,6 +47,7 @@ custom_groups:
4747
- name: Structures
4848
children:
4949
- filepath /Structs.swift/
50+
- filepath /ManualTypes.swift/
5051
- SteamID
5152
- GameID
5253
- name: Protocols

docs/api-clients.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -4263,7 +4263,7 @@ <h5>Declaration</h5>
42634263

42644264
<div class="j2-swift j2-always">
42654265
<div class="j2-callout-title" role="heading" aria-level="6">Swift</div>
4266-
<pre><code class="language-swift">public final class SteamAPI: <a href="steamworks/types/steambaseapi3.html?swift">SteamBaseAPI</a></code></pre>
4266+
<pre><code class="language-swift">public final class SteamAPI: <a href="steamworks/types/steambaseapi3.html?swift">SteamBaseAPI</a>, <a href="https://developer.apple.com/documentation/swift/sendable?language=swift">Sendable</a></code></pre>
42674267
</div>
42684268

42694269

@@ -4285,7 +4285,7 @@ <h5>Declaration</h5>
42854285
</span>
42864286

42874287

4288-
<span class="j2-item-nav-item"><a href="https://github.com/johnfairh/swift-steamworks/blob/main/Sources/Steamworks/SteamAPI.swift#L24-L94">Show on GitHub</a></span>
4288+
<span class="j2-item-nav-item"><a href="https://github.com/johnfairh/swift-steamworks/blob/main/Sources/Steamworks/SteamAPI.swift#L24-L93">Show on GitHub</a></span>
42894289

42904290
</nav>
42914291
</div>
@@ -4331,7 +4331,7 @@ <h5>Declaration</h5>
43314331

43324332
<div class="j2-swift j2-always">
43334333
<div class="j2-callout-title" role="heading" aria-level="6">Swift</div>
4334-
<pre><code class="language-swift">public final class SteamGameServerAPI: <a href="steamworks/types/steambaseapi3.html?swift">SteamBaseAPI</a></code></pre>
4334+
<pre><code class="language-swift">public final class SteamGameServerAPI: <a href="steamworks/types/steambaseapi3.html?swift">SteamBaseAPI</a>, <a href="https://developer.apple.com/documentation/swift/sendable?language=swift">Sendable</a></code></pre>
43354335
</div>
43364336

43374337

@@ -4366,12 +4366,12 @@ <h5>Declaration</h5>
43664366

43674367

43684368
<section id="steamencryptedappticket" class="j2-item j2-swift j2-always">
4369-
<a name="//apple_ref/cpp/Class/class%20SteamEncryptedAppTicket" class="dashAnchor j2-item-dash-anchor" data-item-id="steamencryptedappticket"></a>
4370-
<h4 class="visually-hidden">class SteamEncryptedAppTicket</h4>
4369+
<a name="//apple_ref/cpp/Struct/struct%20SteamEncryptedAppTicket" class="dashAnchor j2-item-dash-anchor" data-item-id="steamencryptedappticket"></a>
4370+
<h4 class="visually-hidden">struct SteamEncryptedAppTicket</h4>
43714371

43724372

43734373
<a class="j2-item-title" href="#_steamencryptedappticket" data-bs-toggle="collapse" role="button" aria-expanded="false" aria-controls="_steamencryptedappticket"><code>
4374-
<span class="j2-swift j2-always"><span class="j2-item-secondary">class </span>SteamEncryptedAppTicket</span>
4374+
<span class="j2-swift j2-always"><span class="j2-item-secondary">struct </span>SteamEncryptedAppTicket</span>
43754375

43764376
</code></a>
43774377
<div class="collapse j2-item-popopen-wrapper" id="_steamencryptedappticket">
@@ -4398,7 +4398,7 @@ <h5>Declaration</h5>
43984398

43994399
<div class="j2-swift j2-always">
44004400
<div class="j2-callout-title" role="heading" aria-level="6">Swift</div>
4401-
<pre><code class="language-swift">public final class SteamEncryptedAppTicket</code></pre>
4401+
<pre><code class="language-swift">public struct SteamEncryptedAppTicket: <a href="https://developer.apple.com/documentation/swift/sendable?language=swift">Sendable</a></code></pre>
44024402
</div>
44034403

44044404

@@ -4420,7 +4420,7 @@ <h5>Declaration</h5>
44204420
</span>
44214421

44224422

4423-
<span class="j2-item-nav-item"><a href="https://github.com/johnfairh/swift-steamworks/blob/main/Sources/SteamworksEncryptedAppTicket/SteamEncryptedAppTicket.swift#L31-L110">Show on GitHub</a></span>
4423+
<span class="j2-item-nav-item"><a href="https://github.com/johnfairh/swift-steamworks/blob/main/Sources/SteamworksEncryptedAppTicket/SteamEncryptedAppTicket.swift#L15-L114">Show on GitHub</a></span>
44244424

44254425
</nav>
44264426
</div>

docs/enumerations.html

+221-221
Large diffs are not rendered by default.

docs/index.html

+120-37
Original file line numberDiff line numberDiff line change
@@ -4127,32 +4127,35 @@
41274127

41284128

41294129
<p><img src="https://shields.io/badge/platform-macOS%20%7C%20%3F%3F-lightgrey" alt="macOS" />
4130-
<img src="https://shields.io/badge/steamworks-1.54-lightgrey" alt="Steamworks 1.53a" />
4130+
<img src="https://shields.io/badge/steamworks-1.54-lightgrey" alt="Steamworks 1.54" />
41314131
<img src="https://shields.io/badge/license-MIT-black" alt="MIT" /></p>
41324132
<h1 class="j2-anchor j2-heading heading" id="steamworksswift">
41334133
<span data-anchor-id="steamworksswift">
41344134
steamworks-swift
41354135
</span></h1>
4136-
<p>Experiment with Steamworks SDK and Swift C++ importer.</p>
4136+
<p>A practical interface to the Steamworks SDK using the Swift C++ importer.</p>
4137+
<p><strong>Caveat Integrator: The Swift C++ importer is a chaotic science project; this package is built on top</strong></p>
41374138
<p>Current state:</p>
41384139
<ul>
4139-
<li>Requires Swift 5.7, Xcode 14 beta</li>
4140+
<li>All Steamworks interfaces complete - see <a href="https://johnfairh.github.io/swift-steamworks/index.html">rough docs</a></li>
41404141
<li>Code gen creates Swift versions of Steam types; callbacks and call-returns work</li>
4141-
<li>All interfaces complete - see <a href="https://johnfairh.github.io/swift-steamworks/index.html">rough docs</a></li>
4142-
<li>Some interface quality-of-life helpers in a spearate module</li>
4143-
<li><code>make</code> builds and runs a demo Swift program that accesses the C++
4144-
Steam API to initialize, do various sync and async queries, then shut it down.</li>
4145-
<li>Separate demo showing encrypted app-ticket stuff.</li>
4142+
<li>Some interface quality-of-life helpers in a separate <code>SteamworksHelpers</code> module</li>
4143+
<li><code>make test</code> builds and runs unit tests that run frame loops and access portions of the Steam API
4144+
doing various sync and async tasks.</li>
4145+
<li>Encrypted app ticket support in separate <code>SteamworksEncryptedAppTicket</code> module</li>
4146+
<li>Separate demo showing encrypted app-ticket stuff, <code>make run_ticket</code></li>
4147+
<li>Requires Swift 5.7, Xcode 14 beta 3</li>
41464148
<li>The Xcode project basically works, assumes <code>sdk</code> exists. SourceKit can manage
4147-
tab completion even if module interface gen is beyond it.</li>
4149+
tab completion even if module interface gen is beyond it</li>
4150+
<li>Can’t get anything out of SteamInput so can’t tell if the translation is reasonable :/</li>
41484151
</ul>
41494152
<h3 class="j2-anchor j2-heading heading" id="concept">
41504153
<span data-anchor-id="concept">
41514154
Concept
41524155
</span></h3>
41534156
<ul>
4154-
<li>Offer a pure Swift module <code>Steamworks</code> covering all of the current Steamworks API.</li>
4155-
<li>Leave out the deprecated and WIN32-only stuff.</li>
4157+
<li>Offer a pure Swift module <code>Steamworks</code> covering all of the current Steamworks API</li>
4158+
<li>Leave out the deprecated and WIN32-only stuff</li>
41564159
<li>Do not diverge too far from the ‘real’ API names to aid docs / searching / porting:
41574160
I think this is a better starting point than doing a complete OO analysis to carve
41584161
out function. Can go to build <code>SteamworksPatterns</code> or something if worthwhile. Name
@@ -4165,13 +4168,21 @@ <h3 class="j2-anchor j2-heading heading" id="concept">
41654168
<li>Map unions onto enums with associated values</li>
41664169
</ul>
41674170
</li>
4168-
<li>Provide custom API-lifetime and message dispatch classes.</li>
4169-
<li>Provide strongly typed handles.</li>
4170-
<li>Access interfaces via central types.</li>
4171+
<li>Provide custom API-lifetime and message dispatch classes</li>
4172+
<li>Provide strongly typed handles</li>
4173+
<li>Access interfaces via central types</li>
41714174
<li>Use code gen to deal with the ~900 APIs and their ~400 types, taking advantage of the
4172-
handy JSON file. This code-gen piece is the actual main work in this project.</li>
4175+
handy JSON file. This code-gen piece is the actual main work in this project</li>
41734176
<li>Provide quality-of-life helpers module <code>SteamworksHelpers</code> to wrap up API patterns
4174-
involving multiple calls, usually determining buffer lengths.</li>
4177+
involving multiple calls, usually determining buffer lengths</li>
4178+
</ul>
4179+
<h3 class="j2-anchor j2-heading heading" id="next">
4180+
<span data-anchor-id="next">
4181+
Next
4182+
</span></h3>
4183+
<ul>
4184+
<li>Try generating a DocC package, using code-gen to make a sensible layout</li>
4185+
<li>Port Spacewar over to Swift</li>
41754186
</ul>
41764187
<h3 class="j2-anchor j2-heading heading" id="api-mapping-design">
41774188
<span data-anchor-id="api-mapping-design">
@@ -4181,14 +4192,88 @@ <h3 class="j2-anchor j2-heading heading" id="lifecycle">
41814192
<span data-anchor-id="lifecycle">
41824193
Lifecycle
41834194
</span></h3>
4195+
<pre><code class="language-swift">// Initialization
4196+
let steam = SteamAPI(appID: MyAppId) // or `SteamGameServerAPI`
4197+
4198+
// Frame loop
4199+
steam.runCallbacks() // or `steam.releaseCurrentThreadMemory()`
4200+
4201+
// Shutdown
4202+
// ...when `steam` goes out of scope
4203+
</code></pre>
4204+
<h3 class="j2-anchor j2-heading heading" id="callbacks">
4205+
<span data-anchor-id="callbacks">
4206+
Callbacks
4207+
</span></h3>
4208+
<p>C++</p>
4209+
<pre><code class="language-cpp">STEAM_CALLBACK(MyClass, OnUserStatsReceived, UserStatsReceived_t, m_CallbackUserStatsReceived);
4210+
4211+
...
4212+
4213+
m_CallbackUserStatsReceived( this, &amp;MyClass::OnUserStatsReceived )
4214+
4215+
...
4216+
4217+
void MyClass::OnUserStatsReceived( UserStatsReceived_t *pCallback ) {
4218+
...
4219+
}
4220+
</code></pre>
4221+
<p>Swift</p>
4222+
<pre><code class="language-swift">steam.onUserStatsReceived { userStatsReceived in
4223+
...
4224+
}
4225+
</code></pre>
4226+
<p>There are async versions too, like:</p>
4227+
<pre><code class="language-swift">for await userStatsReceived in steam.userStatsReceived {
4228+
...
4229+
}
4230+
</code></pre>
4231+
<p>…but these need the panacea of custom executors to be practical.</p>
41844232
<h4 class="j2-anchor j2-heading heading" id="functions">
41854233
<span data-anchor-id="functions">
41864234
Functions
41874235
</span></h4>
41884236
<pre><code class="language-cpp">auto handle = SteamInventory()-&gt;StartUpdateProperties();
41894237
</code></pre>
4190-
<pre><code class="language-swift">let handle = steamAPI.inventory.startUpdateProperties()
4238+
<pre><code class="language-swift">let handle = steam.inventory.startUpdateProperties()
41914239
</code></pre>
4240+
<h3 class="j2-anchor j2-heading heading" id="callreturn-style">
4241+
<span data-anchor-id="callreturn-style">
4242+
Call-return style
4243+
</span></h3>
4244+
<p>C++</p>
4245+
<pre><code class="language-cpp">CCallResult&lt;MyClass, FriendsGetFollowerCount_t&gt; m_GetFollowerCountCallResult;
4246+
4247+
...
4248+
4249+
auto hSteamAPICall = SteamFriends.GetFollowerCount(steamID);
4250+
m_GetFollowerCountCallResult.Set(hSteamAPICall, this, &amp;MyClass::OnGetFollowerCount);
4251+
4252+
...
4253+
4254+
void MyClass::OnGetFollowerCount(FriendsGetFollowerCount_t *pCallback, bool bIOFailure) {
4255+
...
4256+
}
4257+
4258+
</code></pre>
4259+
<p>Swift</p>
4260+
<pre><code class="language-swift">steam.friends.getFollowerCount(steamID: steamID) { getFollowerCount in
4261+
guard let getFollowerCount = getFollowerCount else {
4262+
// `bIOFailure` case
4263+
...
4264+
}
4265+
...
4266+
}
4267+
</code></pre>
4268+
<p>Again there are async versions that are impractical for now:</p>
4269+
<pre><code class="language-swift">let getFollowerCount = await steam.friends.getFollowerCount(steamID: steamID)
4270+
</code></pre>
4271+
<h3 class="j2-anchor j2-heading heading" id="arraylength-parameters">
4272+
<span data-anchor-id="arraylength-parameters">
4273+
Array-length parameters
4274+
</span></h3>
4275+
<p>Parameters carrying the length of an input array are discarded because Swift arrays
4276+
carry their length with them.</p>
41924277
<h3 class="j2-anchor j2-heading heading" id="out-parameters">
41934278
<span data-anchor-id="out-parameters">
41944279
‘Out’ parameters
@@ -4198,7 +4283,7 @@ <h3 class="j2-anchor j2-heading heading" id="out-parameters">
41984283
<pre><code class="language-cpp">SteamInventoryResult_t result;
41994284
bool rc = SteamInventory()-&gt;GrantPromoItems(&amp;result);
42004285
</code></pre>
4201-
<pre><code class="language-swift">let (rc, result) = steamAPI.inventory.grantPromotItems()
4286+
<pre><code class="language-swift">let (rc, result) = steamAPI.inventory.grantPromoItems()
42024287
</code></pre>
42034288
<h3 class="j2-anchor j2-heading heading" id="optional-out-parameters">
42044289
<span data-anchor-id="optional-out-parameters">
@@ -4230,8 +4315,6 @@ <h3 class="j2-anchor j2-heading heading" id="inout-parameters">
42304315
let (rc2, itemDefIDs, _) = steamAPI.inventory.
42314316
getItemDefinitionIDs(itemDefIDsArraySize: itemDefIDCount)
42324317
</code></pre>
4233-
<p>This pattern is a best-effort translation of the Steamworks API that inherently requires two
4234-
calls - still pretty ugly and would expect to be wrapped up in a utility.</p>
42354318
<h3 class="j2-anchor j2-heading heading" id="default-parameter-values">
42364319
<span data-anchor-id="default-parameter-values">
42374320
Default parameter values
@@ -4245,23 +4328,25 @@ <h3 class="j2-anchor j2-heading heading" id="swift-c-bugs">
42454328
<span data-anchor-id="swift-c-bugs">
42464329
Swift C++ Bugs
42474330
</span></h3>
4248-
<p>Tech limitations, on 5.6:</p>
4331+
<p>Tech limitations, on 5.7 Xcode 14.0b3:</p>
42494332
<ul>
4250-
<li>Have to manually tell Swift to link with <code>libc++</code>. Verify by commenting from
4251-
Makefile. When resolved tidy Makefile.</li>
4252-
<li>Importing <code>Dispatch</code> and <code>-enable-cxx-interop</code> makes <code>DispatchSemaphore</code> disappear
4253-
but not the rest of the module?? Work around. When resolved rewrite mutex.</li>
4333+
<li><del>Have to manually tell Swift to link with <code>libc++</code>. Verify by commenting from
4334+
Makefile. When resolved tidy Makefile.</del> currently fixed in 5.7</li>
4335+
<li><del>Importing <code>Dispatch</code> and <code>-enable-cxx-interop</code> makes <code>DispatchSemaphore</code> disappear
4336+
but not the rest of the module?? Work around. When resolved rewrite mutex.</del> currently
4337+
fixed in 5.7</li>
42544338
<li>Some structures/classes aren’t imported – the common factor seems to be a <code>protected</code>
42554339
destructor. Verify by trying to use <code>SteamNetworkingMessage_t</code>.</li>
4256-
<li>Something goes wrong storing pointers to base classes and they get nobbled by
4257-
something. Verify by making <a href="steamworks/types/steamipaddress.html?swift"><code>SteamIPAddress</code></a> a struct, changing interfaces to cache
4258-
the interface pointers.</li>
4259-
<li>C++ types with <code>operator ==</code> don’t have <a href="https://developer.apple.com/documentation/swift/equatable?language=swift" class="j2-swift"><code>Equatable</code></a><a href="https://developer.apple.com/documentation/swift/equatable?language=objc" class="j2-objc j2-secondary"><code>Equatable</code></a> generated. Verify with
4260-
<a href="steamworks/types/steamnetworkingipaddr.html?swift"><code>SteamNetworkingIPAddr</code></a>.</li>
4261-
<li>Importing <code>Foundation</code> and <code>-enable-cxx-interop</code> and a C++ module goes wrong. Swift
4340+
<li>Something goes wrong storing pointers to classes and they get nobbled by something.
4341+
Verify by making <a href="steamworks/types/steamipaddress.html?swift"><code>SteamIPAddress</code></a> a struct, changing interfaces to cache the interface
4342+
pointers.</li>
4343+
<li>Some C++ types with <code>operator ==</code> don’t have <a href="https://developer.apple.com/documentation/swift/equatable?language=swift" class="j2-swift"><code>Equatable</code></a><a href="https://developer.apple.com/documentation/swift/equatable?language=objc" class="j2-objc j2-secondary"><code>Equatable</code></a> generated. Verify with
4344+
<a href="steamworks/types/steamnetworkingipaddr.html?swift"><code>SteamNetworkingIPAddr</code></a>. Got worse in 5.7</li>
4345+
<li><del>Importing <code>Foundation</code> and <code>-enable-cxx-interop</code> and a C++ module goes wrong. Swift
42624346
5.6 doesn’t crash; worse the compiler goes slow, spits out warnings, then the binary
4263-
runs like treacle. Will aim to not depend on Foundation, see how that goes.</li>
4264-
<li>Calls to (?pure) virtual functions aren’t generated properly: Swift generates a ref
4347+
runs like treacle. Will aim to not depend on Foundation, see how that goes.</del> seems
4348+
fixed in 5.7 but build is really slow - keep up not using Foundation?</li>
4349+
<li>Calls to virtual functions aren’t generated properly: Swift generates a ref
42654350
to a symbol instead of doing the vtable call. So the actual C++ interfaces are not
42664351
usable in practice. Will use the flat API.</li>
42674352
<li>Anonymous enums are not imported at all. Affects callback etc. ID constants.
@@ -4321,10 +4406,6 @@ <h3 class="j2-anchor j2-heading heading" id="interface-plan">
43214406
ISteamParentalSettings, ISteamParties, ISteamRemotePlay, ISteamRemoteStorage,
43224407
ISteamScreenshots, ISteamUGC, ISteamUser, ISteamUserStats, ISteamUtils, ISteamVideo,
43234408
SteamEncryptedAppTicket</p>
4324-
<p>Left to do:</p>
4325-
<ul>
4326-
<li>Pondering of int types etc.</li>
4327-
</ul>
43284409
<p>Skip:</p>
43294410
<ul>
43304411
<li>ISteamAppTicket - er not actually a thing?</li>
@@ -4346,6 +4427,8 @@ <h3 class="j2-anchor j2-heading heading" id="json-notes">
43464427
<code>SteamDatagramGameCoordinatorServerLogin</code>, <code>SteamDatagramHostedAddress</code> are missing
43474428
from the header files. The online API docs are hilariously broken here, scads of
43484429
broken links. Have to wait for Valve to fix this.</p>
4430+
<p>I found some of this in the SDR SDK, but it’s not supported on macOS and uses actual
4431+
grown-up C++ with <code>std::string</code> and friends so best leave it alone for now.</p>
43494432
</li>
43504433
<li>
43514434
<p><code>SteamNetworkingMessage_t</code> doesn’t import into Swift. Probably stumbling into a hole

0 commit comments

Comments
 (0)