mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 22:23:29 -07:00
[iOS] Add MonoPInvokeCallback tag to fix error on device
See https://stackoverflow.com/questions/12340113/monotouchbass-dll-application-crash-attempting-to-jit-compile-method-whi
This commit is contained in:
parent
a550a60428
commit
872dbaa06e
1 changed files with 46 additions and 1 deletions
|
@ -102,17 +102,28 @@ namespace CalculationManager
|
|||
[DllImport(DllPath)]
|
||||
public static extern CommandType IExpressionCommand_GetCommandType(IntPtr pExpressionCommand);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate IntPtr GetCEngineStringFunc(IntPtr state, IntPtr id);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void BinaryOperatorReceivedFunc(IntPtr state);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetPrimaryDisplayCallbackFunc(IntPtr state, IntPtr pDisplayStringValue, bool isError);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetIsInErrorCallbackFunc(IntPtr state, bool isError);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetParenthesisNumberCallbackFunc(IntPtr state, int parenthesisCount);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void MaxDigitsReachedCallbackFunc(IntPtr state);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void MemoryItemChangedCallbackFunc(IntPtr state, int indexOfMemory);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void OnHistoryItemAddedCallbackFunc(IntPtr state, int addedItemIndex);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void OnNoRightParenAddedCallbackFunc(IntPtr state);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetExpressionDisplayCallbackFunc(IntPtr state, IntPtr data);
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetMemorizedNumbersCallbackFunc(IntPtr state, int count, IntPtr newMemorizedNumbers);
|
||||
|
||||
public static GetCEngineStringFunc _getCEngineStringCallback = GetCEngineStringCallback;
|
||||
|
@ -128,6 +139,9 @@ namespace CalculationManager
|
|||
public static SetExpressionDisplayCallbackFunc _setExpressionDisplayCallback = SetExpressionDisplayCallback;
|
||||
public static SetMemorizedNumbersCallbackFunc _setMemorizedNumbersCallback = SetMemorizedNumbersCallback;
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(MaxDigitsReachedCallbackFunc))]
|
||||
#endif
|
||||
public static void MaxDigitsReachedCallback(IntPtr state)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -136,6 +150,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.MaxDigitsReachedCallback");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(MemoryItemChangedCallbackFunc))]
|
||||
#endif
|
||||
public static void MemoryItemChangedCallback(IntPtr state, int indexOfMemory)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -144,6 +161,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.MemoryItemChangedCallback({indexOfMemory})");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(OnHistoryItemAddedCallbackFunc))]
|
||||
#endif
|
||||
public static void OnHistoryItemAddedCallback(IntPtr state, int addedItemIndex)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -152,6 +172,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.OnHistoryItemAddedCallback({addedItemIndex})");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(OnNoRightParenAddedCallbackFunc))]
|
||||
#endif
|
||||
public static void OnNoRightParenAddedCallback(IntPtr state)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -160,6 +183,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.OnNoRightParenAddedCallback");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(SetExpressionDisplayCallbackFunc))]
|
||||
#endif
|
||||
public static void SetExpressionDisplayCallback(IntPtr state, IntPtr historyItem)
|
||||
{
|
||||
DebugTrace($"CalculatorManager.SetExpressionDisplayCallback({state}, {historyItem})");
|
||||
|
@ -177,6 +203,9 @@ namespace CalculationManager
|
|||
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(SetMemorizedNumbersCallbackFunc))]
|
||||
#endif
|
||||
public static void SetMemorizedNumbersCallback(IntPtr state, int count, IntPtr newMemorizedNumbers)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -193,6 +222,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.SetMemorizedNumbersCallback({string.Join(";", numbers)})");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(SetParenthesisNumberCallbackFunc))]
|
||||
#endif
|
||||
public static void SetParenthesisNumberCallback(IntPtr state, int parenthesisCount)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -201,6 +233,10 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.SetParenthesisNumberCallback({parenthesisCount})");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(BinaryOperatorReceivedFunc))]
|
||||
#endif
|
||||
|
||||
public static void BinaryOperatorReceivedCallback(IntPtr state)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -209,6 +245,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.BinaryOperatorReceivedCallback");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(SetPrimaryDisplayCallbackFunc))]
|
||||
#endif
|
||||
public static void SetPrimaryDisplayCallback(IntPtr state, IntPtr pDisplayStringValue, bool isError)
|
||||
{
|
||||
var displayStringValue = PtrToString(pDisplayStringValue);
|
||||
|
@ -219,6 +258,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.SetPrimaryDisplayCallback({displayStringValue}, {isError})");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(SetIsInErrorCallbackFunc))]
|
||||
#endif
|
||||
public static void SetIsInErrorCallback(IntPtr state, bool isError)
|
||||
{
|
||||
var manager = GCHandle.FromIntPtr((IntPtr)state).Target as CalculatorDisplay;
|
||||
|
@ -227,6 +269,9 @@ namespace CalculationManager
|
|||
DebugTrace($"CalculatorManager.SetIsInErrorCallback({isError})");
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
[ObjCRuntime.MonoPInvokeCallback(typeof(GetCEngineStringFunc))]
|
||||
#endif
|
||||
public static IntPtr GetCEngineStringCallback(IntPtr state, IntPtr pResourceId)
|
||||
{
|
||||
var provider = GCHandle.FromIntPtr(state).Target as EngineResourceProvider;
|
||||
|
@ -321,7 +366,7 @@ namespace CalculationManager
|
|||
|
||||
|
||||
public partial class CalculatorManager : ICalcDisplay
|
||||
{
|
||||
{
|
||||
|
||||
private GCHandle _displayCallbackHandle;
|
||||
private GCHandle _resourceProviderHandle;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue