From bfd9a40f20eb35b8064641d83692a9219cb635f6 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 Feb 2024 19:45:34 +0800 Subject: [PATCH 1/7] Add addInput API --- .../Headers/AGAttribute.h | 14 +++++++------- .../Headers/AGInputOptions.h | 18 ++++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 1 + .../arm64-apple-ios.swiftinterface | 9 +++++++++ .../arm64e-apple-ios.swiftinterface | 9 +++++++++ .../Headers/AGAttribute.h | 14 +++++++------- .../Headers/AGInputOptions.h | 18 ++++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 1 + .../arm64-apple-ios-simulator.swiftinterface | 9 +++++++++ .../x86_64-apple-ios-simulator.swiftinterface | 9 +++++++++ .../Headers/AGAttribute.h | 14 +++++++------- .../Headers/AGInputOptions.h | 18 ++++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 1 + .../arm64-apple-macos.swiftinterface | 9 +++++++++ .../arm64e-apple-macos.swiftinterface | 9 +++++++++ .../x86_64-apple-macos.swiftinterface | 9 +++++++++ AG/Sources/Headers/AGAttribute.h | 14 +++++++------- AG/Sources/Headers/AGInputOptions.h | 18 ++++++++++++++++++ AG/Sources/Headers/AttributeGraph-umbrella.h | 1 + .../template.swiftinterface | 9 +++++++++ Sources/OpenGraph/Attribute/Attribute.swift | 12 +++++++++++- .../Attribute/OGExtension/OGAttribute.swift | 12 +++++++++++- Sources/OpenGraphShims/GraphShims.swift | 7 +++++++ Sources/_OpenGraph/Attribute/OGAttribute.cpp | 12 ++++++++++-- Sources/_OpenGraph/Attribute/OGAttribute.h | 9 +++++++-- Sources/_OpenGraph/Attribute/OGInputOptions.h | 18 ++++++++++++++++++ Sources/_OpenGraph/include/OGInputOptions.h | 1 + Sources/_OpenGraph/include/_OGGraph.h | 1 + .../GraphShims.swift | 7 +++++++ 29 files changed, 249 insertions(+), 34 deletions(-) create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGInputOptions.h create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGInputOptions.h create mode 100644 AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGInputOptions.h create mode 100644 AG/Sources/Headers/AGInputOptions.h create mode 100644 Sources/_OpenGraph/Attribute/OGInputOptions.h create mode 120000 Sources/_OpenGraph/include/OGInputOptions.h diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h index 4c1a2c97..0c1d1915 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h @@ -11,6 +11,7 @@ #include "AGBase.h" #include "AGAttributeFlags.h" +#include "AGInputOptions.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -19,22 +20,17 @@ AG_EXTERN_C_BEGIN AG_EXPORT const AGAttribute AGAttributeNil; -AG_EXTERN_C_BEGIN -AG_EXPORT -const AGAttribute AGAttributeNil; -AG_EXTERN_C_END - AG_EXPORT AG_REFINED_FOR_SWIFT AGAttribute AGGraphGetCurrentAttribute(void); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, uint64_t offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); +AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, long offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, uint64_t offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); +AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, long offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); AG_EXPORT AG_REFINED_FOR_SWIFT @@ -44,6 +40,10 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphSetFlags(AGAttribute attribute, AGAttributeFlags flags) AG_SWIFT_NAME(setter:AGAttribute.flags(self:_:)); +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGInputOptions.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGInputOptions.h new file mode 100644 index 00000000..54abdc1e --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGInputOptions.h @@ -0,0 +1,18 @@ +// +// AGInputOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGInputOptions_h +#define AGInputOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGInputOptions) { + AGInputOptions_0 = 0, + AGInputOptions_1 = 1, +}; + +#endif /* AGInputOptions_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 2bec2681..765985db 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -14,6 +14,7 @@ #include "AGComparisonMode.h" #include "AGDebugServer.h" #include "AGGraph.h" +#include "AGInputOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface index 7fbce9da..d0fbe81f 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface @@ -21,6 +21,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -60,6 +64,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface index 7fbce9da..d0fbe81f 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface @@ -21,6 +21,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -60,6 +64,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h index 4c1a2c97..0c1d1915 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h @@ -11,6 +11,7 @@ #include "AGBase.h" #include "AGAttributeFlags.h" +#include "AGInputOptions.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -19,22 +20,17 @@ AG_EXTERN_C_BEGIN AG_EXPORT const AGAttribute AGAttributeNil; -AG_EXTERN_C_BEGIN -AG_EXPORT -const AGAttribute AGAttributeNil; -AG_EXTERN_C_END - AG_EXPORT AG_REFINED_FOR_SWIFT AGAttribute AGGraphGetCurrentAttribute(void); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, uint64_t offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); +AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, long offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, uint64_t offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); +AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, long offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); AG_EXPORT AG_REFINED_FOR_SWIFT @@ -44,6 +40,10 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphSetFlags(AGAttribute attribute, AGAttributeFlags flags) AG_SWIFT_NAME(setter:AGAttribute.flags(self:_:)); +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGInputOptions.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGInputOptions.h new file mode 100644 index 00000000..54abdc1e --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGInputOptions.h @@ -0,0 +1,18 @@ +// +// AGInputOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGInputOptions_h +#define AGInputOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGInputOptions) { + AGInputOptions_0 = 0, + AGInputOptions_1 = 1, +}; + +#endif /* AGInputOptions_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 2bec2681..765985db 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -14,6 +14,7 @@ #include "AGComparisonMode.h" #include "AGDebugServer.h" #include "AGGraph.h" +#include "AGInputOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface index 9c19df6c..3adcaad7 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface @@ -21,6 +21,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -60,6 +64,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface index 9197e012..97702858 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface @@ -21,6 +21,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -60,6 +64,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h index 4c1a2c97..0c1d1915 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h @@ -11,6 +11,7 @@ #include "AGBase.h" #include "AGAttributeFlags.h" +#include "AGInputOptions.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -19,22 +20,17 @@ AG_EXTERN_C_BEGIN AG_EXPORT const AGAttribute AGAttributeNil; -AG_EXTERN_C_BEGIN -AG_EXPORT -const AGAttribute AGAttributeNil; -AG_EXTERN_C_END - AG_EXPORT AG_REFINED_FOR_SWIFT AGAttribute AGGraphGetCurrentAttribute(void); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, uint64_t offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); +AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, long offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, uint64_t offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); +AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, long offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); AG_EXPORT AG_REFINED_FOR_SWIFT @@ -44,6 +40,10 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphSetFlags(AGAttribute attribute, AGAttributeFlags flags) AG_SWIFT_NAME(setter:AGAttribute.flags(self:_:)); +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGInputOptions.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGInputOptions.h new file mode 100644 index 00000000..54abdc1e --- /dev/null +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGInputOptions.h @@ -0,0 +1,18 @@ +// +// AGInputOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGInputOptions_h +#define AGInputOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGInputOptions) { + AGInputOptions_0 = 0, + AGInputOptions_1 = 1, +}; + +#endif /* AGInputOptions_h */ diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 2bec2681..765985db 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -14,6 +14,7 @@ #include "AGComparisonMode.h" #include "AGDebugServer.h" #include "AGGraph.h" +#include "AGInputOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface index e01333e5..b944e7f4 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface @@ -21,6 +21,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -60,6 +64,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface index af2e8f29..1b062fa2 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface @@ -21,6 +21,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -60,6 +64,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface index dcda9b41..5a431a5a 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface @@ -21,6 +21,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -60,6 +64,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/AG/Sources/Headers/AGAttribute.h b/AG/Sources/Headers/AGAttribute.h index 4c1a2c97..0c1d1915 100644 --- a/AG/Sources/Headers/AGAttribute.h +++ b/AG/Sources/Headers/AGAttribute.h @@ -11,6 +11,7 @@ #include "AGBase.h" #include "AGAttributeFlags.h" +#include "AGInputOptions.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -19,22 +20,17 @@ AG_EXTERN_C_BEGIN AG_EXPORT const AGAttribute AGAttributeNil; -AG_EXTERN_C_BEGIN -AG_EXPORT -const AGAttribute AGAttributeNil; -AG_EXTERN_C_END - AG_EXPORT AG_REFINED_FOR_SWIFT AGAttribute AGGraphGetCurrentAttribute(void); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, uint64_t offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); +AGAttribute AGGraphCreateOffsetAttribute(AGAttribute attribute, long offset) AG_SWIFT_NAME(AGAttribute.create(self:offset:)); AG_EXPORT AG_REFINED_FOR_SWIFT -AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, uint64_t offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); +AGAttribute AGGraphCreateOffsetAttribute2(AGAttribute attribute, long offset, uint64_t size) AG_SWIFT_NAME(AGAttribute.create(self:offset:size:)); AG_EXPORT AG_REFINED_FOR_SWIFT @@ -44,6 +40,10 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphSetFlags(AGAttribute attribute, AGAttributeFlags flags) AG_SWIFT_NAME(setter:AGAttribute.flags(self:_:)); +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/Sources/Headers/AGInputOptions.h b/AG/Sources/Headers/AGInputOptions.h new file mode 100644 index 00000000..54abdc1e --- /dev/null +++ b/AG/Sources/Headers/AGInputOptions.h @@ -0,0 +1,18 @@ +// +// AGInputOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGInputOptions_h +#define AGInputOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGInputOptions) { + AGInputOptions_0 = 0, + AGInputOptions_1 = 1, +}; + +#endif /* AGInputOptions_h */ diff --git a/AG/Sources/Headers/AttributeGraph-umbrella.h b/AG/Sources/Headers/AttributeGraph-umbrella.h index 2bec2681..765985db 100644 --- a/AG/Sources/Headers/AttributeGraph-umbrella.h +++ b/AG/Sources/Headers/AttributeGraph-umbrella.h @@ -14,6 +14,7 @@ #include "AGComparisonMode.h" #include "AGDebugServer.h" #include "AGGraph.h" +#include "AGInputOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface b/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface index 6f634d33..8b8ffc21 100644 --- a/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface +++ b/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface @@ -17,6 +17,10 @@ extension AGAttribute { public func unsafeOffset(at offset: Int) -> AGAttribute @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } extension AGAttribute: Swift.CustomStringConvertible { @@ -56,6 +60,11 @@ extension AGAttribute: Swift.CustomStringConvertible { public func hash(into hasher: inout Swift.Hasher) public var hashValue: Swift.Int { get } public var value: Value { get set } + + @inlinable + public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) + @inlinable + public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) } // MARK: - _AttributeBody diff --git a/Sources/OpenGraph/Attribute/Attribute.swift b/Sources/OpenGraph/Attribute/Attribute.swift index ae5ef89e..144b465b 100644 --- a/Sources/OpenGraph/Attribute/Attribute.swift +++ b/Sources/OpenGraph/Attribute/Attribute.swift @@ -2,7 +2,7 @@ import _OpenGraph @propertyWrapper public struct Attribute { - var identifier: OGAttribute + public var identifier: OGAttribute public init() { fatalError("TODO") @@ -19,6 +19,16 @@ public struct Attribute { get { wrappedValue } set { fatalError("TODO") } } + + @inlinable + public func addInput(_ attribute: OGAttribute, options: OGInputOptions, token: Int) { + __OGGraphAddInput(self.identifier, attribute, options, token) + } + + @inlinable + public func addInput(_ attribute: Attribute, options: OGInputOptions, token: Int) { + addInput(attribute.identifier, options: options, token: token) + } } extension Attribute: Equatable {} diff --git a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift index baeb9dc0..a8a0b4fd 100644 --- a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift +++ b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift @@ -21,13 +21,23 @@ extension OGAttribute { @inlinable public func unsafeOffset(at offset: Int) -> OGAttribute { - create(offset: UInt64(offset)) + create(offset: offset) } @inlinable public func setFlags(_ newFlags: OGAttributeFlags, mask: OGAttributeFlags) { flags = flags.subtracting(mask).union(newFlags.intersection(mask)) } + + @inlinable + public func addInput(_ attribute: OGAttribute, options: OGInputOptions, token: Int) { + __OGGraphAddInput(self, attribute, options, token) + } + + @inlinable + public func addInput(_ attribute: Attribute, options: OGInputOptions, token: Int) { + addInput(attribute.identifier, options: options, token: token) + } } // MARK: CustomStringConvertible diff --git a/Sources/OpenGraphShims/GraphShims.swift b/Sources/OpenGraphShims/GraphShims.swift index 64a75a79..ce1e5f4a 100644 --- a/Sources/OpenGraphShims/GraphShims.swift +++ b/Sources/OpenGraphShims/GraphShims.swift @@ -8,12 +8,19 @@ #if OPENGRAPH_ATTRIBUTEGRAPH @_exported import AttributeGraph public typealias OGAttribute = AGAttribute +public typealias OGAttributeFlags = AGAttributeFlags +public typealias OGAttributeTypeFlags = AGAttributeTypeFlags +public typealias OGComparisonMode = AGComparisonMode +public typealias OGComparisonOptions = AGComparisonOptions public typealias OGDebugServer = AGDebugServer public typealias OGGraph = AGGraph +public typealias OGGraphContext = AGGraphContext +public typealias OGInputOptions = AGInputOptions public typealias OGSubgraph = AGSubgraph public typealias OGSwiftMetadata = AGSwiftMetadata public typealias OGTupleType = AGTupleType public typealias OGTypeApplyOptions = AGTypeApplyOptions +public typealias OGTypeKind = AGTypeKind public typealias OGTypeID = AGTypeID public typealias OGUniqueID = AGUniqueID #else diff --git a/Sources/_OpenGraph/Attribute/OGAttribute.cpp b/Sources/_OpenGraph/Attribute/OGAttribute.cpp index 63a3f832..7a791c59 100644 --- a/Sources/_OpenGraph/Attribute/OGAttribute.cpp +++ b/Sources/_OpenGraph/Attribute/OGAttribute.cpp @@ -25,11 +25,11 @@ OGAttribute create_offset_attribute(OGAttribute attribute, uint64_t offset, std: } } -OGAttribute OGGraphCreateOffsetAttribute(OGAttribute attribute, uint64_t offset) { +OGAttribute OGGraphCreateOffsetAttribute(OGAttribute attribute, long offset) { return create_offset_attribute(attribute, offset, std::nullopt); } -OGAttribute OGGraphCreateOffsetAttribute2(OGAttribute attribute, uint64_t offset, uint64_t size) { +OGAttribute OGGraphCreateOffsetAttribute2(OGAttribute attribute, long offset, uint64_t size) { return create_offset_attribute(attribute, offset, std::optional(size)); } @@ -49,3 +49,11 @@ void OGGraphSetFlags(OGAttribute attribute, OGAttributeFlags flags) { } // TODO: data/table } + +void OGGraphAddInput(OGAttribute attribute1, OGAttribute attribute2, OGInputOptions options, long token) { + const OG::AttributeID id = OG::AttributeID(attribute1); + if (!id.isDirect()) { + OG::precondition_failure("non-direct attribute id: %u", id); + } + // TODO: data/table +} diff --git a/Sources/_OpenGraph/Attribute/OGAttribute.h b/Sources/_OpenGraph/Attribute/OGAttribute.h index cb040d13..0159442d 100644 --- a/Sources/_OpenGraph/Attribute/OGAttribute.h +++ b/Sources/_OpenGraph/Attribute/OGAttribute.h @@ -10,6 +10,7 @@ #include "OGBase.h" #include "OGAttributeFlags.h" +#include "OGInputOptions.h" typedef uint32_t OGAttribute __attribute((swift_newtype(struct))); @@ -24,11 +25,11 @@ OGAttribute OGGraphGetCurrentAttribute(void); OG_EXPORT OG_REFINED_FOR_SWIFT -OGAttribute OGGraphCreateOffsetAttribute(OGAttribute attribute, uint64_t offset) OG_SWIFT_NAME(OGAttribute.create(self:offset:)); +OGAttribute OGGraphCreateOffsetAttribute(OGAttribute attribute, long offset) OG_SWIFT_NAME(OGAttribute.create(self:offset:)); OG_EXPORT OG_REFINED_FOR_SWIFT -OGAttribute OGGraphCreateOffsetAttribute2(OGAttribute attribute, uint64_t offset, uint64_t size) OG_SWIFT_NAME(OGAttribute.create(self:offset:size:)); +OGAttribute OGGraphCreateOffsetAttribute2(OGAttribute attribute, long offset, uint64_t size) OG_SWIFT_NAME(OGAttribute.create(self:offset:size:)); OG_EXPORT OG_REFINED_FOR_SWIFT @@ -38,6 +39,10 @@ OG_EXPORT OG_REFINED_FOR_SWIFT void OGGraphSetFlags(OGAttribute attribute, OGAttributeFlags flags) OG_SWIFT_NAME(setter:OGAttribute.flags(self:_:)); +OG_EXPORT +OG_REFINED_FOR_SWIFT +void OGGraphAddInput(OGAttribute attribute1, OGAttribute attribute2, OGInputOptions options, long token); + OG_EXTERN_C_END #endif /* OGAttribute_h */ diff --git a/Sources/_OpenGraph/Attribute/OGInputOptions.h b/Sources/_OpenGraph/Attribute/OGInputOptions.h new file mode 100644 index 00000000..477d263c --- /dev/null +++ b/Sources/_OpenGraph/Attribute/OGInputOptions.h @@ -0,0 +1,18 @@ +// +// OGInputOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef OGInputOptions_h +#define OGInputOptions_h + +#include "OGBase.h" + +typedef OG_OPTIONS(uint32_t, OGInputOptions) { + OGInputOptions_0 = 0, + OGInputOptions_1 = 1, +}; + +#endif /* OGInputOptions_h */ diff --git a/Sources/_OpenGraph/include/OGInputOptions.h b/Sources/_OpenGraph/include/OGInputOptions.h new file mode 120000 index 00000000..6c0f1710 --- /dev/null +++ b/Sources/_OpenGraph/include/OGInputOptions.h @@ -0,0 +1 @@ +../Attribute/OGInputOptions.h \ No newline at end of file diff --git a/Sources/_OpenGraph/include/_OGGraph.h b/Sources/_OpenGraph/include/_OGGraph.h index 2b529fc5..61e2fee1 100644 --- a/Sources/_OpenGraph/include/_OGGraph.h +++ b/Sources/_OpenGraph/include/_OGGraph.h @@ -17,6 +17,7 @@ #include "OGDebugServer.h" #include "OGGraph.h" #include "OGGraphContext.h" +#include "OGInputOptions.h" #include "OGSubgraph.h" #include "OGSwiftMetadata.h" #include "OGTupleType.h" diff --git a/Tests/OpenGraphCompatibilityTests/GraphShims.swift b/Tests/OpenGraphCompatibilityTests/GraphShims.swift index 9a569196..16584a5f 100644 --- a/Tests/OpenGraphCompatibilityTests/GraphShims.swift +++ b/Tests/OpenGraphCompatibilityTests/GraphShims.swift @@ -8,12 +8,19 @@ #if OPENGRAPH_COMPATIBILITY_TEST @_exported import AttributeGraph public typealias OGAttribute = AGAttribute +public typealias OGAttributeFlags = AGAttributeFlags +public typealias OGAttributeTypeFlags = AGAttributeTypeFlags +public typealias OGComparisonMode = AGComparisonMode +public typealias OGComparisonOptions = AGComparisonOptions public typealias OGDebugServer = AGDebugServer public typealias OGGraph = AGGraph +public typealias OGGraphContext = AGGraphContext +public typealias OGInputOptions = AGInputOptions public typealias OGSubgraph = AGSubgraph public typealias OGSwiftMetadata = AGSwiftMetadata public typealias OGTupleType = AGTupleType public typealias OGTypeApplyOptions = AGTypeApplyOptions +public typealias OGTypeKind = AGTypeKind public typealias OGTypeID = AGTypeID public typealias OGUniqueID = AGUniqueID #else From ee26a96c43d41d9d632ccb86fc4b6beec7e17955 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 Feb 2024 19:55:30 +0800 Subject: [PATCH 2/7] Add OGSearchOptions --- .../Headers/AGSearchOptions.h | 18 ++++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 1 + .../Headers/AGSearchOptions.h | 18 ++++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 1 + .../Headers/AGSearchOptions.h | 18 ++++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 1 + AG/Sources/Headers/AGSearchOptions.h | 18 ++++++++++++++++++ AG/Sources/Headers/AttributeGraph-umbrella.h | 1 + Sources/OpenGraphShims/GraphShims.swift | 1 + Sources/_OpenGraph/Attribute/OGSearchOptions.h | 18 ++++++++++++++++++ Sources/_OpenGraph/include/OGSearchOptions.h | 1 + Sources/_OpenGraph/include/_OGGraph.h | 1 + .../GraphShims.swift | 1 + 13 files changed, 98 insertions(+) create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGSearchOptions.h create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGSearchOptions.h create mode 100644 AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGSearchOptions.h create mode 100644 AG/Sources/Headers/AGSearchOptions.h create mode 100644 Sources/_OpenGraph/Attribute/OGSearchOptions.h create mode 120000 Sources/_OpenGraph/include/OGSearchOptions.h diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGSearchOptions.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGSearchOptions.h new file mode 100644 index 00000000..8cd7de49 --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGSearchOptions.h @@ -0,0 +1,18 @@ +// +// AGSearchOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGSearchOptions_h +#define AGSearchOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGSearchOptions) { + AGSearchOptions_0 = 0, + AGSearchOptions_1 = 1, +}; + +#endif /* Header_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 765985db..782fda90 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -15,6 +15,7 @@ #include "AGDebugServer.h" #include "AGGraph.h" #include "AGInputOptions.h" +#include "AGSearchOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGSearchOptions.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGSearchOptions.h new file mode 100644 index 00000000..8cd7de49 --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGSearchOptions.h @@ -0,0 +1,18 @@ +// +// AGSearchOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGSearchOptions_h +#define AGSearchOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGSearchOptions) { + AGSearchOptions_0 = 0, + AGSearchOptions_1 = 1, +}; + +#endif /* Header_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 765985db..782fda90 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -15,6 +15,7 @@ #include "AGDebugServer.h" #include "AGGraph.h" #include "AGInputOptions.h" +#include "AGSearchOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGSearchOptions.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGSearchOptions.h new file mode 100644 index 00000000..8cd7de49 --- /dev/null +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGSearchOptions.h @@ -0,0 +1,18 @@ +// +// AGSearchOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGSearchOptions_h +#define AGSearchOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGSearchOptions) { + AGSearchOptions_0 = 0, + AGSearchOptions_1 = 1, +}; + +#endif /* Header_h */ diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 765985db..782fda90 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -15,6 +15,7 @@ #include "AGDebugServer.h" #include "AGGraph.h" #include "AGInputOptions.h" +#include "AGSearchOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/AG/Sources/Headers/AGSearchOptions.h b/AG/Sources/Headers/AGSearchOptions.h new file mode 100644 index 00000000..8cd7de49 --- /dev/null +++ b/AG/Sources/Headers/AGSearchOptions.h @@ -0,0 +1,18 @@ +// +// AGSearchOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGSearchOptions_h +#define AGSearchOptions_h + +#include "AGBase.h" + +typedef AG_OPTIONS(uint32_t, AGSearchOptions) { + AGSearchOptions_0 = 0, + AGSearchOptions_1 = 1, +}; + +#endif /* Header_h */ diff --git a/AG/Sources/Headers/AttributeGraph-umbrella.h b/AG/Sources/Headers/AttributeGraph-umbrella.h index 765985db..782fda90 100644 --- a/AG/Sources/Headers/AttributeGraph-umbrella.h +++ b/AG/Sources/Headers/AttributeGraph-umbrella.h @@ -15,6 +15,7 @@ #include "AGDebugServer.h" #include "AGGraph.h" #include "AGInputOptions.h" +#include "AGSearchOptions.h" #include "AGSubgraph.h" #include "AGSwiftMetadata.h" #include "AGTupleType.h" diff --git a/Sources/OpenGraphShims/GraphShims.swift b/Sources/OpenGraphShims/GraphShims.swift index ce1e5f4a..0386b9f3 100644 --- a/Sources/OpenGraphShims/GraphShims.swift +++ b/Sources/OpenGraphShims/GraphShims.swift @@ -16,6 +16,7 @@ public typealias OGDebugServer = AGDebugServer public typealias OGGraph = AGGraph public typealias OGGraphContext = AGGraphContext public typealias OGInputOptions = AGInputOptions +public typealias OGSearchOptions = AGSearchOptions public typealias OGSubgraph = AGSubgraph public typealias OGSwiftMetadata = AGSwiftMetadata public typealias OGTupleType = AGTupleType diff --git a/Sources/_OpenGraph/Attribute/OGSearchOptions.h b/Sources/_OpenGraph/Attribute/OGSearchOptions.h new file mode 100644 index 00000000..42142e63 --- /dev/null +++ b/Sources/_OpenGraph/Attribute/OGSearchOptions.h @@ -0,0 +1,18 @@ +// +// OGSearchOptions.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef OGSearchOptions_h +#define OGSearchOptions_h + +#include "OGBase.h" + +typedef OG_OPTIONS(uint32_t, OGSearchOptions) { + OGSearchOptions_0 = 0, + OGSearchOptions_1 = 1, +}; + +#endif /* Header_h */ diff --git a/Sources/_OpenGraph/include/OGSearchOptions.h b/Sources/_OpenGraph/include/OGSearchOptions.h new file mode 120000 index 00000000..010d47b4 --- /dev/null +++ b/Sources/_OpenGraph/include/OGSearchOptions.h @@ -0,0 +1 @@ +../Attribute/OGSearchOptions.h \ No newline at end of file diff --git a/Sources/_OpenGraph/include/_OGGraph.h b/Sources/_OpenGraph/include/_OGGraph.h index 61e2fee1..de670f95 100644 --- a/Sources/_OpenGraph/include/_OGGraph.h +++ b/Sources/_OpenGraph/include/_OGGraph.h @@ -18,6 +18,7 @@ #include "OGGraph.h" #include "OGGraphContext.h" #include "OGInputOptions.h" +#include "OGSearchOptions.h" #include "OGSubgraph.h" #include "OGSwiftMetadata.h" #include "OGTupleType.h" diff --git a/Tests/OpenGraphCompatibilityTests/GraphShims.swift b/Tests/OpenGraphCompatibilityTests/GraphShims.swift index 16584a5f..eb570d05 100644 --- a/Tests/OpenGraphCompatibilityTests/GraphShims.swift +++ b/Tests/OpenGraphCompatibilityTests/GraphShims.swift @@ -16,6 +16,7 @@ public typealias OGDebugServer = AGDebugServer public typealias OGGraph = AGGraph public typealias OGGraphContext = AGGraphContext public typealias OGInputOptions = AGInputOptions +public typealias OGSearchOptions = AGSearchOptions public typealias OGSubgraph = AGSubgraph public typealias OGSwiftMetadata = AGSwiftMetadata public typealias OGTupleType = AGTupleType From c2d292e99532fc15ad7403cd8c2e3e1f9cc9703c Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 Feb 2024 20:01:11 +0800 Subject: [PATCH 3/7] Update OGAttribute API --- .../arm64-apple-ios.swiftinterface | 16 +++++++++ .../arm64e-apple-ios.swiftinterface | 16 +++++++++ .../arm64-apple-ios-simulator.swiftinterface | 16 +++++++++ .../x86_64-apple-ios-simulator.swiftinterface | 16 +++++++++ .../arm64-apple-macos.swiftinterface | 16 +++++++++ .../arm64e-apple-macos.swiftinterface | 16 +++++++++ .../x86_64-apple-macos.swiftinterface | 16 +++++++++ .../template.swiftinterface | 16 +++++++++ .../Attribute/OGExtension/OGAttribute.swift | 35 +++++++++++++++++++ 9 files changed, 163 insertions(+) diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface index d0fbe81f..274083a1 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface @@ -13,6 +13,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -25,6 +27,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface index d0fbe81f..274083a1 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface @@ -13,6 +13,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -25,6 +27,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface index 3adcaad7..3781ff26 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface @@ -13,6 +13,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -25,6 +27,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface index 97702858..244ef7ac 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface @@ -13,6 +13,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -25,6 +27,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface index b944e7f4..043543af 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface @@ -13,6 +13,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -25,6 +27,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface index 1b062fa2..308c03cb 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface @@ -13,6 +13,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -25,6 +27,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface index 5a431a5a..05fb8dd9 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface @@ -13,6 +13,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -25,6 +27,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface b/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface index 8b8ffc21..d0362487 100644 --- a/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface +++ b/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface @@ -9,6 +9,8 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { + @inlinable + public init(_ attribute: AttributeGraph.Attribute) @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute @inlinable @@ -21,6 +23,20 @@ extension AGAttribute { public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) + @inlinable + public func visitBody(_ visitor: inout Visitor); + @inlinable + public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) + @inlinable + public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool + @inlinable + public var _bodyType: Any.Type { get } + @inlinable + public var _bodyPointer: UnsafeRawPointer { get } + @inlinable + public var valueType: Any.Type { get } + @inlinable + public var indirectDependency: AGAttribute { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift index a8a0b4fd..c36858d0 100644 --- a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift +++ b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift @@ -8,6 +8,11 @@ import _OpenGraph extension OGAttribute { + @inlinable + public init(_ attribute: Attribute) { + self = attribute.identifier + } + @inlinable public func unsafeCast(to type: Value.Type) -> Attribute { fatalError("TODO") @@ -38,6 +43,36 @@ extension OGAttribute { public func addInput(_ attribute: Attribute, options: OGInputOptions, token: Int) { addInput(attribute.identifier, options: options, token: token) } + + @inlinable + public func visitBody(_ visitor: inout Visitor) { + fatalError("TODO") + } + + @inlinable + public func mutateBody(as: Value.Type, invalidating: Bool, _ body: (inout Value) -> ()) { + fatalError("TODO") + } + + @inlinable + public func breadthFirstSearch(options: OGSearchOptions, _: (OGAttribute) -> Bool) -> Bool { + fatalError("TODO") + } + + @inlinable + public var _bodyType: Any.Type { fatalError("TODO") } + + @inlinable + public var _bodyPointer: UnsafeRawPointer { fatalError("TODO") } + + @inlinable + public var valueType: Any.Type { fatalError("TODO") } + + @inlinable + public var indirectDependency: OGAttribute { + get { fatalError("TODO") } + set { fatalError("TODO") } + } } // MARK: CustomStringConvertible From dd504559fd53eedef9f3a421dd7b5cb5839468cc Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 Feb 2024 20:03:09 +0800 Subject: [PATCH 4/7] [NFC] Update Status information --- Sources/OpenGraph/Attribute/AttributeBodyVisitor.swift | 4 ++-- Sources/OpenGraph/Attribute/External.swift | 2 +- Sources/OpenGraph/Attribute/Focus.swift | 2 +- Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift | 5 +++-- Status.md | 4 ++++ 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Sources/OpenGraph/Attribute/AttributeBodyVisitor.swift b/Sources/OpenGraph/Attribute/AttributeBodyVisitor.swift index 7756d953..aa1d9801 100644 --- a/Sources/OpenGraph/Attribute/AttributeBodyVisitor.swift +++ b/Sources/OpenGraph/Attribute/AttributeBodyVisitor.swift @@ -1,9 +1,9 @@ // // AttributeBodyVisitor.swift -// +// OpenGraph // // Created by Kyle on 2024/2/16. -// +// Status: WIP public protocol AttributeBodyVisitor { func visit(body: UnsafePointer) diff --git a/Sources/OpenGraph/Attribute/External.swift b/Sources/OpenGraph/Attribute/External.swift index c97ff2ef..5342dad2 100644 --- a/Sources/OpenGraph/Attribute/External.swift +++ b/Sources/OpenGraph/Attribute/External.swift @@ -1,6 +1,6 @@ // // External.swift -// +// OpenGraph // // Created by Kyle on 2024/2/16. // Lastest Version: iOS 15.5 diff --git a/Sources/OpenGraph/Attribute/Focus.swift b/Sources/OpenGraph/Attribute/Focus.swift index 70ddb6dc..57c73357 100644 --- a/Sources/OpenGraph/Attribute/Focus.swift +++ b/Sources/OpenGraph/Attribute/Focus.swift @@ -1,6 +1,6 @@ // // Focus.swift -// +// OpenGraph // // Created by Kyle on 2024/2/16. // Lastest Version: iOS 15.5 diff --git a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift index c36858d0..8f16d3ab 100644 --- a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift +++ b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift @@ -1,9 +1,10 @@ // // OGAttribute.swift -// +// OpenGraph // // Created by Kyle on 2024/2/17. -// +// Lastest Version: iOS 15.5 +// Status: API complete import _OpenGraph diff --git a/Status.md b/Status.md index 79f196b3..58d69bc4 100644 --- a/Status.md +++ b/Status.md @@ -8,6 +8,10 @@ Only have an empty namespace used as placeholder type in other implementation. Some interface is implemented while some is not. +## API Complete + +All interface is added while some implementation is empty. + ## Blocked Most implementation is complete. From 51e99b9f8d0ce594daee23e0fdf87d64f942cfb6 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 Feb 2024 20:37:32 +0800 Subject: [PATCH 5/7] Add reset script --- AG/reset.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 AG/reset.sh diff --git a/AG/reset.sh b/AG/reset.sh new file mode 100755 index 00000000..3968c2d8 --- /dev/null +++ b/AG/reset.sh @@ -0,0 +1,20 @@ +#!/bin/zsh + +# A `realpath` alternative using the default C implementation. +filepath() { + [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" +} + +AG_ROOT="$(dirname $(filepath $0))" +xcframework_path="${AG_ROOT}/AttributeGraph.xcframework" +framework_name=AttributeGraph.framework + +reset_framework() { + local frmework_name=$1 + rm -rf ${xcframework_path}/${frmework_name}/${framework_name}/Headers + rm -rf ${xcframework_path}/${frmework_name}/${framework_name}/Modules +} + +reset_framework ios-arm64-x86_64-simulator +reset_framework ios-arm64-arm64e +reset_framework macos-arm64e-arm64-x86_64 From 5fb1da75c3f8fb891effd612bce0b670fbe74f46 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 Feb 2024 21:30:55 +0800 Subject: [PATCH 6/7] Add OGAttributeType and OGAttributeInfo --- .../Headers/AGAttributeInfo.h | 23 ++++++++++++++++ .../Headers/AGAttributeType.h | 24 +++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 2 ++ .../Headers/AGAttributeInfo.h | 23 ++++++++++++++++ .../Headers/AGAttributeType.h | 24 +++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 2 ++ .../Headers/AGAttributeInfo.h | 23 ++++++++++++++++ .../Headers/AGAttributeType.h | 24 +++++++++++++++++ .../Headers/AttributeGraph-umbrella.h | 2 ++ AG/Sources/Headers/AGAttributeInfo.h | 23 ++++++++++++++++ AG/Sources/Headers/AGAttributeType.h | 24 +++++++++++++++++ AG/Sources/Headers/AttributeGraph-umbrella.h | 2 ++ .../Attribute/OGExtension/OGAttribute.swift | 26 ++++++++++++++++--- Sources/OpenGraph/Runtime/OGTypeID.swift | 7 +++++ Sources/OpenGraphShims/GraphShims.swift | 2 ++ .../_OpenGraph/Attribute/AttributeType.cpp | 8 ++++++ .../_OpenGraph/Attribute/AttributeType.hpp | 19 ++++++++++++++ Sources/_OpenGraph/Attribute/OGAttribute.cpp | 9 +++++++ Sources/_OpenGraph/Attribute/OGAttribute.h | 5 ++++ .../_OpenGraph/Attribute/OGAttributeInfo.h | 23 ++++++++++++++++ .../_OpenGraph/Attribute/OGAttributeType.h | 24 +++++++++++++++++ Sources/_OpenGraph/Debug/og-debug-server.mm | 4 +-- .../_OpenGraph/Graph/{graph.cpp => Graph.cpp} | 4 +-- .../_OpenGraph/Graph/{graph.hpp => Graph.hpp} | 8 +++--- .../{graph-context.cpp => GraphContext.cpp} | 6 ++--- ...h-description.hpp => GraphDescription.hpp} | 8 +++--- ...aph-description.mm => GraphDescription.mm} | 6 ++--- Sources/_OpenGraph/Graph/OGGraph.cpp | 2 +- Sources/_OpenGraph/Graph/OGSubgraph.cpp | 2 +- .../Graph/{subgraph.cpp => Subgraph.cpp} | 4 +-- .../Graph/{subgraph.hpp => Subgraph.hpp} | 12 ++++----- Sources/_OpenGraph/include/OGAttributeInfo.h | 1 + Sources/_OpenGraph/include/OGAttributeType.h | 1 + Sources/_OpenGraph/include/_OGGraph.h | 2 ++ .../GraphShims.swift | 2 ++ 35 files changed, 350 insertions(+), 31 deletions(-) create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeInfo.h create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeType.h create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeInfo.h create mode 100644 AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeType.h create mode 100644 AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeInfo.h create mode 100644 AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeType.h create mode 100644 AG/Sources/Headers/AGAttributeInfo.h create mode 100644 AG/Sources/Headers/AGAttributeType.h create mode 100644 Sources/_OpenGraph/Attribute/AttributeType.cpp create mode 100644 Sources/_OpenGraph/Attribute/AttributeType.hpp create mode 100644 Sources/_OpenGraph/Attribute/OGAttributeInfo.h create mode 100644 Sources/_OpenGraph/Attribute/OGAttributeType.h rename Sources/_OpenGraph/Graph/{graph.cpp => Graph.cpp} (73%) rename Sources/_OpenGraph/Graph/{graph.hpp => Graph.hpp} (95%) rename Sources/_OpenGraph/Graph/{graph-context.cpp => GraphContext.cpp} (90%) rename Sources/_OpenGraph/Graph/{graph-description.hpp => GraphDescription.hpp} (59%) rename Sources/_OpenGraph/Graph/{graph-description.mm => GraphDescription.mm} (91%) rename Sources/_OpenGraph/Graph/{subgraph.cpp => Subgraph.cpp} (92%) rename Sources/_OpenGraph/Graph/{subgraph.hpp => Subgraph.hpp} (94%) create mode 120000 Sources/_OpenGraph/include/OGAttributeInfo.h create mode 120000 Sources/_OpenGraph/include/OGAttributeType.h diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeInfo.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeInfo.h new file mode 100644 index 00000000..390547a5 --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeInfo.h @@ -0,0 +1,23 @@ +// +// AGAttributeInfo.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeInfo_h +#define AGAttributeInfo_h + +#include "AGBase.h" +#include "AGAttributeType.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeInfo { + const AGAttributeType* type; + const void *body; +} AGAttributeInfo; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeInfo_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeType.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeType.h new file mode 100644 index 00000000..4229ac2c --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttributeType.h @@ -0,0 +1,24 @@ +// +// AGAttributeType.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeType_h +#define AGAttributeType_h + +#include "AGBase.h" +#include "AGTypeID.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeType { + AGTypeID typeID; + AGTypeID valueTypeID; + // TODO +} AGAttributeType; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeType_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 782fda90..2d97ccc3 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -8,6 +8,8 @@ #include "AGAttribute.h" #include "AGAttributeFlags.h" +#include "AGAttributeInfo.h" +#include "AGAttributeType.h" #include "AGAttributeTypeFlags.h" #include "AGBase.h" #include "AGCompareValues.h" diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeInfo.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeInfo.h new file mode 100644 index 00000000..390547a5 --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeInfo.h @@ -0,0 +1,23 @@ +// +// AGAttributeInfo.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeInfo_h +#define AGAttributeInfo_h + +#include "AGBase.h" +#include "AGAttributeType.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeInfo { + const AGAttributeType* type; + const void *body; +} AGAttributeInfo; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeInfo_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeType.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeType.h new file mode 100644 index 00000000..4229ac2c --- /dev/null +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttributeType.h @@ -0,0 +1,24 @@ +// +// AGAttributeType.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeType_h +#define AGAttributeType_h + +#include "AGBase.h" +#include "AGTypeID.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeType { + AGTypeID typeID; + AGTypeID valueTypeID; + // TODO +} AGAttributeType; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeType_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 782fda90..2d97ccc3 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -8,6 +8,8 @@ #include "AGAttribute.h" #include "AGAttributeFlags.h" +#include "AGAttributeInfo.h" +#include "AGAttributeType.h" #include "AGAttributeTypeFlags.h" #include "AGBase.h" #include "AGCompareValues.h" diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeInfo.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeInfo.h new file mode 100644 index 00000000..390547a5 --- /dev/null +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeInfo.h @@ -0,0 +1,23 @@ +// +// AGAttributeInfo.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeInfo_h +#define AGAttributeInfo_h + +#include "AGBase.h" +#include "AGAttributeType.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeInfo { + const AGAttributeType* type; + const void *body; +} AGAttributeInfo; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeInfo_h */ diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeType.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeType.h new file mode 100644 index 00000000..4229ac2c --- /dev/null +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttributeType.h @@ -0,0 +1,24 @@ +// +// AGAttributeType.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeType_h +#define AGAttributeType_h + +#include "AGBase.h" +#include "AGTypeID.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeType { + AGTypeID typeID; + AGTypeID valueTypeID; + // TODO +} AGAttributeType; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeType_h */ diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h index 782fda90..2d97ccc3 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AttributeGraph-umbrella.h @@ -8,6 +8,8 @@ #include "AGAttribute.h" #include "AGAttributeFlags.h" +#include "AGAttributeInfo.h" +#include "AGAttributeType.h" #include "AGAttributeTypeFlags.h" #include "AGBase.h" #include "AGCompareValues.h" diff --git a/AG/Sources/Headers/AGAttributeInfo.h b/AG/Sources/Headers/AGAttributeInfo.h new file mode 100644 index 00000000..390547a5 --- /dev/null +++ b/AG/Sources/Headers/AGAttributeInfo.h @@ -0,0 +1,23 @@ +// +// AGAttributeInfo.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeInfo_h +#define AGAttributeInfo_h + +#include "AGBase.h" +#include "AGAttributeType.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeInfo { + const AGAttributeType* type; + const void *body; +} AGAttributeInfo; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeInfo_h */ diff --git a/AG/Sources/Headers/AGAttributeType.h b/AG/Sources/Headers/AGAttributeType.h new file mode 100644 index 00000000..4229ac2c --- /dev/null +++ b/AG/Sources/Headers/AGAttributeType.h @@ -0,0 +1,24 @@ +// +// AGAttributeType.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AGAttributeType_h +#define AGAttributeType_h + +#include "AGBase.h" +#include "AGTypeID.h" + +AG_ASSUME_NONNULL_BEGIN + +typedef struct AGAttributeType { + AGTypeID typeID; + AGTypeID valueTypeID; + // TODO +} AGAttributeType; + +AG_ASSUME_NONNULL_END + +#endif /* AGAttributeType_h */ diff --git a/AG/Sources/Headers/AttributeGraph-umbrella.h b/AG/Sources/Headers/AttributeGraph-umbrella.h index 782fda90..2d97ccc3 100644 --- a/AG/Sources/Headers/AttributeGraph-umbrella.h +++ b/AG/Sources/Headers/AttributeGraph-umbrella.h @@ -8,6 +8,8 @@ #include "AGAttribute.h" #include "AGAttributeFlags.h" +#include "AGAttributeInfo.h" +#include "AGAttributeType.h" #include "AGAttributeTypeFlags.h" #include "AGBase.h" #include "AGCompareValues.h" diff --git a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift index 8f16d3ab..f17a8a65 100644 --- a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift +++ b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift @@ -10,66 +10,86 @@ import _OpenGraph extension OGAttribute { @inlinable + @inline(__always) public init(_ attribute: Attribute) { self = attribute.identifier } @inlinable + @inline(__always) public func unsafeCast(to type: Value.Type) -> Attribute { fatalError("TODO") } @inlinable + @inline(__always) public static var current: OGAttribute? { let current = __OGGraphGetCurrentAttribute() return current == .nil ? nil : current } @inlinable + @inline(__always) public func unsafeOffset(at offset: Int) -> OGAttribute { create(offset: offset) } @inlinable + @inline(__always) public func setFlags(_ newFlags: OGAttributeFlags, mask: OGAttributeFlags) { flags = flags.subtracting(mask).union(newFlags.intersection(mask)) } @inlinable + @inline(__always) public func addInput(_ attribute: OGAttribute, options: OGInputOptions, token: Int) { __OGGraphAddInput(self, attribute, options, token) } @inlinable + @inline(__always) public func addInput(_ attribute: Attribute, options: OGInputOptions, token: Int) { addInput(attribute.identifier, options: options, token: token) } @inlinable + @inline(__always) public func visitBody(_ visitor: inout Visitor) { fatalError("TODO") } @inlinable + @inline(__always) public func mutateBody(as: Value.Type, invalidating: Bool, _ body: (inout Value) -> ()) { fatalError("TODO") } @inlinable + @inline(__always) public func breadthFirstSearch(options: OGSearchOptions, _: (OGAttribute) -> Bool) -> Bool { fatalError("TODO") } @inlinable - public var _bodyType: Any.Type { fatalError("TODO") } + @inline(__always) + public var _bodyType: Any.Type { + __OGGraphGetAttributeInfo(self).type.pointee.typeID.type + } @inlinable - public var _bodyPointer: UnsafeRawPointer { fatalError("TODO") } + @inline(__always) + public var _bodyPointer: UnsafeRawPointer { + __OGGraphGetAttributeInfo(self).body + } @inlinable - public var valueType: Any.Type { fatalError("TODO") } + @inline(__always) + public var valueType: Any.Type { + __OGGraphGetAttributeInfo(self).type.pointee.valueTypeID.type + } @inlinable + @inline(__always) public var indirectDependency: OGAttribute { get { fatalError("TODO") } set { fatalError("TODO") } diff --git a/Sources/OpenGraph/Runtime/OGTypeID.swift b/Sources/OpenGraph/Runtime/OGTypeID.swift index 00495c62..1048f0d4 100644 --- a/Sources/OpenGraph/Runtime/OGTypeID.swift +++ b/Sources/OpenGraph/Runtime/OGTypeID.swift @@ -25,16 +25,19 @@ public func OGTypeApplyFields2( ) -> Bool extension OGTypeID: Hashable, CustomStringConvertible { + @inlinable @inline(__always) public init(_ type: Any.Type) { self.init(rawValue: unsafeBitCast(type, to: UnsafePointer.self)) } + @inlinable @inline(__always) public var type: Any.Type { unsafeBitCast(rawValue, to: Any.Type.self) } + @inlinable @inline(__always) public var description: String { #if canImport(ObjectiveC) @@ -44,12 +47,16 @@ extension OGTypeID: Hashable, CustomStringConvertible { #endif } + @inlinable + @inline(__always) /* public */func forEachField( do body: (UnsafePointer, Int, Any.Type) -> Void ) { OGTypeApplyFields(type, body: body) } + @inlinable + @inline(__always) public func forEachField( options: OGTypeApplyOptions, do body: (UnsafePointer, Int, Any.Type) -> Bool diff --git a/Sources/OpenGraphShims/GraphShims.swift b/Sources/OpenGraphShims/GraphShims.swift index 0386b9f3..9b8a1d3a 100644 --- a/Sources/OpenGraphShims/GraphShims.swift +++ b/Sources/OpenGraphShims/GraphShims.swift @@ -9,6 +9,8 @@ @_exported import AttributeGraph public typealias OGAttribute = AGAttribute public typealias OGAttributeFlags = AGAttributeFlags +public typealias OGAttributeInfo = AGAttributeInfo +public typealias OGAttributeType = AGAttributeType public typealias OGAttributeTypeFlags = AGAttributeTypeFlags public typealias OGComparisonMode = AGComparisonMode public typealias OGComparisonOptions = AGComparisonOptions diff --git a/Sources/_OpenGraph/Attribute/AttributeType.cpp b/Sources/_OpenGraph/Attribute/AttributeType.cpp new file mode 100644 index 00000000..91c8ede1 --- /dev/null +++ b/Sources/_OpenGraph/Attribute/AttributeType.cpp @@ -0,0 +1,8 @@ +// +// OGAttributeType.cpp +// +// +// Created by Kyle on 2024/2/17. +// + +#include "OGAttributeType.h" diff --git a/Sources/_OpenGraph/Attribute/AttributeType.hpp b/Sources/_OpenGraph/Attribute/AttributeType.hpp new file mode 100644 index 00000000..8deffb3b --- /dev/null +++ b/Sources/_OpenGraph/Attribute/AttributeType.hpp @@ -0,0 +1,19 @@ +// +// AttributeType.hpp +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef AttributeType_hpp +#define AttributeType_hpp + +#include "OGBase.h" +#include "OGAttributeType.h" + +namespace OG { +struct AttributeType { + OGAttributeType storage; +}; +} +#endif /* AttributeType_2_hpp */ diff --git a/Sources/_OpenGraph/Attribute/OGAttribute.cpp b/Sources/_OpenGraph/Attribute/OGAttribute.cpp index 7a791c59..573bf069 100644 --- a/Sources/_OpenGraph/Attribute/OGAttribute.cpp +++ b/Sources/_OpenGraph/Attribute/OGAttribute.cpp @@ -57,3 +57,12 @@ void OGGraphAddInput(OGAttribute attribute1, OGAttribute attribute2, OGInputOpti } // TODO: data/table } + +const OGAttributeInfo OGGraphGetAttributeInfo(OGAttribute attribute) { + const OG::AttributeID id = OG::AttributeID(attribute); + if (!id.isDirect()) { + OG::precondition_failure("non-direct attribute id: %u", id); + } + // TODO + return { nullptr, nullptr }; +} diff --git a/Sources/_OpenGraph/Attribute/OGAttribute.h b/Sources/_OpenGraph/Attribute/OGAttribute.h index 0159442d..204539d7 100644 --- a/Sources/_OpenGraph/Attribute/OGAttribute.h +++ b/Sources/_OpenGraph/Attribute/OGAttribute.h @@ -11,6 +11,7 @@ #include "OGBase.h" #include "OGAttributeFlags.h" #include "OGInputOptions.h" +#include "OGAttributeInfo.h" typedef uint32_t OGAttribute __attribute((swift_newtype(struct))); @@ -43,6 +44,10 @@ OG_EXPORT OG_REFINED_FOR_SWIFT void OGGraphAddInput(OGAttribute attribute1, OGAttribute attribute2, OGInputOptions options, long token); +OG_EXPORT +OG_REFINED_FOR_SWIFT +const OGAttributeInfo OGGraphGetAttributeInfo(OGAttribute attribute); + OG_EXTERN_C_END #endif /* OGAttribute_h */ diff --git a/Sources/_OpenGraph/Attribute/OGAttributeInfo.h b/Sources/_OpenGraph/Attribute/OGAttributeInfo.h new file mode 100644 index 00000000..a9994df5 --- /dev/null +++ b/Sources/_OpenGraph/Attribute/OGAttributeInfo.h @@ -0,0 +1,23 @@ +// +// OGAttributeInfo.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef OGAttributeInfo_h +#define OGAttributeInfo_h + +#include "OGBase.h" +#include "OGAttributeType.h" + +OG_ASSUME_NONNULL_BEGIN + +typedef struct OGAttributeInfo { + const OGAttributeType* type; + const void *body; +} OGAttributeInfo; + +OG_ASSUME_NONNULL_END + +#endif /* OGAttributeInfo_h */ diff --git a/Sources/_OpenGraph/Attribute/OGAttributeType.h b/Sources/_OpenGraph/Attribute/OGAttributeType.h new file mode 100644 index 00000000..73fbfe68 --- /dev/null +++ b/Sources/_OpenGraph/Attribute/OGAttributeType.h @@ -0,0 +1,24 @@ +// +// OGAttributeType.h +// +// +// Created by Kyle on 2024/2/17. +// + +#ifndef OGAttributeType_h +#define OGAttributeType_h + +#include "OGBase.h" +#include "OGTypeID.h" + +OG_ASSUME_NONNULL_BEGIN + +typedef struct OGAttributeType { + OGTypeID typeID; + OGTypeID valueTypeID; + // TODO +} OGAttributeType; + +OG_ASSUME_NONNULL_END + +#endif /* OGAttributeType_h */ diff --git a/Sources/_OpenGraph/Debug/og-debug-server.mm b/Sources/_OpenGraph/Debug/og-debug-server.mm index f2dde12f..4458b917 100644 --- a/Sources/_OpenGraph/Debug/og-debug-server.mm +++ b/Sources/_OpenGraph/Debug/og-debug-server.mm @@ -10,8 +10,8 @@ #include "../Util/log.hpp" #include "../Util/assert.hpp" -#include "../Graph/graph-description.hpp" -#include "../Graph/graph.hpp" +#include "../Graph/GraphDescription.hpp" +#include "../Graph/Graph.hpp" #include #include diff --git a/Sources/_OpenGraph/Graph/graph.cpp b/Sources/_OpenGraph/Graph/Graph.cpp similarity index 73% rename from Sources/_OpenGraph/Graph/graph.cpp rename to Sources/_OpenGraph/Graph/Graph.cpp index 6ead831d..e55f0637 100644 --- a/Sources/_OpenGraph/Graph/graph.cpp +++ b/Sources/_OpenGraph/Graph/Graph.cpp @@ -1,10 +1,10 @@ // -// graph.cpp +// Graph.cpp // // // Created by Kyle on 2024/1/18. // -#include "graph.hpp" +#include "Graph.hpp" pthread_key_t OG::Graph::_current_update_key; diff --git a/Sources/_OpenGraph/Graph/graph.hpp b/Sources/_OpenGraph/Graph/Graph.hpp similarity index 95% rename from Sources/_OpenGraph/Graph/graph.hpp rename to Sources/_OpenGraph/Graph/Graph.hpp index 424447a6..155ee882 100644 --- a/Sources/_OpenGraph/Graph/graph.hpp +++ b/Sources/_OpenGraph/Graph/Graph.hpp @@ -1,12 +1,12 @@ // -// graph.hpp +// Graph.hpp // // // Created by Kyle on 2024/1/18. // -#ifndef graph_hpp -#define graph_hpp +#ifndef Graph_hpp +#define Graph_hpp #include "OGBase.h" #include "OGGraph.h" @@ -79,4 +79,4 @@ struct OGGraphContextStorage { OG::Graph::Context context; }; -#endif /* graph_hpp */ +#endif /* Graph_hpp */ diff --git a/Sources/_OpenGraph/Graph/graph-context.cpp b/Sources/_OpenGraph/Graph/GraphContext.cpp similarity index 90% rename from Sources/_OpenGraph/Graph/graph-context.cpp rename to Sources/_OpenGraph/Graph/GraphContext.cpp index c2311be9..f1f7fe45 100644 --- a/Sources/_OpenGraph/Graph/graph-context.cpp +++ b/Sources/_OpenGraph/Graph/GraphContext.cpp @@ -1,11 +1,11 @@ // -// graph-context.cpp -// +// GraphContext.cpp +// // // Created by Kyle on 2024/2/16. // -#include "graph.hpp" +#include "Graph.hpp" #include "OGGraph.h" #include "../Util/assert.hpp" diff --git a/Sources/_OpenGraph/Graph/graph-description.hpp b/Sources/_OpenGraph/Graph/GraphDescription.hpp similarity index 59% rename from Sources/_OpenGraph/Graph/graph-description.hpp rename to Sources/_OpenGraph/Graph/GraphDescription.hpp index 59c79d76..303c5d11 100644 --- a/Sources/_OpenGraph/Graph/graph-description.hpp +++ b/Sources/_OpenGraph/Graph/GraphDescription.hpp @@ -1,12 +1,12 @@ // -// graph-description.hpp +// GraphDescription.hpp // // // Created by Kyle on 2024/1/21. // -#ifndef graph_description_hpp -#define graph_description_hpp +#ifndef GraphDescription_hpp +#define GraphDescription_hpp #include "OGBase.h" @@ -17,4 +17,4 @@ CFStringRef OGDescriptionFormat; OG_EXTERN_C_END #endif -#endif /* graph_description_hpp */ +#endif /* GraphDescription_hpp */ diff --git a/Sources/_OpenGraph/Graph/graph-description.mm b/Sources/_OpenGraph/Graph/GraphDescription.mm similarity index 91% rename from Sources/_OpenGraph/Graph/graph-description.mm rename to Sources/_OpenGraph/Graph/GraphDescription.mm index ebe18c5c..3c14e234 100644 --- a/Sources/_OpenGraph/Graph/graph-description.mm +++ b/Sources/_OpenGraph/Graph/GraphDescription.mm @@ -1,13 +1,13 @@ // -// graph-description.cpp +// GraphDescription.mm // // // Created by Kyle on 2024/1/21. // -#include "graph-description.hpp" +#include "GraphDescription.hpp" #include "OGGraph.h" -#include "graph.hpp" +#include "Graph.hpp" #include "../Util/assert.hpp" #if OG_OBJC_FOUNDATION diff --git a/Sources/_OpenGraph/Graph/OGGraph.cpp b/Sources/_OpenGraph/Graph/OGGraph.cpp index c260cd2d..02cb1a1d 100644 --- a/Sources/_OpenGraph/Graph/OGGraph.cpp +++ b/Sources/_OpenGraph/Graph/OGGraph.cpp @@ -6,7 +6,7 @@ // #include "OGGraph.h" -#include "graph.hpp" +#include "Graph.hpp" #include "../Util/assert.hpp" OGGraphRef OGGraphCreate() { diff --git a/Sources/_OpenGraph/Graph/OGSubgraph.cpp b/Sources/_OpenGraph/Graph/OGSubgraph.cpp index 3ff7d912..a12e876e 100644 --- a/Sources/_OpenGraph/Graph/OGSubgraph.cpp +++ b/Sources/_OpenGraph/Graph/OGSubgraph.cpp @@ -7,7 +7,7 @@ #include "OGSubgraph.h" #include "OGGraph.h" -#include "subgraph.hpp" +#include "Subgraph.hpp" #include "../Util/assert.hpp" #include #include "OGGraphContext.h" diff --git a/Sources/_OpenGraph/Graph/subgraph.cpp b/Sources/_OpenGraph/Graph/Subgraph.cpp similarity index 92% rename from Sources/_OpenGraph/Graph/subgraph.cpp rename to Sources/_OpenGraph/Graph/Subgraph.cpp index 16a0f25b..87476aaa 100644 --- a/Sources/_OpenGraph/Graph/subgraph.cpp +++ b/Sources/_OpenGraph/Graph/Subgraph.cpp @@ -1,11 +1,11 @@ // -// subgraph.cpp +// Subgraph.cpp // // // Created by Kyle on 2024/2/15. // -#include "subgraph.hpp" +#include "Subgraph.hpp" #include "OGSubgraph.h" pthread_key_t OG::Subgraph::_current_subgraph_key; diff --git a/Sources/_OpenGraph/Graph/subgraph.hpp b/Sources/_OpenGraph/Graph/Subgraph.hpp similarity index 94% rename from Sources/_OpenGraph/Graph/subgraph.hpp rename to Sources/_OpenGraph/Graph/Subgraph.hpp index c36c9f92..27ace20d 100644 --- a/Sources/_OpenGraph/Graph/subgraph.hpp +++ b/Sources/_OpenGraph/Graph/Subgraph.hpp @@ -1,16 +1,16 @@ // -// subgraph.hpp -// +// Subgraph.hpp +// // // Created by Kyle on 2024/2/15. // -#ifndef subgraph_hpp -#define subgraph_hpp +#ifndef Subgraph_hpp +#define Subgraph_hpp #include "OGBase.h" #include "../Attribute/AttributeID.hpp" -#include "graph.hpp" +#include "Graph.hpp" #include typedef struct OG_BRIDGED_TYPE(id) OGSubgraphStorage * OGSubgraphRef; @@ -88,4 +88,4 @@ class SubgraphObject final { }; } -#endif /* subgraph_hpp */ +#endif /* Subgraph_hpp */ diff --git a/Sources/_OpenGraph/include/OGAttributeInfo.h b/Sources/_OpenGraph/include/OGAttributeInfo.h new file mode 120000 index 00000000..e141ee8a --- /dev/null +++ b/Sources/_OpenGraph/include/OGAttributeInfo.h @@ -0,0 +1 @@ +../Attribute/OGAttributeInfo.h \ No newline at end of file diff --git a/Sources/_OpenGraph/include/OGAttributeType.h b/Sources/_OpenGraph/include/OGAttributeType.h new file mode 120000 index 00000000..a6a7b2e0 --- /dev/null +++ b/Sources/_OpenGraph/include/OGAttributeType.h @@ -0,0 +1 @@ +../Attribute/OGAttributeType.h \ No newline at end of file diff --git a/Sources/_OpenGraph/include/_OGGraph.h b/Sources/_OpenGraph/include/_OGGraph.h index de670f95..2cf594ca 100644 --- a/Sources/_OpenGraph/include/_OGGraph.h +++ b/Sources/_OpenGraph/include/_OGGraph.h @@ -10,6 +10,8 @@ #include "OGAttribute.h" #include "OGAttributeFlags.h" +#include "OGAttributeInfo.h" +#include "OGAttributeType.h" #include "OGAttributeTypeFlags.h" #include "OGBase.h" #include "OGCompareValues.h" diff --git a/Tests/OpenGraphCompatibilityTests/GraphShims.swift b/Tests/OpenGraphCompatibilityTests/GraphShims.swift index eb570d05..191da20c 100644 --- a/Tests/OpenGraphCompatibilityTests/GraphShims.swift +++ b/Tests/OpenGraphCompatibilityTests/GraphShims.swift @@ -9,6 +9,8 @@ @_exported import AttributeGraph public typealias OGAttribute = AGAttribute public typealias OGAttributeFlags = AGAttributeFlags +public typealias OGAttributeInfo = AGAttributeInfo +public typealias OGAttributeType = AGAttributeType public typealias OGAttributeTypeFlags = AGAttributeTypeFlags public typealias OGComparisonMode = AGComparisonMode public typealias OGComparisonOptions = AGComparisonOptions From b733bd7e909b87abd179deee1c534d500eec68cd Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 17 Feb 2024 22:56:58 +0800 Subject: [PATCH 7/7] Add indirect dependency --- .../Headers/AGAttribute.h | 18 +++++ .../arm64-apple-ios.swiftinterface | 16 +---- .../arm64e-apple-ios.swiftinterface | 16 +---- .../Headers/AGAttribute.h | 18 +++++ .../arm64-apple-ios-simulator.swiftinterface | 16 +---- .../x86_64-apple-ios-simulator.swiftinterface | 16 +---- .../Headers/AGAttribute.h | 18 +++++ .../arm64-apple-macos.swiftinterface | 16 +---- .../arm64e-apple-macos.swiftinterface | 16 +---- .../x86_64-apple-macos.swiftinterface | 16 +---- AG/Sources/Headers/AGAttribute.h | 18 +++++ .../template.swiftinterface | 16 +---- .../Attribute/OGExtension/OGAttribute.swift | 69 +++++++------------ Sources/_OpenGraph/Attribute/OGAttribute.cpp | 13 ++++ Sources/_OpenGraph/Attribute/OGAttribute.h | 13 ++++ .../OGExtension/OGAttributeTests.swift | 12 ++++ .../Graph/GraphTests.swift | 6 +- 17 files changed, 148 insertions(+), 165 deletions(-) diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h index 0c1d1915..f30041d9 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Headers/AGAttribute.h @@ -12,6 +12,8 @@ #include "AGBase.h" #include "AGAttributeFlags.h" #include "AGInputOptions.h" +#include "AGAttributeInfo.h" +#include "AGTypeID.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -44,6 +46,22 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); +AG_EXPORT +AG_REFINED_FOR_SWIFT +const AGAttributeInfo AGGraphGetAttributeInfo(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphMutateAttribute(AGAttribute attribute, const AGTypeID type, bool invalidating/*, closure*/); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +AGAttribute AGGraphGetIndirectDependency(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphSetIndirectDependency(AGAttribute attribute1, AGAttribute attribute2); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface index 274083a1..fdd66c28 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios.swiftinterface @@ -13,34 +13,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface index 274083a1..fdd66c28 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-arm64e/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-ios.swiftinterface @@ -13,34 +13,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h index 0c1d1915..f30041d9 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Headers/AGAttribute.h @@ -12,6 +12,8 @@ #include "AGBase.h" #include "AGAttributeFlags.h" #include "AGInputOptions.h" +#include "AGAttributeInfo.h" +#include "AGTypeID.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -44,6 +46,22 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); +AG_EXPORT +AG_REFINED_FOR_SWIFT +const AGAttributeInfo AGGraphGetAttributeInfo(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphMutateAttribute(AGAttribute attribute, const AGTypeID type, bool invalidating/*, closure*/); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +AGAttribute AGGraphGetIndirectDependency(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphSetIndirectDependency(AGAttribute attribute1, AGAttribute attribute2); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface index 3781ff26..b08d1296 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-ios-simulator.swiftinterface @@ -13,34 +13,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface index 244ef7ac..5bf1d130 100644 --- a/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +++ b/AG/AttributeGraph.xcframework/ios-arm64-x86_64-simulator/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-ios-simulator.swiftinterface @@ -13,34 +13,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h index 0c1d1915..f30041d9 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Headers/AGAttribute.h @@ -12,6 +12,8 @@ #include "AGBase.h" #include "AGAttributeFlags.h" #include "AGInputOptions.h" +#include "AGAttributeInfo.h" +#include "AGTypeID.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -44,6 +46,22 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); +AG_EXPORT +AG_REFINED_FOR_SWIFT +const AGAttributeInfo AGGraphGetAttributeInfo(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphMutateAttribute(AGAttribute attribute, const AGTypeID type, bool invalidating/*, closure*/); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +AGAttribute AGGraphGetIndirectDependency(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphSetIndirectDependency(AGAttribute attribute1, AGAttribute attribute2); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface index 043543af..8a8f6bb7 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64-apple-macos.swiftinterface @@ -13,34 +13,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface index 308c03cb..d6eb6df1 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/arm64e-apple-macos.swiftinterface @@ -13,34 +13,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface index 05fb8dd9..b14e4bb5 100644 --- a/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface +++ b/AG/AttributeGraph.xcframework/macos-arm64e-arm64-x86_64/AttributeGraph.framework/Modules/AttributeGraph.swiftmodule/x86_64-apple-macos.swiftinterface @@ -13,34 +13,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/AG/Sources/Headers/AGAttribute.h b/AG/Sources/Headers/AGAttribute.h index 0c1d1915..f30041d9 100644 --- a/AG/Sources/Headers/AGAttribute.h +++ b/AG/Sources/Headers/AGAttribute.h @@ -12,6 +12,8 @@ #include "AGBase.h" #include "AGAttributeFlags.h" #include "AGInputOptions.h" +#include "AGAttributeInfo.h" +#include "AGTypeID.h" typedef uint32_t AGAttribute __attribute((swift_newtype(struct))); @@ -44,6 +46,22 @@ AG_EXPORT AG_REFINED_FOR_SWIFT void AGGraphAddInput(AGAttribute attribute1, AGAttribute attribute2, AGInputOptions options, long token); +AG_EXPORT +AG_REFINED_FOR_SWIFT +const AGAttributeInfo AGGraphGetAttributeInfo(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphMutateAttribute(AGAttribute attribute, const AGTypeID type, bool invalidating/*, closure*/); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +AGAttribute AGGraphGetIndirectDependency(AGAttribute attribute); + +AG_EXPORT +AG_REFINED_FOR_SWIFT +void AGGraphSetIndirectDependency(AGAttribute attribute1, AGAttribute attribute2); + AG_EXTERN_C_END #endif /* AGAttribute_h */ diff --git a/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface b/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface index d0362487..ad5bad53 100644 --- a/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface +++ b/AG/Sources/Modules/AttributeGraph.swiftmodule/template.swiftinterface @@ -9,34 +9,20 @@ import _StringProcessing // MARK: - AGAttribute extension AGAttribute { - @inlinable public init(_ attribute: AttributeGraph.Attribute) - @inlinable public func unsafeCast(to type: Value.Type) -> AttributeGraph.Attribute - @inlinable public static var current: AGAttribute? { get } - @inlinable public func unsafeOffset(at offset: Int) -> AGAttribute - @inlinable public func setFlags(_ newFlags: AGAttributeFlags, mask: AGAttributeFlags) - @inlinable public func addInput(_ attribute: AGAttribute, options: AGInputOptions, token: Swift.Int) - @inlinable public func addInput(_ attribute: AttributeGraph.Attribute, options: AGInputOptions, token: Int) - @inlinable public func visitBody(_ visitor: inout Visitor); - @inlinable public func mutateBody(as: Value.Type, invalidating: Swift.Bool, _ body: (inout Value) -> ()) - @inlinable public func breadthFirstSearch(options: AGSearchOptions, _: (AGAttribute) -> Swift.Bool) -> Swift.Bool - @inlinable public var _bodyType: Any.Type { get } - @inlinable public var _bodyPointer: UnsafeRawPointer { get } - @inlinable public var valueType: Any.Type { get } - @inlinable - public var indirectDependency: AGAttribute { get set } + public var indirectDependency: AGAttribute? { get set } } extension AGAttribute: Swift.CustomStringConvertible { diff --git a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift index f17a8a65..a438fc05 100644 --- a/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift +++ b/Sources/OpenGraph/Attribute/OGExtension/OGAttribute.swift @@ -9,90 +9,71 @@ import _OpenGraph extension OGAttribute { - @inlinable - @inline(__always) public init(_ attribute: Attribute) { self = attribute.identifier } - @inlinable - @inline(__always) - public func unsafeCast(to type: Value.Type) -> Attribute { + public func unsafeCast(to _: Value.Type) -> Attribute { fatalError("TODO") } - @inlinable - @inline(__always) public static var current: OGAttribute? { let current = __OGGraphGetCurrentAttribute() return current == .nil ? nil : current } - @inlinable - @inline(__always) public func unsafeOffset(at offset: Int) -> OGAttribute { create(offset: offset) } - - @inlinable - @inline(__always) + public func setFlags(_ newFlags: OGAttributeFlags, mask: OGAttributeFlags) { flags = flags.subtracting(mask).union(newFlags.intersection(mask)) } - - @inlinable - @inline(__always) + public func addInput(_ attribute: OGAttribute, options: OGInputOptions, token: Int) { __OGGraphAddInput(self, attribute, options, token) } - - @inlinable - @inline(__always) - public func addInput(_ attribute: Attribute, options: OGInputOptions, token: Int) { + + public func addInput(_ attribute: Attribute, options: OGInputOptions, token: Int) { addInput(attribute.identifier, options: options, token: token) } - @inlinable - @inline(__always) - public func visitBody(_ visitor: inout Visitor) { - fatalError("TODO") + // Question + public func visitBody(_ visitor: inout some AttributeBodyVisitor) { + let info = __OGGraphGetAttributeInfo(self) + let bodyType = info.type.advanced(by: 1).pointee.typeID.type as! _AttributeBody.Type + bodyType._visitBody(&visitor, info.body) } - - @inlinable - @inline(__always) - public func mutateBody(as: Value.Type, invalidating: Bool, _ body: (inout Value) -> ()) { - fatalError("TODO") + + public func mutateBody(as type: Value.Type, invalidating: Bool, _: (inout Value) -> Void) { + // FIXME: pass body + __OGGraphMutateAttribute(self, OGTypeID(type), invalidating) } - @inlinable - @inline(__always) - public func breadthFirstSearch(options: OGSearchOptions, _: (OGAttribute) -> Bool) -> Bool { + public func breadthFirstSearch(options _: OGSearchOptions, _: (OGAttribute) -> Bool) -> Bool { fatalError("TODO") } - @inlinable - @inline(__always) public var _bodyType: Any.Type { __OGGraphGetAttributeInfo(self).type.pointee.typeID.type } - - @inlinable - @inline(__always) + public var _bodyPointer: UnsafeRawPointer { __OGGraphGetAttributeInfo(self).body } - @inlinable - @inline(__always) public var valueType: Any.Type { __OGGraphGetAttributeInfo(self).type.pointee.valueTypeID.type } - - @inlinable - @inline(__always) - public var indirectDependency: OGAttribute { - get { fatalError("TODO") } - set { fatalError("TODO") } + + public var indirectDependency: OGAttribute? { + get { + let indirectDependency = __OGGraphGetIndirectDependency(self) + return indirectDependency == .nil ? nil : indirectDependency + } + nonmutating set { + __OGGraphSetIndirectDependency(self, newValue ?? .nil) + } } } diff --git a/Sources/_OpenGraph/Attribute/OGAttribute.cpp b/Sources/_OpenGraph/Attribute/OGAttribute.cpp index 573bf069..b3be2043 100644 --- a/Sources/_OpenGraph/Attribute/OGAttribute.cpp +++ b/Sources/_OpenGraph/Attribute/OGAttribute.cpp @@ -66,3 +66,16 @@ const OGAttributeInfo OGGraphGetAttributeInfo(OGAttribute attribute) { // TODO return { nullptr, nullptr }; } + +void OGGraphMutateAttribute(OGAttribute attribute, const OGTypeID type, bool invalidating) { + // TODO +} + +OGAttribute OGGraphGetIndirectDependency(OGAttribute attribute) { + // TODO + return OGAttributeNil; +} + +void OGGraphSetIndirectDependency(OGAttribute attribute1, OGAttribute attribute2) { + // TODO +} diff --git a/Sources/_OpenGraph/Attribute/OGAttribute.h b/Sources/_OpenGraph/Attribute/OGAttribute.h index 204539d7..6798707b 100644 --- a/Sources/_OpenGraph/Attribute/OGAttribute.h +++ b/Sources/_OpenGraph/Attribute/OGAttribute.h @@ -12,6 +12,7 @@ #include "OGAttributeFlags.h" #include "OGInputOptions.h" #include "OGAttributeInfo.h" +#include "OGTypeID.h" typedef uint32_t OGAttribute __attribute((swift_newtype(struct))); @@ -48,6 +49,18 @@ OG_EXPORT OG_REFINED_FOR_SWIFT const OGAttributeInfo OGGraphGetAttributeInfo(OGAttribute attribute); +OG_EXPORT +OG_REFINED_FOR_SWIFT +void OGGraphMutateAttribute(OGAttribute attribute, const OGTypeID type, bool invalidating/*, closure*/); + +OG_EXPORT +OG_REFINED_FOR_SWIFT +OGAttribute OGGraphGetIndirectDependency(OGAttribute attribute); + +OG_EXPORT +OG_REFINED_FOR_SWIFT +void OGGraphSetIndirectDependency(OGAttribute attribute1, OGAttribute attribute2); + OG_EXTERN_C_END #endif /* OGAttribute_h */ diff --git a/Tests/OpenGraphCompatibilityTests/Attribute/OGExtension/OGAttributeTests.swift b/Tests/OpenGraphCompatibilityTests/Attribute/OGExtension/OGAttributeTests.swift index 87adde64..83be0407 100644 --- a/Tests/OpenGraphCompatibilityTests/Attribute/OGExtension/OGAttributeTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Attribute/OGExtension/OGAttributeTests.swift @@ -40,5 +40,17 @@ final class OGAttributeTests: XCTestCase { // TODO: Add OGAttribute init func testSetFlags() throws {} + + func testVisitBody() { + // FIXME: attribute is invalid here. +// struct Visitor: AttributeBodyVisitor { +// func visit(body: UnsafePointer) where Body : _AttributeBody { +// print("Visit") +// } +// } +// let attribute = OGAttribute.nil +// var visitor = Visitor() +// attribute.visitBody(&visitor) + } #endif } diff --git a/Tests/OpenGraphCompatibilityTests/Graph/GraphTests.swift b/Tests/OpenGraphCompatibilityTests/Graph/GraphTests.swift index 6c8aaff4..f9018dd0 100644 --- a/Tests/OpenGraphCompatibilityTests/Graph/GraphTests.swift +++ b/Tests/OpenGraphCompatibilityTests/Graph/GraphTests.swift @@ -27,7 +27,11 @@ final class GraphTests: XCTestCase { } let name = "empty_graph.json" name.withCString { OGGraph.archiveJSON(name: $0) } - let url = URL(filePath: NSTemporaryDirectory().appending(name)) + let url = if #available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) { + URL(filePath: NSTemporaryDirectory().appending(name)) + } else { + URL(fileURLWithPath: NSTemporaryDirectory().appending(name)) + } let data = try Data(contentsOf: url) let graphs = try JSONDecoder().decode(Graphs.self, from: data) XCTAssertEqual(graphs.version, 2)