From 4ecf3e9a91bd201396b18e4fa2f7fcfb85715821 Mon Sep 17 00:00:00 2001 From: zentia <363476658@qq.com> Date: Thu, 21 Nov 2024 17:23:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E7=9A=84=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E4=BD=93=E5=9C=A8IOS=E4=BC=A0=E5=8F=82=E6=97=B6?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=86=85=E5=AD=98=E5=B8=83=E5=B1=80?= =?UTF-8?q?crash=20(#1925)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../puerts/templates/il2cppvaluetype.tpl.mjs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppvaluetype.tpl.mjs b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppvaluetype.tpl.mjs index d954a1d0c9f..9b243b6f138 100644 --- a/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppvaluetype.tpl.mjs +++ b/unity/Assets/core/upm/Editor/Resources/puerts/templates/il2cppvaluetype.tpl.mjs @@ -9,18 +9,29 @@ import { FOR, default as t, IF, ENDIF, ELSE } from "./tte.mjs" import * as il2cpp_snippets from "./il2cpp_snippets.mjs" function defineValueType(valueTypeInfo) { - // TODO 会存在一个 IsEnum 且 IsGenericParameter 的类型,signature为空,先过滤处理,晚点彻查。 + // TODO 会存在一个 IsEnum 且 IsGenericParameter 的类型,signature为空,先过滤处理,晚点彻查。 if (!valueTypeInfo.Signature) return '' + var fieldSignatures = il2cpp_snippets.listToJsArray(valueTypeInfo.FieldSignatures); return t`// ${valueTypeInfo.CsName} struct ${valueTypeInfo.Signature} { - ${FOR(il2cpp_snippets.listToJsArray(valueTypeInfo.FieldSignatures), (s, i) => t` + ${IF(fieldSignatures.length == 0)} + union + { + struct + { + }; + uint8_t __padding[1]; + }; + ${ELSE()} + ${FOR(fieldSignatures, (s, i) => t` ${IF(il2cpp_snippets.isNullableStruct(valueTypeInfo.Signature) && i == valueTypeInfo.NullableHasValuePosition)} ${il2cpp_snippets.SToCPPType(s)} hasValue; ${ELSE()} ${il2cpp_snippets.SToCPPType(s)} p${i}; ${ENDIF()} `)} + ${ENDIF()} }; `; }