-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathScriptEngine.c
More file actions
68 lines (58 loc) · 1.36 KB
/
ScriptEngine.c
File metadata and controls
68 lines (58 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// MonoLib.cpp : 定义 DLL 应用程序的导出函数。
//
#include "runtime.h"
#include "Mediator.h"
#include "mono/metadata/exception.h"
// Macro to put before functions that need to be exposed to C#
#ifdef _WIN32
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif
const char* il2cpp_exception = NULL;
const char* mono_exception = NULL;
void* g_manageFuncPtr = NULL;
DLLEXPORT void SetupMono(char* bundleDir, const char* dllName)
{
mono_setup(bundleDir,dllName);
}
DLLEXPORT void CloseMono()
{
mono_exit();
}
DLLEXPORT void SetFuncPointer(void * ptr)
{
g_manageFuncPtr = ptr;
}
DLLEXPORT void* GetFuncPointer()
{
return g_manageFuncPtr;
}
DLLEXPORT void OnExceptionIl2cpp(const char* msg)
{
//raise_mono_exception_runtime(msg);
il2cpp_exception = msg;
}
DLLEXPORT void CheckExceptionIl2cpp()
{
if (il2cpp_exception)
{
MonoException* exc = mono_exception_from_name_msg(mono_get_corlib(), "System", "Exception", il2cpp_exception);
il2cpp_exception = NULL;
mono_raise_exception(exc);
}
}
DLLEXPORT void OnExceptionMono(const char* msg)
{
//raise_il2cpp_exception_runtime(msg);
mono_exception = msg;
}
DLLEXPORT void CheckExceptionMono()
{
if (mono_exception)
{
Il2CppException* exc = il2cpp_exception_from_name_msg(il2cpp_get_corlib(), "System", "Exception", mono_exception);
mono_exception = NULL;
il2cpp_raise_exception(exc);
}
}