Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include <AttributeGraph/AGBase.h>

#if TARGET_OS_MAC
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#else
#include <CoreFoundation/CFString.h>
#endif
#else
#include <SwiftCorelibsCoreFoundation/CFString.h>
#endif
Expand All @@ -16,19 +20,23 @@ AG_EXTERN_C_BEGIN

#if TARGET_OS_MAC

#ifdef __OBJC__
typedef NSString *AGDescriptionOption AG_SWIFT_STRUCT AG_SWIFT_NAME(DescriptionOption);
#else
typedef CFStringRef AGDescriptionOption AG_SWIFT_STRUCT AG_SWIFT_NAME(DescriptionOption);
#endif

AG_EXPORT
const AGDescriptionOption AGDescriptionFormat AG_SWIFT_NAME(AGDescriptionOption.format);
const AGDescriptionOption AGDescriptionFormat AG_SWIFT_NAME(DescriptionOption.format);

AG_EXPORT
const AGDescriptionOption AGDescriptionMaxFrames AG_SWIFT_NAME(AGDescriptionOption.maxFrames);
const AGDescriptionOption AGDescriptionMaxFrames AG_SWIFT_NAME(DescriptionOption.maxFrames);

AG_EXPORT
const AGDescriptionOption AGDescriptionIncludeValues AG_SWIFT_NAME(AGDescriptionOption.includeValues);
const AGDescriptionOption AGDescriptionIncludeValues AG_SWIFT_NAME(DescriptionOption.includeValues);

AG_EXPORT
const AGDescriptionOption AGDescriptionTruncationLimit AG_SWIFT_NAME(AGDescriptionOption.truncationLimit);
const AGDescriptionOption AGDescriptionTruncationLimit AG_SWIFT_NAME(DescriptionOption.truncationLimit);

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ extension AttributeGraph.Rule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
}
extension AttributeGraph.Rule {
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var attribute: AttributeGraph.Attribute<Self.Value> {
get
Expand All @@ -420,8 +422,10 @@ extension AttributeGraph.StatefulRule {
}
extension AttributeGraph.StatefulRule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var value: Self.Value {
unsafeAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ extension AttributeGraph.Rule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
}
extension AttributeGraph.Rule {
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var attribute: AttributeGraph.Attribute<Self.Value> {
get
Expand All @@ -420,8 +422,10 @@ extension AttributeGraph.StatefulRule {
}
extension AttributeGraph.StatefulRule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var value: Self.Value {
unsafeAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ extension AttributeGraph.Rule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
}
extension AttributeGraph.Rule {
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var attribute: AttributeGraph.Attribute<Self.Value> {
get
Expand All @@ -420,8 +422,10 @@ extension AttributeGraph.StatefulRule {
}
extension AttributeGraph.StatefulRule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var value: Self.Value {
unsafeAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include <AttributeGraph/AGBase.h>

#if TARGET_OS_MAC
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#else
#include <CoreFoundation/CFString.h>
#endif
#else
#include <SwiftCorelibsCoreFoundation/CFString.h>
#endif
Expand All @@ -16,19 +20,23 @@ AG_EXTERN_C_BEGIN

#if TARGET_OS_MAC

#ifdef __OBJC__
typedef NSString *AGDescriptionOption AG_SWIFT_STRUCT AG_SWIFT_NAME(DescriptionOption);
#else
typedef CFStringRef AGDescriptionOption AG_SWIFT_STRUCT AG_SWIFT_NAME(DescriptionOption);
#endif

AG_EXPORT
const AGDescriptionOption AGDescriptionFormat AG_SWIFT_NAME(AGDescriptionOption.format);
const AGDescriptionOption AGDescriptionFormat AG_SWIFT_NAME(DescriptionOption.format);

AG_EXPORT
const AGDescriptionOption AGDescriptionMaxFrames AG_SWIFT_NAME(AGDescriptionOption.maxFrames);
const AGDescriptionOption AGDescriptionMaxFrames AG_SWIFT_NAME(DescriptionOption.maxFrames);

AG_EXPORT
const AGDescriptionOption AGDescriptionIncludeValues AG_SWIFT_NAME(AGDescriptionOption.includeValues);
const AGDescriptionOption AGDescriptionIncludeValues AG_SWIFT_NAME(DescriptionOption.includeValues);

AG_EXPORT
const AGDescriptionOption AGDescriptionTruncationLimit AG_SWIFT_NAME(AGDescriptionOption.truncationLimit);
const AGDescriptionOption AGDescriptionTruncationLimit AG_SWIFT_NAME(DescriptionOption.truncationLimit);

#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ extension AttributeGraph.Rule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
}
extension AttributeGraph.Rule {
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var attribute: AttributeGraph.Attribute<Self.Value> {
get
Expand All @@ -420,8 +422,10 @@ extension AttributeGraph.StatefulRule {
}
extension AttributeGraph.StatefulRule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var value: Self.Value {
unsafeAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ extension AttributeGraph.Rule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
}
extension AttributeGraph.Rule {
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var attribute: AttributeGraph.Attribute<Self.Value> {
get
Expand All @@ -420,8 +422,10 @@ extension AttributeGraph.StatefulRule {
}
extension AttributeGraph.StatefulRule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var value: Self.Value {
unsafeAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ extension AttributeGraph.Rule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
}
extension AttributeGraph.Rule {
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var attribute: AttributeGraph.Attribute<Self.Value> {
get
Expand All @@ -420,8 +422,10 @@ extension AttributeGraph.StatefulRule {
}
extension AttributeGraph.StatefulRule {
public static func _update(_ self: Swift.UnsafeMutableRawPointer, attribute: AttributeGraph.AnyAttribute)
public var bodyChanged: Swift.Bool {
get
@_alwaysEmitIntoClient public var bodyChanged: Swift.Bool {
get {
AnyAttribute.currentWasModified
}
}
public var value: Self.Value {
unsafeAddress
Expand Down
17 changes: 5 additions & 12 deletions Sources/Compute/Attribute/Rule/Rule.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import ComputeCxx

public protocol Rule: _AttributeBody {

associatedtype Value

static var initialValue: Value? { get }
var value: Value { get }

}

extension Rule {

public static var initialValue: Value? {
return nil
nil
}

public static func _updateDefault(_ self: UnsafeMutableRawPointer) {
Expand All @@ -31,23 +28,21 @@ extension Rule {
Graph.setOutputValue(valuePointer)
}
}

}

extension Rule {

@_alwaysEmitIntoClient
public var bodyChanged: Bool {
fatalError("not implemented")
AnyAttribute.currentWasModified
}

public var attribute: Attribute<Value> {
return Attribute<Value>(identifier: AnyAttribute.current!)
Attribute<Value>(identifier: AnyAttribute.current!)
}

public var context: RuleContext<Value> {
return RuleContext<Value>(attribute: attribute)
RuleContext<Value>(attribute: attribute)
}

}

@_silgen_name("IAGGraphReadCachedAttribute")
Expand All @@ -63,7 +58,6 @@ func IAGGraphReadCachedAttribute(
) -> UnsafeRawPointer

extension Rule where Self: Hashable {

public func cachedValue(options: CachedValueOptions, owner: AnyAttribute?) -> Value {
return withUnsafePointer(to: self) { bodyPointer in
Self._cachedValue(
Expand Down Expand Up @@ -120,5 +114,4 @@ extension Rule where Self: Hashable {
}
return value.assumingMemoryBound(to: Value.self)
}

}
16 changes: 6 additions & 10 deletions Sources/Compute/Attribute/Rule/StatefulRule.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import ComputeCxx

public protocol StatefulRule: _AttributeBody {

associatedtype Value

static var initialValue: Value? { get }
mutating func updateValue()

}

extension StatefulRule {

public static var initialValue: Value? {
return nil
nil
}

public static func _updateDefault(_ default: UnsafeMutableRawPointer) {
Expand All @@ -26,14 +23,14 @@ extension StatefulRule {
}

extension StatefulRule {

public static func _update(_ self: UnsafeMutableRawPointer, attribute: AnyAttribute) {
let rule = self.assumingMemoryBound(to: Self.self)
rule.pointee.updateValue()
}

@_alwaysEmitIntoClient
public var bodyChanged: Bool {
fatalError("not implemented")
AnyAttribute.currentWasModified
}

public var value: Value {
Expand All @@ -50,15 +47,14 @@ extension StatefulRule {
}

public var hasValue: Bool {
return context.hasValue
context.hasValue
}

public var attribute: Attribute<Value> {
return Attribute<Value>(identifier: AnyAttribute.current!)
Attribute<Value>(identifier: AnyAttribute.current!)
}

public var context: RuleContext<Value> {
return RuleContext<Value>(attribute: attribute)
RuleContext<Value>(attribute: attribute)
}

}
10 changes: 10 additions & 0 deletions Sources/Compute/Graph/Graph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,23 @@ extension Graph {
data: Data? = nil,
flags: Graph.NamedTraceEventFlags = []
) {
#if canImport(Darwin)
addNamedTraceEvent(
eventID: eventID,
eventArgCount: eventArgs.count,
eventArgs: eventArgs,
data: data as CFData?,
flags: flags
)
#else
addNamedTraceEvent(
eventID: eventID,
eventArgCount: eventArgs.count,
eventArgs: eventArgs,
data: data?.cfData,
flags: flags
)
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import Foundation

#if !canImport(Darwin)
extension Data {
@usableFromInline
var cfData: CFData {
#if canImport(Darwin)
self as CFData
#else
withUnsafeBytes { raw -> CFData in
CFDataCreate(
kCFAllocatorDefault,
raw.baseAddress?.assumingMemoryBound(to: UInt8.self),
raw.count
)!
}
#endif

}
}
#endif
Loading