-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Graph+Debug.swift | ||
// OpenGraphShims | ||
|
||
// FIXME: Update name in OpenGraph | ||
public typealias Graph = OGGraph | ||
public typealias Subgraph = OGSubgraph | ||
|
||
#if canImport(Darwin) | ||
|
||
import Foundation | ||
|
||
@_spi(Debug) | ||
extension Graph { | ||
public var dict: [String: Any]? { | ||
let options = ["format": "graph/dict"] as NSDictionary | ||
guard let description = Graph.description(nil, options: options) else { | ||
return nil | ||
} | ||
guard let dictionary = description.takeUnretainedValue() as? NSDictionary else { | ||
return nil | ||
} | ||
return dictionary as? [String: Any] | ||
} | ||
|
||
// style: | ||
// - bold: empty input/output edge | ||
// - dashed: indirect or has no value | ||
// color: | ||
// - red: is_changed | ||
public var dot: String? { | ||
let options = ["format": "graph/dot"] as NSDictionary | ||
guard let description = Graph.description(self, options: options) | ||
else { | ||
return nil | ||
} | ||
return description.takeUnretainedValue() as? String | ||
} | ||
} | ||
|
||
#endif |