Added demo for cpp module and updated the CppModule
This commit is contained in:
@@ -4,12 +4,6 @@ namespace CppCompatibilityModule.Extern;
|
||||
|
||||
public static class Delegates
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ProcessObject(ref object obj);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void ExecuteDelegateFunction();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void SetExternFunctionPointerDelegate(IntPtr funcPtr);
|
||||
|
||||
|
||||
@@ -116,23 +116,6 @@ namespace CppCompatibilityModule.Extern
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void CallFunction(string methodName, ref object parameter)
|
||||
{
|
||||
var functionDelegate = GetDelegateForFunctionPointer<Delegates.ProcessObject>(methodName);
|
||||
|
||||
functionDelegate(ref parameter);
|
||||
|
||||
_Logger.Log($"Function {methodName} called successfully with parameter");
|
||||
}
|
||||
|
||||
public void CallFunction(string methodName)
|
||||
{
|
||||
var functionDelegate = GetDelegateForFunctionPointer<Delegates.ExecuteDelegateFunction>(methodName);
|
||||
|
||||
functionDelegate();
|
||||
|
||||
_Logger.Log($"Function {methodName} called successfully");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,24 +17,14 @@ public class ExternalApplication
|
||||
this._Logger = logger;
|
||||
}
|
||||
|
||||
internal void CallFunction(string methodName, ref object parameter)
|
||||
{
|
||||
_ExternLibrary.CallFunction(methodName, ref parameter);
|
||||
}
|
||||
|
||||
internal void CallFunction(string methodName)
|
||||
{
|
||||
_ExternLibrary.CallFunction(methodName);
|
||||
}
|
||||
|
||||
internal T GetDelegateForFunctionPointer<T>(string methodName) where T : Delegate
|
||||
{
|
||||
return _ExternLibrary.GetDelegateForFunctionPointer<T>(methodName);
|
||||
}
|
||||
|
||||
internal void SetExternFunctionToPointToFunction(string externalFunctionName, Delegates.CsharpFunctionDelegate localFunction)
|
||||
internal object? SetExternFunctionToPointToFunction<TLocalFunctionDelegate>(string externalFunctionName, TLocalFunctionDelegate localFunction) where TLocalFunctionDelegate : Delegate
|
||||
{
|
||||
_ExternLibrary.SetExternFunctionSetterPointerToCustomDelegate<Delegates.SetExternFunctionPointerDelegate, Delegates.CsharpFunctionDelegate>(externalFunctionName, localFunction);
|
||||
return _ExternLibrary.SetExternFunctionSetterPointerToCustomDelegate<Delegates.SetExternFunctionPointerDelegate, TLocalFunctionDelegate>(externalFunctionName, localFunction);
|
||||
}
|
||||
|
||||
internal void FreeLibrary()
|
||||
|
||||
Reference in New Issue
Block a user