mirror of
https://github.com/krzysztofzablocki/Sourcery.git
synced 2026-04-07 19:17:40 +00:00
cec7895f0a
* Adjusted file structure to accommodate two generated files * Adjusted scripting * Removed Description, Diffable, Equality for now * Removed Stencil import * Updated templates * Updated scripting * Updated generated coding * Disable build deletion (temp) * Updated template * Updated generated code * updated generated code * Updated generated code * Adjusted scripting * Updated scripting * Updated generated code * Reverted template deletion * Removed Stencil imports * Updated generated code * trigger CI * Removed description, diffable and equality stencil templates * Reverted temporary changes * Commented failing tests * Skipping JSExport for description & hash * Updated generated code * Enabled failing tests * Adding stencil templates back to test tests * Reset generated file for linux for test * Reverted Extensions for testing * Reverted ParserResultsComposed * Attempt to fix unit tests * Attempt to resolve unit test * Reverted TypeName asSource * Reverted TypeName revertion * Reverted revert of ParserResultComposed * Reverted revert of Extensions * Reverted revert of Linux.content.generated * Reverted attempts to fix unit tests * Fix for the failing codegen tests * Added clarifying comment * Removed description, diffable and equality stencil templates * Updated generated code * Tinkering with optimization level for speed boost * Excluded stencil templates for codegen * Fixed wrong compiler flag * Removed speed optimization to a separate PR * Reverted test code
38 lines
1.1 KiB
Swift
38 lines
1.1 KiB
Swift
//
|
|
// Stencil
|
|
// Copyright © 2022 Stencil
|
|
// MIT Licence
|
|
//
|
|
|
|
#if !canImport(ObjectiveC)
|
|
#if canImport(Stencil)
|
|
import Stencil
|
|
#else
|
|
// This is not supposed to work at all, since in Stencil there is a protocol conformance check against `DynamicMemberLookup`,
|
|
// and, of course, a substitute with the "same name" but in `Sourcery` will never satisfy that check.
|
|
// Here, we are just mimicking `Stencil.DynamicMemberLookup` to showcase what is happening within the `Sourcery` during runtime.
|
|
|
|
/// Marker protocol so we can know which types support `@dynamicMemberLookup`. Add this to your own types that support
|
|
/// lookup by String.
|
|
public protocol DynamicMemberLookup {
|
|
/// Get a value for a given `String` key
|
|
subscript(dynamicMember member: String) -> Any? { get }
|
|
}
|
|
|
|
public extension DynamicMemberLookup where Self: RawRepresentable {
|
|
/// Get a value for a given `String` key
|
|
subscript(dynamicMember member: String) -> Any? {
|
|
switch member {
|
|
case "rawValue":
|
|
return rawValue
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
public protocol SourceryDynamicMemberLookup: DynamicMemberLookup {}
|
|
|
|
#endif
|