Skip to content

Commit c9bdf38

Browse files
authored
Merge pull request #544 from abertelrud/factor-out-c99-identifier-mangling
Move the details of C99 identifier mangling out of `ProjectModel`
2 parents 8ad47ad + 24aaf6e commit c9bdf38

File tree

8 files changed

+289
-273
lines changed

8 files changed

+289
-273
lines changed

Sources/Commands/init.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ final class InitPackage {
5555

5656
init(mode: InitMode) throws {
5757
self.mode = mode
58-
pkgname = rootd.basename
59-
// Also validates that the name is valid.
60-
moduleName = try c99name(name: rootd.basename)
58+
let dirname = rootd.basename
59+
assert(!dirname.isEmpty) // a base name is never empty
60+
self.pkgname = dirname
61+
self.moduleName = dirname.mangledToC99ExtendedIdentifier()
6162
}
6263

6364
func writePackageStructure() throws {

Sources/PackageModel/Module.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public class Module: ModuleProtocol {
6363
self.type = type
6464
self.sources = sources
6565
self.dependencies = []
66-
self.c99name = try PackageModel.c99name(name: self.name)
66+
self.c99name = self.name.mangledToC99ExtendedIdentifier()
6767
self.isTest = isTest
6868
}
6969

Sources/PackageModel/c99name().swift

Lines changed: 0 additions & 222 deletions
This file was deleted.

0 commit comments

Comments
 (0)