|
1 | 1 | /* |
2 | 2 | * Tencent is pleased to support the open source community by making Puerts available. |
3 | | -* Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved. |
| 3 | +* Copyright (C) 2020 Tencent. All rights reserved. |
4 | 4 | * Puerts is licensed under the BSD 3-Clause License, except for the third-party components listed in the file 'LICENSE' which may be subject to their corresponding license terms. |
5 | 5 | * This file is subject to the terms and conditions defined in file 'LICENSE', which is part of this source code package. |
6 | 6 | */ |
@@ -40,7 +40,8 @@ function genBridge(bridgeInfo, isOptimizeSize) { |
40 | 40 | var parameterSignatures = il2cpp_snippets.listToJsArray(bridgeInfo.ParameterSignatures); |
41 | 41 | let hasVarArgs = parameterSignatures.length > 0 && parameterSignatures[parameterSignatures.length -1][0] == 'V' |
42 | 42 | return t` |
43 | | -static ${il2cpp_snippets.SToCPPType(bridgeInfo.ReturnSignature)} b_${bridgeInfo.Signature}${isOptimizeSize ? '_inner' : ''}(void* target, ${parameterSignatures.map((S, i) => `${il2cpp_snippets.SToCPPType(S)} p${i}`).map(s => `${s}, `).join('')}MethodInfo* method) { |
| 43 | +// ${bridgeInfo.CsName} |
| 44 | +static ${il2cpp_snippets.SToCPPType(bridgeInfo.ReturnSignature)} b_${bridgeInfo.Signature}(void* target, ${parameterSignatures.map((S, i) => `${il2cpp_snippets.SToCPPType(S)} p${i}`).map(s => `${s}, `).join('')}MethodInfo* method) { |
44 | 45 | // PLog("Running b_${bridgeInfo.Signature}"); |
45 | 46 |
|
46 | 47 | ${IF(bridgeInfo.ReturnSignature && !(il2cpp_snippets.getSignatureWithoutRefAndPrefix(bridgeInfo.ReturnSignature) in il2cpp_snippets.PrimitiveSignatureCppTypeMap))} |
@@ -84,11 +85,11 @@ static ${il2cpp_snippets.SToCPPType(bridgeInfo.ReturnSignature)} b_${bridgeInfo. |
84 | 85 | } |
85 | 86 | ${IF(isOptimizeSize)} |
86 | 87 |
|
87 | | -static void b_${bridgeInfo.Signature}(void* target, ${parameterSignatures.map((S, i) => `Il2CppFullySharedGenericAny p${i}`).map(s => `${s}, `).join('')}${bridgeInfo.ReturnSignature != 'v' ? `Il2CppFullySharedGenericAny * il2ppRetVal,` : ''}MethodInfo* method) { |
| 88 | +static void b_${bridgeInfo.Signature}_Shared(void* target, ${parameterSignatures.map((S, i) => `Il2CppFullySharedGenericAny p${i}`).map(s => `${s}, `).join('')}${bridgeInfo.ReturnSignature != 'v' ? `Il2CppFullySharedGenericAny * il2ppRetVal,` : ''}MethodInfo* method) { |
88 | 89 | ${IF(bridgeInfo.ReturnSignature != 'v')} |
89 | 90 | *((${il2cpp_snippets.SToCPPType(bridgeInfo.ReturnSignature)} *)il2ppRetVal) = |
90 | 91 | ${ENDIF()} |
91 | | - b_${bridgeInfo.Signature}_inner(target, ${parameterSignatures.map((S, i) => `${il2cpp_snippets.FromAny(S)}p${i}`).map(s => `${s}, `).join('')}method); |
| 92 | + b_${bridgeInfo.Signature}(target, ${parameterSignatures.map((S, i) => `${il2cpp_snippets.FromAny(S)}p${i}`).map(s => `${s}, `).join('')}method); |
92 | 93 | } |
93 | 94 | ${ENDIF()} |
94 | 95 | `; |
@@ -132,14 +133,23 @@ static BridgeFuncInfo g_bridgeFuncInfos[] = { |
132 | 133 | {nullptr, nullptr} |
133 | 134 | }; |
134 | 135 |
|
| 136 | +${genInfos.IsOptimizeSize ? ` |
| 137 | +static Il2CppMethodPointer g_bridgeSharedFuncs[] = { |
| 138 | + ${FOR(bridgeInfos, info => t` |
| 139 | + (Il2CppMethodPointer)b_${info.Signature}_Shared, |
| 140 | + `)} |
| 141 | + nullptr |
| 142 | +};` : '' |
| 143 | +} |
| 144 | +
|
135 | 145 |
|
136 | | -Il2CppMethodPointer FindBridgeFunc(const char* signature) |
| 146 | +Il2CppMethodPointer FindBridgeFunc(const char* signature, bool IsShared) |
137 | 147 | { |
138 | 148 | auto begin = &g_bridgeFuncInfos[0]; |
139 | 149 | auto end = &g_bridgeFuncInfos[sizeof(g_bridgeFuncInfos) / sizeof(BridgeFuncInfo) - 1]; |
140 | 150 | auto first = std::lower_bound(begin, end, signature, [](const BridgeFuncInfo& x, const char* signature) {return strcmp(x.Signature, signature) < 0;}); |
141 | 151 | if (first != end && strcmp(first->Signature, signature) == 0) { |
142 | | - return first->Method; |
| 152 | + ${genInfos.IsOptimizeSize ? 'return IsShared ? g_bridgeSharedFuncs[first - begin] : first->Method' : 'return first->Method'}; |
143 | 153 | } |
144 | 154 | return nullptr; |
145 | 155 | } |
|
0 commit comments