[net9.0] Merge main into net9.0.
This commit is contained in:
Коммит
8c39f793ac
|
@ -0,0 +1,131 @@
|
|||
# Objective-C protocols
|
||||
|
||||
This document describes how we bind Objective-C protocols in C#, and in
|
||||
particular improvements we've done in .NET 9.
|
||||
|
||||
## Can Objective-C protocols be modeled as C# interfaces?
|
||||
|
||||
Objective-C protocols are quite similar to C# interfaces, except when they're
|
||||
not, and that makes binding them somewhat complicated.
|
||||
|
||||
### Optional/required members
|
||||
|
||||
Objective-C protocols can have both optional and required members. It's always
|
||||
been possible to represent required members in a C# interface (any interface
|
||||
member would be required), but optional members were not possible until C#
|
||||
added support for default interface members in C# 8.
|
||||
|
||||
We represent optional members in two ways:
|
||||
|
||||
* As an extension method on the interface (useful when calling the optional member).
|
||||
* As an IDE feature that would show any optional members from an interface by
|
||||
typing 'override ...' in the text editor (useful when implementing an optional member).
|
||||
|
||||
This has a few drawbacks:
|
||||
|
||||
* There are no extension properties, so optional properties would have to be
|
||||
bound as a pair of GetProperty/SetProperty methods.
|
||||
|
||||
* The IDE feature was obscure, few people knew about it, it broke on pretty
|
||||
much every major release of Visual Studio for Mac, and it was never
|
||||
implemented for Visual Studio on Windows. This made it quite hard to
|
||||
implement optional members in a managed class extending an Objective-C
|
||||
protocol, since developers would have to figure out the correct Export
|
||||
attribute as well as the signature (which is quite complicated for more
|
||||
complex signatures, especially if blocks are involved).
|
||||
|
||||
### Changing requiredness
|
||||
|
||||
It's entirely possible to change a member from being required to being optional
|
||||
in Objective-C. Technically it's also a breaking change to do the opposite (make
|
||||
an optional member required), but Apple does it all the time.
|
||||
|
||||
We've handled this by just not updating the binding until we're able to do
|
||||
breaking changes (which happens very rarely).
|
||||
|
||||
### Static members
|
||||
|
||||
Objective-C protocols can have static members. C# didn't allow for static
|
||||
members in interfaces until C# 11, so until recently there hasn't been any
|
||||
good way to bind static protocol members on a protocol.
|
||||
|
||||
Our workaround is to manually inline every static member in all classes that
|
||||
implemented a given protocol.
|
||||
|
||||
### Initializers
|
||||
|
||||
Objective-C protocols can have initializers (constructors). C# still doesn't
|
||||
allow for constructors in interfaces.
|
||||
|
||||
In the past we haven't bound any protocol initializer at all, we've completely
|
||||
ignored them.
|
||||
|
||||
## Binding in C#
|
||||
|
||||
### Initializers
|
||||
|
||||
Given the following API definition:
|
||||
|
||||
```cs
|
||||
[Protocol]
|
||||
public interface Protocol {
|
||||
[Abstract]
|
||||
[Export ("init")]
|
||||
IntPtr Constructor ();
|
||||
|
||||
[Export ("initWithValue:")]
|
||||
IntPtr Constructor (IntPtr value);
|
||||
|
||||
[Bind ("Create")]
|
||||
[Export ("initWithPlanet:")]
|
||||
IntPtr Constructor ();
|
||||
}
|
||||
```
|
||||
|
||||
we're binding it like this:
|
||||
|
||||
```cs
|
||||
[Protocol ("Protocol")]
|
||||
public interface IProtocol : INativeObject {
|
||||
[Export ("init")]
|
||||
public static T CreateInstance<T> () where T: NSObject, IProtocol { /* default implementation */ }
|
||||
|
||||
[Export ("initWithValue:")]
|
||||
public static T CreateInstance<T> () where T: NSObject, IProtocol { /* default implementation */ }
|
||||
|
||||
[Export ("initWithPlanet:")]
|
||||
public static T Create<T> () where T: NSObject, IProtocol { /* default implementation */ }
|
||||
}
|
||||
```
|
||||
|
||||
In other words: we bind initializers as a static C# factory method that takes
|
||||
a generic type argument specifying the type to instantiate.
|
||||
|
||||
Notes:
|
||||
|
||||
1. Constructors are currently not inlined in any implementing classes, like
|
||||
other members are. This is something we could look into if there's enough
|
||||
interest.
|
||||
2. If a managed class implements a protocol with a constructor, the class has
|
||||
to implement the constructor manually using the `[Export]` attribute in
|
||||
order to conform to the protocol:
|
||||
|
||||
```cs
|
||||
[Protocol]
|
||||
interface IMyProtocol {
|
||||
[Export ("initWithValue:")]
|
||||
IntPtr Constructor (string value);
|
||||
}
|
||||
```
|
||||
|
||||
```cs
|
||||
class MyClass : NSObject, IMyProtocol {
|
||||
public string Value { get; private set; }
|
||||
|
||||
[Export ("initWithValue:")]
|
||||
public MyClass (string value)
|
||||
{
|
||||
this.Value = value;
|
||||
}
|
||||
}
|
||||
```
|
|
@ -39,6 +39,9 @@
|
|||
<Reference Include="Microsoft.Build.Utilities.Core">
|
||||
<HintPath>$(MonoMSBuildBinPath)/Microsoft.Build.Utilities.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Compile Include="..\..\Versions.g.cs">
|
||||
<Link>Versions.g.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyCompanyAttribute ("Microsoft Corp.")]
|
||||
[assembly: AssemblyFileVersionAttribute (VersionConstants.XamarinIOSVersion)]
|
||||
[assembly: AssemblyInformationalVersionAttribute (VersionConstants.XamarinIOSVersion + "." + VersionConstants.NuGetPrereleaseIdentifier + "+" + VersionConstants.NuGetBuildMetadata)]
|
||||
[assembly: AssemblyProductAttribute ("Xamarin.Localization.MSBuild")]
|
||||
[assembly: AssemblyTitleAttribute ("Xamarin.Localization.MSBuild")]
|
||||
[assembly: AssemblyVersionAttribute (VersionConstants.XamarinIOSVersion)]
|
|
@ -7,6 +7,7 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<WarningsAsErrors>Nullable</WarningsAsErrors>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
|
||||
|
@ -27,6 +28,9 @@
|
|||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Versions.g.cs">
|
||||
<Link>Versions.g.cs</Link>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="TranslatedAssemblies/MSBStrings.cs.resx">
|
||||
<Link>MSBStrings.cs.resx</Link>
|
||||
<ManifestResourceName>Xamarin.Localization.MSBuild.MSBStrings.cs</ManifestResourceName>
|
||||
|
|
|
@ -85,9 +85,6 @@
|
|||
<Compile Include="..\..\tools\common\NullableAttributes.cs">
|
||||
<Link>external\NullableAttributes.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Versions.g.cs">
|
||||
<Link>Versions.g.cs</Link>
|
||||
</Compile>
|
||||
<Compile Remove="Errors.designer.cs" /> <!-- The 'CoreResGen' target will add it again from the EmbeddedResource item, this avoids a warning about the file being compiled twice -->
|
||||
<Compile Include="..\..\tools\common\SdkVersions.cs">
|
||||
<Link>external\SdkVersions.cs</Link>
|
||||
|
|
|
@ -1473,6 +1473,27 @@ objc_skip_type (const char *type)
|
|||
// COOP: no managed memory access: any mode
|
||||
switch (type [0]) {
|
||||
case _C_ID:
|
||||
type++;
|
||||
if (*type == '"') {
|
||||
// https://github.com/xamarin/xamarin-macios/issues/18562
|
||||
// @"..." is an object with the class name inside the quotes.
|
||||
// https://github.com/llvm/llvm-project/blob/24a082878f7baec3651de56d54e5aa2b75a21b5f/clang/lib/AST/ASTContext.cpp#L8505-L8516
|
||||
type++;
|
||||
while (*type && *type != '"')
|
||||
type++;
|
||||
type++;
|
||||
} else if (*type == '?' && type [1] == '<') {
|
||||
// https://github.com/xamarin/xamarin-macios/issues/18562
|
||||
// @?<...> is a block pointer
|
||||
// https://github.com/llvm/llvm-project/blob/24a082878f7baec3651de56d54e5aa2b75a21b5f/clang/lib/AST/ASTContext.cpp#L8405-L8426
|
||||
type += 2;
|
||||
do {
|
||||
type = objc_skip_type (type);
|
||||
} while (*type && *type != '>');
|
||||
if (*type)
|
||||
type++;
|
||||
}
|
||||
return type;
|
||||
case _C_CLASS:
|
||||
case _C_SEL:
|
||||
case _C_CHR:
|
||||
|
|
|
@ -331,6 +331,20 @@ get_type_description_length (const char *desc)
|
|||
if (desc [1] == '?') {
|
||||
// Example: [AVAssetImageGenerator generateCGImagesAsynchronouslyForTimes:completionHandler:] = 'v16@0:4@8@?12'
|
||||
length = 2;
|
||||
if (desc [2] == '<') {
|
||||
length = 3;
|
||||
do {
|
||||
int nestedLength = get_type_description_length (desc + length);
|
||||
length += nestedLength;
|
||||
} while (desc [length] && desc [length] != '>');
|
||||
if (desc [length] == '>')
|
||||
length++;
|
||||
}
|
||||
} else if (desc [1] == '"') {
|
||||
length = 2;
|
||||
while (desc [length] && desc [length] != '"')
|
||||
length++;
|
||||
length++;
|
||||
} else {
|
||||
length = 1;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
using System;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -110,19 +111,28 @@ namespace AudioUnit {
|
|||
|
||||
public bool IsInitialized {
|
||||
get {
|
||||
return AUGraphIsInitialized (Handle, out var b) == AUGraphError.OK && b;
|
||||
byte b;
|
||||
unsafe {
|
||||
return AUGraphIsInitialized (Handle, &b) == AUGraphError.OK && b != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOpen {
|
||||
get {
|
||||
return AUGraphIsOpen (Handle, out var b) == AUGraphError.OK && b;
|
||||
byte b;
|
||||
unsafe {
|
||||
return AUGraphIsOpen (Handle, &b) == AUGraphError.OK && b != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRunning {
|
||||
get {
|
||||
return AUGraphIsRunning (Handle, out var b) == AUGraphError.OK && b;
|
||||
byte b;
|
||||
unsafe {
|
||||
return AUGraphIsRunning (Handle, &b) == AUGraphError.OK && b != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +249,11 @@ namespace AudioUnit {
|
|||
|
||||
public int AddNode (AudioComponentDescription description)
|
||||
{
|
||||
var err = AUGraphAddNode (Handle, ref description, out var node);
|
||||
AUGraphError err;
|
||||
int node;
|
||||
unsafe {
|
||||
err = AUGraphAddNode (Handle, &description, &node);
|
||||
}
|
||||
if (err != 0)
|
||||
throw new ArgumentException (String.Format ("Error code: {0}", err));
|
||||
|
||||
|
@ -253,22 +267,34 @@ namespace AudioUnit {
|
|||
|
||||
public AUGraphError GetCPULoad (out float averageCPULoad)
|
||||
{
|
||||
return AUGraphGetCPULoad (Handle, out averageCPULoad);
|
||||
averageCPULoad = default;
|
||||
unsafe {
|
||||
return AUGraphGetCPULoad (Handle, (float*) Unsafe.AsPointer<float> (ref averageCPULoad));
|
||||
}
|
||||
}
|
||||
|
||||
public AUGraphError GetMaxCPULoad (out float maxCPULoad)
|
||||
{
|
||||
return AUGraphGetMaxCPULoad (Handle, out maxCPULoad);
|
||||
maxCPULoad = default;
|
||||
unsafe {
|
||||
return AUGraphGetMaxCPULoad (Handle, (float*) Unsafe.AsPointer<float> (ref maxCPULoad));
|
||||
}
|
||||
}
|
||||
|
||||
public AUGraphError GetNode (uint index, out int node)
|
||||
{
|
||||
return AUGraphGetIndNode (Handle, index, out node);
|
||||
node = default;
|
||||
unsafe {
|
||||
return AUGraphGetIndNode (Handle, index, (int*) Unsafe.AsPointer<int> (ref node));
|
||||
}
|
||||
}
|
||||
|
||||
public AUGraphError GetNodeCount (out int count)
|
||||
{
|
||||
return AUGraphGetNodeCount (Handle, out count);
|
||||
count = default;
|
||||
unsafe {
|
||||
return AUGraphGetNodeCount (Handle, (int*) Unsafe.AsPointer<int> (ref count));
|
||||
}
|
||||
}
|
||||
|
||||
public AudioUnit GetNodeInfo (int node)
|
||||
|
@ -287,7 +313,10 @@ namespace AudioUnit {
|
|||
|
||||
public AudioUnit? GetNodeInfo (int node, out AUGraphError error)
|
||||
{
|
||||
error = AUGraphNodeInfo (GetCheckedHandle (), node, IntPtr.Zero, out var ptr);
|
||||
IntPtr ptr;
|
||||
unsafe {
|
||||
error = AUGraphNodeInfo (GetCheckedHandle (), node, null, &ptr);
|
||||
}
|
||||
|
||||
if (error != AUGraphError.OK || ptr == IntPtr.Zero)
|
||||
return null;
|
||||
|
@ -299,7 +328,11 @@ namespace AudioUnit {
|
|||
// Following current Api behaviour of returning an AudioUnit instead of an error
|
||||
public AudioUnit? GetNodeInfo (int node, out AudioComponentDescription cd, out AUGraphError error)
|
||||
{
|
||||
error = AUGraphNodeInfo (GetCheckedHandle (), node, out cd, out var ptr);
|
||||
IntPtr ptr;
|
||||
cd = default;
|
||||
unsafe {
|
||||
error = AUGraphNodeInfo (GetCheckedHandle (), node, (AudioComponentDescription*) Unsafe.AsPointer<AudioComponentDescription> (ref cd), &ptr);
|
||||
}
|
||||
|
||||
if (error != AUGraphError.OK || ptr == IntPtr.Zero)
|
||||
return null;
|
||||
|
@ -309,12 +342,18 @@ namespace AudioUnit {
|
|||
|
||||
public AUGraphError GetNumberOfInteractions (out uint interactionsCount)
|
||||
{
|
||||
return AUGraphGetNumberOfInteractions (Handle, out interactionsCount);
|
||||
interactionsCount = default;
|
||||
unsafe {
|
||||
return AUGraphGetNumberOfInteractions (Handle, (uint*) Unsafe.AsPointer<uint> (ref interactionsCount));
|
||||
}
|
||||
}
|
||||
|
||||
public AUGraphError GetNumberOfInteractions (int node, out uint interactionsCount)
|
||||
{
|
||||
return AUGraphCountNodeInteractions (Handle, node, out interactionsCount);
|
||||
interactionsCount = default;
|
||||
unsafe {
|
||||
return AUGraphCountNodeInteractions (Handle, node, (uint*) Unsafe.AsPointer<uint> (ref interactionsCount));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -357,15 +396,15 @@ namespace AudioUnit {
|
|||
nodesCallbacks [destInputNumber] = renderDelegate;
|
||||
|
||||
var cb = new AURenderCallbackStruct ();
|
||||
#if NET
|
||||
unsafe {
|
||||
#if NET
|
||||
cb.Proc = &RenderCallbackImpl;
|
||||
}
|
||||
#else
|
||||
cb.Proc = Marshal.GetFunctionPointerForDelegate (CreateRenderCallback);
|
||||
cb.Proc = Marshal.GetFunctionPointerForDelegate (CreateRenderCallback);
|
||||
#endif
|
||||
cb.ProcRefCon = GCHandle.ToIntPtr (gcHandle);
|
||||
return AUGraphSetNodeInputCallback (Handle, destNode, destInputNumber, ref cb);
|
||||
cb.ProcRefCon = GCHandle.ToIntPtr (gcHandle);
|
||||
return AUGraphSetNodeInputCallback (Handle, destNode, destInputNumber, &cb);
|
||||
}
|
||||
}
|
||||
#if NET
|
||||
[UnmanagedCallersOnly]
|
||||
|
@ -415,7 +454,10 @@ namespace AudioUnit {
|
|||
|
||||
public bool Update ()
|
||||
{
|
||||
return AUGraphUpdate (Handle, out var isUpdated) == AUGraphError.OK && isUpdated;
|
||||
byte isUpdated;
|
||||
unsafe {
|
||||
return AUGraphUpdate (Handle, &isUpdated) == AUGraphError.OK && isUpdated != 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Quote from Learning CoreAudio Book:
|
||||
|
@ -447,22 +489,19 @@ namespace AudioUnit {
|
|||
static extern int /* OSStatus */ AUGraphOpen (IntPtr inGraph);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphAddNode (IntPtr inGraph, ref AudioComponentDescription inDescription, out int /* AUNode = SInt32* */ outNode);
|
||||
unsafe static extern AUGraphError AUGraphAddNode (IntPtr inGraph, AudioComponentDescription* inDescription, int* /* AUNode = SInt32* */ outNode);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphRemoveNode (IntPtr inGraph, int /* AUNode = SInt32 */ inNode);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphGetNodeCount (IntPtr inGraph, out int /* UInt32* */ outNumberOfNodes);
|
||||
unsafe static extern AUGraphError AUGraphGetNodeCount (IntPtr inGraph, int* /* UInt32* */ outNumberOfNodes);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphGetIndNode (IntPtr inGraph, uint /* UInt32 */ inIndex, out int /* AUNode = SInt32* */ outNode);
|
||||
unsafe static extern AUGraphError AUGraphGetIndNode (IntPtr inGraph, uint /* UInt32 */ inIndex, int* /* AUNode = SInt32* */ outNode);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphNodeInfo (IntPtr inGraph, int /* AUNode = SInt32 */ inNode, IntPtr outDescription, out IntPtr outAudioUnit);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphNodeInfo (IntPtr inGraph, int /* AUNode = SInt32 */ inNode, out AudioComponentDescription outDescription, out IntPtr outAudioUnit);
|
||||
unsafe static extern AUGraphError AUGraphNodeInfo (IntPtr inGraph, int /* AUNode = SInt32 */ inNode, AudioComponentDescription* outDescription, IntPtr* outAudioUnit);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphClearConnections (IntPtr inGraph);
|
||||
|
@ -474,10 +513,10 @@ namespace AudioUnit {
|
|||
static extern AUGraphError AUGraphDisconnectNodeInput (IntPtr inGraph, int /* AUNode = SInt32 */ inDestNode, uint /* UInt32 */ inDestInputNumber);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphGetNumberOfInteractions (IntPtr inGraph, out uint /* UInt32* */ outNumInteractions);
|
||||
unsafe static extern AUGraphError AUGraphGetNumberOfInteractions (IntPtr inGraph, uint* /* UInt32* */ outNumInteractions);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphCountNodeInteractions (IntPtr inGraph, int /* AUNode = SInt32 */ inNode, out uint /* UInt32* */ outNumInteractions);
|
||||
unsafe static extern AUGraphError AUGraphCountNodeInteractions (IntPtr inGraph, int /* AUNode = SInt32 */ inNode, uint* /* UInt32* */ outNumInteractions);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphInitialize (IntPtr inGraph);
|
||||
|
@ -513,25 +552,25 @@ namespace AudioUnit {
|
|||
static extern int /* OSStatus */ DisposeAUGraph (IntPtr inGraph);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphIsOpen (IntPtr inGraph, [MarshalAs (UnmanagedType.I1)] out bool outIsOpen);
|
||||
unsafe static extern AUGraphError AUGraphIsOpen (IntPtr inGraph, byte* outIsOpen);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphIsInitialized (IntPtr inGraph, [MarshalAs (UnmanagedType.I1)] out bool outIsInitialized);
|
||||
unsafe static extern AUGraphError AUGraphIsInitialized (IntPtr inGraph, byte* outIsInitialized);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphIsRunning (IntPtr inGraph, [MarshalAs (UnmanagedType.I1)] out bool outIsRunning);
|
||||
unsafe static extern AUGraphError AUGraphIsRunning (IntPtr inGraph, byte* outIsRunning);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphGetCPULoad (IntPtr inGraph, out float /* Float32* */ outAverageCPULoad);
|
||||
unsafe static extern AUGraphError AUGraphGetCPULoad (IntPtr inGraph, float* /* Float32* */ outAverageCPULoad);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphGetMaxCPULoad (IntPtr inGraph, out float /* Float32* */ outMaxLoad);
|
||||
unsafe static extern AUGraphError AUGraphGetMaxCPULoad (IntPtr inGraph, float* /* Float32* */ outMaxLoad);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphSetNodeInputCallback (IntPtr inGraph, int /* AUNode = SInt32 */ inDestNode, uint /* UInt32 */ inDestInputNumber, ref AURenderCallbackStruct inInputCallback);
|
||||
unsafe static extern AUGraphError AUGraphSetNodeInputCallback (IntPtr inGraph, int /* AUNode = SInt32 */ inDestNode, uint /* UInt32 */ inDestInputNumber, AURenderCallbackStruct* inInputCallback);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern AUGraphError AUGraphUpdate (IntPtr inGraph, [MarshalAs (UnmanagedType.I1)] out bool outIsUpdated);
|
||||
unsafe static extern AUGraphError AUGraphUpdate (IntPtr inGraph, byte* outIsUpdated);
|
||||
|
||||
[DllImport (Constants.AudioToolboxLibrary)]
|
||||
static extern void CAShow (IntPtr handle);
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
using ObjCRuntime;
|
||||
using Foundation;
|
||||
|
||||
namespace GameController {
|
||||
|
||||
#if !XAMCORE_5_0
|
||||
// The GCMouse doesn't conform to NSCoding/NSSecureCoding, but it probably did in an early beta, which is why we declared it as such.
|
||||
public partial class GCMouse : INSCoding, INSSecureCoding {
|
||||
[BindingImpl (BindingImplOptions.Optimizable)]
|
||||
[EditorBrowsable (EditorBrowsableState.Never)]
|
||||
public GCMouse (NSCoder coder) : base (NSObjectFlag.Empty)
|
||||
{
|
||||
if (IsDirectBinding) {
|
||||
InitializeHandle (global::ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr (this.Handle, Selector.GetHandle ("initWithCoder:"), coder.Handle), "initWithCoder:");
|
||||
} else {
|
||||
InitializeHandle (global::ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr (this.SuperHandle, Selector.GetHandle ("initWithCoder:"), coder.Handle), "initWithCoder:");
|
||||
}
|
||||
}
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("ios14.0")]
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("tvos14.0")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
[BindingImpl (BindingImplOptions.Optimizable)]
|
||||
[EditorBrowsable (EditorBrowsableState.Never)]
|
||||
public virtual void EncodeTo (NSCoder encoder)
|
||||
{
|
||||
var encoder__handle__ = encoder!.GetNonNullHandle (nameof (encoder));
|
||||
#if NET
|
||||
if (IsDirectBinding) {
|
||||
global::ObjCRuntime.Messaging.void_objc_msgSend_NativeHandle (this.Handle, Selector.GetHandle ("encodeWithCoder:"), encoder__handle__);
|
||||
} else {
|
||||
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_NativeHandle (this.SuperHandle, Selector.GetHandle ("encodeWithCoder:"), encoder__handle__);
|
||||
}
|
||||
#else
|
||||
if (IsDirectBinding) {
|
||||
global::ObjCRuntime.Messaging.void_objc_msgSend_IntPtr (this.Handle, Selector.GetHandle ("encodeWithCoder:"), encoder__handle__);
|
||||
} else {
|
||||
global::ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (this.SuperHandle, Selector.GetHandle ("encodeWithCoder:"), encoder__handle__);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // !XAMCORE_5_0
|
||||
}
|
|
@ -41,8 +41,7 @@ namespace Network {
|
|||
#endif
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
static extern bool nw_protocol_definition_is_equal (OS_nw_protocol_definition definition1, OS_nw_protocol_definition definition2);
|
||||
static extern byte nw_protocol_definition_is_equal (OS_nw_protocol_definition definition1, OS_nw_protocol_definition definition2);
|
||||
|
||||
public bool Equals (object other)
|
||||
{
|
||||
|
@ -50,7 +49,7 @@ namespace Network {
|
|||
return false;
|
||||
if (!(other is NWProtocolDefinition otherDefinition))
|
||||
return false;
|
||||
return nw_protocol_definition_is_equal (GetCheckedHandle (), otherDefinition.Handle);
|
||||
return nw_protocol_definition_is_equal (GetCheckedHandle (), otherDefinition.Handle) != 0;
|
||||
}
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
|
|
|
@ -47,13 +47,13 @@ namespace Network {
|
|||
=> nw_ip_options_set_hop_limit (GetCheckedHandle (), (byte) hopLimit);
|
||||
|
||||
public void SetUseMinimumMtu (bool useMinimumMtu)
|
||||
=> nw_ip_options_set_use_minimum_mtu (GetCheckedHandle (), useMinimumMtu);
|
||||
=> nw_ip_options_set_use_minimum_mtu (GetCheckedHandle (), useMinimumMtu.AsByte ());
|
||||
|
||||
public void SetDisableFragmentation (bool disableFragmentation)
|
||||
=> nw_ip_options_set_disable_fragmentation (GetCheckedHandle (), disableFragmentation);
|
||||
=> nw_ip_options_set_disable_fragmentation (GetCheckedHandle (), disableFragmentation.AsByte ());
|
||||
|
||||
public void SetCalculateReceiveTime (bool shouldCalculateReceiveTime)
|
||||
=> nw_ip_options_set_calculate_receive_time (GetCheckedHandle (), shouldCalculateReceiveTime);
|
||||
=> nw_ip_options_set_calculate_receive_time (GetCheckedHandle (), shouldCalculateReceiveTime.AsByte ());
|
||||
|
||||
public void SetIPLocalAddressPreference (NWIPLocalAddressPreference localAddressPreference)
|
||||
=> nw_ip_options_set_local_address_preference (GetCheckedHandle (), localAddressPreference);
|
||||
|
@ -70,7 +70,7 @@ namespace Network {
|
|||
[MacCatalyst (15, 0)]
|
||||
#endif
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
static extern void nw_ip_options_set_disable_multicast_loopback (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool disableMulticastLoopback);
|
||||
static extern void nw_ip_options_set_disable_multicast_loopback (OS_nw_protocol_options options, byte disableMulticastLoopback);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos15.0")]
|
||||
|
@ -84,6 +84,6 @@ namespace Network {
|
|||
[MacCatalyst (15, 0)]
|
||||
#endif
|
||||
public void DisableMulticastLoopback (bool disable)
|
||||
=> nw_ip_options_set_disable_multicast_loopback (GetCheckedHandle (), disable);
|
||||
=> nw_ip_options_set_disable_multicast_loopback (GetCheckedHandle (), disable.AsByte ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,28 +71,24 @@ namespace Network {
|
|||
public NWProtocolDefinition ProtocolDefinition => new NWProtocolDefinition (nw_protocol_metadata_copy_definition (GetCheckedHandle ()), owns: true);
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
internal static extern bool nw_protocol_metadata_is_ip (OS_nw_protocol_metadata metadata);
|
||||
internal static extern byte nw_protocol_metadata_is_ip (OS_nw_protocol_metadata metadata);
|
||||
|
||||
public bool IsIP => nw_protocol_metadata_is_ip (GetCheckedHandle ());
|
||||
public bool IsIP => nw_protocol_metadata_is_ip (GetCheckedHandle ()) != 0;
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
internal static extern bool nw_protocol_metadata_is_udp (OS_nw_protocol_metadata metadata);
|
||||
internal static extern byte nw_protocol_metadata_is_udp (OS_nw_protocol_metadata metadata);
|
||||
|
||||
public bool IsUdp => nw_protocol_metadata_is_udp (GetCheckedHandle ());
|
||||
public bool IsUdp => nw_protocol_metadata_is_udp (GetCheckedHandle ()) != 0;
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
internal static extern bool nw_protocol_metadata_is_tls (OS_nw_protocol_metadata metadata);
|
||||
internal static extern byte nw_protocol_metadata_is_tls (OS_nw_protocol_metadata metadata);
|
||||
|
||||
public bool IsTls => nw_protocol_metadata_is_tls (GetCheckedHandle ());
|
||||
public bool IsTls => nw_protocol_metadata_is_tls (GetCheckedHandle ()) != 0;
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
internal static extern bool nw_protocol_metadata_is_tcp (OS_nw_protocol_metadata metadata);
|
||||
internal static extern byte nw_protocol_metadata_is_tcp (OS_nw_protocol_metadata metadata);
|
||||
|
||||
public bool IsTcp => nw_protocol_metadata_is_tcp (GetCheckedHandle ());
|
||||
public bool IsTcp => nw_protocol_metadata_is_tcp (GetCheckedHandle ()) != 0;
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos15.0")]
|
||||
|
@ -106,8 +102,7 @@ namespace Network {
|
|||
[MacCatalyst (15, 0)]
|
||||
#endif
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
static extern bool nw_protocol_metadata_is_quic (OS_nw_protocol_metadata metadata);
|
||||
static extern byte nw_protocol_metadata_is_quic (OS_nw_protocol_metadata metadata);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos15.0")]
|
||||
|
@ -120,7 +115,7 @@ namespace Network {
|
|||
[iOS (15, 0)]
|
||||
[MacCatalyst (15, 0)]
|
||||
#endif
|
||||
public bool IsQuic => nw_protocol_metadata_is_quic (GetCheckedHandle ());
|
||||
public bool IsQuic => nw_protocol_metadata_is_quic (GetCheckedHandle ()) != 0;
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal static extern IntPtr nw_tls_copy_sec_protocol_metadata (IntPtr handle);
|
||||
|
@ -249,8 +244,7 @@ namespace Network {
|
|||
[iOS (13, 0)]
|
||||
#endif
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
internal static extern bool nw_protocol_metadata_is_framer_message (OS_nw_protocol_metadata metadata);
|
||||
internal static extern byte nw_protocol_metadata_is_framer_message (OS_nw_protocol_metadata metadata);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos13.0")]
|
||||
|
@ -261,7 +255,7 @@ namespace Network {
|
|||
[TV (13, 0)]
|
||||
[iOS (13, 0)]
|
||||
#endif
|
||||
public bool IsFramerMessage => nw_protocol_metadata_is_framer_message (GetCheckedHandle ());
|
||||
public bool IsFramerMessage => nw_protocol_metadata_is_framer_message (GetCheckedHandle ()) != 0;
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos13.0")]
|
||||
|
@ -273,8 +267,7 @@ namespace Network {
|
|||
[iOS (13, 0)]
|
||||
#endif
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
internal static extern bool nw_protocol_metadata_is_ws (OS_nw_protocol_metadata metadata);
|
||||
internal static extern byte nw_protocol_metadata_is_ws (OS_nw_protocol_metadata metadata);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos13.0")]
|
||||
|
@ -285,6 +278,6 @@ namespace Network {
|
|||
[TV (13, 0)]
|
||||
[iOS (13, 0)]
|
||||
#endif
|
||||
public bool IsWebSocket => nw_protocol_metadata_is_ws (GetCheckedHandle ());
|
||||
public bool IsWebSocket => nw_protocol_metadata_is_ws (GetCheckedHandle ()) != 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,35 +129,35 @@ namespace Network {
|
|||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal static extern void nw_ip_options_set_use_minimum_mtu (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool use_minimum_mtu);
|
||||
internal static extern void nw_ip_options_set_use_minimum_mtu (IntPtr options, byte use_minimum_mtu);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
|
||||
public void IPSetUseMinimumMtu (bool useMinimumMtu)
|
||||
{
|
||||
nw_ip_options_set_use_minimum_mtu (GetCheckedHandle (), useMinimumMtu);
|
||||
nw_ip_options_set_use_minimum_mtu (GetCheckedHandle (), useMinimumMtu.AsByte ());
|
||||
}
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal static extern void nw_ip_options_set_disable_fragmentation (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool disable_fragmentation);
|
||||
internal static extern void nw_ip_options_set_disable_fragmentation (IntPtr options, byte disable_fragmentation);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
|
||||
public void IPSetDisableFragmentation (bool disableFragmentation)
|
||||
{
|
||||
nw_ip_options_set_disable_fragmentation (GetCheckedHandle (), disableFragmentation);
|
||||
nw_ip_options_set_disable_fragmentation (GetCheckedHandle (), disableFragmentation.AsByte ());
|
||||
}
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal static extern void nw_ip_options_set_calculate_receive_time (IntPtr options, [MarshalAs (UnmanagedType.I1)] bool calculateReceiveTime);
|
||||
internal static extern void nw_ip_options_set_calculate_receive_time (IntPtr options, byte calculateReceiveTime);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolIPOptions' class instead.")]
|
||||
public void IPSetCalculateReceiveTime (bool calculateReceiveTime)
|
||||
{
|
||||
nw_ip_options_set_calculate_receive_time (GetCheckedHandle (), calculateReceiveTime);
|
||||
nw_ip_options_set_calculate_receive_time (GetCheckedHandle (), calculateReceiveTime.AsByte ());
|
||||
}
|
||||
#endif // !NET
|
||||
|
||||
|
@ -187,35 +187,35 @@ namespace Network {
|
|||
//
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_no_delay (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noDelay);
|
||||
internal extern static void nw_tcp_options_set_no_delay (IntPtr handle, byte noDelay);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay);
|
||||
public void TcpSetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_no_push (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noPush);
|
||||
internal extern static void nw_tcp_options_set_no_push (IntPtr handle, byte noPush);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetNoPush (bool noPush) => nw_tcp_options_set_no_push (GetCheckedHandle (), noPush);
|
||||
public void TcpSetNoPush (bool noPush) => nw_tcp_options_set_no_push (GetCheckedHandle (), noPush.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_no_options (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool noOptions);
|
||||
internal extern static void nw_tcp_options_set_no_options (IntPtr handle, byte noOptions);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions);
|
||||
public void TcpSetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_enable_keepalive (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool enableKeepAlive);
|
||||
internal extern static void nw_tcp_options_set_enable_keepalive (IntPtr handle, byte enableKeepAlive);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive);
|
||||
public void TcpSetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
|
@ -275,46 +275,46 @@ namespace Network {
|
|||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_retransmit_fin_drop (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool retransmitFinDrop);
|
||||
internal extern static void nw_tcp_options_set_retransmit_fin_drop (IntPtr handle, byte retransmitFinDrop);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetRetransmitFinDrop (bool retransmitFinDrop) => nw_tcp_options_set_retransmit_fin_drop (GetCheckedHandle (), retransmitFinDrop);
|
||||
public void TcpSetRetransmitFinDrop (bool retransmitFinDrop) => nw_tcp_options_set_retransmit_fin_drop (GetCheckedHandle (), retransmitFinDrop.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_disable_ack_stretching (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool disableAckStretching);
|
||||
internal extern static void nw_tcp_options_set_disable_ack_stretching (IntPtr handle, byte disableAckStretching);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetDisableAckStretching (bool disableAckStretching) => nw_tcp_options_set_disable_ack_stretching (GetCheckedHandle (), disableAckStretching);
|
||||
public void TcpSetDisableAckStretching (bool disableAckStretching) => nw_tcp_options_set_disable_ack_stretching (GetCheckedHandle (), disableAckStretching.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_enable_fast_open (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool enableFastOpen);
|
||||
internal extern static void nw_tcp_options_set_enable_fast_open (IntPtr handle, byte enableFastOpen);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen);
|
||||
public void TcpSetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_tcp_options_set_disable_ecn (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool disableEcn);
|
||||
internal extern static void nw_tcp_options_set_disable_ecn (IntPtr handle, byte disableEcn);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolTcpOptions' class instead.")]
|
||||
public void TcpSetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn);
|
||||
public void TcpSetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
//
|
||||
// UDP Options
|
||||
//
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
internal extern static void nw_udp_options_set_prefer_no_checksum (IntPtr handle, [MarshalAs (UnmanagedType.U1)] bool preferNoChecksums);
|
||||
internal extern static void nw_udp_options_set_prefer_no_checksum (IntPtr handle, byte preferNoChecksums);
|
||||
|
||||
#if !NET
|
||||
[Obsolete ("Use the 'NWProtocolUdpOptions' class instead.")]
|
||||
public void UdpSetPreferNoChecksum (bool preferNoChecksums) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksums);
|
||||
public void UdpSetPreferNoChecksum (bool preferNoChecksums) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksums.AsByte ());
|
||||
#endif // !NET
|
||||
|
||||
//
|
||||
|
@ -341,9 +341,8 @@ namespace Network {
|
|||
[MacCatalyst (15, 0)]
|
||||
#endif
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
static extern bool nw_protocol_options_is_quic (IntPtr options);
|
||||
static extern byte nw_protocol_options_is_quic (IntPtr options);
|
||||
|
||||
public bool IsQuic => nw_protocol_options_is_quic (GetCheckedHandle ());
|
||||
public bool IsQuic => nw_protocol_options_is_quic (GetCheckedHandle ()) != 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,15 +53,14 @@ namespace Network {
|
|||
=> new SecProtocolOptions (nw_quic_copy_sec_protocol_options (GetCheckedHandle ()), true);
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
static extern bool nw_quic_get_stream_is_unidirectional (OS_nw_protocol_options options);
|
||||
static extern byte nw_quic_get_stream_is_unidirectional (OS_nw_protocol_options options);
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
static extern void nw_quic_set_stream_is_unidirectional (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool isUnidirectional);
|
||||
static extern void nw_quic_set_stream_is_unidirectional (OS_nw_protocol_options options, byte isUnidirectional);
|
||||
|
||||
public bool StreamIsUnidirectional {
|
||||
get => nw_quic_get_stream_is_unidirectional (GetCheckedHandle ());
|
||||
set => nw_quic_set_stream_is_unidirectional (GetCheckedHandle (), value);
|
||||
get => nw_quic_get_stream_is_unidirectional (GetCheckedHandle ()) != 0;
|
||||
set => nw_quic_set_stream_is_unidirectional (GetCheckedHandle (), value.AsByte ());
|
||||
}
|
||||
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
|
@ -208,8 +207,7 @@ namespace Network {
|
|||
[Watch (9, 0)]
|
||||
#endif
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
static extern bool nw_quic_get_stream_is_datagram (OS_nw_protocol_options options);
|
||||
static extern byte nw_quic_get_stream_is_datagram (OS_nw_protocol_options options);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos16.0")]
|
||||
|
@ -223,7 +221,7 @@ namespace Network {
|
|||
[Watch (9, 0)]
|
||||
#endif
|
||||
[DllImport (Constants.NetworkLibrary)]
|
||||
static extern void nw_quic_set_stream_is_datagram (OS_nw_protocol_options options, [MarshalAs (UnmanagedType.I1)] bool is_datagram);
|
||||
static extern void nw_quic_set_stream_is_datagram (OS_nw_protocol_options options, byte is_datagram);
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos16.0")]
|
||||
|
@ -237,8 +235,8 @@ namespace Network {
|
|||
[Watch (9, 0)]
|
||||
#endif
|
||||
public bool StreamIsDatagram {
|
||||
get => nw_quic_get_stream_is_datagram (GetCheckedHandle ());
|
||||
set => nw_quic_set_stream_is_datagram (GetCheckedHandle (), value);
|
||||
get => nw_quic_get_stream_is_datagram (GetCheckedHandle ()) != 0;
|
||||
set => nw_quic_set_stream_is_datagram (GetCheckedHandle (), value.AsByte ());
|
||||
}
|
||||
|
||||
#if NET
|
||||
|
|
|
@ -41,13 +41,13 @@ namespace Network {
|
|||
|
||||
public NWProtocolTcpOptions () : this (nw_tcp_create_options (), owns: true) { }
|
||||
|
||||
public void SetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay);
|
||||
public void SetNoDelay (bool noDelay) => nw_tcp_options_set_no_delay (GetCheckedHandle (), noDelay.AsByte ());
|
||||
|
||||
public void SetNoPush (bool noPush) => nw_tcp_options_set_no_push (GetCheckedHandle (), noPush);
|
||||
public void SetNoPush (bool noPush) => nw_tcp_options_set_no_push (GetCheckedHandle (), noPush.AsByte ());
|
||||
|
||||
public void SetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions);
|
||||
public void SetNoOptions (bool noOptions) => nw_tcp_options_set_no_options (GetCheckedHandle (), noOptions.AsByte ());
|
||||
|
||||
public void SetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive);
|
||||
public void SetEnableKeepAlive (bool enableKeepAlive) => nw_tcp_options_set_enable_keepalive (GetCheckedHandle (), enableKeepAlive.AsByte ());
|
||||
|
||||
public void SetKeepAliveCount (uint keepAliveCount) => nw_tcp_options_set_keepalive_count (GetCheckedHandle (), keepAliveCount);
|
||||
|
||||
|
@ -69,14 +69,14 @@ namespace Network {
|
|||
public void SetRetransmitConnectionDropTime (TimeSpan connectionDropTime)
|
||||
=> nw_tcp_options_set_retransmit_connection_drop_time (GetCheckedHandle (), (uint) connectionDropTime.Seconds);
|
||||
|
||||
public void SetRetransmitFinDrop (bool retransmitFinDrop) => nw_tcp_options_set_retransmit_fin_drop (GetCheckedHandle (), retransmitFinDrop);
|
||||
public void SetRetransmitFinDrop (bool retransmitFinDrop) => nw_tcp_options_set_retransmit_fin_drop (GetCheckedHandle (), retransmitFinDrop.AsByte ());
|
||||
|
||||
public void SetDisableAckStretching (bool disableAckStretching)
|
||||
=> nw_tcp_options_set_disable_ack_stretching (GetCheckedHandle (), disableAckStretching);
|
||||
=> nw_tcp_options_set_disable_ack_stretching (GetCheckedHandle (), disableAckStretching.AsByte ());
|
||||
|
||||
public void SetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen);
|
||||
public void SetEnableFastOpen (bool enableFastOpen) => nw_tcp_options_set_enable_fast_open (GetCheckedHandle (), enableFastOpen.AsByte ());
|
||||
|
||||
public void SetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn);
|
||||
public void SetDisableEcn (bool disableEcn) => nw_tcp_options_set_disable_ecn (GetCheckedHandle (), disableEcn.AsByte ());
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("tvos15.0")]
|
||||
|
|
|
@ -35,6 +35,6 @@ namespace Network {
|
|||
|
||||
public NWProtocolUdpOptions () : this (nw_udp_create_options (), owns: true) { }
|
||||
|
||||
public void SetPreferNoChecksum (bool preferNoChecksum) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksum);
|
||||
public void SetPreferNoChecksum (bool preferNoChecksum) => nw_udp_options_set_prefer_no_checksum (GetCheckedHandle (), preferNoChecksum.AsByte ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -471,7 +471,7 @@ namespace OpenTK {
|
|||
/// <param name="height">The height of the projection volume.</param>
|
||||
/// <param name="zNear">The near edge of the projection volume.</param>
|
||||
/// <param name="zFar">The far edge of the projection volume.</param>
|
||||
/// <rereturns>The resulting Matrix4 instance.</rereturns>
|
||||
/// <returns>The resulting Matrix4 instance.</rereturns>
|
||||
public static Matrix4 CreateOrthographic (float width, float height, float zNear, float zFar)
|
||||
{
|
||||
Matrix4 result;
|
||||
|
|
|
@ -471,7 +471,7 @@ namespace OpenTK {
|
|||
/// <param name="height">The height of the projection volume.</param>
|
||||
/// <param name="zNear">The near edge of the projection volume.</param>
|
||||
/// <param name="zFar">The far edge of the projection volume.</param>
|
||||
/// <rereturns>The resulting Matrix4d instance.</rereturns>
|
||||
/// <returns>The resulting Matrix4d instance.</returns>
|
||||
public static Matrix4d CreateOrthographic (double width, double height, double zNear, double zFar)
|
||||
{
|
||||
Matrix4d result;
|
||||
|
|
|
@ -580,7 +580,7 @@ namespace SceneKit {
|
|||
/// <param name="height">The height of the projection volume.</param>
|
||||
/// <param name="zNear">The near edge of the projection volume.</param>
|
||||
/// <param name="zFar">The far edge of the projection volume.</param>
|
||||
/// <rereturns>The resulting SCNMatrix4 instance.</rereturns>
|
||||
/// <returns>The resulting SCNMatrix4 instance.</returns>
|
||||
public static SCNMatrix4 CreateOrthographic (pfloat width, pfloat height, pfloat zNear, pfloat zFar)
|
||||
{
|
||||
SCNMatrix4 result;
|
||||
|
|
|
@ -647,7 +647,7 @@ namespace SceneKit {
|
|||
/// <param name="height">The height of the projection volume.</param>
|
||||
/// <param name="zNear">The near edge of the projection volume.</param>
|
||||
/// <param name="zFar">The far edge of the projection volume.</param>
|
||||
/// <rereturns>The resulting SCNMatrix4 instance.</rereturns>
|
||||
/// <returns>The resulting SCNMatrix4 instance.</returns>
|
||||
public static SCNMatrix4 CreateOrthographic (pfloat width, pfloat height, pfloat zNear, pfloat zFar)
|
||||
{
|
||||
SCNMatrix4 result;
|
||||
|
@ -777,7 +777,7 @@ namespace SceneKit {
|
|||
#region CreatePerspectiveOffCenter
|
||||
|
||||
/// <summary>
|
||||
/// Creates an perspective projection matrix.
|
||||
/// Creates a perspective projection matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">Left edge of the view frustum</param>
|
||||
/// <param name="right">Right edge of the view frustum</param>
|
||||
|
@ -818,7 +818,7 @@ namespace SceneKit {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an perspective projection matrix.
|
||||
/// Creates a perspective projection matrix.
|
||||
/// </summary>
|
||||
/// <param name="left">Left edge of the view frustum</param>
|
||||
/// <param name="right">Right edge of the view frustum</param>
|
||||
|
@ -849,7 +849,7 @@ namespace SceneKit {
|
|||
/// <summary>
|
||||
/// Build a scaling matrix
|
||||
/// </summary>
|
||||
/// <param name="scale">Single scale factor for x,y and z axes</param>
|
||||
/// <param name="scale">Single scale factor for x, y and z axes</param>
|
||||
/// <returns>A scaling matrix</returns>
|
||||
public static SCNMatrix4 Scale (pfloat scale)
|
||||
{
|
||||
|
@ -859,7 +859,7 @@ namespace SceneKit {
|
|||
/// <summary>
|
||||
/// Build a scaling matrix
|
||||
/// </summary>
|
||||
/// <param name="scale">Scale factors for x,y and z axes</param>
|
||||
/// <param name="scale">Scale factors for x, y and z axes</param>
|
||||
/// <returns>A scaling matrix</returns>
|
||||
public static SCNMatrix4 Scale (SCNVector3 scale)
|
||||
{
|
||||
|
@ -1147,7 +1147,7 @@ namespace SceneKit {
|
|||
/// Calculate the inverse of the given matrix
|
||||
/// </summary>
|
||||
/// <param name="matrix">The matrix to invert</param>
|
||||
/// <returns>The inverse of the given matrix if it has one, or the input if it is singular</returns>
|
||||
/// <returns>The inverse of the given matrix if it has one.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown if the SCNMatrix4 is singular.</exception>
|
||||
public static SCNMatrix4 Invert (SCNMatrix4 matrix)
|
||||
{
|
||||
|
|
|
@ -238,7 +238,7 @@ namespace SceneKit {
|
|||
public static readonly SCNVector3 UnitY = new SCNVector3 (0, 1, 0);
|
||||
|
||||
/// <summary>
|
||||
/// /// Defines a unit-length SCNVector3 that points towards the Z-axis.
|
||||
/// Defines a unit-length SCNVector3 that points towards the Z-axis.
|
||||
/// </summary>
|
||||
public static readonly SCNVector3 UnitZ = new SCNVector3 (0, 0, 1);
|
||||
|
||||
|
@ -733,10 +733,10 @@ namespace SceneKit {
|
|||
#region Transform
|
||||
|
||||
#if NET
|
||||
/// <summary>Transform a direction vector by the given Matrix
|
||||
/// Assumes the matrix has a right-most column of (0,0,0,1), that is the translation part is ignored.
|
||||
/// </summary>
|
||||
/// <param name="vec">The column vector to transform</param>
|
||||
/// <summary>Transform a direction vector by the given Matrix
|
||||
/// Assumes the matrix has a right-most column of (0,0,0,1), that is the translation part is ignored.
|
||||
/// </summary>
|
||||
/// <param name="vec">The column vector to transform</param>
|
||||
/// <param name="mat">The desired transformation</param>
|
||||
/// <returns>The transformed vector</returns>
|
||||
#else
|
||||
|
@ -754,14 +754,14 @@ namespace SceneKit {
|
|||
}
|
||||
|
||||
#if NET
|
||||
/// <summary>Transform a direction vector by the given Matrix
|
||||
/// Assumes the matrix has a right-most column of (0,0,0,1), that is the translation part is ignored.
|
||||
/// </summary>
|
||||
/// <param name="vec">The column vector to transform</param>
|
||||
/// <summary>Transform a direction vector by the given matrix.
|
||||
/// Assumes the matrix has a right-most column of (0,0,0,1), that is the translation part is ignored.
|
||||
/// </summary>
|
||||
/// <param name="vec">The column vector to transform</param>
|
||||
/// <param name="mat">The desired transformation</param>
|
||||
/// <param name="result">The transformed vector</param>
|
||||
#else
|
||||
/// <summary>Transform a direction vector by the given Matrix
|
||||
/// <summary>Transform a direction vector by the given matrix.
|
||||
/// Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.
|
||||
/// </summary>
|
||||
/// <param name="vec">The row vector to transform</param>
|
||||
|
|
|
@ -2543,11 +2543,14 @@ public partial class Generator : IMemberGatherer {
|
|||
}
|
||||
}
|
||||
|
||||
public string SelectorField (string s, bool ignore_inline_directive = false)
|
||||
public string SelectorField (string s, bool ignore_inline_directive = false, bool force_gethandle = false)
|
||||
{
|
||||
string name;
|
||||
|
||||
if (InlineSelectors && !ignore_inline_directive)
|
||||
force_gethandle = true;
|
||||
|
||||
if (force_gethandle)
|
||||
return "Selector.GetHandle (\"" + s + "\")";
|
||||
|
||||
if (selector_names.TryGetValue (s, out name))
|
||||
|
@ -2654,17 +2657,38 @@ public partial class Generator : IMemberGatherer {
|
|||
return AttributeManager.HasAttribute<ProtocolAttribute> (type);
|
||||
}
|
||||
|
||||
public string GetMethodName (MemberInformation minfo, bool is_async)
|
||||
{
|
||||
var mi = minfo.Method;
|
||||
string name;
|
||||
if (minfo.is_ctor) {
|
||||
if (minfo.is_protocol_member) {
|
||||
var bindAttribute = GetBindAttribute (mi);
|
||||
name = bindAttribute?.Selector ?? "CreateInstance";
|
||||
} else {
|
||||
name = Nomenclator.GetGeneratedTypeName (mi.DeclaringType);
|
||||
}
|
||||
} else if (is_async) {
|
||||
name = GetAsyncName (mi);
|
||||
} else {
|
||||
name = mi.Name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public string MakeSignature (MemberInformation minfo, bool is_async, ParameterInfo [] parameters, string extra = "", bool alreadyPreserved = false)
|
||||
{
|
||||
var mi = minfo.Method;
|
||||
var category_class = minfo.category_extension_type;
|
||||
StringBuilder sb = new StringBuilder ();
|
||||
string name = minfo.is_ctor ? Nomenclator.GetGeneratedTypeName (mi.DeclaringType) : is_async ? GetAsyncName (mi) : mi.Name;
|
||||
string name = GetMethodName (minfo, is_async);
|
||||
|
||||
// Some codepaths already write preservation info
|
||||
PrintAttributes (minfo.mi, preserve: !alreadyPreserved, advice: true, bindAs: true, requiresSuper: true);
|
||||
|
||||
if (!minfo.is_ctor && !is_async) {
|
||||
if (minfo.is_ctor && minfo.is_protocol_member) {
|
||||
sb.Append ("T? ");
|
||||
} else if (!minfo.is_ctor && !is_async) {
|
||||
var prefix = "";
|
||||
if (!BindThirdPartyLibrary) {
|
||||
if (minfo.Method.ReturnType.IsArray) {
|
||||
|
@ -2700,6 +2724,13 @@ public partial class Generator : IMemberGatherer {
|
|||
name = "Set" + name.Substring (4);
|
||||
}
|
||||
sb.Append (name);
|
||||
|
||||
if (minfo.is_protocol_member) {
|
||||
if (minfo.is_ctor || minfo.is_static) {
|
||||
sb.Append ("<T>");
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append (" (");
|
||||
|
||||
bool comma = false;
|
||||
|
@ -2718,6 +2749,14 @@ public partial class Generator : IMemberGatherer {
|
|||
MakeSignatureFromParameterInfo (comma, sb, mi, minfo.type, parameters);
|
||||
sb.Append (extra);
|
||||
sb.Append (")");
|
||||
|
||||
if (minfo.is_protocol_member) {
|
||||
if (minfo.is_static || minfo.is_ctor) {
|
||||
sb.Append (" where T: NSObject, ");
|
||||
sb.Append ("I").Append (minfo.Method.DeclaringType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
|
@ -2929,10 +2968,10 @@ public partial class Generator : IMemberGatherer {
|
|||
if (minfo.is_interface_impl || minfo.is_extension_method) {
|
||||
var tmp = InlineSelectors;
|
||||
InlineSelectors = true;
|
||||
selector_field = SelectorField (selector);
|
||||
selector_field = SelectorField (selector, force_gethandle: minfo.is_protocol_member);
|
||||
InlineSelectors = tmp;
|
||||
} else {
|
||||
selector_field = SelectorField (selector);
|
||||
selector_field = SelectorField (selector, force_gethandle: minfo.is_protocol_member);
|
||||
}
|
||||
|
||||
if (ShouldMarshalNativeExceptions (mi))
|
||||
|
@ -2946,6 +2985,12 @@ public partial class Generator : IMemberGatherer {
|
|||
print ("{0} ({5}, {1}{2}, {3}{4});", sig, target_name, handle, selector_field, args, ret_val);
|
||||
|
||||
print ("aligned_assigned = true;");
|
||||
} else if (minfo.is_protocol_member && mi.Name == "Constructor") {
|
||||
const string handleName = "__handle__";
|
||||
print ($"IntPtr {handleName};");
|
||||
print ($"{handleName} = global::{NamespaceCache.Messaging}.IntPtr_objc_msgSend (Class.GetHandle (typeof (T)), Selector.GetHandle (\"alloc\"));");
|
||||
print ($"{handleName} = {sig} ({handleName}, {selector_field}{args});");
|
||||
print ($"{(assign_to_temp ? "ret = " : "return ")} global::ObjCRuntime.Runtime.GetINativeObject<T> ({handleName}, true);");
|
||||
} else {
|
||||
bool returns = mi.ReturnType != TypeCache.System_Void && mi.Name != "Constructor";
|
||||
string cast_a = "", cast_b = "";
|
||||
|
@ -3510,7 +3555,8 @@ public partial class Generator : IMemberGatherer {
|
|||
(IsNativeEnum (mi.ReturnType)) ||
|
||||
(mi.ReturnType == TypeCache.System_Boolean) ||
|
||||
(mi.ReturnType == TypeCache.System_Char) ||
|
||||
(mi.Name != "Constructor" && by_ref_processing.Length > 0 && mi.ReturnType != TypeCache.System_Void);
|
||||
minfo.is_protocol_member && disposes.Length > 0 && mi.Name == "Constructor" ||
|
||||
((mi.Name != "Constructor" || minfo.is_protocol_member) && by_ref_processing.Length > 0 && mi.ReturnType != TypeCache.System_Void);
|
||||
|
||||
if (use_temp_return) {
|
||||
// for properties we (most often) put the attribute on the property itself, not the getter/setter methods
|
||||
|
@ -3530,6 +3576,8 @@ public partial class Generator : IMemberGatherer {
|
|||
print ("byte ret;");
|
||||
} else if (mi.ReturnType == TypeCache.System_Char) {
|
||||
print ("ushort ret;");
|
||||
} else if (minfo.is_ctor && minfo.is_protocol_member) {
|
||||
print ($"T? ret;");
|
||||
} else {
|
||||
var isClassType = mi.ReturnType.IsClass || mi.ReturnType.IsInterface;
|
||||
var nullableReturn = isClassType ? "?" : string.Empty;
|
||||
|
@ -3540,7 +3588,7 @@ public partial class Generator : IMemberGatherer {
|
|||
bool needs_temp = use_temp_return || disposes.Length > 0;
|
||||
if (minfo.is_virtual_method || mi.Name == "Constructor") {
|
||||
//print ("if (this.GetType () == TypeManager.{0}) {{", type.Name);
|
||||
if (external || minfo.is_interface_impl || minfo.is_extension_method) {
|
||||
if (external || minfo.is_interface_impl || minfo.is_extension_method || minfo.is_protocol_member) {
|
||||
GenerateNewStyleInvoke (false, mi, minfo, sel, argsArray, needs_temp, category_type);
|
||||
} else {
|
||||
var may_throw = shouldMarshalNativeExceptions;
|
||||
|
@ -3655,6 +3703,8 @@ public partial class Generator : IMemberGatherer {
|
|||
print ("return ret != 0;");
|
||||
} else if (mi.ReturnType == TypeCache.System_Char) {
|
||||
print ("return (char) ret;");
|
||||
} else if (minfo.is_ctor && minfo.is_protocol_member) {
|
||||
print ("return ret;");
|
||||
} else {
|
||||
// we can't be 100% confident that the ObjC API annotations are correct so we always null check inside generated code
|
||||
print ("return ret!;");
|
||||
|
@ -4363,6 +4413,9 @@ public partial class Generator : IMemberGatherer {
|
|||
|
||||
void PrintExport (MemberInformation minfo)
|
||||
{
|
||||
if (minfo.is_ctor && minfo.is_protocol_member)
|
||||
return;
|
||||
|
||||
if (minfo.is_export)
|
||||
print ("[Export (\"{0}\"{1})]", minfo.selector, minfo.is_variadic ? ", IsVariadic = true" : string.Empty);
|
||||
}
|
||||
|
@ -4440,7 +4493,7 @@ public partial class Generator : IMemberGatherer {
|
|||
|
||||
#if NET
|
||||
var is_abstract = false;
|
||||
var do_not_call_base = minfo.is_abstract || minfo.is_model;
|
||||
var do_not_call_base = (minfo.is_abstract || minfo.is_model) && !(minfo.is_ctor && minfo.is_protocol_member);
|
||||
#else
|
||||
var is_abstract = minfo.is_abstract;
|
||||
var do_not_call_base = minfo.is_model;
|
||||
|
@ -4454,7 +4507,7 @@ public partial class Generator : IMemberGatherer {
|
|||
|
||||
|
||||
if (!is_abstract) {
|
||||
if (minfo.is_ctor) {
|
||||
if (minfo.is_ctor && !minfo.is_protocol_member) {
|
||||
indent++;
|
||||
print (": {0}", minfo.wrap_method is null ? "base (NSObjectFlag.Empty)" : minfo.wrap_method);
|
||||
indent--;
|
||||
|
@ -4580,7 +4633,7 @@ public partial class Generator : IMemberGatherer {
|
|||
}
|
||||
}
|
||||
|
||||
IEnumerable<MethodInfo> SelectProtocolMethods (Type type, bool? @static = null, bool? required = null)
|
||||
IEnumerable<MethodInfo> SelectProtocolMethods (Type type, bool? @static = null, bool? required = null, bool selectConstructors = false)
|
||||
{
|
||||
var list = type.GetMethods (BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
|
@ -4588,7 +4641,7 @@ public partial class Generator : IMemberGatherer {
|
|||
if (m.IsSpecialName)
|
||||
continue;
|
||||
|
||||
if (m.Name == "Constructor")
|
||||
if ((m.Name == "Constructor") != selectConstructors)
|
||||
continue;
|
||||
|
||||
var attrs = AttributeManager.GetCustomAttributes<Attribute> (m);
|
||||
|
@ -4686,6 +4739,7 @@ public partial class Generator : IMemberGatherer {
|
|||
{
|
||||
var allProtocolMethods = new List<MethodInfo> ();
|
||||
var allProtocolProperties = new List<PropertyInfo> ();
|
||||
var allProtocolConstructors = new List<MethodInfo> ();
|
||||
var ifaces = (IEnumerable<Type>) type.GetInterfaces ().Concat (new Type [] { ReflectionExtensions.GetBaseType (type, this) }).OrderBy (v => v.FullName, StringComparer.Ordinal);
|
||||
|
||||
if (type.Namespace is not null) {
|
||||
|
@ -4697,6 +4751,7 @@ public partial class Generator : IMemberGatherer {
|
|||
|
||||
allProtocolMethods.AddRange (SelectProtocolMethods (type));
|
||||
allProtocolProperties.AddRange (SelectProtocolProperties (type));
|
||||
allProtocolConstructors.AddRange (SelectProtocolMethods (type, selectConstructors: true));
|
||||
|
||||
var requiredInstanceMethods = allProtocolMethods.Where ((v) => IsRequired (v) && !AttributeManager.HasAttribute<StaticAttribute> (v)).ToList ();
|
||||
var optionalInstanceMethods = allProtocolMethods.Where ((v) => !IsRequired (v) && !AttributeManager.HasAttribute<StaticAttribute> (v));
|
||||
|
@ -4838,6 +4893,15 @@ public partial class Generator : IMemberGatherer {
|
|||
|
||||
print ("{");
|
||||
indent++;
|
||||
|
||||
#if NET
|
||||
foreach (var ctor in allProtocolConstructors) {
|
||||
var minfo = new MemberInformation (this, this, ctor, type, null);
|
||||
minfo.is_protocol_member = true;
|
||||
GenerateMethod (minfo);
|
||||
print ("");
|
||||
}
|
||||
#endif
|
||||
foreach (var mi in requiredInstanceMethods) {
|
||||
if (AttributeManager.HasAttribute<StaticAttribute> (mi))
|
||||
continue;
|
||||
|
|
|
@ -33,6 +33,7 @@ public class MemberInformation {
|
|||
public bool is_variadic;
|
||||
public bool is_interface_impl;
|
||||
public bool is_extension_method;
|
||||
public bool is_protocol_member;
|
||||
public bool is_appearance;
|
||||
public bool is_model;
|
||||
public bool is_ctor;
|
||||
|
@ -215,6 +216,8 @@ public class MemberInformation {
|
|||
|
||||
if (is_sealed) {
|
||||
mods += "";
|
||||
} else if (is_ctor && is_protocol_member) {
|
||||
mods += "unsafe static ";
|
||||
} else if (is_static || is_category_extension || is_extension_method) {
|
||||
mods += "static ";
|
||||
} else if (is_abstract) {
|
||||
|
|
|
@ -1847,7 +1847,7 @@ namespace CoreAnimation {
|
|||
[Export ("seed")]
|
||||
int Seed { get; set; } // unsigned int
|
||||
|
||||
/** `emitterShape' values. **/
|
||||
/* `emitterShape' values. */
|
||||
[Field ("kCAEmitterLayerPoint")]
|
||||
NSString ShapePoint { get; }
|
||||
|
||||
|
@ -1866,7 +1866,7 @@ namespace CoreAnimation {
|
|||
[Field ("kCAEmitterLayerSphere")]
|
||||
NSString ShapeSphere { get; }
|
||||
|
||||
/** `emitterMode' values. **/
|
||||
/* `emitterMode' values. */
|
||||
[Field ("kCAEmitterLayerPoints")]
|
||||
NSString ModePoints { get; }
|
||||
|
||||
|
@ -1879,7 +1879,7 @@ namespace CoreAnimation {
|
|||
[Field ("kCAEmitterLayerVolume")]
|
||||
NSString ModeVolume { get; }
|
||||
|
||||
/** `renderOrder' values. **/
|
||||
/* `renderOrder' values. */
|
||||
[Field ("kCAEmitterLayerUnordered")]
|
||||
NSString RenderUnordered { get; }
|
||||
|
||||
|
|
|
@ -927,6 +927,7 @@ GAMECONTROLLER_SOURCES = \
|
|||
GameController/GCExtendedGamepadSnapshot.cs \
|
||||
GameController/GCGamepadSnapshot.cs \
|
||||
GameController/GCMicroGamepadSnapshot.cs \
|
||||
GameController/GCMouse.cs \
|
||||
|
||||
# GameKit
|
||||
|
||||
|
|
|
@ -871,7 +871,7 @@ namespace GameController {
|
|||
[iOS (14, 0), TV (14, 0)]
|
||||
[MacCatalyst (14, 0)]
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface GCMouse : GCDevice, NSSecureCoding, NSCoding {
|
||||
interface GCMouse : GCDevice {
|
||||
[NullAllowed, Export ("mouseInput", ArgumentSemantic.Strong)]
|
||||
GCMouseInput MouseInput { get; }
|
||||
|
||||
|
|
|
@ -2486,8 +2486,6 @@ namespace HealthKit {
|
|||
[Mac (13, 0)]
|
||||
[MacCatalyst (13, 1)]
|
||||
enum HKCategoryTypeIdentifier {
|
||||
/**** HKCategoryType Identifiers ****/
|
||||
|
||||
[Field ("HKCategoryTypeIdentifierSleepAnalysis")]
|
||||
SleepAnalysis,
|
||||
|
||||
|
@ -2809,8 +2807,6 @@ namespace HealthKit {
|
|||
[Mac (13, 0)]
|
||||
[MacCatalyst (13, 1)]
|
||||
enum HKCharacteristicTypeIdentifier {
|
||||
/**** HKCharacteristicType Identifiers ****/
|
||||
|
||||
[Field ("HKCharacteristicTypeIdentifierBiologicalSex")]
|
||||
BiologicalSex,
|
||||
|
||||
|
|
|
@ -84,5 +84,11 @@
|
|||
<Compile Include="..\..\tools\common\SdkVersions.cs">
|
||||
<Link>SdkVersions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\generator\BGenBase.cs">
|
||||
<Link>BGenBase.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\generator\ProtocolTests.cs">
|
||||
<Link>ProtocolTest.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -429,6 +429,34 @@ namespace Bindings.Test {
|
|||
delegate void InnerBlock (int magic_number);
|
||||
delegate void OuterBlock ([BlockCallback] InnerBlock callback);
|
||||
|
||||
#if NET
|
||||
[Protocol]
|
||||
interface ConstructorProtocol {
|
||||
[Abstract]
|
||||
[Export ("initRequired:")]
|
||||
IntPtr Constructor (string p0);
|
||||
|
||||
[Export ("initOptional:")]
|
||||
IntPtr Constructor (NSDate p0);
|
||||
}
|
||||
|
||||
[BaseType (typeof (NSObject))]
|
||||
[DisableDefaultCtor]
|
||||
interface TypeProvidingProtocolConstructors : ConstructorProtocol {
|
||||
[Export ("initRequired:")]
|
||||
new IntPtr Constructor (string p0);
|
||||
|
||||
[Export ("initOptional:")]
|
||||
new IntPtr Constructor (NSDate p0);
|
||||
|
||||
[Export ("stringValue")]
|
||||
string StringValue { get; set; }
|
||||
|
||||
[Export ("dateValue")]
|
||||
NSDate DateValue { get; set; }
|
||||
}
|
||||
#endif
|
||||
|
||||
[BaseType (typeof (NSObject))]
|
||||
interface EvilDeallocator {
|
||||
[Export ("evilCallback")]
|
||||
|
@ -462,6 +490,21 @@ namespace Bindings.Test {
|
|||
interface SwiftTestClass {
|
||||
[Export ("SayHello")]
|
||||
string SayHello ();
|
||||
|
||||
[Export ("DoSomethingWithMessage:")]
|
||||
string DoSomething (string message);
|
||||
|
||||
[Export ("DoSomethingAsyncWithMessage:completionHandler:")]
|
||||
void DoSomethingAsync (string message, Action<NSString> completionHandler);
|
||||
|
||||
[Export ("DoSomethingComplexAsyncWithMessage:complexParameter:completionHandler:")]
|
||||
// The type for 'complexParameter' is something like: Func<Func<Int16, Int64>, NSString>
|
||||
// But the generator can't handle that, it generates code that doesn't compile.
|
||||
// So just bind it as IntPtr.
|
||||
// This is not a problem for this test, because the point of this test is to verify that
|
||||
// we're able to skip the corresponding objc type encoding, and for that we don't need to
|
||||
// provide an actual argument when calling the method.
|
||||
void DoSomethingComplexAsync (string message, IntPtr complexParameter, Action<NSString> completionHandler);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ using ObjCRuntime;
|
|||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Bindings.Test;
|
||||
|
||||
namespace Xamarin.BindingTests {
|
||||
[TestFixture]
|
||||
[Preserve (AllMembers = true)]
|
||||
|
@ -29,6 +31,77 @@ namespace Xamarin.BindingTests {
|
|||
}
|
||||
}
|
||||
|
||||
#if NET
|
||||
[Test]
|
||||
public void Constructors ()
|
||||
{
|
||||
using var dateNow = (NSDate) DateTime.Now;
|
||||
|
||||
using (var obj = IConstructorProtocol.CreateInstance<TypeProvidingProtocolConstructors> ("Hello world")) {
|
||||
Assert.AreEqual ("Hello world", obj.StringValue, "A StringValue");
|
||||
Assert.IsNull (obj.DateValue, "A DateValue");
|
||||
}
|
||||
|
||||
using (var obj = IConstructorProtocol.CreateInstance<TypeProvidingProtocolConstructors> (dateNow)) {
|
||||
Assert.IsNull (obj.StringValue, "B StringValue");
|
||||
Assert.AreEqual (dateNow, obj.DateValue, "B DateValue");
|
||||
}
|
||||
|
||||
using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors> ("Hello Subclassed")) {
|
||||
Assert.AreEqual ("Hello Subclassed", obj.StringValue, "C1 StringValue");
|
||||
Assert.IsNull (obj.DateValue, "C1 DateValue");
|
||||
}
|
||||
|
||||
using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors> (dateNow)) {
|
||||
Assert.IsNull (obj.StringValue, "C2 StringValue");
|
||||
Assert.AreEqual (dateNow, obj.DateValue, "C2 DateValue");
|
||||
}
|
||||
|
||||
if (global::XamarinTests.ObjCRuntime.Registrar.IsDynamicRegistrar) {
|
||||
Assert.Throws<RuntimeException> (() => {
|
||||
IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors2> ("Hello Subclassed 2");
|
||||
}, "D1 Exception");
|
||||
} else {
|
||||
using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors2> ("Hello Subclassed 2")) {
|
||||
Assert.AreEqual ("Managed interceptor! Hello Subclassed 2", obj.StringValue, "D1 StringValue");
|
||||
Assert.IsNull (obj.DateValue, "D1 DateValue");
|
||||
}
|
||||
}
|
||||
|
||||
if (XamarinTests.ObjCRuntime.Registrar.IsDynamicRegistrar) {
|
||||
Assert.Throws<RuntimeException> (() => {
|
||||
IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors2> (dateNow);
|
||||
}, "D2 Exception");
|
||||
} else {
|
||||
using (var obj = IConstructorProtocol.CreateInstance<SubclassedTypeProvidingProtocolConstructors2> (dateNow)) {
|
||||
Assert.IsNull (obj.StringValue, "D2 StringValue");
|
||||
Assert.AreEqual (dateNow.AddSeconds (42), obj.DateValue, "D2 DateValue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SubclassedTypeProvidingProtocolConstructors : TypeProvidingProtocolConstructors {
|
||||
SubclassedTypeProvidingProtocolConstructors (NativeHandle handle) : base (handle) {}
|
||||
|
||||
}
|
||||
|
||||
class SubclassedTypeProvidingProtocolConstructors2 : TypeProvidingProtocolConstructors {
|
||||
SubclassedTypeProvidingProtocolConstructors2 (NativeHandle handle) : base (handle) {}
|
||||
|
||||
[Export ("initRequired:")]
|
||||
public SubclassedTypeProvidingProtocolConstructors2 (string value)
|
||||
: base ($"Managed interceptor! " + value)
|
||||
{
|
||||
}
|
||||
|
||||
[Export ("initOptional:")]
|
||||
public SubclassedTypeProvidingProtocolConstructors2 (NSDate value)
|
||||
: base (value.AddSeconds (42))
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
#if NET
|
||||
[UnconditionalSuppressMessage ("Trimming", "IL2026", Justification = "This test verifies trimmer behavior, and as such must do trimmer-unsafe stuff.")]
|
||||
|
|
|
@ -104,6 +104,27 @@ namespace Xamarin.Tests {
|
|||
using var obj = new SwiftTestClass ();
|
||||
Assert.AreEqual ("Hello from Swift", obj.SayHello (), "Hello");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SwiftTypeEncodings ()
|
||||
{
|
||||
TestRuntime.AssertXcodeVersion (13, 0);
|
||||
|
||||
using var obj = new SwiftTestClass ();
|
||||
|
||||
Assert.AreEqual ("42", obj.DoSomething ("42"), "DoSomething");
|
||||
|
||||
string asyncResult = null;
|
||||
obj.DoSomethingAsync ("dolphins", (v) => asyncResult = v);
|
||||
var done = TestRuntime.RunAsync (TimeSpan.FromSeconds (5), () => asyncResult is not null);
|
||||
Assert.AreEqual ("dolphins", asyncResult, "DoSomethingAsync");
|
||||
Assert.IsTrue (done, "Done");
|
||||
|
||||
obj.DoSomethingComplexAsync ("fish", IntPtr.Zero, (v) => asyncResult = v);
|
||||
done = TestRuntime.RunAsync (TimeSpan.FromSeconds (5), () => asyncResult is not null);
|
||||
Assert.AreEqual ("fish", asyncResult, "DoSomethingComplexAsync");
|
||||
Assert.IsTrue (done, "Done 2");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
<!-- We're warning-free, so let's make sure we stay that way -->
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<WarningsAsErrors>Nullable</WarningsAsErrors>
|
||||
|
||||
<DefineConstants>$(DefineConstants);BINDINGS_TEST</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(RootTestsDirectory)/common/shared-dotnet.csproj" />
|
||||
|
@ -57,6 +59,9 @@
|
|||
<Compile Include="$(RootTestsDirectory)\common\TestRuntime.cs">
|
||||
<Link>TestRuntime.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(RootTestsDirectory)\common\TestRuntime.RunAsync.cs">
|
||||
<Link>TestRuntime.RunAsync.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="$(RootTestsDirectory)\..\tools\common\ApplePlatform.cs">
|
||||
<Link>ApplePlatform.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -17,20 +17,6 @@ using Xamarin.Utils;
|
|||
namespace Cecil.Tests {
|
||||
public partial class BlittablePInvokes {
|
||||
static HashSet<string> knownFailuresPInvokes = new HashSet<string> {
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphAddNode(System.IntPtr,AudioUnit.AudioComponentDescription&,System.Int32&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphCountNodeInteractions(System.IntPtr,System.Int32,System.UInt32&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphGetCPULoad(System.IntPtr,System.Single&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphGetIndNode(System.IntPtr,System.UInt32,System.Int32&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphGetMaxCPULoad(System.IntPtr,System.Single&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphGetNodeCount(System.IntPtr,System.Int32&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphGetNumberOfInteractions(System.IntPtr,System.UInt32&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphIsInitialized(System.IntPtr,System.Boolean&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphIsOpen(System.IntPtr,System.Boolean&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphIsRunning(System.IntPtr,System.Boolean&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphNodeInfo(System.IntPtr,System.Int32,AudioUnit.AudioComponentDescription&,System.IntPtr&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphNodeInfo(System.IntPtr,System.Int32,System.IntPtr,System.IntPtr&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphSetNodeInputCallback(System.IntPtr,System.Int32,System.UInt32,AudioUnit.AURenderCallbackStruct&)",
|
||||
"AudioUnit.AUGraphError AudioUnit.AUGraph::AUGraphUpdate(System.IntPtr,System.Boolean&)",
|
||||
"AVFoundation.AVSampleCursorAudioDependencyInfo ObjCRuntime.Messaging::AVSampleCursorAudioDependencyInfo_objc_msgSend(System.IntPtr,System.IntPtr)",
|
||||
"AVFoundation.AVSampleCursorAudioDependencyInfo ObjCRuntime.Messaging::AVSampleCursorAudioDependencyInfo_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
|
||||
"AVFoundation.AVSampleCursorChunkInfo ObjCRuntime.Messaging::AVSampleCursorChunkInfo_objc_msgSend_stret(System.IntPtr,System.IntPtr)",
|
||||
|
@ -72,17 +58,6 @@ namespace Cecil.Tests {
|
|||
"System.Boolean Network.NWPath::nw_path_is_equal(System.IntPtr,System.IntPtr)",
|
||||
"System.Boolean Network.NWPath::nw_path_is_expensive(System.IntPtr)",
|
||||
"System.Boolean Network.NWPath::nw_path_uses_interface_type(System.IntPtr,Network.NWInterfaceType)",
|
||||
"System.Boolean Network.NWProtocolDefinition::nw_protocol_definition_is_equal(System.IntPtr,System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolMetadata::nw_protocol_metadata_is_framer_message(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolMetadata::nw_protocol_metadata_is_ip(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolMetadata::nw_protocol_metadata_is_quic(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolMetadata::nw_protocol_metadata_is_tcp(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolMetadata::nw_protocol_metadata_is_tls(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolMetadata::nw_protocol_metadata_is_udp(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolMetadata::nw_protocol_metadata_is_ws(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolOptions::nw_protocol_options_is_quic(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolQuicOptions::nw_quic_get_stream_is_datagram(System.IntPtr)",
|
||||
"System.Boolean Network.NWProtocolQuicOptions::nw_quic_get_stream_is_unidirectional(System.IntPtr)",
|
||||
"System.Boolean Network.NWTxtRecord::nw_txt_record_access_bytes(System.IntPtr,ObjCRuntime.BlockLiteral*)",
|
||||
"System.Boolean Network.NWTxtRecord::nw_txt_record_access_key(System.IntPtr,System.IntPtr,ObjCRuntime.BlockLiteral*)",
|
||||
"System.Boolean Network.NWTxtRecord::nw_txt_record_apply(System.IntPtr,ObjCRuntime.BlockLiteral*)",
|
||||
|
@ -110,21 +85,6 @@ namespace Cecil.Tests {
|
|||
"System.Void Network.NWParameters::nw_parameters_set_requires_dnssec_validation(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWParameters::nw_parameters_set_reuse_local_address(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWPrivacyContext::nw_privacy_context_require_encrypted_name_resolution(System.IntPtr,System.Boolean,System.IntPtr)",
|
||||
"System.Void Network.NWProtocolIPOptions::nw_ip_options_set_disable_multicast_loopback(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_ip_options_set_calculate_receive_time(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_ip_options_set_disable_fragmentation(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_ip_options_set_use_minimum_mtu(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_disable_ack_stretching(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_disable_ecn(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_enable_fast_open(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_enable_keepalive(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_no_delay(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_no_options(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_no_push(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_tcp_options_set_retransmit_fin_drop(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolOptions::nw_udp_options_set_prefer_no_checksum(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolQuicOptions::nw_quic_set_stream_is_datagram(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWProtocolQuicOptions::nw_quic_set_stream_is_unidirectional(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWWebSocketOptions::nw_ws_options_set_auto_reply_ping(System.IntPtr,System.Boolean)",
|
||||
"System.Void Network.NWWebSocketOptions::nw_ws_options_set_skip_handshake(System.IntPtr,System.Boolean)",
|
||||
"System.Void ObjCRuntime.Messaging::void_objc_msgSend_GCDualSenseAdaptiveTriggerPositionalAmplitudes_float(System.IntPtr,System.IntPtr,GameController.GCDualSenseAdaptiveTriggerPositionalAmplitudes,System.Single)",
|
||||
|
|
|
@ -30278,6 +30278,7 @@ M:CoreML.IMLBatchProvider.GetFeatures(System.IntPtr)
|
|||
M:CoreML.IMLCustomLayer.EvaluateOnCpu(CoreML.MLMultiArray[],CoreML.MLMultiArray[],Foundation.NSError@)
|
||||
M:CoreML.IMLCustomLayer.GetOutputShapes(Foundation.NSArray[],Foundation.NSError@)
|
||||
M:CoreML.IMLCustomLayer.SetWeightData(Foundation.NSData[],Foundation.NSError@)
|
||||
M:CoreML.IMLCustomModel.CreateInstance``1(CoreML.MLModelDescription,Foundation.NSDictionary{Foundation.NSString,Foundation.NSObject},Foundation.NSError@)
|
||||
M:CoreML.IMLCustomModel.GetPrediction(CoreML.IMLFeatureProvider,CoreML.MLPredictionOptions,Foundation.NSError@)
|
||||
M:CoreML.IMLFeatureProvider.GetFeatureValue(System.String)
|
||||
M:CoreML.IMLWritable.Write(Foundation.NSUrl,Foundation.NSError@)
|
||||
|
@ -31568,6 +31569,7 @@ M:Foundation.ExportAttribute.ToGetter(System.Reflection.PropertyInfo)
|
|||
M:Foundation.ExportAttribute.ToSetter(System.Reflection.PropertyInfo)
|
||||
M:Foundation.FieldAttribute.#ctor(System.String,System.String)
|
||||
M:Foundation.FieldAttribute.#ctor(System.String)
|
||||
M:Foundation.INSCoding.CreateInstance``1(Foundation.NSCoder)
|
||||
M:Foundation.INSCoding.EncodeTo(Foundation.NSCoder)
|
||||
M:Foundation.INSCopying.Copy(Foundation.NSZone)
|
||||
M:Foundation.INSDiscardableContent.BeginContentAccess
|
||||
|
@ -33070,7 +33072,6 @@ M:GameController.GCMotion.SetGravity(GameController.GCAcceleration)
|
|||
M:GameController.GCMotion.SetRotationRate(GameController.GCRotationRate)
|
||||
M:GameController.GCMotion.SetState(GameController.GCMotion)
|
||||
M:GameController.GCMotion.SetUserAcceleration(GameController.GCAcceleration)
|
||||
M:GameController.GCMouse.EncodeTo(Foundation.NSCoder)
|
||||
M:GameController.GCPhysicalInputProfile.Capture
|
||||
M:GameController.GCPhysicalInputProfile.Dispose(System.Boolean)
|
||||
M:GameController.GCPhysicalInputProfile.GetMappedElementAlias(System.String)
|
||||
|
@ -36496,9 +36497,11 @@ M:MetalKit.MTKView.Dispose(System.Boolean)
|
|||
M:MetalKit.MTKView.MTKViewAppearance.#ctor(System.IntPtr)
|
||||
M:MetalKit.MTKViewDelegate.Draw(MetalKit.MTKView)
|
||||
M:MetalKit.MTKViewDelegate.DrawableSizeWillChange(MetalKit.MTKView,CoreGraphics.CGSize)
|
||||
M:MetalPerformanceShaders.IMPSCnnBatchNormalizationDataSource.CreateInstance``1(Foundation.NSCoder)
|
||||
M:MetalPerformanceShaders.IMPSCnnBatchNormalizationDataSource.Purge
|
||||
M:MetalPerformanceShaders.IMPSCnnConvolutionDataSource.Load
|
||||
M:MetalPerformanceShaders.IMPSCnnConvolutionDataSource.Purge
|
||||
M:MetalPerformanceShaders.IMPSCnnInstanceNormalizationDataSource.CreateInstance``1(Foundation.NSCoder)
|
||||
M:MetalPerformanceShaders.IMPSDeviceProvider.GetMTLDevice
|
||||
M:MetalPerformanceShaders.IMPSHeapProvider.GetNewHeap(Metal.MTLHeapDescriptor)
|
||||
M:MetalPerformanceShaders.IMPSImageAllocator.GetImage(Metal.IMTLCommandBuffer,MetalPerformanceShaders.MPSImageDescriptor,MetalPerformanceShaders.MPSKernel)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#if !__WATCHOS__
|
||||
#if !__WATCHOS__ && !BINDINGS_TEST
|
||||
#define CAN_SHOW_ASYNC_UI
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -157,8 +158,13 @@ partial class TestRuntime {
|
|||
var vc = new AsyncController (imageToShow);
|
||||
|
||||
#if HAS_UIKIT
|
||||
window = UIApplication.SharedApplication.KeyWindow;
|
||||
initialRootViewController = window.RootViewController;
|
||||
// UIApplication.KeyWindow is deprecated, so we have to do this monstruosity instead (https://stackoverflow.com/a/58031897/183422):
|
||||
window = UIApplication
|
||||
.SharedApplication
|
||||
.ConnectedScenes
|
||||
.SelectMany<UIScene, UIWindow> (v => (v as UIWindowScene)?.Windows ?? Array.Empty<UIWindow> ())
|
||||
.Last (v => v.IsKeyWindow);
|
||||
initialRootViewController = window.RootViewController!;
|
||||
navigation = initialRootViewController as UINavigationController;
|
||||
|
||||
// Pushing something to a navigation controller doesn't seem to work on phones
|
||||
|
@ -237,7 +243,7 @@ partial class TestRuntime {
|
|||
}
|
||||
|
||||
#if HAS_UIKIT
|
||||
View.BackgroundColor = backgroundColor;
|
||||
View!.BackgroundColor = backgroundColor;
|
||||
#else
|
||||
View.WantsLayer = true;
|
||||
View.Layer.BackgroundColor = backgroundColor.CGColor;
|
||||
|
@ -257,7 +263,7 @@ partial class TestRuntime {
|
|||
}
|
||||
|
||||
namespace Foundation {
|
||||
public static class NSRunLoop_Extensions {
|
||||
static class NSRunLoop_Extensions {
|
||||
// Returns true if task completed before the timeout,
|
||||
// otherwise returns false
|
||||
public static bool RunUntil (this NSRunLoop self, Task task, TimeSpan timeout)
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Xamarin.Tests;
|
||||
|
||||
namespace GeneratorTests {
|
||||
public class BGenBase {
|
||||
internal BGenTool BuildFile (Profile profile, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, true, false, filenames);
|
||||
}
|
||||
|
||||
internal BGenTool BuildFile (Profile profile, bool nowarnings, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, nowarnings, false, filenames);
|
||||
}
|
||||
|
||||
internal BGenTool BuildFile (Profile profile, bool nowarnings, bool processEnums, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, nowarnings, processEnums, Enumerable.Empty<string> (), filenames);
|
||||
}
|
||||
|
||||
internal BGenTool BuildFile (Profile profile, bool nowarnings, bool processEnums, IEnumerable<string> references, params string [] filenames)
|
||||
{
|
||||
Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ());
|
||||
var bgen = new BGenTool ();
|
||||
bgen.Profile = profile;
|
||||
bgen.ProcessEnums = processEnums;
|
||||
bgen.Defines = BGenTool.GetDefaultDefines (bgen.Profile);
|
||||
bgen.References = references.ToList ();
|
||||
TestContext.Out.WriteLine (TestContext.CurrentContext.Test.FullName);
|
||||
foreach (var filename in filenames)
|
||||
TestContext.Out.WriteLine ($"\t{filename}");
|
||||
bgen.CreateTemporaryBinding (filenames.Select ((filename) => File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", filename))).ToArray ());
|
||||
bgen.AssertExecute ("build");
|
||||
if (nowarnings)
|
||||
bgen.AssertNoWarnings ();
|
||||
return bgen;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ using Xamarin.Utils;
|
|||
namespace GeneratorTests {
|
||||
[TestFixture ()]
|
||||
[Parallelizable (ParallelScope.All)]
|
||||
public class BGenTests {
|
||||
public class BGenTests : BGenBase {
|
||||
// Removing the following variable might make running the unit tests in VSMac fail.
|
||||
static Type variable_to_keep_reference_to_system_runtime_compilerservices_unsafe_assembly = typeof (System.Runtime.CompilerServices.Unsafe);
|
||||
|
||||
|
@ -1556,38 +1556,5 @@ namespace GeneratorTests {
|
|||
bgen.AssertNoWarnings ();
|
||||
}
|
||||
#endif
|
||||
|
||||
BGenTool BuildFile (Profile profile, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, true, false, filenames);
|
||||
}
|
||||
|
||||
BGenTool BuildFile (Profile profile, bool nowarnings, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, nowarnings, false, filenames);
|
||||
}
|
||||
|
||||
BGenTool BuildFile (Profile profile, bool nowarnings, bool processEnums, params string [] filenames)
|
||||
{
|
||||
return BuildFile (profile, nowarnings, processEnums, Enumerable.Empty<string> (), filenames);
|
||||
}
|
||||
|
||||
BGenTool BuildFile (Profile profile, bool nowarnings, bool processEnums, IEnumerable<string> references, params string [] filenames)
|
||||
{
|
||||
Configuration.IgnoreIfIgnoredPlatform (profile.AsPlatform ());
|
||||
var bgen = new BGenTool ();
|
||||
bgen.Profile = profile;
|
||||
bgen.ProcessEnums = processEnums;
|
||||
bgen.Defines = BGenTool.GetDefaultDefines (bgen.Profile);
|
||||
bgen.References = references.ToList ();
|
||||
TestContext.Out.WriteLine (TestContext.CurrentContext.Test.FullName);
|
||||
foreach (var filename in filenames)
|
||||
TestContext.Out.WriteLine ($"\t{filename}");
|
||||
bgen.CreateTemporaryBinding (filenames.Select ((filename) => File.ReadAllText (Path.Combine (Configuration.SourceRoot, "tests", "generator", filename))).ToArray ());
|
||||
bgen.AssertExecute ("build");
|
||||
if (nowarnings)
|
||||
bgen.AssertNoWarnings ();
|
||||
return bgen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Tests;
|
||||
|
||||
namespace GeneratorTests {
|
||||
[TestFixture ()]
|
||||
[Parallelizable (ParallelScope.All)]
|
||||
public class ProtocolTests : BGenBase {
|
||||
#if !NET
|
||||
[Ignore ("This only applies to .NET")]
|
||||
#endif
|
||||
[TestCase (Profile.MacCatalyst)]
|
||||
[TestCase (Profile.iOS)]
|
||||
public void Members (Profile profile)
|
||||
{
|
||||
var bgen = BuildFile (profile, "tests/protocols.cs");
|
||||
|
||||
var allTypeDefinitions = bgen.ApiAssembly.MainModule.GetTypes ().ToArray ();
|
||||
var allTypes = allTypeDefinitions.Select (v => v.FullName).ToArray ();
|
||||
|
||||
var allTypeNames = allTypes.OrderBy (v => v).ToArray ();
|
||||
var expectedTypes = new string [] {
|
||||
"<Module>",
|
||||
"api0.Messaging",
|
||||
"Protocols.IProtocolWithConstructors",
|
||||
"Protocols.ProtocolWithConstructorsWrapper",
|
||||
};
|
||||
CollectionAssert.AreEqual (expectedTypes, allTypeNames, "Types");
|
||||
|
||||
var allMethods = allTypeDefinitions.SelectMany (v => v.Methods).Select (v => v.ToString ()).OrderBy (v => v).ToArray ();
|
||||
var expectedMethods = new string [] {
|
||||
"ObjCRuntime.NativeHandle api0.Messaging::NativeHandle_objc_msgSend_NativeHandle(System.IntPtr,System.IntPtr,ObjCRuntime.NativeHandle)",
|
||||
"ObjCRuntime.NativeHandle api0.Messaging::NativeHandle_objc_msgSend_ref_NativeHandle(System.IntPtr,System.IntPtr,ObjCRuntime.NativeHandle*)",
|
||||
"ObjCRuntime.NativeHandle api0.Messaging::NativeHandle_objc_msgSend(System.IntPtr,System.IntPtr)",
|
||||
"ObjCRuntime.NativeHandle api0.Messaging::NativeHandle_objc_msgSendSuper_NativeHandle(System.IntPtr,System.IntPtr,ObjCRuntime.NativeHandle)",
|
||||
"ObjCRuntime.NativeHandle api0.Messaging::NativeHandle_objc_msgSendSuper_ref_NativeHandle(System.IntPtr,System.IntPtr,ObjCRuntime.NativeHandle*)",
|
||||
"ObjCRuntime.NativeHandle api0.Messaging::NativeHandle_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
|
||||
"System.IntPtr api0.Messaging::IntPtr_objc_msgSend_IntPtr(System.IntPtr,System.IntPtr,System.IntPtr)",
|
||||
"System.IntPtr api0.Messaging::IntPtr_objc_msgSend(System.IntPtr,System.IntPtr)",
|
||||
"System.IntPtr api0.Messaging::IntPtr_objc_msgSendSuper_IntPtr(System.IntPtr,System.IntPtr,System.IntPtr)",
|
||||
"System.IntPtr api0.Messaging::IntPtr_objc_msgSendSuper(System.IntPtr,System.IntPtr)",
|
||||
"System.Void api0.Messaging::.cctor()",
|
||||
"System.Void Protocols.ProtocolWithConstructorsWrapper::.ctor(ObjCRuntime.NativeHandle,System.Boolean)",
|
||||
"T Protocols.IProtocolWithConstructors::Create(Foundation.NSDate)",
|
||||
"T Protocols.IProtocolWithConstructors::CreateInstance()",
|
||||
"T Protocols.IProtocolWithConstructors::CreateInstance(Foundation.NSError&)",
|
||||
"T Protocols.IProtocolWithConstructors::CreateInstance(System.String)",
|
||||
};
|
||||
|
||||
CollectionAssert.AreEqual (expectedMethods, allMethods, "Types");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -67,6 +67,8 @@
|
|||
<Compile Include="GeneratorTests.cs" />
|
||||
<Compile Include="BGenTests.cs" />
|
||||
<Compile Include="Asserts.cs" />
|
||||
<Compile Include="BGenBase.cs" />
|
||||
<Compile Include="ProtocolTests.cs" />
|
||||
<Compile Include="..\common\Profile.cs">
|
||||
<Link>Profile.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
|
||||
namespace Protocols {
|
||||
[Protocol]
|
||||
interface ProtocolWithConstructors {
|
||||
[Abstract]
|
||||
[Export ("init")]
|
||||
NativeHandle Constructor ();
|
||||
|
||||
[Export ("initWithValue:")]
|
||||
NativeHandle Constructor (string p0);
|
||||
|
||||
[Export ("initWithError:")]
|
||||
NativeHandle Constructor (out NSError error);
|
||||
|
||||
[Bind ("Create")]
|
||||
[Export ("initWithCustomName:")]
|
||||
NativeHandle Constructor (NSDate error);
|
||||
}
|
||||
}
|
|
@ -90,20 +90,10 @@ namespace MonoTouchFixtures.ImageIO {
|
|||
{
|
||||
using (var imgsrc = CGImageSource.FromUrl (fileUrl)) {
|
||||
using (var img = imgsrc.CreateThumbnail (0, null)) {
|
||||
#if NET
|
||||
Assert.Null (img, "#a1");
|
||||
#else
|
||||
Assert.NotNull (img, "#a1");
|
||||
Assert.AreEqual (IntPtr.Zero, img.Handle, "#a2");
|
||||
#endif
|
||||
Assert.That (img, Is.Null.Or.Not.Null, "#a1"); // sometimes we get an image, and sometimes we don't 🤷♂️
|
||||
}
|
||||
using (var img = imgsrc.CreateThumbnail (0, new CGImageThumbnailOptions ())) {
|
||||
#if NET
|
||||
Assert.Null (img, "#b1");
|
||||
#else
|
||||
Assert.NotNull (img, "#b1");
|
||||
Assert.AreEqual (IntPtr.Zero, img.Handle, "#b2");
|
||||
#endif
|
||||
Assert.That (img, Is.Null.Or.Not.Null, "#b1"); // sometimes we get an image, and sometimes we don't 🤷♂️
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,38 @@
|
|||
import Foundation
|
||||
|
||||
@objc(SwiftTestClass)
|
||||
@available(iOS 15, tvOS 15, macOS 12, macCatalyst 12, watchOS 8, *)
|
||||
public class SwiftTestClass : NSObject {
|
||||
@objc
|
||||
public func SayHello() -> String {
|
||||
return "Hello from Swift"
|
||||
}
|
||||
|
||||
@objc
|
||||
// encoding for 'message': @"NSString"
|
||||
public func DoSomething(message: String) -> String {
|
||||
return message
|
||||
}
|
||||
|
||||
@objc
|
||||
// encoding for 'message': @"NSString"
|
||||
// objc encoding for implicit callback: @?<v@?@"NSString">
|
||||
public func DoSomethingAsync(message: String) async -> String {
|
||||
do {
|
||||
try await Task.sleep(nanoseconds: 1)
|
||||
} catch {}
|
||||
return message;
|
||||
}
|
||||
|
||||
@objc
|
||||
// objc encoding for 'message': @"NSString"
|
||||
// objc encoding for 'complexParameter': @?<@"NSString"@?@?<q@?s>>
|
||||
// in particular this argument has nested <<>>
|
||||
// objc encoding for implicit callback: @?<v@?@"NSString">
|
||||
public func DoSomethingComplexAsync(message: String, complexParameter: @escaping ((Int16) -> Int64) -> String?) async -> String {
|
||||
do {
|
||||
try await Task.sleep(nanoseconds: 1)
|
||||
} catch {}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,6 +277,23 @@ typedef void (^outerBlock) (innerBlock callback);
|
|||
// And Apple does (see UIAppearance appearanceWhenContainedInInstancesOfClasses for an example).
|
||||
@end
|
||||
|
||||
@protocol ConstructorProtocol
|
||||
@required
|
||||
-(id) initRequired: (NSString *) p0;
|
||||
@optional
|
||||
-(id) initOptional: (NSDate *) p0;
|
||||
@end
|
||||
|
||||
@interface TypeProvidingProtocolConstructors : NSObject <ConstructorProtocol> {
|
||||
}
|
||||
-(id) initRequired: (NSString *) p0;
|
||||
-(id) initOptional: (NSDate *) p0;
|
||||
|
||||
@property (copy) NSString* stringValue;
|
||||
@property (copy) NSDate* dateValue;
|
||||
|
||||
@end
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
|
|
@ -1346,4 +1346,26 @@ static void block_called ()
|
|||
}
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation TypeProvidingProtocolConstructors
|
||||
-(id) initRequired: (NSString *) p0
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_stringValue = [p0 copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(id) initOptional: (NSDate *) p0
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_dateValue = [p0 copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#include "libtest.decompile.m"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#define UltimateMachine object_UltimateMachine
|
||||
#define FrameworkTest object_FrameworkTest
|
||||
#define RefOutParameters object_RefOutParameters
|
||||
#define TypeProvidingProtocolConstructors objecct_TypeProvidingProtocolConstructors
|
||||
#define Sc object_Sc
|
||||
#define Scc object_Scc
|
||||
#define Sccc object_Sccc
|
||||
|
@ -85,6 +86,7 @@
|
|||
#define UltimateMachine ar_UltimateMachine
|
||||
#define FrameworkTest ar_FrameworkTest
|
||||
#define RefOutParameters ar_RefOutParameters
|
||||
#define TypeProvidingProtocolConstructors ar_TypeProvidingProtocolConstructors
|
||||
#define Sc ar_Sc
|
||||
#define Scc ar_Scc
|
||||
#define Sccc ar_Sccc
|
||||
|
|
Загрузка…
Ссылка в новой задаче