peachsim 0.1.780 → 0.1.782
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/commands/detox.ts +6 -2
- package/detox/expectations.ts +1 -1
- package/detox/gestures.ts +1 -1
- package/detox/index.ts +27 -3
- package/detox/navigation-lifecycle.ts +1 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +3533 -133
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +6781 -2442
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +4664 -1266
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +1114 -2
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +9017 -366
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2229 -583
- package/dist-lib/vite.cjs +38 -16
- package/package.json +1 -1
- package/skills/contrast/SKILL.md +2 -0
- package/src/one-widget-package.ts +202 -0
- package/src/oneWidgetContract.ts +16 -0
- package/src/swift-host.ts +56 -29
- package/src/swift-standin-emit.ts +471 -242
- package/src/swift-standins.ts +288 -40
- package/src/vite-plugin-one.ts +45 -17
- package/src/vite-plugin-swift.ts +2 -0
|
@@ -9,14 +9,22 @@
|
|
|
9
9
|
// a body, a setter, or a stored property for one declaration path, so the
|
|
10
10
|
// declarations stay the sdk's and only those bodies stop trapping.
|
|
11
11
|
|
|
12
|
-
export type SymbolFragment = {
|
|
12
|
+
export type SymbolFragment = {
|
|
13
|
+
kind: string
|
|
14
|
+
spelling: string
|
|
15
|
+
preciseIdentifier?: string
|
|
16
|
+
}
|
|
13
17
|
export type GraphSymbol = {
|
|
14
18
|
kind: { identifier: string }
|
|
15
19
|
identifier: { precise: string }
|
|
16
20
|
pathComponents: string[]
|
|
17
21
|
declarationFragments?: SymbolFragment[]
|
|
18
22
|
accessLevel: string
|
|
19
|
-
availability?: {
|
|
23
|
+
availability?: {
|
|
24
|
+
domain?: string
|
|
25
|
+
isUnconditionallyUnavailable?: boolean
|
|
26
|
+
obsoleted?: unknown
|
|
27
|
+
}[]
|
|
20
28
|
}
|
|
21
29
|
export type GraphRelationship = {
|
|
22
30
|
kind: string
|
|
@@ -70,6 +78,9 @@ export type StandinResult = {
|
|
|
70
78
|
owners: string[]
|
|
71
79
|
}
|
|
72
80
|
|
|
81
|
+
/** bump when emitted source changes: the stand-in cache keys on it. */
|
|
82
|
+
export const STANDIN_EMIT_VERSION = '1'
|
|
83
|
+
|
|
73
84
|
const TYPE_KINDS = new Set([
|
|
74
85
|
'swift.class',
|
|
75
86
|
'swift.struct',
|
|
@@ -107,14 +118,19 @@ const KEEP_EXTERNAL = new Map([
|
|
|
107
118
|
const LEADING_ATTRS = /^((?:@\w+(?:\([^)]*\))?\s*|nonisolated\s+)*)(.*)$/s
|
|
108
119
|
|
|
109
120
|
// objective-c-only attributes and modifiers pure swift cannot spell
|
|
110
|
-
const OBJC_ONLY =
|
|
121
|
+
const OBJC_ONLY =
|
|
122
|
+
/@(?:objcMembers|objc|IBOutlet|IBInspectable|IBAction|IBSegueAction|GKInspectable|nonobjc|NSCopying|NSManaged)(?:\([^)]*\))?\s*|\bdynamic\s+/g
|
|
111
123
|
const text = (symbol: GraphSymbol) =>
|
|
112
124
|
(symbol.declarationFragments ?? [])
|
|
113
125
|
.map((fragment) => fragment.spelling)
|
|
114
126
|
.join('')
|
|
115
127
|
.replace(OBJC_ONLY, '')
|
|
116
128
|
.replace(/(^|\s)optional (?=func|var|init|subscript|static|class)/, '$1')
|
|
117
|
-
|
|
129
|
+
// swift-corelibs-foundation has no autoreleasing spelling; peach's own
|
|
130
|
+
// AVFoundation scaffolds the same alias onto a plain pointer.
|
|
131
|
+
.replace(/\bAutoreleasingUnsafeMutablePointer</g, 'UnsafeMutablePointer<')
|
|
132
|
+
const leaf = (symbol: GraphSymbol) =>
|
|
133
|
+
symbol.pathComponents[symbol.pathComponents.length - 1]!
|
|
118
134
|
const pathOf = (symbol: GraphSymbol) => symbol.pathComponents.join('.')
|
|
119
135
|
const unavailable = (symbol: GraphSymbol) =>
|
|
120
136
|
(symbol.availability ?? []).some(
|
|
@@ -124,9 +140,13 @@ const unavailable = (symbol: GraphSymbol) =>
|
|
|
124
140
|
const witnessKey = (symbol: GraphSymbol) =>
|
|
125
141
|
`${symbol.kind.identifier.startsWith('swift.type.') ? 'type' : 'instance'}|${leaf(symbol)}`
|
|
126
142
|
const isObjC = (symbol: GraphSymbol) => symbol.identifier.precise.startsWith('c:')
|
|
127
|
-
const trap = (path: string) =>
|
|
143
|
+
const trap = (path: string) =>
|
|
144
|
+
`fatalError("${path} is a binary framework peach cannot run")`
|
|
128
145
|
|
|
129
|
-
export function emitSwiftStandin(
|
|
146
|
+
export function emitSwiftStandin(
|
|
147
|
+
graphs: SymbolGraph[],
|
|
148
|
+
options: StandinOptions,
|
|
149
|
+
): StandinResult {
|
|
130
150
|
const skipped: StandinResult['skipped'] = []
|
|
131
151
|
const behavior = options.behavior ?? new Map<string, StandinBehavior>()
|
|
132
152
|
const used = new Set<string>()
|
|
@@ -161,7 +181,13 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
161
181
|
if (local) return { name: pathOf(local), local: true }
|
|
162
182
|
if (!fallback) return null
|
|
163
183
|
const parts = fallback.split('.')
|
|
164
|
-
return {
|
|
184
|
+
return {
|
|
185
|
+
name: family.has(parts[0]!)
|
|
186
|
+
? parts.join('.')
|
|
187
|
+
: parts.slice(1).join('.') || parts[0]!,
|
|
188
|
+
module: parts[0]!,
|
|
189
|
+
local: false,
|
|
190
|
+
}
|
|
165
191
|
}
|
|
166
192
|
for (const graph of graphs)
|
|
167
193
|
for (const edge of graph.relationships) {
|
|
@@ -172,7 +198,10 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
172
198
|
const parent = byId.get(edge.target)
|
|
173
199
|
if (parent) {
|
|
174
200
|
owner.set(edge.source, edge.target)
|
|
175
|
-
children.set(edge.target, [
|
|
201
|
+
children.set(edge.target, [
|
|
202
|
+
...(children.get(edge.target) ?? []),
|
|
203
|
+
...all(edge.source),
|
|
204
|
+
])
|
|
176
205
|
} else if (edge.targetFallback) {
|
|
177
206
|
const name = nameOf(edge.target, edge.targetFallback)!.name
|
|
178
207
|
external.set(name, [...(external.get(name) ?? []), ...all(edge.source)])
|
|
@@ -189,10 +218,16 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
189
218
|
case 'conformsTo': {
|
|
190
219
|
const target = nameOf(edge.target, edge.targetFallback)
|
|
191
220
|
const kept = KEEP_EXTERNAL.get(edge.target)
|
|
192
|
-
const name =
|
|
193
|
-
|
|
221
|
+
const name =
|
|
222
|
+
kept ??
|
|
223
|
+
(target && (target.local || family.has(target.module ?? ''))
|
|
224
|
+
? target.name
|
|
225
|
+
: null)
|
|
226
|
+
if (name)
|
|
227
|
+
conforms.set(edge.source, [...(conforms.get(edge.source) ?? []), name])
|
|
194
228
|
if (byId.has(edge.target)) {
|
|
195
|
-
const map =
|
|
229
|
+
const map =
|
|
230
|
+
source.kind.identifier === 'swift.protocol' ? protocolParents : conformIds
|
|
196
231
|
map.set(edge.source, [...(map.get(edge.source) ?? []), edge.target])
|
|
197
232
|
}
|
|
198
233
|
break
|
|
@@ -203,7 +238,10 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
203
238
|
if (edge.kind === 'optionalRequirementOf') optional.add(edge.source)
|
|
204
239
|
if (byId.has(edge.target) && !owner.has(edge.source)) {
|
|
205
240
|
owner.set(edge.source, edge.target)
|
|
206
|
-
children.set(edge.target, [
|
|
241
|
+
children.set(edge.target, [
|
|
242
|
+
...(children.get(edge.target) ?? []),
|
|
243
|
+
...all(edge.source),
|
|
244
|
+
])
|
|
207
245
|
}
|
|
208
246
|
break
|
|
209
247
|
case 'overrides':
|
|
@@ -222,7 +260,8 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
222
260
|
owners.push(...physical.map(() => current))
|
|
223
261
|
}
|
|
224
262
|
// every declaration runs under its own path, so each line names it
|
|
225
|
-
const scoped =
|
|
263
|
+
const scoped =
|
|
264
|
+
<T extends unknown[]>(body: (symbol: GraphSymbol, ...rest: T) => void) =>
|
|
226
265
|
(symbol: GraphSymbol, ...rest: T) => {
|
|
227
266
|
const path = pathOf(symbol)
|
|
228
267
|
if (omit.has(path)) return void skipped.push({ path, reason: omit.get(path)! })
|
|
@@ -250,71 +289,110 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
250
289
|
const access = (symbol: GraphSymbol, openOwner: boolean) =>
|
|
251
290
|
symbol.accessLevel === 'open' && openOwner ? 'open' : 'public'
|
|
252
291
|
|
|
253
|
-
const emitMember = scoped(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
292
|
+
const emitMember = scoped(
|
|
293
|
+
(
|
|
294
|
+
member: GraphSymbol,
|
|
295
|
+
indent: string,
|
|
296
|
+
context: { openOwner: boolean; inClass: boolean; ownerName: string },
|
|
297
|
+
) => {
|
|
298
|
+
const path = pathOf(member)
|
|
299
|
+
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
300
|
+
emitType(member, indent)
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
if (member.kind.identifier === 'swift.enum.case') return
|
|
304
|
+
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
305
|
+
skipped.push({ path, reason: `unhandled ${member.kind.identifier}` })
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member))!
|
|
309
|
+
const modifiers =
|
|
310
|
+
/^((?:(?:required|final|override|convenience|unowned(?:\(\w+\))?|weak|lazy|nonisolated|mutating|nonmutating) )*)(.*)$/s.exec(
|
|
311
|
+
rest!,
|
|
312
|
+
)!
|
|
313
|
+
const flags = new Set(
|
|
314
|
+
modifiers[1]!
|
|
315
|
+
.trim()
|
|
316
|
+
.split(/\s+/)
|
|
317
|
+
.filter(Boolean)
|
|
318
|
+
.map((flag) => flag.replace(/\(.*/, '')),
|
|
319
|
+
)
|
|
320
|
+
const required = context.inClass && flags.has('required')
|
|
321
|
+
const final = context.inClass && flags.has('final') ? 'final ' : ''
|
|
322
|
+
const mutating = flags.has('mutating')
|
|
323
|
+
? 'mutating '
|
|
324
|
+
: flags.has('nonmutating')
|
|
325
|
+
? 'nonmutating '
|
|
326
|
+
: ''
|
|
327
|
+
let core = `${context.inClass && flags.has('convenience') ? 'convenience ' : ''}${modifiers[2]!}`
|
|
328
|
+
// a class's init() always overrides NSObject's in an objective-c class
|
|
329
|
+
const override =
|
|
330
|
+
context.inClass &&
|
|
331
|
+
!options.plain?.has(path) &&
|
|
332
|
+
(flags.has('override') ||
|
|
333
|
+
overrides.has(member.identifier.precise) ||
|
|
334
|
+
(isObjC(member) && path.endsWith('.init()')))
|
|
335
|
+
? 'override '
|
|
336
|
+
: ''
|
|
337
|
+
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? 'required ' : ''}${final}${override}${mutating}`
|
|
338
|
+
const measured = behavior.get(path)
|
|
339
|
+
if (measured) used.add(path)
|
|
340
|
+
const overloadBody = /\basync\b/.test(core)
|
|
341
|
+
? measured?.asyncBody
|
|
342
|
+
: /\bResult</.test(core)
|
|
343
|
+
? measured?.resultBody
|
|
344
|
+
: undefined
|
|
345
|
+
const body = overloadBody ?? measured?.body ?? trap(path)
|
|
346
|
+
switch (member.kind.identifier) {
|
|
347
|
+
case 'swift.property':
|
|
348
|
+
case 'swift.type.property':
|
|
349
|
+
case 'swift.subscript':
|
|
350
|
+
case 'swift.type.subscript': {
|
|
351
|
+
const accessors = ACCESSORS.exec(core)
|
|
352
|
+
const decl = core.replace(ACCESSORS, '').trimEnd()
|
|
353
|
+
const effects = `${accessors?.[1] ?? ''}${accessors?.[2] ?? ''}`
|
|
354
|
+
const settable = accessors
|
|
355
|
+
? Boolean(accessors[3])
|
|
356
|
+
: /^(?:static |class )?var /.test(core)
|
|
357
|
+
const computed = decl.replace(/^((?:static |class )*)let /, '$1var ')
|
|
358
|
+
if (measured?.stored !== undefined) {
|
|
359
|
+
// a read-only sdk property stays read-only outside the module
|
|
360
|
+
const ownership = flags.has('weak')
|
|
361
|
+
? 'weak '
|
|
362
|
+
: flags.has('unowned')
|
|
363
|
+
? 'unowned '
|
|
364
|
+
: ''
|
|
365
|
+
const setter = settable ? '' : 'internal(set) '
|
|
366
|
+
const value = measured.stored ? ` = ${measured.stored}` : ''
|
|
367
|
+
emit(
|
|
368
|
+
`${indent}${attrs}${access(member, context.openOwner)} ${setter}${final}${override}${ownership}${computed}${value}`,
|
|
369
|
+
)
|
|
370
|
+
return
|
|
371
|
+
}
|
|
372
|
+
emit(
|
|
373
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` set { ${measured?.set ?? trap(path)} }` : ''} }`,
|
|
374
|
+
)
|
|
303
375
|
return
|
|
304
376
|
}
|
|
305
|
-
|
|
306
|
-
|
|
377
|
+
default:
|
|
378
|
+
emit(`${head}${core} { ${body} }`)
|
|
307
379
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
}
|
|
311
|
-
})
|
|
380
|
+
},
|
|
381
|
+
)
|
|
312
382
|
|
|
313
383
|
const header = (symbol: GraphSymbol, keyword: string, indent: string) => {
|
|
314
384
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol))!
|
|
315
|
-
const shape = new RegExp(
|
|
385
|
+
const shape = new RegExp(
|
|
386
|
+
`^(?:final )?${keyword}\\s+\`?(\\w+)\`?(<[^>]*>)?\\s*(?::\\s*([^{]*?))?(\\s+where\\s+.*)?$`,
|
|
387
|
+
).exec(rest!)
|
|
316
388
|
if (!shape) return null
|
|
317
|
-
return {
|
|
389
|
+
return {
|
|
390
|
+
attrs: attrs!,
|
|
391
|
+
name: shape[1]!,
|
|
392
|
+
generics: shape[2] ?? '',
|
|
393
|
+
where: shape[4] ?? '',
|
|
394
|
+
indent,
|
|
395
|
+
}
|
|
318
396
|
}
|
|
319
397
|
|
|
320
398
|
// the first ancestor outside the module, or null for a root swift class
|
|
@@ -337,7 +415,8 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
337
415
|
!options.superclasses?.has(pathOf(byId.get(id)!))
|
|
338
416
|
)
|
|
339
417
|
return `superclass ${pathOf(parentSymbol)} is generic and the graph omits its arguments`
|
|
340
|
-
if (unavailable(parentSymbol))
|
|
418
|
+
if (unavailable(parentSymbol))
|
|
419
|
+
return `superclass ${pathOf(parentSymbol)} is unavailable`
|
|
341
420
|
return classBlocked(parent!) && `superclass ${pathOf(parentSymbol)} is left out`
|
|
342
421
|
}
|
|
343
422
|
|
|
@@ -345,14 +424,18 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
345
424
|
// stand-in protocol without @objc cannot, so a generic requirement naming
|
|
346
425
|
// one is left out; every argument the sdk accepts still satisfies the rest.
|
|
347
426
|
const objcProtocols = new Set(
|
|
348
|
-
[...byId.values()]
|
|
427
|
+
[...byId.values()]
|
|
428
|
+
.filter((s) => s.kind.identifier === 'swift.protocol' && isObjC(s))
|
|
429
|
+
.map(pathOf),
|
|
349
430
|
)
|
|
350
431
|
const selfConforming = (where: string) => {
|
|
351
432
|
const kept = where
|
|
352
433
|
.replace(/^\s+where\s+/, '')
|
|
353
434
|
.split(',')
|
|
354
435
|
.filter((term) => !objcProtocols.has(term.split(':')[1]?.trim() ?? ''))
|
|
355
|
-
return where && kept.length
|
|
436
|
+
return where && kept.length
|
|
437
|
+
? ` where ${kept.map((term) => term.trim()).join(', ')}`
|
|
438
|
+
: ''
|
|
356
439
|
}
|
|
357
440
|
|
|
358
441
|
const inheritance = (id: string, first?: string) => {
|
|
@@ -360,183 +443,273 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
360
443
|
return [...new Set(list)]
|
|
361
444
|
}
|
|
362
445
|
|
|
363
|
-
const emitType: (symbol: GraphSymbol, indent: string) => void = scoped(
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
case 'swift.class': {
|
|
374
|
-
const shape = header(symbol, 'class', indent)
|
|
375
|
-
if (!shape) return void skipped.push({ path, reason: `unparsed class ${text(symbol)}` })
|
|
376
|
-
const parent = options.superclasses?.get(path) ?? superclass.get(id)
|
|
377
|
-
const blocked = classBlocked(id)
|
|
378
|
-
if (blocked) return void skipped.push({ path, reason: blocked })
|
|
379
|
-
// a subclass restates only protocols its ancestors do not already
|
|
380
|
-
// bring; NSObject brings the standard ones.
|
|
381
|
-
const ancestors = new Set<string>()
|
|
382
|
-
for (let at = superId.get(id); at; at = superId.get(at))
|
|
383
|
-
for (const name of conforms.get(at) ?? []) ancestors.add(name)
|
|
384
|
-
const list = [
|
|
385
|
-
...(parent ? [parent] : []),
|
|
386
|
-
...(conforms.get(id) ?? []).filter(
|
|
387
|
-
(name) => !ancestors.has(name) && !(parent && [...KEEP_EXTERNAL.values()].includes(name)),
|
|
388
|
-
),
|
|
389
|
-
].filter((name, at, all) => all.indexOf(name) === at)
|
|
390
|
-
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)!) : undefined
|
|
391
|
-
const open =
|
|
392
|
-
symbol.accessLevel === 'open' &&
|
|
393
|
-
(!parentSymbol || parentSymbol.accessLevel === 'open')
|
|
394
|
-
emit(`${indent}${shape.attrs}${open ? 'open' : 'public'} class ${shape.name}${shape.generics}${list.length ? `: ${list.join(', ')}` : ''}${selfConforming(shape.where)} {`)
|
|
395
|
-
const members = membersOf(id)
|
|
396
|
-
for (const member of members)
|
|
397
|
-
emitMember(member, inner, { openOwner: open, inClass: true, ownerName: shape.name })
|
|
398
|
-
// a class that declares any designated init loses the inherited
|
|
399
|
-
// ones, and a coder-requiring superclass then needs its own.
|
|
400
|
-
const designated = members.some(
|
|
401
|
-
(member) => member.kind.identifier === 'swift.init' && !text(member).startsWith('convenience'),
|
|
402
|
-
)
|
|
403
|
-
// an objective-c class implements its protocols' requirements in the
|
|
404
|
-
// binary without restating them in its header; swift needs a
|
|
405
|
-
// witness, which traps like every other member.
|
|
406
|
-
const have = new Set<string>()
|
|
407
|
-
for (let at: string | undefined = id; at; at = superId.get(at))
|
|
408
|
-
for (const member of children.get(at) ?? []) have.add(witnessKey(member))
|
|
409
|
-
const protocols: string[] = []
|
|
410
|
-
const visit = (protocolId: string) => {
|
|
411
|
-
if (protocols.includes(protocolId)) return
|
|
412
|
-
protocols.push(protocolId)
|
|
413
|
-
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge)
|
|
446
|
+
const emitType: (symbol: GraphSymbol, indent: string) => void = scoped(
|
|
447
|
+
(symbol: GraphSymbol, indent: string) => {
|
|
448
|
+
const path = pathOf(symbol)
|
|
449
|
+
const id = symbol.identifier.precise
|
|
450
|
+
const inner = `${indent} `
|
|
451
|
+
switch (symbol.kind.identifier) {
|
|
452
|
+
case 'swift.typealias': {
|
|
453
|
+
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol))!
|
|
454
|
+
emit(`${indent}${attrs}public ${rest}`)
|
|
455
|
+
return
|
|
414
456
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
457
|
+
case 'swift.class': {
|
|
458
|
+
const shape = header(symbol, 'class', indent)
|
|
459
|
+
if (!shape)
|
|
460
|
+
return void skipped.push({ path, reason: `unparsed class ${text(symbol)}` })
|
|
461
|
+
const parent = options.superclasses?.get(path) ?? superclass.get(id)
|
|
462
|
+
const blocked = classBlocked(id)
|
|
463
|
+
if (blocked) return void skipped.push({ path, reason: blocked })
|
|
464
|
+
// a subclass restates only protocols its ancestors do not already
|
|
465
|
+
// bring; NSObject brings the standard ones.
|
|
466
|
+
const ancestors = new Set<string>()
|
|
467
|
+
for (let at = superId.get(id); at; at = superId.get(at))
|
|
468
|
+
for (const name of conforms.get(at) ?? []) ancestors.add(name)
|
|
469
|
+
const list = [
|
|
470
|
+
...(parent ? [parent] : []),
|
|
471
|
+
...(conforms.get(id) ?? []).filter(
|
|
472
|
+
(name) =>
|
|
473
|
+
!ancestors.has(name) &&
|
|
474
|
+
!(parent && [...KEEP_EXTERNAL.values()].includes(name)),
|
|
475
|
+
),
|
|
476
|
+
].filter((name, at, all) => all.indexOf(name) === at)
|
|
477
|
+
const parentSymbol = superId.has(id) ? byId.get(superId.get(id)!) : undefined
|
|
478
|
+
const open =
|
|
479
|
+
symbol.accessLevel === 'open' &&
|
|
480
|
+
(!parentSymbol || parentSymbol.accessLevel === 'open')
|
|
481
|
+
emit(
|
|
482
|
+
`${indent}${shape.attrs}${open ? 'open' : 'public'} class ${shape.name}${shape.generics}${list.length ? `: ${list.join(', ')}` : ''}${selfConforming(shape.where)} {`,
|
|
483
|
+
)
|
|
484
|
+
const members = membersOf(id)
|
|
485
|
+
for (const member of members)
|
|
486
|
+
emitMember(member, inner, {
|
|
487
|
+
openOwner: open,
|
|
488
|
+
inClass: true,
|
|
489
|
+
ownerName: shape.name,
|
|
490
|
+
})
|
|
491
|
+
// a class that declares any designated init loses the inherited
|
|
492
|
+
// ones, and a coder-requiring superclass then needs its own.
|
|
493
|
+
const designated = members.some(
|
|
494
|
+
(member) =>
|
|
495
|
+
member.kind.identifier === 'swift.init' &&
|
|
496
|
+
!text(member).startsWith('convenience'),
|
|
497
|
+
)
|
|
498
|
+
// an objective-c class implements its protocols' requirements in the
|
|
499
|
+
// binary without restating them in its header; swift needs a
|
|
500
|
+
// witness, which traps like every other member.
|
|
501
|
+
const have = new Set<string>()
|
|
502
|
+
for (let at: string | undefined = id; at; at = superId.get(at))
|
|
503
|
+
for (const member of children.get(at) ?? []) have.add(witnessKey(member))
|
|
504
|
+
const protocols: string[] = []
|
|
505
|
+
const visit = (protocolId: string) => {
|
|
506
|
+
if (protocols.includes(protocolId)) return
|
|
507
|
+
protocols.push(protocolId)
|
|
508
|
+
for (const edge of protocolParents.get(protocolId) ?? []) visit(edge)
|
|
423
509
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
510
|
+
for (const protocolId of conformIds.get(id) ?? []) visit(protocolId)
|
|
511
|
+
for (const protocolId of protocols)
|
|
512
|
+
for (const member of children.get(protocolId) ?? []) {
|
|
513
|
+
if (
|
|
514
|
+
!requirement.has(member.identifier.precise) ||
|
|
515
|
+
optional.has(member.identifier.precise)
|
|
516
|
+
)
|
|
517
|
+
continue
|
|
518
|
+
if (isObjC(member) && / async\b/.test(text(member))) continue
|
|
519
|
+
if (
|
|
520
|
+
have.has(witnessKey(member)) ||
|
|
521
|
+
member.kind.identifier === 'swift.associatedtype'
|
|
522
|
+
)
|
|
523
|
+
continue
|
|
524
|
+
have.add(witnessKey(member))
|
|
525
|
+
emitWitness(member, inner, path)
|
|
526
|
+
}
|
|
527
|
+
const coder = members.some((member) => leaf(member) === 'init(coder:)')
|
|
528
|
+
if (
|
|
529
|
+
designated &&
|
|
530
|
+
!coder &&
|
|
531
|
+
externalRoot(id) !== 'NSObject' &&
|
|
532
|
+
externalRoot(id) !== null
|
|
533
|
+
)
|
|
534
|
+
emit(
|
|
535
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path}.init(coder:)`)} }`,
|
|
536
|
+
)
|
|
537
|
+
emit(`${indent}}`)
|
|
538
|
+
return
|
|
440
539
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
540
|
+
case 'swift.struct': {
|
|
541
|
+
const shape = header(symbol, 'struct', indent)
|
|
542
|
+
if (!shape)
|
|
543
|
+
return void skipped.push({ path, reason: `unparsed struct ${text(symbol)}` })
|
|
544
|
+
const members = membersOf(id)
|
|
545
|
+
const raw = rawType(members)
|
|
546
|
+
const list = inheritance(id)
|
|
547
|
+
emit(
|
|
548
|
+
`${indent}${shape.attrs}public struct ${shape.name}${shape.generics}${list.length ? `: ${list.join(', ')}` : ''}${shape.where} {`,
|
|
549
|
+
)
|
|
550
|
+
if (raw) {
|
|
551
|
+
emit(`${inner}public let rawValue: ${raw}`)
|
|
552
|
+
emit(`${inner}public init(rawValue: ${raw}) { self.rawValue = rawValue }`)
|
|
448
553
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const value = values.get(member.identifier.precise)
|
|
470
|
-
// objective-c aliases a value under a second name; swift spells
|
|
471
|
-
// the alias as a static member of the first case.
|
|
472
|
-
if (value !== undefined && seenValues.has(value)) {
|
|
473
|
-
emit(`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`)
|
|
474
|
-
continue
|
|
554
|
+
for (const member of members) {
|
|
555
|
+
if (
|
|
556
|
+
raw &&
|
|
557
|
+
(leaf(member) === 'rawValue' ||
|
|
558
|
+
leaf(member) === 'init(rawValue:)' ||
|
|
559
|
+
leaf(member) === 'init(_:)')
|
|
560
|
+
)
|
|
561
|
+
continue
|
|
562
|
+
const value = values.get(member.identifier.precise)
|
|
563
|
+
if (value !== undefined && member.kind.identifier === 'swift.type.property') {
|
|
564
|
+
emit(
|
|
565
|
+
`${inner}public static let ${tick(leaf(member))} = ${shape.name}(rawValue: ${value})`,
|
|
566
|
+
)
|
|
567
|
+
continue
|
|
568
|
+
}
|
|
569
|
+
emitMember(member, inner, {
|
|
570
|
+
openOwner: false,
|
|
571
|
+
inClass: false,
|
|
572
|
+
ownerName: shape.name,
|
|
573
|
+
})
|
|
475
574
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
emit(`${inner}case ${caseText}${value !== undefined ? ` = ${value}` : ''}`)
|
|
479
|
-
}
|
|
480
|
-
for (const member of members) {
|
|
481
|
-
if (member.kind.identifier === 'swift.enum.case') continue
|
|
482
|
-
if (raw && (leaf(member) === 'rawValue' || leaf(member) === 'init(rawValue:)')) continue
|
|
483
|
-
emitMember(member, inner, { openOwner: false, inClass: false, ownerName: shape.name })
|
|
575
|
+
emit(`${indent}}`)
|
|
576
|
+
return
|
|
484
577
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
578
|
+
case 'swift.enum': {
|
|
579
|
+
const shape = header(symbol, 'enum', indent)
|
|
580
|
+
if (!shape)
|
|
581
|
+
return void skipped.push({ path, reason: `unparsed enum ${text(symbol)}` })
|
|
582
|
+
const members = membersOf(id)
|
|
583
|
+
const raw = rawType(members)
|
|
584
|
+
const cases = (children.get(id) ?? []).filter(
|
|
585
|
+
(member) => member.kind.identifier === 'swift.enum.case',
|
|
586
|
+
)
|
|
587
|
+
const missing = raw
|
|
588
|
+
? cases.filter((member) => !values.has(member.identifier.precise))
|
|
589
|
+
: []
|
|
590
|
+
// an objective-c enum's numbering is the header's; without it the
|
|
591
|
+
// cases would invent values, so the enum is left out.
|
|
592
|
+
if (raw && isObjC(symbol) && missing.length > 0)
|
|
593
|
+
return void skipped.push({
|
|
594
|
+
path,
|
|
595
|
+
reason: `no header value for ${missing.map(leaf).join(', ')}`,
|
|
596
|
+
})
|
|
597
|
+
const list = inheritance(id, raw ?? undefined).filter(
|
|
598
|
+
(name) => name !== 'RawRepresentable',
|
|
599
|
+
)
|
|
600
|
+
emit(
|
|
601
|
+
`${indent}${shape.attrs}public enum ${shape.name}${shape.generics}${list.length ? `: ${list.join(', ')}` : ''}${shape.where} {`,
|
|
602
|
+
)
|
|
603
|
+
const seenValues = new Map<string, string>()
|
|
604
|
+
for (const member of cases) {
|
|
605
|
+
const value = values.get(member.identifier.precise)
|
|
606
|
+
// objective-c aliases a value under a second name; swift spells
|
|
607
|
+
// the alias as a static member of the first case.
|
|
608
|
+
if (value !== undefined && seenValues.has(value)) {
|
|
609
|
+
emit(
|
|
610
|
+
`${inner}public static var ${tick(leaf(member))}: ${shape.name} { .${seenValues.get(value)} }`,
|
|
611
|
+
)
|
|
612
|
+
continue
|
|
613
|
+
}
|
|
614
|
+
if (value !== undefined) seenValues.set(value, tick(leaf(member)))
|
|
615
|
+
const caseText = text(member).replace(/^case\s+/, '')
|
|
616
|
+
emit(`${inner}case ${caseText}${value !== undefined ? ` = ${value}` : ''}`)
|
|
500
617
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
618
|
+
for (const member of members) {
|
|
619
|
+
if (member.kind.identifier === 'swift.enum.case') continue
|
|
620
|
+
if (
|
|
621
|
+
raw &&
|
|
622
|
+
(leaf(member) === 'rawValue' || leaf(member) === 'init(rawValue:)')
|
|
623
|
+
)
|
|
624
|
+
continue
|
|
625
|
+
emitMember(member, inner, {
|
|
626
|
+
openOwner: false,
|
|
627
|
+
inClass: false,
|
|
628
|
+
ownerName: shape.name,
|
|
629
|
+
})
|
|
508
630
|
}
|
|
509
|
-
|
|
510
|
-
|
|
631
|
+
emit(`${indent}}`)
|
|
632
|
+
return
|
|
511
633
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
634
|
+
case 'swift.protocol': {
|
|
635
|
+
const shape = header(symbol, 'protocol', indent)
|
|
636
|
+
if (!shape)
|
|
637
|
+
return void skipped.push({
|
|
638
|
+
path,
|
|
639
|
+
reason: `unparsed protocol ${text(symbol)}`,
|
|
640
|
+
})
|
|
641
|
+
// objective-c protocols are class-bound; swift needs it spelled.
|
|
642
|
+
const list = [...(isObjC(symbol) ? ['AnyObject'] : []), ...inheritance(id)]
|
|
643
|
+
emit(
|
|
644
|
+
`${indent}${shape.attrs}public protocol ${shape.name}${list.length ? `: ${list.join(', ')}` : ''}${shape.where} {`,
|
|
645
|
+
)
|
|
646
|
+
const members = membersOf(id)
|
|
647
|
+
const defaults: GraphSymbol[] = []
|
|
648
|
+
for (const member of members) {
|
|
649
|
+
if (member.kind.identifier === 'swift.associatedtype') {
|
|
650
|
+
emit(`${inner}${text(member)}`)
|
|
651
|
+
continue
|
|
652
|
+
}
|
|
653
|
+
// objective-c imports a completion-handler requirement twice, the
|
|
654
|
+
// second as async; one witness satisfies both there, so the async
|
|
655
|
+
// spelling is an extension member here.
|
|
656
|
+
const asyncTwin = isObjC(member) && / async\b/.test(text(member))
|
|
657
|
+
if (!requirement.has(member.identifier.precise) || asyncTwin) {
|
|
658
|
+
defaults.push(member)
|
|
659
|
+
continue
|
|
660
|
+
}
|
|
661
|
+
emitRequirement(member, inner)
|
|
662
|
+
if (optional.has(member.identifier.precise)) defaults.push(member)
|
|
522
663
|
}
|
|
523
664
|
emit(`${indent}}`)
|
|
665
|
+
if (defaults.length > 0) {
|
|
666
|
+
emit(`${indent}extension ${path} {`)
|
|
667
|
+
for (const member of defaults) {
|
|
668
|
+
// an optional objective-c requirement the conformer leaves out
|
|
669
|
+
// is never called; a Void method's default is that no-op.
|
|
670
|
+
const decl = text(member)
|
|
671
|
+
if (
|
|
672
|
+
optional.has(member.identifier.precise) &&
|
|
673
|
+
member.kind.identifier === 'swift.method' &&
|
|
674
|
+
!decl.replace(/\([^)]*\)/g, '').includes('->') &&
|
|
675
|
+
!/ async\b/.test(decl)
|
|
676
|
+
)
|
|
677
|
+
emitNoop(member, inner)
|
|
678
|
+
else
|
|
679
|
+
emitMember(member, inner, {
|
|
680
|
+
openOwner: false,
|
|
681
|
+
inClass: false,
|
|
682
|
+
ownerName: shape.name,
|
|
683
|
+
})
|
|
684
|
+
}
|
|
685
|
+
emit(`${indent}}`)
|
|
686
|
+
}
|
|
687
|
+
return
|
|
524
688
|
}
|
|
525
|
-
return
|
|
526
689
|
}
|
|
527
|
-
}
|
|
528
|
-
|
|
690
|
+
},
|
|
691
|
+
)
|
|
529
692
|
|
|
530
693
|
const emitWitness = (member: GraphSymbol, indent: string, owner: string) => {
|
|
531
694
|
const { 2: rest } = LEADING_ATTRS.exec(text(member))!
|
|
532
|
-
const decl = rest
|
|
695
|
+
const decl = rest!
|
|
696
|
+
.replace(/^(?:weak |unowned )/, '')
|
|
697
|
+
.replace(/^((?:static )?)let /, '$1var ')
|
|
533
698
|
const witness = `${owner}.${leaf(member)}`
|
|
534
699
|
const body = trap(witness)
|
|
535
|
-
if (
|
|
700
|
+
if (
|
|
701
|
+
member.kind.identifier === 'swift.property' ||
|
|
702
|
+
member.kind.identifier === 'swift.type.property'
|
|
703
|
+
) {
|
|
536
704
|
const accessors = ACCESSORS.exec(decl)
|
|
537
705
|
const bare = decl.replace(ACCESSORS, '').trimEnd()
|
|
538
|
-
emit(
|
|
539
|
-
|
|
706
|
+
emit(
|
|
707
|
+
`${indent}public ${bare} { get { ${body} }${accessors?.[3] ? ` set { ${body} }` : ''} }`,
|
|
708
|
+
)
|
|
709
|
+
} else
|
|
710
|
+
emit(
|
|
711
|
+
`${indent}public ${member.kind.identifier === 'swift.init' ? 'required ' : ''}${stripDefaults(decl)} { ${body} }`,
|
|
712
|
+
)
|
|
540
713
|
}
|
|
541
714
|
|
|
542
715
|
const emitNoop = scoped((member: GraphSymbol, indent: string) => {
|
|
@@ -546,7 +719,9 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
546
719
|
// a protocol requirement: no access modifier, body, or default values
|
|
547
720
|
const emitRequirement = scoped((member: GraphSymbol, indent: string) => {
|
|
548
721
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member))!
|
|
549
|
-
emit(
|
|
722
|
+
emit(
|
|
723
|
+
`${indent}${attrs}${stripDefaults(rest!.replace(/^(?:weak |unowned )/, '').replace(/^((?:static )?)let /, '$1var '))}`,
|
|
724
|
+
)
|
|
550
725
|
})
|
|
551
726
|
|
|
552
727
|
const rawType = (members: GraphSymbol[]) => {
|
|
@@ -556,12 +731,19 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
556
731
|
|
|
557
732
|
const emitGlobal = scoped((symbol: GraphSymbol) => {
|
|
558
733
|
const path = pathOf(symbol)
|
|
559
|
-
if (
|
|
734
|
+
if (
|
|
735
|
+
symbol.kind.identifier === 'swift.func' ||
|
|
736
|
+
symbol.kind.identifier === 'swift.func.op'
|
|
737
|
+
) {
|
|
560
738
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol))!
|
|
561
739
|
emit(`${attrs}public ${rest} { ${trap(path)} }`)
|
|
562
740
|
} else if (symbol.kind.identifier === 'swift.var') {
|
|
563
741
|
const decl = text(symbol).replace(/^let /, 'var ').replace(ACCESSORS, '').trimEnd()
|
|
564
|
-
|
|
742
|
+
// a measured global keeps the sdk's declaration with a working getter,
|
|
743
|
+
// the same way a member keeps its declaration with a working body.
|
|
744
|
+
const measured = behavior.get(path)
|
|
745
|
+
if (measured) used.add(path)
|
|
746
|
+
emit(`public ${decl} { ${measured?.body ?? trap(path)} }`)
|
|
565
747
|
} else skipped.push({ path, reason: `unhandled top-level ${symbol.kind.identifier}` })
|
|
566
748
|
})
|
|
567
749
|
|
|
@@ -584,12 +766,24 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
584
766
|
if (kept.length === 0) continue
|
|
585
767
|
emit(`extension ${name} {`)
|
|
586
768
|
for (const member of kept)
|
|
587
|
-
if (
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
769
|
+
if (
|
|
770
|
+
member.kind.identifier === 'swift.init' &&
|
|
771
|
+
!text(member).startsWith('convenience')
|
|
772
|
+
)
|
|
773
|
+
emitMember(
|
|
774
|
+
{
|
|
775
|
+
...member,
|
|
776
|
+
declarationFragments: [
|
|
777
|
+
{ kind: 'text', spelling: `convenience ${text(member)}` },
|
|
778
|
+
],
|
|
779
|
+
},
|
|
780
|
+
' ',
|
|
781
|
+
{
|
|
782
|
+
openOwner: false,
|
|
783
|
+
inClass: true,
|
|
784
|
+
ownerName: name,
|
|
785
|
+
},
|
|
786
|
+
)
|
|
593
787
|
else emitMember(member, ' ', { openOwner: false, inClass: false, ownerName: name })
|
|
594
788
|
emit(`}`)
|
|
595
789
|
}
|
|
@@ -604,7 +798,8 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
604
798
|
'',
|
|
605
799
|
]
|
|
606
800
|
for (const path of behavior.keys())
|
|
607
|
-
if (!used.has(path))
|
|
801
|
+
if (!used.has(path))
|
|
802
|
+
skipped.push({ path, reason: 'behavior names no emitted declaration' })
|
|
608
803
|
return {
|
|
609
804
|
source: `${[...banner, ...lines].join('\n')}\n`,
|
|
610
805
|
skipped,
|
|
@@ -612,7 +807,41 @@ export function emitSwiftStandin(graphs: SymbolGraph[], options: StandinOptions)
|
|
|
612
807
|
}
|
|
613
808
|
}
|
|
614
809
|
|
|
615
|
-
const KEYWORDS = new Set([
|
|
810
|
+
const KEYWORDS = new Set([
|
|
811
|
+
'Type',
|
|
812
|
+
'Protocol',
|
|
813
|
+
'Self',
|
|
814
|
+
'default',
|
|
815
|
+
'init',
|
|
816
|
+
'self',
|
|
817
|
+
'class',
|
|
818
|
+
'func',
|
|
819
|
+
'var',
|
|
820
|
+
'let',
|
|
821
|
+
'in',
|
|
822
|
+
'is',
|
|
823
|
+
'as',
|
|
824
|
+
'repeat',
|
|
825
|
+
'internal',
|
|
826
|
+
'public',
|
|
827
|
+
'private',
|
|
828
|
+
'operator',
|
|
829
|
+
'extension',
|
|
830
|
+
'subscript',
|
|
831
|
+
'static',
|
|
832
|
+
'struct',
|
|
833
|
+
'protocol',
|
|
834
|
+
'enum',
|
|
835
|
+
'case',
|
|
836
|
+
'where',
|
|
837
|
+
'return',
|
|
838
|
+
'throw',
|
|
839
|
+
'throws',
|
|
840
|
+
'import',
|
|
841
|
+
'true',
|
|
842
|
+
'false',
|
|
843
|
+
'nil',
|
|
844
|
+
])
|
|
616
845
|
const tick = (name: string) => (KEYWORDS.has(name) ? `\`${name}\`` : name)
|
|
617
846
|
|
|
618
847
|
// requirements carry no default argument values
|