public UnmanagedMethodDescription GetMethodDescriptionAndObject(Type type, IntPtr selector, IntPtr obj, ref IntPtr mthis) { var sel = new Selector(selector); var res = GetMethodNoThrow(type, type, sel.Name); if (res == null) { throw ErrorHelper.CreateError(8006, "Failed to find the selector '{0}' on the type '{1}'", sel.Name, type.FullName); } var md = res.MethodDescription; if (md.IsInstanceCategory) { mthis = IntPtr.Zero; } else { var nsobj = Runtime.GetNSObject(obj, Runtime.MissingCtorResolution.ThrowConstructor1NotFound, true); mthis = ObjectWrapper.Convert(nsobj); if (res.Method.ContainsGenericParameters) { return(new MethodDescription(FindClosedMethod(nsobj.GetType(), res.Method), res.ArgumentSemantic).GetUnmanagedDescription()); } } return(md.GetUnmanagedDescription()); }
public void GetMethodDescriptionAndObject(Type type, IntPtr selector, bool is_static, IntPtr obj, ref IntPtr mthis, IntPtr desc) { var sel = Selector.GetName(selector); var res = GetMethodNoThrow(type, type, sel, is_static); if (res == null) { throw ErrorHelper.CreateError(8006, "Failed to find the selector '{0}' on the type '{1}'", sel, type.FullName); } if (res.IsInstanceCategory) { mthis = IntPtr.Zero; } else { try { var nsobj = Runtime.GetNSObject(obj, Runtime.MissingCtorResolution.ThrowConstructor1NotFound, true); mthis = ObjectWrapper.Convert(nsobj); if (res.Method.ContainsGenericParameters) { res.WriteUnmanagedDescription(desc, Runtime.FindClosedMethod(nsobj.GetType(), res.Method)); return; } } catch (Exception e) { throw ErrorHelper.CreateError(8035, e, $"Failed to get the 'this' instance in a method call to {res.DescriptiveMethodName}."); } } res.WriteUnmanagedDescription(desc); }
static void alloc_handle() { var obj = new object(); handle = GCHandle.Alloc(obj, GCHandleType.Pinned); original_addr = ObjectWrapper.Convert(obj); }
public static int test_0_pinned_handle_pins_target() { var t = new Thread(alloc_handle); t.Start(); t.Join(); GC.Collect(); var newAddr = ObjectWrapper.Convert(handle.Target); return(original_addr == newAddr ? 0 : 1); }
void ReleaseManagedRef() { xamarin_release_managed_ref(handle, ObjectWrapper.Convert(this)); }
void CreateManagedRef(bool retain) { xamarin_create_managed_ref(handle, ObjectWrapper.Convert(this), retain); }