2016-04-21 15:19:32 +03:00
|
|
|
// vim: set filetype=c :
|
|
|
|
//
|
|
|
|
// Delegates.generated.cs:
|
|
|
|
//
|
|
|
|
// Authors:
|
|
|
|
// Rolf Bjarne Kvinge <rolf@xamarin.com>
|
|
|
|
//
|
|
|
|
// Copyright 2013-2014 Xamarin Inc.
|
|
|
|
//
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file was generated from Delegates.cs.t4, any modifications will be lost once this file is re-generated.
|
|
|
|
*/
|
|
|
|
|
|
|
|
<#@ include file="delegates.t4" #>
|
|
|
|
#if !COREBUILD
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2018-02-05 18:26:29 +03:00
|
|
|
using Foundation;
|
|
|
|
using Registrar;
|
2016-04-21 15:19:32 +03:00
|
|
|
|
2018-02-05 18:26:29 +03:00
|
|
|
namespace ObjCRuntime {
|
2016-04-21 15:19:32 +03:00
|
|
|
public unsafe partial class Runtime {
|
|
|
|
|
|
|
|
<# foreach (var d in delegates) { #>
|
2020-05-04 12:08:25 +03:00
|
|
|
internal delegate <#= d.ReturnType.MType #> <#= d.SimpleEntryPoint #>_delegate (<#= d.MArgumentSignature #>);
|
2016-04-21 15:19:32 +03:00
|
|
|
<# } #>
|
|
|
|
|
|
|
|
internal struct Delegates {
|
|
|
|
<# foreach (var d in delegates) { #>
|
|
|
|
public IntPtr <#= d.SimpleEntryPoint #>;
|
|
|
|
<# } #>
|
|
|
|
}
|
|
|
|
|
|
|
|
<# foreach (var d in delegates) { #>
|
|
|
|
[MonoPInvokeCallback (typeof (<#= d.SimpleEntryPoint #>_delegate))]
|
2020-05-04 12:08:25 +03:00
|
|
|
static <#= d.ReturnType.MType #> <#= d.SimpleEntryPoint #> (<#= d.MArgumentSignature #>)
|
2016-06-02 13:18:45 +03:00
|
|
|
<# if (d.ExceptionHandling) { #>
|
|
|
|
{
|
|
|
|
exception_gchandle = 0;
|
|
|
|
try {
|
|
|
|
<# if (string.IsNullOrEmpty (d.WrappedManagedFunction)) { #>
|
|
|
|
throw new NotImplementedException ();
|
|
|
|
<# } else { #>
|
2020-05-04 12:08:25 +03:00
|
|
|
<# if (d.ReturnType.MType != "void") { #>return <# } #><#=d.WrappedManagedFunction#> (<#=d.MArgumentNames#>);
|
2016-06-02 13:18:45 +03:00
|
|
|
<# } #>
|
|
|
|
} catch (Exception ex) {
|
|
|
|
var handle = GCHandle.Alloc (ex, GCHandleType.Normal);
|
|
|
|
exception_gchandle = GCHandle.ToIntPtr (handle).ToInt32 ();
|
|
|
|
<# if (d.SimpleEntryPoint == "get_nsobject_with_type") { #> created = false;
|
|
|
|
<# } #>
|
2020-05-04 12:08:25 +03:00
|
|
|
<# if (d.ReturnType.MType != "void") { #> return default (<#= d.ReturnType.MType #>);
|
2016-06-02 13:18:45 +03:00
|
|
|
<# } #>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
<# } else { #>
|
2016-04-21 15:19:32 +03:00
|
|
|
{
|
|
|
|
<# if (string.IsNullOrEmpty (d.WrappedManagedFunction)) { #>
|
|
|
|
throw new NotImplementedException ();
|
|
|
|
<# } else { #>
|
2020-05-04 12:08:25 +03:00
|
|
|
<# if (d.ReturnType.MType != "void") { #>return <# } #><#=d.WrappedManagedFunction#> (<#=d.MArgumentNames#>);
|
2016-04-21 15:19:32 +03:00
|
|
|
<# } #>
|
|
|
|
}
|
2016-06-02 13:18:45 +03:00
|
|
|
<# } #>
|
2016-04-21 15:19:32 +03:00
|
|
|
|
|
|
|
<# } #>
|
|
|
|
|
2018-02-02 20:20:58 +03:00
|
|
|
[BindingImpl (BindingImplOptions.Optimizable)] // To inline the Runtime.DynamicRegistrationSupported code if possible.
|
2016-11-01 14:40:51 +03:00
|
|
|
static void RegisterDelegates (InitializationOptions* options)
|
2016-04-21 15:19:32 +03:00
|
|
|
{
|
2018-02-02 20:20:58 +03:00
|
|
|
<# foreach (var d in delegates) {
|
|
|
|
if (d.OnlyDynamicUsage) continue; #>
|
|
|
|
options->Delegates-><#= d.SimpleEntryPoint #> = GetFunctionPointer (new <#= d.SimpleEntryPoint #>_delegate (<#= d.SimpleEntryPoint #>));
|
|
|
|
<# } #>
|
|
|
|
|
|
|
|
// The linker will remove this condition (and the subsequent method call) if possible
|
|
|
|
if (DynamicRegistrationSupported)
|
|
|
|
RegisterDelegatesDynamic (options);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void RegisterDelegatesDynamic (InitializationOptions* options)
|
|
|
|
{
|
|
|
|
<# foreach (var d in delegates) {
|
|
|
|
if (!d.OnlyDynamicUsage) continue; #>
|
2016-11-01 14:40:51 +03:00
|
|
|
options->Delegates-><#= d.SimpleEntryPoint #> = GetFunctionPointer (new <#= d.SimpleEntryPoint #>_delegate (<#= d.SimpleEntryPoint #>));
|
2016-04-21 15:19:32 +03:00
|
|
|
<# } #>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|