Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"metadata":{"formatVersion":{"major":0,"minor":6,"patch":0},"generator":"Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)"},"module":{"name":"Foundation","platform":{"architecture":"arm64e","vendor":"apple","operatingSystem":{"name":"macosx","minimumVersion":{"major":26,"minor":1}}}},"symbols":[{"kind":{"identifier":"swift.func.op","displayName":"Operator"},"identifier":{"precise":"s:10Foundation18_ErrorCodeProtocolPAAE2teoiySbx_s0B0_ptFZ::SYNTHESIZED::c:@M@Darwin@E@MachErrorCode","interfaceLanguage":"swift"},"pathComponents":["MachErrorCode","~=(_:_:)"],"names":{"title":"~=(_:_:)","subHeading":[{"kind":"keyword","spelling":"static"},{"kind":"text","spelling":" "},{"kind":"keyword","spelling":"func"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"~="},{"kind":"text","spelling":" "},{"kind":"text","spelling":"("},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":", any "},{"kind":"typeIdentifier","spelling":"Error","preciseIdentifier":"s:s5ErrorP"},{"kind":"text","spelling":") -> "},{"kind":"typeIdentifier","spelling":"Bool","preciseIdentifier":"s:Sb"}]},"docComment":{"module":"Foundation","lines":[{"text":"Allow one to match an error code against an arbitrary error."}]},"functionSignature":{"parameters":[{"name":"match","declarationFragments":[{"kind":"identifier","spelling":"match"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"Self"}]},{"name":"error","declarationFragments":[{"kind":"identifier","spelling":"error"},{"kind":"text","spelling":": any "},{"kind":"typeIdentifier","spelling":"Error","preciseIdentifier":"s:s5ErrorP"}]}],"returns":[{"kind":"typeIdentifier","spelling":"Bool","preciseIdentifier":"s:Sb"}]},"swiftExtension":{"extendedModule":"Foundation","typeKind":"swift.protocol"},"declarationFragments":[{"kind":"keyword","spelling":"static"},{"kind":"text","spelling":" "},{"kind":"keyword","spelling":"func"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"~="},{"kind":"text","spelling":" "},{"kind":"text","spelling":"("},{"kind":"internalParam","spelling":"match"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":", "},{"kind":"internalParam","spelling":"error"},{"kind":"text","spelling":": any "},{"kind":"typeIdentifier","spelling":"Error","preciseIdentifier":"s:s5ErrorP"},{"kind":"text","spelling":") -> "},{"kind":"typeIdentifier","spelling":"Bool","preciseIdentifier":"s:Sb"}],"accessLevel":"public","availability":[{"domain":"macOS","introduced":{"major":10,"minor":10}},{"domain":"watchOS","introduced":{"major":2,"minor":0}},{"domain":"iOS","introduced":{"major":8,"minor":0}},{"domain":"tvOS","introduced":{"major":9,"minor":0}}]}],"relationships":[{"kind":"conformsTo","source":"c:@M@Darwin@E@MachErrorCode","target":"s:s8CopyableP","targetFallback":"Swift.Copyable"},{"kind":"conformsTo","source":"c:@M@Darwin@E@MachErrorCode","target":"s:SQ","targetFallback":"Swift.Equatable"},{"kind":"memberOf","source":"s:10Foundation18_ErrorCodeProtocolPAAE2teoiySbx_s0B0_ptFZ::SYNTHESIZED::c:@M@Darwin@E@MachErrorCode","target":"c:@M@Darwin@E@MachErrorCode","targetFallback":"Darwin.MachErrorCode"}]}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"metadata":{"formatVersion":{"major":0,"minor":6,"patch":0},"generator":"Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)"},"module":{"name":"Foundation","platform":{"architecture":"arm64e","vendor":"apple","operatingSystem":{"name":"macosx","minimumVersion":{"major":26,"minor":1}}}},"symbols":[{"kind":{"identifier":"swift.init","displayName":"Initializer"},"identifier":{"precise":"s:6System8FilePathV10FoundationEyACSgAD3URLVcfc","interfaceLanguage":"swift"},"pathComponents":["FilePath","init(_:)"],"names":{"title":"init(_:)","subHeading":[{"kind":"keyword","spelling":"init"},{"kind":"text","spelling":"?("},{"kind":"typeIdentifier","spelling":"URL","preciseIdentifier":"s:10Foundation3URLV"},{"kind":"text","spelling":")"}]},"docComment":{"module":"Foundation","lines":[{"text":"Creates a file path from a URL"},{"text":""},{"text":"The result is nil if `url` doesn't refer to a local file."}]},"functionSignature":{"parameters":[{"name":"url","declarationFragments":[{"kind":"identifier","spelling":"url"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"URL","preciseIdentifier":"s:10Foundation3URLV"}]}]},"swiftExtension":{"extendedModule":"System","typeKind":"swift.struct"},"declarationFragments":[{"kind":"keyword","spelling":"init"},{"kind":"text","spelling":"?("},{"kind":"externalParam","spelling":"_"},{"kind":"text","spelling":" "},{"kind":"internalParam","spelling":"url"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"URL","preciseIdentifier":"s:10Foundation3URLV"},{"kind":"text","spelling":")"}],"accessLevel":"public","availability":[{"domain":"macOS","introduced":{"major":11,"minor":0}},{"domain":"watchOS","introduced":{"major":7,"minor":0}},{"domain":"iOS","introduced":{"major":14,"minor":0}},{"domain":"tvOS","introduced":{"major":14,"minor":0}}]}],"relationships":[{"kind":"memberOf","source":"s:6System8FilePathV10FoundationEyACSgAD3URLVcfc","target":"s:6System8FilePathV","targetFallback":"System.FilePath"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"metadata":{"formatVersion":{"major":0,"minor":6,"patch":0},"generator":"Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)"},"module":{"name":"Foundation","platform":{"architecture":"arm64e","vendor":"apple","operatingSystem":{"name":"macosx","minimumVersion":{"major":26,"minor":1}}}},"symbols":[{"kind":{"identifier":"swift.property","displayName":"Instance Property"},"identifier":{"precise":"s:Sci10Foundations5UInt8V7ElementRtzrlE5linesAA17AsyncLineSequenceVyxGvp","interfaceLanguage":"swift"},"pathComponents":["AsyncSequence","lines"],"names":{"title":"lines","subHeading":[{"kind":"keyword","spelling":"var"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"lines"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"AsyncLineSequence","preciseIdentifier":"s:10Foundation17AsyncLineSequenceV"},{"kind":"text","spelling":"<"},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":">"}]},"docComment":{"module":"Foundation","lines":[{"text":"A non-blocking sequence of newline-separated `Strings` created by decoding the elements of `self` as UTF8."},{"text":""}]},"swiftExtension":{"extendedModule":"_Concurrency","typeKind":"swift.protocol","constraints":[{"kind":"sameType","lhs":"Self.Element","rhs":"UInt8","rhsPrecise":"s:s5UInt8V"}]},"declarationFragments":[{"kind":"keyword","spelling":"var"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"lines"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"AsyncLineSequence","preciseIdentifier":"s:10Foundation17AsyncLineSequenceV"},{"kind":"text","spelling":"<"},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":"> { "},{"kind":"keyword","spelling":"get"},{"kind":"text","spelling":" }"}],"accessLevel":"public","availability":[{"domain":"macOS","introduced":{"major":12,"minor":0}},{"domain":"watchOS","introduced":{"major":8,"minor":0}},{"domain":"iOS","introduced":{"major":15,"minor":0}},{"domain":"tvOS","introduced":{"major":15,"minor":0}}]},{"kind":{"identifier":"swift.property","displayName":"Instance Property"},"identifier":{"precise":"s:Sci10Foundations5UInt8V7ElementRtzrlE10charactersAA22AsyncCharacterSequenceVyxGvp","interfaceLanguage":"swift"},"pathComponents":["AsyncSequence","characters"],"names":{"title":"characters","subHeading":[{"kind":"keyword","spelling":"var"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"characters"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"AsyncCharacterSequence","preciseIdentifier":"s:10Foundation22AsyncCharacterSequenceV"},{"kind":"text","spelling":"<"},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":">"}]},"docComment":{"module":"Foundation","lines":[{"text":"A non-blocking sequence of `Characters` created by decoding the elements of `self` as UTF8."},{"text":""}]},"swiftExtension":{"extendedModule":"_Concurrency","typeKind":"swift.protocol","constraints":[{"kind":"sameType","lhs":"Self.Element","rhs":"UInt8","rhsPrecise":"s:s5UInt8V"}]},"declarationFragments":[{"kind":"keyword","spelling":"var"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"characters"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"AsyncCharacterSequence","preciseIdentifier":"s:10Foundation22AsyncCharacterSequenceV"},{"kind":"text","spelling":"<"},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":"> { "},{"kind":"keyword","spelling":"get"},{"kind":"text","spelling":" }"}],"accessLevel":"public","availability":[{"domain":"macOS","introduced":{"major":12,"minor":0}},{"domain":"watchOS","introduced":{"major":8,"minor":0}},{"domain":"iOS","introduced":{"major":15,"minor":0}},{"domain":"tvOS","introduced":{"major":15,"minor":0}}]},{"kind":{"identifier":"swift.property","displayName":"Instance Property"},"identifier":{"precise":"s:Sci10Foundations5UInt8V7ElementRtzrlE14unicodeScalarsAA26AsyncUnicodeScalarSequenceVyxGvp","interfaceLanguage":"swift"},"pathComponents":["AsyncSequence","unicodeScalars"],"names":{"title":"unicodeScalars","subHeading":[{"kind":"keyword","spelling":"var"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"unicodeScalars"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"AsyncUnicodeScalarSequence","preciseIdentifier":"s:10Foundation26AsyncUnicodeScalarSequenceV"},{"kind":"text","spelling":"<"},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":">"}]},"docComment":{"module":"Foundation","lines":[{"text":"A non-blocking sequence of `UnicodeScalars` created by decoding the elements of `self` as UTF8."},{"text":""}]},"swiftExtension":{"extendedModule":"_Concurrency","typeKind":"swift.protocol","constraints":[{"kind":"sameType","lhs":"Self.Element","rhs":"UInt8","rhsPrecise":"s:s5UInt8V"}]},"declarationFragments":[{"kind":"keyword","spelling":"var"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"unicodeScalars"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"AsyncUnicodeScalarSequence","preciseIdentifier":"s:10Foundation26AsyncUnicodeScalarSequenceV"},{"kind":"text","spelling":"<"},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":"> { "},{"kind":"keyword","spelling":"get"},{"kind":"text","spelling":" }"}],"accessLevel":"public","availability":[{"domain":"macOS","introduced":{"major":12,"minor":0}},{"domain":"watchOS","introduced":{"major":8,"minor":0}},{"domain":"iOS","introduced":{"major":15,"minor":0}},{"domain":"tvOS","introduced":{"major":15,"minor":0}}]}],"relationships":[{"kind":"memberOf","source":"s:Sci10Foundations5UInt8V7ElementRtzrlE5linesAA17AsyncLineSequenceVyxGvp","target":"s:Sci","targetFallback":"_Concurrency.AsyncSequence"},{"kind":"memberOf","source":"s:Sci10Foundations5UInt8V7ElementRtzrlE10charactersAA22AsyncCharacterSequenceVyxGvp","target":"s:Sci","targetFallback":"_Concurrency.AsyncSequence"},{"kind":"memberOf","source":"s:Sci10Foundations5UInt8V7ElementRtzrlE14unicodeScalarsAA26AsyncUnicodeScalarSequenceVyxGvp","target":"s:Sci","targetFallback":"_Concurrency.AsyncSequence"}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"metadata":{"formatVersion":{"major":0,"minor":6,"patch":0},"generator":"Apple Swift version 6.2.1 (swiftlang-6.2.1.4.8 clang-1700.4.4.1)"},"module":{"name":"Foundation","platform":{"architecture":"arm64e","vendor":"apple","operatingSystem":{"name":"macosx","minimumVersion":{"major":26,"minor":1}}}},"symbols":[{"kind":{"identifier":"swift.func.op","displayName":"Operator"},"identifier":{"precise":"s:10Foundation18_ErrorCodeProtocolPAAE2teoiySbx_s0B0_ptFZ::SYNTHESIZED::c:@M@_DarwinFoundation1@E@POSIXErrorCode","interfaceLanguage":"swift"},"pathComponents":["POSIXErrorCode","~=(_:_:)"],"names":{"title":"~=(_:_:)","subHeading":[{"kind":"keyword","spelling":"static"},{"kind":"text","spelling":" "},{"kind":"keyword","spelling":"func"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"~="},{"kind":"text","spelling":" "},{"kind":"text","spelling":"("},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":", any "},{"kind":"typeIdentifier","spelling":"Error","preciseIdentifier":"s:s5ErrorP"},{"kind":"text","spelling":") -> "},{"kind":"typeIdentifier","spelling":"Bool","preciseIdentifier":"s:Sb"}]},"docComment":{"module":"Foundation","lines":[{"text":"Allow one to match an error code against an arbitrary error."}]},"functionSignature":{"parameters":[{"name":"match","declarationFragments":[{"kind":"identifier","spelling":"match"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"Self"}]},{"name":"error","declarationFragments":[{"kind":"identifier","spelling":"error"},{"kind":"text","spelling":": any "},{"kind":"typeIdentifier","spelling":"Error","preciseIdentifier":"s:s5ErrorP"}]}],"returns":[{"kind":"typeIdentifier","spelling":"Bool","preciseIdentifier":"s:Sb"}]},"swiftExtension":{"extendedModule":"Foundation","typeKind":"swift.protocol"},"declarationFragments":[{"kind":"keyword","spelling":"static"},{"kind":"text","spelling":" "},{"kind":"keyword","spelling":"func"},{"kind":"text","spelling":" "},{"kind":"identifier","spelling":"~="},{"kind":"text","spelling":" "},{"kind":"text","spelling":"("},{"kind":"internalParam","spelling":"match"},{"kind":"text","spelling":": "},{"kind":"typeIdentifier","spelling":"Self"},{"kind":"text","spelling":", "},{"kind":"internalParam","spelling":"error"},{"kind":"text","spelling":": any "},{"kind":"typeIdentifier","spelling":"Error","preciseIdentifier":"s:s5ErrorP"},{"kind":"text","spelling":") -> "},{"kind":"typeIdentifier","spelling":"Bool","preciseIdentifier":"s:Sb"}],"accessLevel":"public","availability":[{"domain":"macOS","introduced":{"major":10,"minor":10}},{"domain":"watchOS","introduced":{"major":2,"minor":0}},{"domain":"iOS","introduced":{"major":8,"minor":0}},{"domain":"tvOS","introduced":{"major":9,"minor":0}}]}],"relationships":[{"kind":"conformsTo","source":"c:@M@_DarwinFoundation1@E@POSIXErrorCode","target":"s:s8CopyableP","targetFallback":"Swift.Copyable"},{"kind":"conformsTo","source":"c:@M@_DarwinFoundation1@E@POSIXErrorCode","target":"s:SQ","targetFallback":"Swift.Equatable"},{"kind":"memberOf","source":"s:10Foundation18_ErrorCodeProtocolPAAE2teoiySbx_s0B0_ptFZ::SYNTHESIZED::c:@M@_DarwinFoundation1@E@POSIXErrorCode","target":"c:@M@_DarwinFoundation1@E@POSIXErrorCode","targetFallback":"_DarwinFoundation1.POSIXErrorCode"}]}

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions pkgs/swift2objc/lib/src/generate_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import 'generator/generator.dart';
import 'parser/parser.dart';
import 'transformer/transform.dart';
import 'utils.dart';
import 'utils/perf_timer.dart';

extension Swift2ObjCGeneratorMethod on Swift2ObjCGenerator {
/// Used to generate the wrapper swift file.
Expand All @@ -26,6 +27,8 @@ Future<void> _generateWrapper(
Swift2ObjCGenerator config,
Context context,
) async {
final scope = PerfScope('swift2objc generation', logger: context.logger);

final Directory tempDir;
final bool deleteTempDirWhenDone;

Expand All @@ -48,15 +51,20 @@ Future<void> _generateWrapper(

final allInputConfigs = [...config.inputs, builtInInputConfig];

// Parse symbolgraph (baseline: no caching)
final parseScope = scope.child('parse symbolgraph');
for (final input in allInputConfigs) {
// Always generate symbolgraph JSON (baseline measurement)
if (input is HasSymbolgraphCommand) {
final extractTimer = scope.child('symbolgraph extraction');
await _generateSymbolgraphJson(
(input as HasSymbolgraphCommand).symbolgraphCommand(
await target(),
path.absolute((await sdkPath()).path),
),
tempDir,
);
extractTimer.close();
}

final symbolgraphFileName = switch (input) {
Expand All @@ -65,33 +73,53 @@ Future<void> _generateWrapper(
JsonFileInputConfig() => path.absolute(input.jsonFile.path),
};
final symbolgraphJsonPath = path.join(tempDir.path, symbolgraphFileName);

final parseTimer = scope.child('json parse');
final symbolgraphJson = readJsonFile(symbolgraphJsonPath);
parseTimer.close();

sourceModules.add(switch (input) {
FilesInputConfig() => null,
ModuleInputConfig() => input.module,
JsonFileInputConfig() => parseModuleName(symbolgraphJson),
});

final mergeTimer = scope.child('symbolgraph merge');
mergedSymbolgraph.merge(parseSymbolgraph(input, symbolgraphJson));
mergeTimer.close();
}
parseScope.close();

// Parse declarations
final declScope = scope.child('parse declarations');
final declarations = parseDeclarations(context, mergedSymbolgraph);
declScope.close();

// Transform declarations
final transformScope = scope.child('transform');
final transformedDeclarations = transform(
context,
declarations,
filter: config.include,
);
transformScope.close();

// Generate code
final genScope = scope.child('generate');
final wrapperCode = generate(
transformedDeclarations,
importedModuleNames: sourceModules.nonNulls.toList(),
preamble: config.preamble,
);
genScope.close();

File.fromUri(config.outputFile).writeAsStringSync(wrapperCode);

if (deleteTempDirWhenDone) {
tempDir.deleteSync(recursive: true);
}

scope.close();
}

Future<void> _generateSymbolgraphJson(
Expand Down
Loading
Loading