forked from swiftlang/swift-corelibs-foundation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of Foundation.
This commit also contains: * Import of CF-1253 ("El Capitan"), plus changes required to support this project. * Initial build system. * Basic framework for unit testing using XCTest. * Starting point for documentation, including Getting Started, Known Issues, and major Design guidelines. There is much more to come. See you on the mailing lists. Foundation Team
- Loading branch information
0 parents
commit a7b2bc1
Showing
483 changed files
with
386,851 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Mac OS X filesystem metadata | ||
.DS_Store | ||
|
||
# Xcode user artifacts | ||
xcuserdata | ||
project.xcworkspace | ||
|
||
# python generated files | ||
*.pyc | ||
|
||
# build files generated by the configure script | ||
*.ninja | ||
.ninja_deps | ||
.ninja_log | ||
|
||
Build | ||
.build | ||
|
452 changes: 452 additions & 0 deletions
452
CoreFoundation/AppServices.subproj/CFUserNotification.c
Large diffs are not rendered by default.
Oops, something went wrong.
192 changes: 192 additions & 0 deletions
192
CoreFoundation/AppServices.subproj/CFUserNotification.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
|
||
|
||
/* CFUserNotification.h | ||
Copyright (c) 2000-2015, Apple Inc. All rights reserved. | ||
*/ | ||
|
||
#if !defined(__COREFOUNDATION_CFUSERNOTIFICATION__) | ||
#define __COREFOUNDATION_CFUSERNOTIFICATION__ 1 | ||
|
||
#include <CoreFoundation/CFBase.h> | ||
#include <CoreFoundation/CFDate.h> | ||
#include <CoreFoundation/CFDictionary.h> | ||
#include <CoreFoundation/CFString.h> | ||
#include <CoreFoundation/CFURL.h> | ||
#include <CoreFoundation/CFRunLoop.h> | ||
|
||
CF_IMPLICIT_BRIDGING_ENABLED | ||
CF_EXTERN_C_BEGIN | ||
|
||
typedef struct CF_BRIDGED_MUTABLE_TYPE(id) __CFUserNotification * CFUserNotificationRef; | ||
|
||
/* A CFUserNotification is a notification intended to be presented to a | ||
user at the console (if one is present). This is for the use of processes | ||
that do not otherwise have user interfaces, but may need occasional | ||
interaction with a user. There is a parallel API for this functionality | ||
at the System framework level, described in UNCUserNotification.h. | ||
The contents of the notification can include a header, a message, textfields, | ||
a popup button, radio buttons or checkboxes, a progress indicator, and up to | ||
three ordinary buttons. All of these items are optional, but a default | ||
button will be supplied even if not specified unless the | ||
kCFUserNotificationNoDefaultButtonFlag is set. | ||
The contents of the notification are specified in the dictionary used to | ||
create the notification, whose keys should be taken from the list of constants | ||
below, and whose values should be either strings or arrays of strings | ||
(except for kCFUserNotificationProgressIndicatorValueKey, in which case the | ||
value should be a number between 0 and 1, for a "definite" progress indicator, | ||
or a boolean, for an "indefinite" progress indicator). Additionally, URLs can | ||
optionally be supplied for an icon, a sound, and a bundle whose Localizable.strings | ||
files will be used to localize strings. | ||
Certain request flags are specified when a notification is created. | ||
These specify an alert level for the notification, determine whether | ||
radio buttons or check boxes are to be used, specify which if any of these | ||
are checked by default, specify whether any of the textfields are to | ||
be secure textfields, and determine which popup item should be selected | ||
by default. A timeout is also specified, which determines how long the | ||
notification should be supplied to the user (if zero, it will not timeout). | ||
A CFUserNotification is dispatched for presentation when it is created. | ||
If any reply is required, it may be awaited in one of two ways: either | ||
synchronously, using CFUserNotificationReceiveResponse, or asynchronously, | ||
using a run loop source. CFUserNotificationReceiveResponse has a timeout | ||
parameter that determines how long it will block (zero meaning indefinitely) | ||
and it may be called as many times as necessary until a response arrives. | ||
If a notification has not yet received a response, it may be updated with | ||
new information, or it may be cancelled. Notifications may not be reused. | ||
When a response arrives, it carries with it response flags that describe | ||
which button was used to dismiss the notification, which checkboxes or | ||
radio buttons were checked, and what the selection of the popup was. | ||
It also carries a response dictionary, which describes the contents | ||
of the textfields. */ | ||
|
||
typedef void (*CFUserNotificationCallBack)(CFUserNotificationRef userNotification, CFOptionFlags responseFlags); | ||
|
||
CF_EXPORT | ||
CFTypeID CFUserNotificationGetTypeID(void); | ||
|
||
CF_EXPORT | ||
CFUserNotificationRef CFUserNotificationCreate(CFAllocatorRef allocator, CFTimeInterval timeout, CFOptionFlags flags, SInt32 *error, CFDictionaryRef dictionary); | ||
|
||
CF_EXPORT | ||
SInt32 CFUserNotificationReceiveResponse(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags *responseFlags); | ||
|
||
CF_EXPORT | ||
CFStringRef CFUserNotificationGetResponseValue(CFUserNotificationRef userNotification, CFStringRef key, CFIndex idx); | ||
|
||
CF_EXPORT | ||
CFDictionaryRef CFUserNotificationGetResponseDictionary(CFUserNotificationRef userNotification); | ||
|
||
CF_EXPORT | ||
SInt32 CFUserNotificationUpdate(CFUserNotificationRef userNotification, CFTimeInterval timeout, CFOptionFlags flags, CFDictionaryRef dictionary); | ||
|
||
CF_EXPORT | ||
SInt32 CFUserNotificationCancel(CFUserNotificationRef userNotification); | ||
|
||
CF_EXPORT | ||
CFRunLoopSourceRef CFUserNotificationCreateRunLoopSource(CFAllocatorRef allocator, CFUserNotificationRef userNotification, CFUserNotificationCallBack callout, CFIndex order); | ||
|
||
/* Convenience functions for handling the simplest and most common cases: | ||
a one-way notification, and a notification with up to three buttons. */ | ||
|
||
CF_EXPORT | ||
SInt32 CFUserNotificationDisplayNotice(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle); | ||
|
||
CF_EXPORT | ||
SInt32 CFUserNotificationDisplayAlert(CFTimeInterval timeout, CFOptionFlags flags, CFURLRef iconURL, CFURLRef soundURL, CFURLRef localizationURL, CFStringRef alertHeader, CFStringRef alertMessage, CFStringRef defaultButtonTitle, CFStringRef alternateButtonTitle, CFStringRef otherButtonTitle, CFOptionFlags *responseFlags); | ||
|
||
|
||
/* Flags */ | ||
|
||
CF_ENUM(CFOptionFlags) { | ||
kCFUserNotificationStopAlertLevel = 0, | ||
kCFUserNotificationNoteAlertLevel = 1, | ||
kCFUserNotificationCautionAlertLevel = 2, | ||
kCFUserNotificationPlainAlertLevel = 3 | ||
}; | ||
|
||
CF_ENUM(CFOptionFlags) { | ||
kCFUserNotificationDefaultResponse = 0, | ||
kCFUserNotificationAlternateResponse = 1, | ||
kCFUserNotificationOtherResponse = 2, | ||
kCFUserNotificationCancelResponse = 3 | ||
}; | ||
|
||
CF_ENUM(CFOptionFlags) { | ||
kCFUserNotificationNoDefaultButtonFlag = (1UL << 5), | ||
kCFUserNotificationUseRadioButtonsFlag = (1UL << 6) | ||
}; | ||
|
||
CF_INLINE CFOptionFlags CFUserNotificationCheckBoxChecked(CFIndex i) {return ((CFOptionFlags)(1UL << (8 + i)));} | ||
CF_INLINE CFOptionFlags CFUserNotificationSecureTextField(CFIndex i) {return ((CFOptionFlags)(1UL << (16 + i)));} | ||
CF_INLINE CFOptionFlags CFUserNotificationPopUpSelection(CFIndex n) {return ((CFOptionFlags)(n << 24));} | ||
|
||
|
||
/* Keys */ | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationIconURLKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationSoundURLKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationLocalizationURLKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationAlertHeaderKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationAlertMessageKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationDefaultButtonTitleKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationAlternateButtonTitleKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationOtherButtonTitleKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationProgressIndicatorValueKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationPopUpTitlesKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationTextFieldTitlesKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationCheckBoxTitlesKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationTextFieldValuesKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationPopUpSelectionKey CF_AVAILABLE(10_3, NA); | ||
|
||
#if (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) | ||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationAlertTopMostKey; | ||
|
||
CF_EXPORT | ||
const CFStringRef kCFUserNotificationKeyboardTypesKey; | ||
#endif | ||
|
||
CF_EXTERN_C_END | ||
CF_IMPLICIT_BRIDGING_DISABLED | ||
|
||
#endif /* ! __COREFOUNDATION_CFUSERNOTIFICATION__ */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
// This source file is part of the Swift.org open source project | ||
// | ||
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors | ||
// Licensed under Apache License v2.0 with Runtime Library Exception | ||
// | ||
// See http://swift.org/LICENSE.txt for license information | ||
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
// | ||
|
||
|
||
/* CFAvailability.h | ||
Copyright (c) 2013 - 2015 Apple Inc. and the Swift project authors | ||
*/ | ||
|
||
#if !defined(__COREFOUNDATION_CFAVAILABILITY__) | ||
#define __COREFOUNDATION_CFAVAILABILITY__ 1 | ||
|
||
#if DEPLOYMENT_RUNTIME_SWIFT | ||
#include <CoreFoundation/TargetConditionals.h> | ||
#else | ||
#include <TargetConditionals.h> | ||
#endif | ||
|
||
#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32) | ||
#include <Availability.h> | ||
|
||
// Even if unused, these must remain here for compatibility, because projects rely on them being included. | ||
#include <AvailabilityMacros.h> | ||
#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 | ||
|
||
// The arguments to these availability macros is a version number, e.g. 10_6, 3_0 or 'NA' | ||
// To use a deprecation message with the macro, add a string as the last argument. | ||
#if __has_feature(attribute_availability_with_version_underscores) || (__has_feature(attribute_availability_with_message) && __clang__ && __clang_major__ >= 7) | ||
#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) | ||
// This section is for compilers targeting OS X which support attribute_availability_with_message | ||
|
||
#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(macosx,introduced=_mac))) | ||
#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(macosx,introduced=_mac))) | ||
#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(macosx,unavailable))) | ||
#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(macosx,introduced=_macIntro,deprecated=_macDep,message="" __VA_ARGS__))) | ||
#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(macosx,introduced=_macIntro,deprecated=_macDep,message="" __VA_ARGS__))) | ||
#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(macosx,unavailable))) | ||
|
||
#elif (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) | ||
// This section is for compilers targeting iOS which support attribute_availability_with_message | ||
|
||
#define CF_AVAILABLE(_mac, _ios) __attribute__((availability(ios,introduced=_ios))) | ||
#define CF_AVAILABLE_MAC(_mac) __attribute__((availability(ios,unavailable))) | ||
#define CF_AVAILABLE_IOS(_ios) __attribute__((availability(ios,introduced=_ios))) | ||
#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __attribute__((availability(ios,introduced=_iosIntro,deprecated=_iosDep,message="" __VA_ARGS__))) | ||
#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __attribute__((availability(ios,unavailable))) | ||
#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __attribute__((availability(ios,introduced=_iosIntro,deprecated=_iosDep,message="" __VA_ARGS__))) | ||
|
||
#endif | ||
|
||
#elif (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) | ||
// This section is for OS X or iOS, and compilers without support for attribute_availability_with_message. We fall back to Availability.h. | ||
|
||
#ifndef __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 | ||
#define __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_0 __AVAILABILITY_INTERNAL_DEPRECATED | ||
#endif | ||
|
||
#define CF_AVAILABLE(_mac, _ios) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_##_ios) | ||
#define CF_AVAILABLE_MAC(_mac) __OSX_AVAILABLE_STARTING(__MAC_##_mac, __IPHONE_NA) | ||
#define CF_AVAILABLE_IOS(_ios) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_##_ios) | ||
#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) | ||
#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_##_macIntro, __MAC_##_macDep, __IPHONE_NA, __IPHONE_NA) | ||
#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_NA, __MAC_NA, __IPHONE_##_iosIntro, __IPHONE_##_iosDep) | ||
|
||
#endif // __has_feature(attribute_availability_with_message) | ||
|
||
#ifndef CF_AVAILABLE | ||
// This section is for platforms which do not support availability | ||
#define CF_AVAILABLE(_mac, _ios) | ||
#define CF_AVAILABLE_MAC(_mac) | ||
#define CF_AVAILABLE_IOS(_ios) | ||
#define CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) | ||
#define CF_DEPRECATED_MAC(_macIntro, _macDep, ...) | ||
#define CF_DEPRECATED_IOS(_iosIntro, _iosDep, ...) | ||
#endif | ||
|
||
// Older versions of these macros; use iOS versions instead | ||
#define CF_AVAILABLE_IPHONE(_ios) CF_AVAILABLE_IOS(_ios) | ||
#define CF_DEPRECATED_IPHONE(_iosIntro, _iosDep) CF_DEPRECATED_IOS(_iosIntro, _iosDep) | ||
|
||
// Enum availability macros | ||
#if __has_feature(enumerator_attributes) && __has_attribute(availability) | ||
#define CF_ENUM_AVAILABLE(_mac, _ios) CF_AVAILABLE(_mac, _ios) | ||
#define CF_ENUM_AVAILABLE_MAC(_mac) CF_AVAILABLE_MAC(_mac) | ||
#define CF_ENUM_AVAILABLE_IOS(_ios) CF_AVAILABLE_IOS(_ios) | ||
#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) CF_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, __VA_ARGS__) | ||
#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) CF_DEPRECATED_MAC(_macIntro, _macDep, __VA_ARGS__) | ||
#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) CF_DEPRECATED_IOS(_iosIntro, _iosDep, __VA_ARGS__) | ||
#else | ||
#define CF_ENUM_AVAILABLE(_mac, _ios) | ||
#define CF_ENUM_AVAILABLE_MAC(_mac) | ||
#define CF_ENUM_AVAILABLE_IOS(_ios) | ||
#define CF_ENUM_DEPRECATED(_macIntro, _macDep, _iosIntro, _iosDep, ...) | ||
#define CF_ENUM_DEPRECATED_MAC(_macIntro, _macDep, ...) | ||
#define CF_ENUM_DEPRECATED_IOS(_iosIntro, _iosDep, ...) | ||
#endif | ||
|
||
// Enums and Options | ||
#define __CF_ENUM_GET_MACRO(_1, _2, NAME, ...) NAME | ||
#if (__cplusplus && __cplusplus >= 201103L && (__has_extension(cxx_strong_enums) || __has_feature(objc_fixed_enum))) || (!__cplusplus && __has_feature(objc_fixed_enum)) | ||
#define __CF_NAMED_ENUM(_type, _name) enum _name : _type _name; enum _name : _type | ||
#define __CF_ANON_ENUM(_type) enum : _type | ||
#if (__cplusplus) | ||
#define CF_OPTIONS(_type, _name) _type _name; enum : _type | ||
#else | ||
#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type | ||
#endif | ||
#else | ||
#define __CF_NAMED_ENUM(_type, _name) _type _name; enum | ||
#define __CF_ANON_ENUM(_type) enum | ||
#define CF_OPTIONS(_type, _name) _type _name; enum | ||
#endif | ||
|
||
/* CF_ENUM supports the use of one or two arguments. The first argument is always the integer type used for the values of the enum. The second argument is an optional type name for the macro. When specifying a type name, you must precede the macro with 'typedef' like so: | ||
typedef CF_ENUM(CFIndex, CFComparisonResult) { | ||
... | ||
}; | ||
If you do not specify a type name, do not use 'typdef', like so: | ||
CF_ENUM(CFIndex) { | ||
... | ||
}; | ||
*/ | ||
#define CF_ENUM(...) __CF_ENUM_GET_MACRO(__VA_ARGS__, __CF_NAMED_ENUM, __CF_ANON_ENUM)(__VA_ARGS__) | ||
|
||
// Extension availability macros | ||
#define CF_EXTENSION_UNAVAILABLE(_msg) __OS_EXTENSION_UNAVAILABLE(_msg) | ||
#define CF_EXTENSION_UNAVAILABLE_MAC(_msg) __OSX_EXTENSION_UNAVAILABLE(_msg) | ||
#define CF_EXTENSION_UNAVAILABLE_IOS(_msg) __IOS_EXTENSION_UNAVAILABLE(_msg) | ||
|
||
// Swift availability macro | ||
#if __has_feature(attribute_availability_swift) | ||
#define CF_SWIFT_UNAVAILABLE(_msg) __attribute__((availability(swift, unavailable, message=_msg))) | ||
#else | ||
#define CF_SWIFT_UNAVAILABLE(_msg) | ||
#endif | ||
|
||
#endif // __COREFOUNDATION_CFAVAILABILITY__ |
Oops, something went wrong.