少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
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
#include "il2cpp-config.h"
#include "vm/InternalCalls.h"
#include "vm/Runtime.h"
 
#include <map>
#include <string>
 
typedef std::map<std::string, Il2CppMethodPointer> ICallMap;
static ICallMap s_InternalCalls;
 
namespace il2cpp
{
namespace vm
{
    void InternalCalls::Add(const char* name, Il2CppMethodPointer method)
    {
        //ICallMap::iterator res = s_InternalCalls.find(name);
 
        // TODO: Don't assert right now because Unity adds some icalls multiple times.
        //if (res != icalls.end())
        //  IL2CPP_ASSERT(0 && "Adding internal call twice!");
 
        IL2CPP_ASSERT(method);
 
        s_InternalCalls[name] = method;
    }
 
    Il2CppMethodPointer InternalCalls::Resolve(const char* name)
    {
        // Try to find the whole name first, then search using just type::method
        // if parameters were passed
        // ex: First, System.Foo::Bar(System.Int32)
        // Then, System.Foo::Bar
        ICallMap::iterator res = s_InternalCalls.find(name);
 
        if (res != s_InternalCalls.end())
            return res->second;
 
        std::string shortName(name);
        size_t index = shortName.find('(');
 
        if (index != std::string::npos)
        {
            shortName = shortName.substr(0, index);
            res = s_InternalCalls.find(shortName);
 
            if (res != s_InternalCalls.end())
                return res->second;
        }
 
        return NULL;
    }
} /* namespace vm */
} /* namespace il2cpp */