Skip to content

Commit 48ca5cc

Browse files
authored
Merge pull request #4 from Cosmo/development
Development
2 parents ef0bf89 + b993c84 commit 48ca5cc

9 files changed

+181
-2
lines changed

Sources/OpenSwiftUI/Binding.swift

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import Foundation
2+
3+
@propertyWrapper @dynamicMemberLookup public struct Binding<Value> {
4+
public var transaction: Transaction
5+
internal var location: AnyLocation<Value>
6+
fileprivate var _value: Value
7+
public init(get: @escaping () -> Value, set: @escaping (Value) -> Void) {
8+
fatalError()
9+
}
10+
public init(get: @escaping () -> Value, set: @escaping (Value, Transaction) -> Void) {
11+
fatalError()
12+
}
13+
public static func constant(_ value: Value) -> Binding<Value> {
14+
fatalError()
15+
}
16+
public var wrappedValue: Value {
17+
get {
18+
fatalError()
19+
}
20+
nonmutating set {
21+
fatalError()
22+
}
23+
}
24+
public var projectedValue: Binding<Value> {
25+
fatalError()
26+
}
27+
public subscript<Subject>(dynamicMember keyPath: WritableKeyPath<Value, Subject>) -> Binding<Subject> {
28+
fatalError()
29+
}
30+
}
31+
32+
extension Binding {
33+
public func transaction(_ transaction: Transaction) -> Binding<Value> {
34+
fatalError()
35+
}
36+
37+
// public func animation(_ animation: Animation? = .default) -> Binding<Value> {
38+
//
39+
// }
40+
}
41+
42+
extension Binding: DynamicProperty {
43+
public static func _makeProperty<V>(in buffer: inout _DynamicPropertyBuffer, container: _GraphValue<V>, fieldOffset: Int, inputs: inout _GraphInputs) {
44+
45+
}
46+
}
47+
48+
extension Binding {
49+
public init<V>(_ base: Binding<V>) where Value == V? {
50+
fatalError()
51+
}
52+
public init?(_ base: Binding<Value?>) {
53+
fatalError()
54+
}
55+
public init<V>(_ base: Binding<V>) where Value == AnyHashable, V : Hashable {
56+
fatalError()
57+
}
58+
}

Sources/OpenSwiftUI/Graph/Graph.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ public struct _Graph {
66
}
77
}
88

9+
public struct _GraphInputs {
10+
public init() {
11+
12+
}
13+
}
14+
915
public struct _ViewInputs {
1016
public init() {
1117

@@ -31,8 +37,10 @@ public struct _ViewListOutputs {
3137
}
3238

3339
public struct _GraphValue<Value>: Equatable {
34-
public init() {
35-
40+
var value: Value
41+
42+
public init(value: Value) {
43+
self.value = value
3644
}
3745

3846
public subscript<U>(keyPath: KeyPath<Value, U>) -> _GraphValue<U> {
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Foundation
2+
3+
internal struct PropertyList: CustomStringConvertible {
4+
internal var elements: PropertyList.Element?
5+
init() { elements = nil }
6+
var description: String {
7+
return ""
8+
}
9+
}
10+
extension PropertyList {
11+
class Tracker {
12+
}
13+
}
14+
extension PropertyList {
15+
internal class Element: CustomStringConvertible {
16+
internal var description: String {
17+
return ""
18+
}
19+
}
20+
}

Sources/OpenSwiftUI/State.swift

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import Foundation
2+
3+
internal class AnyLocationBase {
4+
}
5+
6+
internal class AnyLocation<Value>: AnyLocationBase {
7+
}
8+
9+
public struct _DynamicPropertyBuffer {
10+
}
11+
12+
@propertyWrapper public struct State<Value> : DynamicProperty {
13+
@usableFromInline
14+
internal var _value: Value
15+
internal var _location: AnyLocation<Value>?
16+
17+
public init(wrappedValue value: Value) {
18+
self._value = value
19+
}
20+
21+
public init(initialValue value: Value) {
22+
_value = value
23+
}
24+
public var wrappedValue: Value {
25+
get {
26+
fatalError()
27+
}
28+
nonmutating set {
29+
fatalError()
30+
}
31+
}
32+
public var projectedValue: Binding<Value> {
33+
fatalError()
34+
}
35+
public static func _makeProperty<V>(in buffer: inout _DynamicPropertyBuffer, container: _GraphValue<V>, fieldOffset: Int, inputs: inout _GraphInputs) {
36+
fatalError()
37+
}
38+
}
39+
40+
extension State where Value : ExpressibleByNilLiteral {
41+
@inlinable public init() {
42+
self.init(wrappedValue: nil)
43+
}
44+
}

Sources/OpenSwiftUI/Transaction.swift

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Foundation
2+
3+
public struct Transaction {
4+
var plist: PropertyList
5+
public init() {
6+
plist = PropertyList()
7+
}
8+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Foundation
2+
3+
public struct ForEach<Data, ID, Content> where Data: RandomAccessCollection, ID: Hashable {
4+
public var data: Data
5+
public var content: (Data.Element) -> Content
6+
}
7+
8+
extension ForEach: View where Content: View {
9+
public var body: Never {
10+
fatalError()
11+
}
12+
13+
public typealias Body = Never
14+
public static func _makeView(view: _GraphValue<ForEach<Data, ID, Content>>, inputs: _ViewInputs) -> _ViewOutputs {
15+
fatalError()
16+
}
17+
public static func _makeViewList(view: _GraphValue<ForEach<Data, ID, Content>>, inputs: _ViewListInputs) -> _ViewListOutputs {
18+
fatalError()
19+
}
20+
}
21+
22+
extension ForEach where ID == Data.Element.ID, Content: View, Data.Element: Identifiable {
23+
public init(_ data: Data, @ViewBuilder content: @escaping (Data.Element) -> Content) {
24+
self.data = data
25+
self.content = content
26+
}
27+
}
28+
29+
extension ForEach where Content: View {
30+
public init(_ data: Data, id: KeyPath<Data.Element, ID>, content: @escaping (Data.Element) -> Content) {
31+
self.data = data
32+
self.content = content
33+
}
34+
}
35+
36+
extension ForEach where Data == Range<Int>, ID == Int, Content: View {
37+
public init(_ data: Range<Int>, @ViewBuilder content: @escaping (Int) -> Content) {
38+
self.data = data
39+
self.content = content
40+
}
41+
}

0 commit comments

Comments
 (0)