[ClassKit] Add Xcode 9.4 Beta 1 Bindings (#3853)

* [ClassKit] Add Xcode 9.4 Beta 1 Bindings

* ClassKit moved to v11.4 or we'd link against a private frmework in 11.3

* Turn CLSPredicateKeyPath into a static class

CLSPredicateKeyPath does not make much sense as an enum, we'll use
a static class instead so we do not have to call GetConstant() and
use the NSString directly.

Sample code using CLSPredicateKeyPath:

```csharp
var store = CLSDataStore.Shared;
var predicate = NSPredicate.FromFormat ("%K = %@", CLSPredicateKeyPath.Parent, store.MainAppContext);
var ctxs = await store.FindContextsMatchingAsync (predicate);
foreach (var ctx in ctxs) {
	Console.WriteLine (ctx.Title);
}
```

* [tests] Exclude WeakTopic incorrect check, bound as smart enum
This commit is contained in:
Alex Soto 2018-04-05 10:20:05 -05:00 коммит произвёл GitHub
Родитель bddd5f924a
Коммит 347160cf51
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 385 добавлений и 86 удалений

Просмотреть файл

@ -0,0 +1,24 @@
//
// CLSContext.cs
//
// Authors:
// Alex Soto <alexsoto@microsoft.com>
//
// Copyright 2018 Xamarin Inc. All rights reserved.
//
#if XAMCORE_2_0
using System;
using XamCore.Foundation;
using XamCore.ObjCRuntime;
namespace XamCore.ClassKit {
public partial class CLSContext {
public CLSContextTopic Topic {
get => CLSContextTopicExtensions.GetValue (WeakTopic);
set => WeakTopic = value.GetConstant ();
}
}
}
#endif

Просмотреть файл

@ -119,5 +119,7 @@ namespace MonoTouch {
public const string PdfKitLibrary = "/System/Library/Frameworks/PDFKit.framework/PDFKit";
// iOS 11.3
public const string BusinessChatLibrary = "/System/Library/Frameworks/BusinessChat.framework/BusinessChat";
// iOS 11.4
public const string ClassKitLibrary = "/System/Library/Frameworks/ClassKit.framework/ClassKit";
}
}

336
src/classkit.cs Normal file
Просмотреть файл

@ -0,0 +1,336 @@
//
// ClassKit bindings
//
// Authors:
// Alex Soto <alexsoto@microsoft.com>
//
// Copyright 2018 Xamarin Inc. All rights reserved.
//
#if XAMCORE_2_0
using System;
using XamCore.Foundation;
using XamCore.ObjCRuntime;
using System.Reflection;
namespace XamCore.ClassKit {
[NoWatch, NoTV, NoMac, iOS (11,4)]
[Native]
enum CLSBinaryValueType : nint {
TrueFalse = 0,
PassFail,
YesNo,
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[Native]
enum CLSContextType : nint {
None = 0,
App,
Chapter,
Section,
Level,
Page,
Task,
Challenge,
Quiz,
Exercise,
Lesson,
Book,
Game,
Document,
Audio,
Video,
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[Native]
[ErrorDomain ("CLSErrorCodeDomain")]
public enum CLSErrorCode : nint {
None = 0,
ClassKitUnavailable,
InvalidArgument,
InvalidModification,
AuthorizationDenied,
DatabaseInaccessible,
Limits,
InvalidCreate,
InvalidUpdate,
PartialFailure,
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
enum CLSContextTopic {
[Field ("CLSContextTopicMath")]
Math,
[Field ("CLSContextTopicScience")]
Science,
[Field ("CLSContextTopicLiteracyAndWriting")]
LiteracyAndWriting,
[Field ("CLSContextTopicWorldLanguage")]
WorldLanguage,
[Field ("CLSContextTopicSocialScience")]
SocialScience,
[Field ("CLSContextTopicComputerScienceAndEngineering")]
ComputerScienceAndEngineering,
[Field ("CLSContextTopicArtsAndMusic")]
ArtsAndMusic,
[Field ("CLSContextTopicHealthAndFitness")]
HealthAndFitness,
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[Static]
interface CLSErrorUserInfoKeys {
[Field ("CLSErrorObjectKey")]
NSString ObjectKey { get; }
[Field ("CLSErrorUnderlyingErrorsKey")]
NSString UnderlyingErrorsKey { get; }
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[Static]
interface CLSPredicateKeyPath {
[Field ("CLSPredicateKeyPathDateCreated")]
NSString DateCreated { get; }
[Field ("CLSPredicateKeyPathIdentifier")]
NSString Identifier { get; }
[Field ("CLSPredicateKeyPathTitle")]
NSString Title { get; }
[Field ("CLSPredicateKeyPathUniversalLinkURL")]
NSString UniversalLinkUrl { get; }
[Field ("CLSPredicateKeyPathTopic")]
NSString Topic { get; }
[Field ("CLSPredicateKeyPathParent")]
NSString Parent { get; }
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface CLSObject : NSSecureCoding {
[Export ("dateCreated")]
NSDate DateCreated { get; }
[Export ("dateLastModified")]
NSDate DateLastModified { get; }
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (CLSObject))]
[DisableDefaultCtor]
interface CLSActivity {
[Export ("progress")]
double Progress { get; set; }
[Export ("duration")]
double Duration { get; }
[Export ("primaryActivityItem", ArgumentSemantic.Assign)]
CLSActivityItem PrimaryActivityItem { get; set; }
[Export ("addProgressRangeFromStart:toEnd:")]
void AddProgressRange (double start, double end);
[Export ("addAdditionalActivityItem:")]
void AddAdditionalActivityItem (CLSActivityItem activityItem);
[Export ("additionalActivityItems")]
CLSActivityItem [] AdditionalActivityItems { get; }
// From CLSActivity (Activation) Category
[Export ("started")]
bool Started { [Bind ("isStarted")] get; }
[Export ("start")]
void Start ();
[Export ("stop")]
void Stop ();
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (CLSObject))]
[DisableDefaultCtor]
interface CLSActivityItem {
[Export ("title")]
string Title { get; set; }
[Export ("identifier")]
string Identifier { get; }
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (CLSActivityItem))]
[DisableDefaultCtor]
interface CLSBinaryItem {
[Export ("value")]
bool Value { get; set; }
[Export ("valueType")]
CLSBinaryValueType ValueType { get; }
[Export ("initWithIdentifier:title:type:")]
[DesignatedInitializer]
IntPtr Constructor (string identifier, string title, CLSBinaryValueType valueType);
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (CLSObject))]
[DisableDefaultCtor]
interface CLSContext {
[Export ("identifier")]
string Identifier { get; }
[NullAllowed, Export ("universalLinkURL", ArgumentSemantic.Assign)]
NSUrl UniversalLinkUrl { get; set; }
[Export ("type")]
CLSContextType Type { get; }
[Export ("title")]
string Title { get; set; }
[Export ("displayOrder")]
nint DisplayOrder { get; set; }
[Protected]
[NullAllowed, Export ("topic")]
NSString WeakTopic { get; set; }
[Export ("initWithType:identifier:title:")]
[DesignatedInitializer]
IntPtr Constructor (CLSContextType type, string identifier, string title);
[Export ("active")]
bool Active { [Bind ("isActive")] get; set; }
[Export ("becomeActive")]
void BecomeActive ();
[Export ("resignActive")]
void ResignActive ();
// From CLSContext (Hierarchy) Category
[NullAllowed, Export ("parent")]
CLSContext Parent { get; }
[Export ("removeFromParent")]
void RemoveFromParent ();
[Export ("addChildContext:")]
void AddChild (CLSContext childContext);
[Async]
[Export ("descendantMatchingIdentifierPath:completion:")]
void FindDescendantMatching (string [] identifierPath, Action<CLSContext, NSError> completion);
// From CLSContext (Activity) Category
[NullAllowed, Export ("currentActivity")]
CLSActivity CurrentActivity { get; }
[Export ("createNewActivity")]
CLSActivity CreateNewActivity ();
}
interface ICLSDataStoreDelegate { }
[NoWatch, NoTV, NoMac, iOS (11,4)]
[Protocol, Model]
[BaseType (typeof (NSObject))]
interface CLSDataStoreDelegate {
[Abstract]
[Export ("createContextForIdentifier:parentContext:parentIdentifierPath:")]
CLSContext CreateContext (string identifier, CLSContext parentContext, string [] parentIdentifierPath);
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface CLSDataStore {
[Static]
[Export ("shared")]
CLSDataStore Shared { get; }
[Export ("mainAppContext")]
CLSContext MainAppContext { get; }
[NullAllowed, Export ("activeContext")]
CLSContext ActiveContext { get; }
[NullAllowed, Export ("runningActivity")]
CLSActivity RunningActivity { get; }
[Wrap ("WeakDelegate"), Protocolize]
[NullAllowed]
CLSDataStoreDelegate Delegate { get; set; }
[NullAllowed, Export ("delegate", ArgumentSemantic.Weak)]
NSObject WeakDelegate { get; set; }
[Async]
[Export ("saveWithCompletion:")]
void Save ([NullAllowed] Action<NSError> completion);
// From CLSDataStore (Contexts) Category
[Async]
[Export ("contextsMatchingPredicate:completion:")]
void FindContextsMatching (NSPredicate predicate, Action<CLSContext [], NSError> completion);
[Async]
[Export ("contextsMatchingIdentifierPath:completion:")]
void FindContextsMatching (string [] identifierPath, Action<CLSContext [], NSError> completion);
[Export ("removeContext:")]
void Remove (CLSContext context);
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (CLSActivityItem))]
[DisableDefaultCtor]
interface CLSQuantityItem {
[Export ("quantity")]
double Quantity { get; set; }
[Export ("initWithIdentifier:title:")]
[DesignatedInitializer]
IntPtr Constructor (string identifier, string title);
}
[NoWatch, NoTV, NoMac, iOS (11,4)]
[BaseType (typeof (CLSActivityItem))]
[DisableDefaultCtor]
interface CLSScoreItem {
[Export ("score")]
double Score { get; set; }
[Export ("maxScore")]
double MaxScore { get; set; }
[Export ("initWithIdentifier:title:score:maxScore:")]
[DesignatedInitializer]
IntPtr Constructor (string identifier, string title, double score, double maxScore);
}
}
#endif

Просмотреть файл

@ -5101,6 +5101,16 @@ namespace XamCore.Foundation
[TV (11,3), Mac (10,13,4, onlyOn64: true), iOS (11,3), NoWatch]
[NullAllowed, Export ("detectedBarcodeDescriptor", ArgumentSemantic.Copy)]
CIBarcodeDescriptor DetectedBarcodeDescriptor { get; }
// From NSUserActivity (CLSDeepLinks)
[NoWatch, NoTV, NoMac, iOS (11,4)]
[Export ("isClassKitDeepLink")]
bool IsClassKitDeepLink { get; }
[NoWatch, NoTV, NoMac, iOS (11,4)]
[NullAllowed, Export ("contextIdentifierPath")]
string[] ContextIdentifierPath { get; }
}
[iOS (8,0)][Mac (10,10, onlyOn64 : true)] // same as NSUserActivity

Просмотреть файл

@ -294,6 +294,11 @@ BUSINESSCHAT_SOURCES = \
CALLKIT_SOURCES = \
CallKit/CXProvider.cs \
# ClassKit
CLASSKIT_SOURCES = \
ClassKit/CLSContext.cs \
# ClockKit
CLOCKKIT_CORE_SOURCES = \
@ -1704,6 +1709,7 @@ IOS_FRAMEWORKS = \
BusinessChat \
CallKit \
CFNetwork \
ClassKit \
CloudKit \
Contacts \
ContactsUI \

Просмотреть файл

@ -42,6 +42,9 @@ namespace Introspection {
// VNImageOptions is a DictionaryContainer that exposes a Weak* NSDictionary
case "VNImageOptions":
return property.Name == "WeakProperties";
// NSString manually bound as smart enum CLSContextTopic
case "CLSContext":
return property.Name == "WeakTopic";
#if !XAMCORE_3_0
// #37451 - setter does not exists but we have to keep it for binary compatibility
// OTOH we can't give it a selector (private API) even if we suspect Apple is mostly running `strings` on executable

Просмотреть файл

@ -1,85 +0,0 @@
!missing-enum! CLSBinaryValueType not bound
!missing-enum! CLSContextType not bound
!missing-enum! CLSErrorCode not bound
!missing-field! CLSContextTopicArtsAndMusic not bound
!missing-field! CLSContextTopicComputerScienceAndEngineering not bound
!missing-field! CLSContextTopicHealthAndFitness not bound
!missing-field! CLSContextTopicLiteracyAndWriting not bound
!missing-field! CLSContextTopicMath not bound
!missing-field! CLSContextTopicScience not bound
!missing-field! CLSContextTopicSocialScience not bound
!missing-field! CLSContextTopicWorldLanguage not bound
!missing-field! CLSErrorCodeDomain not bound
!missing-field! CLSErrorObjectKey not bound
!missing-field! CLSErrorUnderlyingErrorsKey not bound
!missing-field! CLSPredicateKeyPathDateCreated not bound
!missing-field! CLSPredicateKeyPathIdentifier not bound
!missing-field! CLSPredicateKeyPathParent not bound
!missing-field! CLSPredicateKeyPathTitle not bound
!missing-field! CLSPredicateKeyPathTopic not bound
!missing-field! CLSPredicateKeyPathUniversalLinkURL not bound
!missing-protocol! CLSDataStoreDelegate not bound
!missing-selector! +CLSDataStore::shared not bound
!missing-selector! CLSActivity::addAdditionalActivityItem: not bound
!missing-selector! CLSActivity::additionalActivityItems not bound
!missing-selector! CLSActivity::addProgressRangeFromStart:toEnd: not bound
!missing-selector! CLSActivity::duration not bound
!missing-selector! CLSActivity::isStarted not bound
!missing-selector! CLSActivity::primaryActivityItem not bound
!missing-selector! CLSActivity::progress not bound
!missing-selector! CLSActivity::setPrimaryActivityItem: not bound
!missing-selector! CLSActivity::setProgress: not bound
!missing-selector! CLSActivityItem::identifier not bound
!missing-selector! CLSActivityItem::setTitle: not bound
!missing-selector! CLSActivityItem::title not bound
!missing-selector! CLSBinaryItem::initWithIdentifier:title:type: not bound
!missing-selector! CLSBinaryItem::setValue: not bound
!missing-selector! CLSBinaryItem::value not bound
!missing-selector! CLSBinaryItem::valueType not bound
!missing-selector! CLSContext::addChildContext: not bound
!missing-selector! CLSContext::currentCLSContext not bound
!missing-selector! CLSContext::descendantMatchingIdentifierPath:completion: not bound
!missing-selector! CLSContext::displayOrder not bound
!missing-selector! CLSContext::identifier not bound
!missing-selector! CLSContext::initWithType:identifier:title: not bound
!missing-selector! CLSContext::isActive not bound
!missing-selector! CLSContext::parent not bound
!missing-selector! CLSContext::setActive: not bound
!missing-selector! CLSContext::setDisplayOrder: not bound
!missing-selector! CLSContext::setTitle: not bound
!missing-selector! CLSContext::setTopic: not bound
!missing-selector! CLSContext::setUniversalLinkURL: not bound
!missing-selector! CLSContext::title not bound
!missing-selector! CLSContext::topic not bound
!missing-selector! CLSContext::type not bound
!missing-selector! CLSContext::universalLinkURL not bound
!missing-selector! CLSDataStore::activeContext not bound
!missing-selector! CLSDataStore::contextsMatchingIdentifierPath:completion: not bound
!missing-selector! CLSDataStore::contextsMatchingPredicate:completion: not bound
!missing-selector! CLSDataStore::delegate not bound
!missing-selector! CLSDataStore::mainAppContext not bound
!missing-selector! CLSDataStore::removeContext: not bound
!missing-selector! CLSDataStore::runningActivity not bound
!missing-selector! CLSDataStore::saveWithCompletion: not bound
!missing-selector! CLSDataStore::setDelegate: not bound
!missing-selector! CLSObject::dateCreated not bound
!missing-selector! CLSObject::dateLastModified not bound
!missing-selector! CLSObject::initWithCoder: not bound
!missing-selector! CLSQuantityItem::initWithIdentifier:title: not bound
!missing-selector! CLSQuantityItem::quantity not bound
!missing-selector! CLSQuantityItem::setQuantity: not bound
!missing-selector! CLSScoreItem::initWithIdentifier:title:score:maxScore: not bound
!missing-selector! CLSScoreItem::maxScore not bound
!missing-selector! CLSScoreItem::score not bound
!missing-selector! CLSScoreItem::setMaxScore: not bound
!missing-selector! CLSScoreItem::setScore: not bound
!missing-selector! NSUserActivity::contextIdentifierPath not bound
!missing-selector! NSUserActivity::isClassKitDeepLink not bound
!missing-type! CLSActivity not bound
!missing-type! CLSActivityItem not bound
!missing-type! CLSBinaryItem not bound
!missing-type! CLSContext not bound
!missing-type! CLSDataStore not bound
!missing-type! CLSObject not bound
!missing-type! CLSQuantityItem not bound
!missing-type! CLSScoreItem not bound

Просмотреть файл

@ -257,6 +257,8 @@ public class Frameworks : Dictionary <string, Framework>
{ "FileProvider", "FileProvider", 11 },
{ "FileProviderUI", "FileProviderUI", 11 },
{ "PdfKit", "PDFKit", 11 },
{ "ClassKit", "ClassKit", 11,4 },
};
}
return ios_frameworks;

Просмотреть файл

@ -280,7 +280,8 @@ SIMLAUNCHER_FRAMEWORKS = \
-weak_framework ARKit \
-weak_framework FileProvider \
-weak_framework FileProviderUI \
-weak_framework BusinessChat
-weak_framework BusinessChat \
-weak_framework ClassKit
# note: there _was_ no CoreAudioKit.framework or Metal.framework for the simulator (before recent iOS9 betas)
# note 2: there's no GameKit, in iOS 9 (beta 3 at least), you're supposed to reference GameCenter instead (looks fixed in beta 4)