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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
submodules: true
- name: Build
run: swift build
- name: Test
run: swift test
- name: Test Compatibility
working-directory: ./CompatibilityTesting
run: swift test
- name: Build XCFramework
run: ./Scripts/create-xcframework.sh
- name: Upload XCFramework
Expand All @@ -47,3 +52,5 @@ jobs:
submodules: true
- name: Build
run: swift build
- name: Test
run: swift test
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>LibraryIdentifier</key>
<string>macos-arm64_arm64e_x86_64</string>
<key>LibraryPath</key>
<string>AttributeGraph.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>arm64e</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>macos</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>maccatalyst-arm64_arm64e_x86_64</string>
<key>LibraryPath</key>
<string>AttributeGraph.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>arm64e</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>maccatalyst</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include <AttributeGraph/AGBase.h>

AG_ASSUME_NONNULL_BEGIN

AG_EXTERN_C_BEGIN

typedef uint32_t AGAttribute AG_SWIFT_STRUCT AG_SWIFT_NAME(AnyAttribute);

AG_EXPORT
const AGAttribute AGAttributeNil;

typedef AG_OPTIONS(uint8_t, AGAttributeFlags) {
AGAttributeFlagsNone = 0,
AGAttributeFlagsAll = 0xFF,
} AG_SWIFT_NAME(AGSubgraphRef.Flags);

AG_EXTERN_C_END

AG_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <AttributeGraph/AGAttributeType.h>
#include <AttributeGraph/AGBase.h>

AG_ASSUME_NONNULL_BEGIN

AG_EXTERN_C_BEGIN

typedef struct AGAttributeInfo {
const AGAttributeType *type;
const void *body;
} AGAttributeInfo;

AG_EXTERN_C_END

AG_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once

#include <AttributeGraph/AGBase.h>

#if TARGET_OS_MAC
#include <CoreFoundation/CFString.h>
#else
#include <SwiftCorelibsCoreFoundation/CFString.h>
#endif

#include <AttributeGraph/AGClosure.h>
#include <AttributeGraph/AGType.h>

AG_ASSUME_NONNULL_BEGIN
AG_IMPLICIT_BRIDGING_ENABLED

AG_EXTERN_C_BEGIN

typedef struct AGAttributeType AGAttributeType;

typedef struct AG_SWIFT_NAME(_AttributeVTable) AGAttributeVTable {
unsigned long version;
void (*_Nullable type_destroy)(AGAttributeType *);
void (*_Nullable self_destroy)(const AGAttributeType *, void *);
#if TARGET_OS_MAC
CFStringRef _Nullable (*_Nullable self_description)(const AGAttributeType *, const void *);
CFStringRef _Nullable (*_Nullable value_description)(const AGAttributeType *, const void *);
#else
CFStringRef _Nullable (*_Nullable copy_self_description)(const AGAttributeType *, const void *);
CFStringRef _Nullable (*_Nullable copy_value_description)(const AGAttributeType *, const void *);
#endif
void (*_Nullable update_default)(const AGAttributeType *, void *);
} AGAttributeVTable;

typedef AG_OPTIONS(uint32_t, AGAttributeTypeFlags) {
AGAttributeTypeFlagsComparisonModeBitwise = 0,
AGAttributeTypeFlagsComparisonModeIndirect = 1,
AGAttributeTypeFlagsComparisonModeEquatableUnlessPOD = 2,
AGAttributeTypeFlagsComparisonModeEquatableAlways = 3,
AGAttributeTypeFlagsComparisonModeMask = 0x03,

AGAttributeTypeFlagsHasDestroySelf = 1 << 2,
AGAttributeTypeFlagsMainThread = 1 << 3,
AGAttributeTypeFlagsExternal = 1 << 4,
AGAttributeTypeFlagsAsyncThread = 1 << 5,
} AG_SWIFT_NAME(_AttributeType.Flags);

typedef struct AG_SWIFT_NAME(_AttributeType) AGAttributeType {
AGTypeID self_id;
AGTypeID value_id;
AGClosureStorage update;
const AGAttributeVTable *vtable;
AGAttributeTypeFlags flags;

uint32_t internal_offset;
const unsigned char *_Nullable value_layout;

struct {
AGTypeID type_id;
const void *witness_table;
} body_conformance;
} AGAttributeType;

AG_EXTERN_C_END

AG_IMPLICIT_BRIDGING_DISABLED
AG_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
#pragma once

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

#include <AttributeGraph/AGTargetConditionals.h>

#ifndef __has_include
#define __has_include(x) 0
#endif
#ifndef __has_feature
#define __has_feature(x) 0
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif

#define _AG_STRINGIFY(_x) #_x

#if !defined(AG_EXTERN_C_BEGIN)
#if defined(__cplusplus)
#define AG_EXTERN_C_BEGIN extern "C" {
#define AG_EXTERN_C_END }
#else
#define AG_EXTERN_C_BEGIN
#define AG_EXTERN_C_END
#endif
#endif

#if __GNUC__
#define AG_EXPORT extern __attribute__((__visibility__("default")))
#else
#define AG_EXPORT extern
#endif

#if __GNUC__
#define AG_INLINE static __inline__
#else
#define AG_INLINE static inline
#endif

#ifndef AG_RETURNS_RETAINED
#if __has_feature(attribute_cf_returns_retained)
#define AG_RETURNS_RETAINED __attribute__((cf_returns_retained))
#else
#define AG_RETURNS_RETAINED
#endif
#endif

#ifndef AG_IMPLICIT_BRIDGING_ENABLED
#if __has_feature(arc_cf_code_audited)
#define AG_IMPLICIT_BRIDGING_ENABLED _Pragma("clang arc_cf_code_audited begin")
#else
#define AG_IMPLICIT_BRIDGING_ENABLED
#endif
#endif

#ifndef AG_IMPLICIT_BRIDGING_DISABLED
#if __has_feature(arc_cf_code_audited)
#define AG_IMPLICIT_BRIDGING_DISABLED _Pragma("clang arc_cf_code_audited end")
#else
#define AG_IMPLICIT_BRIDGING_DISABLED
#endif
#endif

#if __has_attribute(objc_bridge) && __has_feature(objc_bridge_id) && __has_feature(objc_bridge_id_on_typedefs)

#ifdef __OBJC__
@class NSArray;
@class NSAttributedString;
@class NSString;
@class NSNull;
@class NSCharacterSet;
@class NSData;
@class NSDate;
@class NSTimeZone;
@class NSDictionary;
@class NSError;
@class NSLocale;
@class NSNumber;
@class NSSet;
@class NSURL;
#endif

#define AG_BRIDGED_TYPE(T) __attribute__((objc_bridge(T)))
#define AG_BRIDGED_MUTABLE_TYPE(T) __attribute__((objc_bridge_mutable(T)))
#define AG_RELATED_TYPE(T,C,I) __attribute__((objc_bridge_related(T,C,I)))
#else
#define AG_BRIDGED_TYPE(T)
#define AG_BRIDGED_MUTABLE_TYPE(T)
#define AG_RELATED_TYPE(T,C,I)
#endif

#if __has_feature(assume_nonnull)
#define AG_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
#define AG_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
#else
#define AG_ASSUME_NONNULL_BEGIN
#define AG_ASSUME_NONNULL_END
#endif

#if !__has_feature(nullability)
#ifndef _Nullable
#define _Nullable
#endif
#ifndef _Nonnull
#define _Nonnull
#endif
#ifndef _Null_unspecified
#define _Null_unspecified
#endif
#endif

#if __has_attribute(enum_extensibility)
#define __AG_ENUM_ATTRIBUTES __attribute__((enum_extensibility(open)))
#define __AG_CLOSED_ENUM_ATTRIBUTES __attribute__((enum_extensibility(closed)))
#define __AG_OPTIONS_ATTRIBUTES __attribute__((flag_enum,enum_extensibility(open)))
#else
#define __AG_ENUM_ATTRIBUTES
#define __AG_CLOSED_ENUM_ATTRIBUTES
#define __AG_OPTIONS_ATTRIBUTES
#endif

#define __AG_ENUM_FIXED_IS_AVAILABLE (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && (__has_feature(objc_fixed_enum) || __has_extension(cxx_fixed_enum)))

#if __AG_ENUM_FIXED_IS_AVAILABLE
#define AG_ENUM(_type, _name) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \
enum __AG_ENUM_ATTRIBUTES _name : _type _name; \
enum _name : _type \
_Pragma("clang diagnostic pop")
#define AG_CLOSED_ENUM(_type, _name) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \
enum __AG_CLOSED_ENUM_ATTRIBUTES _name : _type _name; \
enum _name : _type \
_Pragma("clang diagnostic pop")
#if (__cplusplus)
#define AG_OPTIONS(_type, _name) __attribute__((availability(swift,unavailable))) _type _name; enum __AG_OPTIONS_ATTRIBUTES : _name
#else
#define AG_OPTIONS(_type, _name) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Welaborated-enum-base\"") \
enum __AG_OPTIONS_ATTRIBUTES _name : _type _name; \
enum _name : _type \
_Pragma("clang diagnostic pop")
#endif
#else
#define AG_ENUM(_type, _name) _type _name; enum
#define AG_CLOSED_ENUM(_type, _name) _type _name; enum
#define AG_OPTIONS(_type, _name) _type _name; enum
#endif

#if __has_attribute(swift_private)
#define AG_REFINED_FOR_SWIFT __attribute__((swift_private))
#else
#define AG_REFINED_FOR_SWIFT
#endif

#if __has_attribute(swift_name)
#define AG_SWIFT_NAME(_name) __attribute__((swift_name(#_name)))
#else
#define AG_SWIFT_NAME(_name)
#endif

#if __has_attribute(swift_wrapper)
#define AG_SWIFT_STRUCT __attribute__((swift_wrapper(struct)))
#else
#define AG_SWIFT_STRUCT
#endif

// Define mappings for calling conventions.

// Annotation for specifying a calling convention of
// a runtime function. It should be used with declarations
// of runtime functions like this:
// void runtime_function_name() AG_SWIFT_CC(swift)
#define AG_SWIFT_CC(CC) AG_SWIFT_CC_##CC

// AG_SWIFT_CC(c) is the C calling convention.
#define AG_SWIFT_CC_c

// AG_SWIFT_CC(swift) is the Swift calling convention.
#if __has_attribute(swiftcall)
#define AG_SWIFT_CC_swift __attribute__((swiftcall))
#define AG_SWIFT_CONTEXT __attribute__((swift_context))
#define AG_SWIFT_ERROR_RESULT __attribute__((swift_error_result))
#define AG_SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result))
#else
#define AG_SWIFT_CC_swift
#define AG_SWIFT_CONTEXT
#define AG_SWIFT_ERROR_RESULT
#define AG_SWIFT_INDIRECT_RESULT
#endif

#if __has_attribute(swift_attr)
#define AG_SWIFT_SHARED_REFERENCE(_retain, _release) \
__attribute__((swift_attr("import_reference"))) \
__attribute__((swift_attr(_AG_STRINGIFY(retain:_retain)))) \
__attribute__((swift_attr(_AG_STRINGIFY(release:_release))))
#else
#define AG_SWIFT_SHARED_REFERENCE(_retain, _release)
#endif

#if __has_include(<ptrcheck.h>)
#include <ptrcheck.h>
#define AG_COUNTED_BY(N) __counted_by(N)
#else
#define AG_COUNTED_BY(N)
#endif
Loading