Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[registrar] Fix verification of generic parameters to accept unrelated generic types. Fixes #6687.#6850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rolfbjarne merged 2 commits intodotnet:xcode11fromrolfbjarne:issue-6687
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletionssrc/ObjCRuntime/DynamicRegistrar.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -503,20 +503,7 @@ protected override bool VerifyIsConstrainedToNSObject (Type type, out Type const
return rv;
}

if (type.IsGenericType) {
var rv = true;
var args = type.GetGenericArguments ();
var constrs = new Type [args.Length];
for (int i = 0; i < args.Length; i++) {
Type constr;
rv &= VerifyIsConstrainedToNSObject (args [i], out constr);
constrs [i] = constr;
}
constrained_type = type.GetGenericTypeDefinition ().MakeGenericType (constrs);
return rv;
}

return false;
return true;
}

protected override Exception CreateException (int code, Exception innerException, MethodBase method, string message, params object[] args)
Expand Down
3 changes: 3 additions & 0 deletionstests/monotouch-test/ObjCRuntime/Messaging.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,6 +254,9 @@ public struct objc_super {

[DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
public extern static void void_objc_msgSend_int_int_int (IntPtr receiver, IntPtr selector, int p1, ref int p2, out int p3);

[DllImport (LIBOBJC_DYLIB, EntryPoint = "objc_msgSend")]
public extern static void void_objc_msgSend_IntPtr_IntPtr_BlockLiteral (IntPtr receiver, IntPtr selector, IntPtr p1, IntPtr p2, ref BlockLiteral p3);
}
}

51 changes: 51 additions & 0 deletionstests/monotouch-test/ObjCRuntime/RegistrarTest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,6 +35,7 @@
#if !__TVOS__
using Contacts;
#endif
using WebKit;
#else
using MonoTouch;
using MonoTouch.AddressBook;
Expand DownExpand Up@@ -5246,6 +5247,44 @@ public override void TestClassArray (int action, ref Class [] refValue, out Clas
}

}

#if !__WATCHOS__ && !__TVOS__ // No WebKit on watchOS/tvOS
[Test]
public void GenericClassWithUnrelatedGenericDelegate ()
{
using (var obj = new GenericWebNavigationThingie<NSObject> ()) {
var handler_called = false;
Action<WKNavigationActionPolicy> handler = new Action<WKNavigationActionPolicy> ((v) => {
handler_called = true;
});
var block = new BlockLiteral ();
var tramp = new DActionArity1V3 (SDActionArity1V3.Invoke);
if (Runtime.DynamicRegistrationSupported) {
block.SetupBlock (tramp, handler);
Messaging.void_objc_msgSend_IntPtr_IntPtr_BlockLiteral (obj.Handle, Selector.GetHandle ("webView:decidePolicyForNavigationAction:decisionHandler:"), IntPtr.Zero, IntPtr.Zero, ref block);
block.CleanupBlock ();
Assert.IsTrue (handler_called, "Handler called");
} else {
Assert.Throws<RuntimeException> (() => block.SetupBlock (tramp, handler));
}
}
}

[UnmanagedFunctionPointerAttribute (CallingConvention.Cdecl)]
internal delegate void DActionArity1V3 (IntPtr block, nint value);
static internal class SDActionArity1V3 {
static internal readonly DActionArity1V3 Handler = Invoke;

[MonoPInvokeCallback (typeof (DActionArity1V3))]
public static unsafe void Invoke (IntPtr block, nint value)
{
var del = BlockLiteral.GetTarget<Action<WKNavigationActionPolicy>> (block);
if (del != null)
del ((WKNavigationActionPolicy) (long) value);
}
}
#endif // !__WATCHOS__ && !__TVOS__

}

#if !__WATCHOS__
Expand DownExpand Up@@ -5382,6 +5421,18 @@ public class FutureClass : NSObject
public class SomeConsumer : NSObject, ISomeDelegate
{
}

#if !__WATCHOS__ && !__TVOS__ // No WebKit on watchOS/tvOS
[Preserve]
public class GenericWebNavigationThingie<WebViewModel> : NSObject, IWKNavigationDelegate {
[Export ("webView:decidePolicyForNavigationAction:decisionHandler:")]
public void DecidePolicy (WKWebView webView, WKNavigationAction navigationAction, Action<WKNavigationActionPolicy> decisionHandler)
{
decisionHandler (WKNavigationActionPolicy.Allow);
}
}
#endif

#if !__WATCHOS__ // no MetalKit on watchOS
// These classes implement Metal* protocols, so that the generated registrar code includes the corresponding Metal* headers.
// https://github.com/xamarin/xamarin-macios/issues/4422
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp