-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathOGGraph.swift
More file actions
73 lines (63 loc) · 2.18 KB
/
OGGraph.swift
File metadata and controls
73 lines (63 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//
// OGGraph.swift
// OpenGraph
//
// Audited for RELEASE_2021
// Status: WIP
public import OpenGraph_SPI
extension OGGraph {
public static func typeIndex(
ctx: OGGraphContext,
body: _AttributeBody.Type,
valueType: Metadata,
flags: OGAttributeTypeFlags,
update: AttributeUpdateBlock
) -> Int {
// TODO: __AGGraphInternAttributeType
0
}
}
extension OGGraph {
@_silgen_name("OGGraphStartProfiling")
public static func startProfiling(_ graph: OGGraph? = nil)
@_silgen_name("OGGraphStopProfiling")
public static func stopProfiling(_ graph: OGGraph? = nil)
}
// FIXME: migrate to use @_extern(c, "xx") in Swift 6
// > Also similar to @_silgen_name, but a function declared with @_extern(c) is assumed to use the C ABI, while @_silgen_name assumes the Swift ABI.
//extension OGGraph {
// @_silgen_name("OGGGraphSetInvalidationCallback") // Use Swift ABI(self: x20) ❌, we need C ABI here(self: x0).
// public func setInvalidationCallback(_ callback: ((AnyAttribute) -> Void)?)
//
// @_silgen_name("OGGGraphSetUpdateCallback")
// public func setUpdateCallback(_ callback: (() -> Void)?)
//}
extension OGGraph {
@_silgen_name("OGGraphSetInvalidationCallback")
public static func setInvalidationCallback(_ graph: OGGraph, callback: ((AnyAttribute) -> Void)?)
@_silgen_name("OGGraphSetUpdateCallback")
public static func setUpdateCallback(_ graph: OGGraph, callback: (() -> Void)?)
}
extension OGGraph {
@_transparent
@inline(__always)
public var mainUpdates: Int { numericCast(counter(for: ._10)) }
}
extension OGGraph {
public static func withoutUpdate<Value>(_ body: () -> Value) -> Value {
let update = clearUpdate()
defer { setUpdate(update) }
return body()
}
}
extension OGGraph {
// NOTE: Currently Swift does not support generic computed variable
@_silgen_name("OGGraphGetOutputValue")
@inline(__always)
@inlinable
public static func outputValue<Value>() -> UnsafePointer<Value>?
@_silgen_name("OGGraphSetOutputValue")
@inline(__always)
@inlinable
public static func setOutputValue<Value>(_ value: UnsafePointer<Value>)
}