Skip to content

Commit

Permalink
Basic untyped dict decoding
Browse files Browse the repository at this point in the history
This is currently very badly written, mostly as a POC at this stage.
  • Loading branch information
cryptoAlgorithm committed Jun 8, 2022
1 parent 7b66924 commit dfc5803
Show file tree
Hide file tree
Showing 7 changed files with 596 additions and 6 deletions.
91 changes: 91 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/ETFKit.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1340"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ETFKit"
BuildableName = "ETFKit"
BlueprintName = "ETFKit"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ETFKitTests"
BuildableName = "ETFKitTests"
BlueprintName = "ETFKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ETFKitTests"
BuildableName = "ETFKitTests"
BlueprintName = "ETFKitTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ETFKit"
BuildableName = "ETFKit"
BlueprintName = "ETFKit"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# ETFKit

A description of this package.
Decode/encode Erlang External Term format (ETF) version 131.

> This is a work in progress.
37 changes: 37 additions & 0 deletions Sources/ETFKit/Decoder/ETFDecoder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// ETFDecoder.swift
//
//
// Created by Vincent Kwok on 8/6/22.
//

import Foundation

open class ETFDecoder {
open func decode<T>(_ type: T.Type, from data: Data) throws -> T where T : Decodable {
return try type.init(from: _ETFDecoder())
}
}

internal class _ETFDecoder: Decoder {
internal(set) public var codingPath: [CodingKey]

/// Contextual user-provided information for use during encoding.
public var userInfo: [CodingUserInfoKey : Any] = [:]

func container<Key>(keyedBy: Key.Type) throws -> KeyedDecodingContainer<Key> {
fatalError()
}

func singleValueContainer() throws -> SingleValueDecodingContainer {
fatalError()
}

func unkeyedContainer() throws -> UnkeyedDecodingContainer {
fatalError()
}

init(at codingPath: [CodingKey] = []) {
self.codingPath = codingPath
}
}
Loading

0 comments on commit dfc5803

Please sign in to comment.