-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Macro-based schema discovery proof of concept
- Loading branch information
Showing
14 changed files
with
993 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// swift-tools-version: 5.9 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
import CompilerPluginSupport | ||
|
||
let package = Package( | ||
name: "RealmMacro", | ||
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .macCatalyst(.v13)], | ||
products: [ | ||
.library( | ||
name: "RealmMacro", | ||
targets: ["RealmMacro"] | ||
), | ||
.executable( | ||
name: "RealmMacroClient", | ||
targets: ["RealmMacroClient"] | ||
), | ||
], | ||
dependencies: [ | ||
.package(url: "https://github.com/apple/swift-syntax.git", branch: "release/5.9") | ||
], | ||
targets: [ | ||
.macro( | ||
name: "RealmMacroMacros", | ||
dependencies: [ | ||
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"), | ||
.product(name: "SwiftCompilerPlugin", package: "swift-syntax") | ||
] | ||
), | ||
.target(name: "RealmMacro", dependencies: ["RealmMacroMacros"]), | ||
.executableTarget(name: "RealmMacroClient", dependencies: ["RealmMacro"]), | ||
.testTarget( | ||
name: "RealmMacroTests", | ||
dependencies: [ | ||
"RealmMacroMacros", | ||
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), | ||
] | ||
), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@attached(conformance) | ||
@attached(member, names: named(_realmProperties)) | ||
//@attached(memberAttribute) | ||
public macro RealmSchemaDiscovery() -> Void = #externalMacro(module: "RealmMacroMacros", type: "RealmSchemaDiscovery") | ||
|
||
@attached(conformance) | ||
@attached(member, names: named(_realmProperties), named(_realmUnmanagedStorage)) | ||
@attached(memberAttribute) | ||
public macro RealmModel() -> () = #externalMacro(module: "RealmMacroMacros", type: "RealmObjectMacro2") | ||
|
||
@attached(accessor) | ||
@attached(peer, names: arbitrary) | ||
public macro _PersistedProperty(index: Int) -> () = #externalMacro(module: "RealmMacroMacros", type: "PersistedProperty2") | ||
|
||
@attached(peer, names: arbitrary) | ||
public macro PersistedProperty(index: Int) -> () = #externalMacro(module: "RealmMacroMacros", type: "PersistedProperty2") | ||
|
||
@attached(accessor) | ||
public macro OriginProperty(name: String) -> () = #externalMacro(module: "RealmMacroMacros", type: "Marker") | ||
|
||
@attached(accessor) | ||
public macro PrimaryKey() -> () = #externalMacro(module: "RealmMacroMacros", type: "Marker") | ||
@attached(accessor) | ||
public macro Indexed() -> () = #externalMacro(module: "RealmMacroMacros", type: "Marker") | ||
@attached(accessor) | ||
public macro Ignored() -> () = #externalMacro(module: "RealmMacroMacros", type: "Marker") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import RealmMacro |
Oops, something went wrong.