forked from loongly/PureScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectStore.cs
More file actions
51 lines (40 loc) · 1.43 KB
/
ObjectStore.cs
File metadata and controls
51 lines (40 loc) · 1.43 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
//#define WRAPPER_SIDE
using AOT;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
internal static class ObjectStore
{
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern object GetObject(IntPtr ptr);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern IntPtr GetObjectPtr(object obj);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void GetReturnArrayToMono(Array src, ref IntPtr dest);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void GetReturnStructToMono(IntPtr src, ref IntPtr dest, Type structType, int size);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern IntPtr ConvertObjectIl2CppToMono(object obj);
public static IntPtr Store(object obj)
{
// if (obj == null)
// {
// UnityEngine.Debug.LogError("ObjectStore.Store() obj is null");
// return IntPtr.Zero;
// }
return GetObjectPtr(obj);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T Get<T>(IntPtr handle) where T : class
{
// if (handle == IntPtr.Zero)
// {
// UnityEngine.Debug.LogError("ObjectStore.Get() handle is IntPtr.Zero");
// return null;
// }
var obj = GetObject(handle);
return obj as T;
}
}