<commit_before>﻿using System;
using System.Linq;
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;

namespace Urho.iOS
{
	public static class ApplicationLauncher
	{
		[DllImport("mono-urho")]
		extern static void InitSdl(string resDir, string docDir);

		[DllImport("mono-urho", CallingConvention = CallingConvention.Cdecl)]
		extern static void SDL_SetMainReady();

		public static void Run(Func<Application> appCreator)
		{
			string docs = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.All, true).FirstOrDefault();
			string resources = NSBundle.MainBundle.ResourcePath;
			Run(appCreator, resources, docs);
		}

		public static void Run(Func<Application> appCreator, string resourcesDir, string docsDir)
		{
			Application.SetCustomApplicationCallback(Setup, Start, Stop);
			InitSdl(resourcesDir, docsDir);
			SDL_SetMainReady();
			NSFileManager.DefaultManager.ChangeCurrentDirectory(resourcesDir);
			appCreator().Run();
		}

		[MonoPInvokeCallback(typeof(Application.ActionIntPtr))]
		private static void Stop(IntPtr value)
		{
			Application.GetApp(value).Stop();
		}

		[MonoPInvokeCallback(typeof(Application.ActionIntPtr))]
		private static void Start(IntPtr value)
		{
			Application.GetApp(value).Start();
		}

		[MonoPInvokeCallback(typeof(Application.ActionIntPtr))]
		private static void Setup(IntPtr value)
		{
			Application.GetApp(value).Setup();
		}
	}
}<commit_msg>[iOS] Callbacks from native to managed should be marked with [MonoPInovokeCallback] - an ugly workaround because I can't use it in PCL :(.<commit_after>﻿using System;
using System.Linq;
using System.Runtime.InteropServices;
using Foundation;
using ObjCRuntime;

namespace Urho.iOS
{
	public static class ApplicationLauncher
	{
		[DllImport("mono-urho")]
		extern static void InitSdl(string resDir, string docDir);

		[DllImport("mono-urho", CallingConvention = CallingConvention.Cdecl)]
		extern static void SDL_SetMainReady();

		public static void Run(Func<Application> appCreator)
		{
			string docs = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.All, true).FirstOrDefault();
			string resources = NSBundle.MainBundle.ResourcePath;
			Run(appCreator, resources, docs);
		}

		public static void Run(Func<Application> appCreator, string resourcesDir, string docsDir)
		{
			Application.SetCustomApplicationCallback(Setup, Start, Stop);
			UrhoObject.SetCustomObjectCallback(ObjectCallback);
			InitSdl(resourcesDir, docsDir);
			SDL_SetMainReady();
			NSFileManager.DefaultManager.ChangeCurrentDirectory(resourcesDir);
			appCreator().Run();
		}

		[MonoPInvokeCallback(typeof(Application.ActionIntPtr))]
		private static void Stop(IntPtr value)
		{
			Application.GetApp(value).Stop();
		}

		[MonoPInvokeCallback(typeof(Application.ActionIntPtr))]
		private static void Start(IntPtr value)
		{
			Application.GetApp(value).Start();
		}

		[MonoPInvokeCallback(typeof(Application.ActionIntPtr))]
		private static void Setup(IntPtr value)
		{
			Application.GetApp(value).Setup();
		}

		[MonoPInvokeCallback(typeof(ObjectCallbackSignature))]
		static void ObjectCallback(IntPtr data, int stringhash, IntPtr variantMap)
		{
			GCHandle gch = GCHandle.FromIntPtr(data);
			Action<IntPtr> a = (Action<IntPtr>)gch.Target;
			a(variantMap);
		}
	}
}
{'fraction_non_alphanumeric': 0.10466507177033493, 'fraction_numerical': 0.0, 'mean_word_length': 5.716867469879518, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4650743', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1020, 'n_words': 208}