Skip to content

Commit 0468e30

Browse files
committed
Add string constructor internal call implementation
1 parent 2aa0375 commit 0468e30

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

il2cpp/RuntimeInternals.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,21 @@ public static bool GenInternalMethod(MethodGenerator metGen, CodePrinter prt)
5656
else if (metName == "FastAllocateString")
5757
{
5858
prt.AppendFormatLine(
59-
"cls_String* str = (cls_String*)IL2CPP_NEW(sizeof(cls_Object) + sizeof(int32_t) + sizeof(uint16_t) * (arg_0 + 1), {0}, 1);",
59+
"cls_String* str = (cls_String*)IL2CPP_NEW(sizeof(cls_String) + sizeof(uint16_t) * arg_0, {0}, 1);",
6060
genContext.GetStringTypeID());
6161
prt.AppendFormatLine("str->{0} = arg_0;",
6262
genContext.GetFieldName(fldLen));
6363
prt.AppendLine("return str;");
6464
return true;
6565
}
66+
else if (metSigName == ".ctor|Void(Char*,Int32,Int32)|20")
67+
{
68+
prt.AppendFormatLine("arg_0->{0} = arg_3;",
69+
genContext.GetFieldName(fldLen));
70+
prt.AppendFormatLine("IL2CPP_MEMCPY(&arg_0->{0}, arg_1 + arg_2, sizeof(uint16_t) * arg_3);",
71+
genContext.GetFieldName(fldFirstChar));
72+
return true;
73+
}
6674
}
6775
else if (typeName == "System.Array")
6876
{

0 commit comments

Comments
 (0)