[gameplaykit] Add bindings from Xcode 9.0 (#2798)

Re-based from Miguel's PR #2476 including reviewers feedback.

[1] https://github.com/xamarin/xamarin-macios/pull/2476

* [spritekit] Add GKSceneRootNodeType to SKScene too and adjust intro tests

* [tests][intro][macos] Don't skip protocol checks for SceneKit on 64 bits
This commit is contained in:
Sebastien Pouliot 2017-09-28 15:41:29 -04:00 коммит произвёл GitHub
Родитель f2f99e945f
Коммит 6aead42617
5 изменённых файлов: 71 добавлений и 3 удалений

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

@ -12,6 +12,7 @@ using System.ComponentModel;
using XamCore.ObjCRuntime;
using XamCore.Foundation;
using XamCore.SpriteKit;
using XamCore.SceneKit;
using Vector2 = global::OpenTK.Vector2;
using Vector2d = global::OpenTK.Vector2d;
using Vector2i = global::OpenTK.Vector2i;
@ -361,6 +362,16 @@ namespace XamCore.GameplayKit {
[Export ("findActionForAnswers:")]
[return: NullAllowed]
NSObject FindAction (NSDictionary<NSObject, NSObject> answers);
[iOS (11,0), TV (11,0)]
[Mac (10,13, onlyOn64: true)]
[Export ("initWithURL:error:")]
IntPtr Constructor (NSUrl url, [NullAllowed] NSError error);
[iOS (11,0), TV (11,0)]
[Mac (10,13, onlyOn64: true)]
[Export ("exportToURL:error:")]
bool Export (NSUrl url, [NullAllowed] NSError error);
}
[iOS (9,0), Mac (10,11, onlyOn64 : true)]
@ -1786,6 +1797,12 @@ namespace XamCore.GameplayKit {
[return: NullAllowed]
GKScene FromFile (string filename);
[iOS (11,0)][TV (11,0)][Mac (10,13, onlyOn64: true)]
[Static]
[Export ("sceneWithFileNamed:rootNode:")]
[return: NullAllowed]
GKScene FromFile (string filename, IGKSceneRootNodeType rootNode);
[Export ("entities")]
GKEntity [] Entities { get; }
@ -1808,6 +1825,23 @@ namespace XamCore.GameplayKit {
void RemoveGraph (string name);
}
[iOS (11,0)]
[TV (11,0)]
[Mac (10,13, onlyOn64: true)]
[BaseType (typeof(GKComponent))]
interface GKSCNNodeComponent : GKAgentDelegate
{
[Static]
[Export ("componentWithNode:")]
GKSCNNodeComponent FromNode (SCNNode node);
[Export ("initWithNode:")]
IntPtr Constructor (SCNNode node);
[Export ("node")]
SCNNode Node { get; }
}
[iOS (10,0), TV (10,0), Mac (10,12, onlyOn64: true)]
[Category]
[BaseType (typeof (SKNode))]
@ -1833,6 +1867,17 @@ namespace XamCore.GameplayKit {
void SetEntity (GKEntity entity);
}
[iOS (11,0), TV (11,0), Mac (10,13, onlyOn64: true)]
[Category]
[BaseType (typeof (SCNNode))]
interface SCNNode_GameplayKit {
[Export ("entity")]
GKEntity GetEntity ();
[Export ("setEntity:")]
void SetEntity (GKEntity entity);
}
[iOS (10,0), TV (10,0), Mac (10,12, onlyOn64: true)]
[BaseType (typeof (NSObject), Name = "GKQuadtreeNode")] // Renamed to GKQuadtreeNode (lower case t) in Xcode8
[DisableDefaultCtor] // <quote>Used as a hint for faster removal via [GKQuadTree removeData:WithNode:]</quote>

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

@ -45,6 +45,7 @@ using XamCore.SpriteKit;
#if (XAMCORE_2_0 || !MONOMAC) && !WATCH
using XamCore.ModelIO;
using XamCore.Metal;
using XamCore.GameplayKit;
#endif
#if MONOMAC
@ -2029,7 +2030,12 @@ namespace XamCore.SceneKit {
[Watch (3,0)]
[Mac (10,8), iOS (8,0)]
[BaseType (typeof (NSObject))]
interface SCNScene : NSSecureCoding {
interface SCNScene :
#if (XAMCORE_2_0 || !MONOMAC) && !WATCH
GKSceneRootNodeType ,
#endif
NSSecureCoding {
[Static]
[Export ("scene")]
SCNScene Create ();

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

@ -521,7 +521,11 @@ namespace XamCore.SpriteKit {
[Mac (10,9, onlyOn64 : true)]
[Since (7,0)]
[BaseType (typeof (SKEffectNode))]
partial interface SKScene {
interface SKScene
#if (XAMCORE_2_0 || !MONOMAC) && !WATCH
: GKSceneRootNodeType
#endif
{
[Export ("initWithSize:")]
IntPtr Constructor (CGSize size);

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

@ -172,6 +172,16 @@ namespace Introspection {
if (!TestRuntime.CheckXcodeVersion (9, 0))
return true;
break;
case "GKSceneRootNodeType":
// it's an empty protocol, defined by a category and does not reply as expected
switch (type.Name) {
// GameplayKit.framework/Headers/SceneKit+Additions.h
case "SCNScene":
// GameplayKit.framework/Headers/SpriteKit+Additions.h
case "SKScene":
return true;
}
break;
}
return false;
}

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

@ -230,7 +230,10 @@ namespace Introspection {
switch (type.Namespace) {
case "MonoMac.SceneKit":
case "SceneKit":
return IntPtr.Size == 4; // 64bits should be fine
// skip on 32 bits but continue otherwise
if (IntPtr.Size == 4)
return true;
break;
}
return base.Skip (type, protocolName);