Skip to content

Commit

Permalink
[NearbyInteraction][Xcode12] Add manual binding for NINearbyObjectDir…
Browse files Browse the repository at this point in the history
…ectionNotAvailable (#9346)

* nearby interaction manual update + test
  • Loading branch information
whitneyschmidt authored Aug 12, 2020
1 parent be26e31 commit fb665c8
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/NearbyInteraction/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace NearbyInteraction {

[NoWatch, NoTV, NoMac, iOS (14,0)]
[ErrorDomain ("NIErrorDomain")]
[Native]
public enum NIErrorCode : long
{
Expand Down
41 changes: 41 additions & 0 deletions src/NearbyInteraction/NINearbyObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// NearbyInteraction manual bindings
//
// Authors:
// Whitney Schmidt <[email protected]>
//
// Copyright 2020 Microsoft Inc.
//

using System;
using System.Runtime.InteropServices;

using CoreFoundation;
using Foundation;
using ObjCRuntime;
using Vector3 = global::OpenTK.Vector3;

#if __IOS__
namespace NearbyInteraction {
partial class NINearbyObject
{
static Vector3? _DirectionNotAvailable;

// TODO: https://github.com/xamarin/maccore/issues/2274
// We do not have generator support to trampoline Vector3 -> vector_float3 for Fields
[Field ("NINearbyObjectDirectionNotAvailable", "NearbyInteraction")]
public static Vector3 DirectionNotAvailable {
get {
if (_DirectionNotAvailable == null) {
unsafe {
Vector3 *pointer = (Vector3 *) Dlfcn.GetIndirect (Libraries.NearbyInteraction.Handle, "NINearbyObjectDirectionNotAvailable");
_DirectionNotAvailable = *pointer;
}
}
return (Vector3)_DirectionNotAvailable;
}
}
}

}
#endif //__IOS__
3 changes: 3 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,9 @@ NETWORK_SOURCES = \
NEARBYINTERACTION_API_SOURCES = \
NearbyInteraction/Enums.cs \

NEARBYINTERACTION_SOURCES = \
NearbyInteraction/NINearbyObject.cs \

# NetworkExtension

NETWORKEXTENSION_API_SOURCES = \
Expand Down
18 changes: 0 additions & 18 deletions src/nearbyinteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@

namespace NearbyInteraction {

[NoWatch, NoTV, NoMac, iOS (14, 0)]
[Static]
interface NIErrorDomain
{
[Field ("NIErrorDomain")]
NSString Domain { get; }
}

[NoWatch, NoTV, NoMac, iOS (14,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
Expand Down Expand Up @@ -64,16 +56,6 @@ Vector3 Direction {

[Field ("NINearbyObjectDistanceNotAvailable")]
float DistanceNotAvailable { get; }

// TODO: https://github.com/xamarin/maccore/issues/2274
// We do not have generator support to trampoline Vector3 -> vector_float3 for Fields
// There is support for Vector3 -> vector_float3 for properties
// error BI1014: bgen: Unsupported type for Fields: global::OpenTK.Vector3 for 'NearbyInteraction.NINearbyObjectDistance DirectionNotAvailable'.
// extern simd_float3 NINearbyObjectDirectionNotAvailable __attribute__((availability(ios, introduced=14.0))) __attribute__((availability(macos, unavailable))) __attribute__((availability(watchos, unavailable))) __attribute__((availability(tvos, unavailable))) __attribute__((visibility("default"))) __attribute__((availability(swift, unavailable)));
// [Unavailable (PlatformName.Swift)]
// [NoWatch, NoTV, NoMac, iOS (14, 0)]
// [Field ("NINearbyObjectDirectionNotAvailable")]
// [unsupported ExtVector: float __attribute__((ext_vector_type(3)))] NINearbyObjectDirectionNotAvailable { get; }
}

[NoWatch, NoTV, NoMac, iOS (14,0)]
Expand Down
36 changes: 36 additions & 0 deletions tests/monotouch-test/NearbyInteraction/NINearbyObjectTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2020 Microsoft Corp.

#if __IOS__

using System;
using Foundation;
using ObjCRuntime;
using NearbyInteraction;
using NUnit.Framework;
using OpenTK;

namespace MonoTouchFixtures.NearbyInteraction {

[TestFixture]
[Preserve (AllMembers = true)]
public class NINearbyObjectTest {

[Test]
public void DirectionNotAvailable ()
{
TestRuntime.AssertXcodeVersion (12, 0);

Vector3 vect = NINearbyObject.DirectionNotAvailable;

unsafe {
Vector3* v = &vect;
byte* ptr = (byte*) v;
byte zero = 0;
for (var i = 0; i < sizeof (Vector3); i++)
Assert.That (ptr [i], Is.EqualTo (zero), $"Position {i}");
}
}
}
}

#endif // __IOS__
1 change: 1 addition & 0 deletions tests/monotouch-test/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
<Folder Include="Compression\" />
<Folder Include="BackgroundTasks\" />
<Folder Include="WebKit\" />
<Folder Include="NearbyInteraction\" />
</ItemGroup>
<ItemGroup>
<Content Include="AudioToolbox\1.caf" />
Expand Down
3 changes: 0 additions & 3 deletions tests/xtro-sharpie/iOS-NearbyInteraction.ignore

This file was deleted.

1 comment on commit fb665c8

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Test run, Test run' 🔥

Build succeeded
✅ Packages:

API Diff (from stable)
⚠️ API Diff (from PR only) (🔥 breaking changes 🔥)
ℹ️ Generator Diff (please review changes)
🔥 Test run failed 🔥

Test results

2 tests failed, 155 tests passed.

Failed tests

  • monotouch-test/iOS Unified 32-bits - simulator/Debug (all optimizations): TimedOut
  • MTouch tests/NUnit: Failed (Execution failed with exit code 5)

Please sign in to comment.