Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support call Utilities.ShuffleArray<T>() #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ public ExternMethodSymbol(IMethodSymbol sourceSymbol, AbstractPhaseContext conte
: base(sourceSymbol, context)
{
if (sourceSymbol != null)
ExternSignature = CompilerUdonInterface.GetUdonMethodName(this, context);
{
if (OriginalSymbol is ExternMethodSymbol originalMethodSymbol)
ExternSignature = CompilerUdonInterface.GetUdonMethodName(originalMethodSymbol, context);
else
ExternSignature = CompilerUdonInterface.GetUdonMethodName(this, context);
}
}

public override bool IsExtern => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ public static string GetUdonEventName(string eventName)
public static string GetUdonTypeName(TypeSymbol externSymbol)
{
if (externSymbol is TypeParameterSymbol)
return "T";
return SanitizeTypeName(externSymbol.IsArray ? "T[]" : "T");

return GetUdonTypeName(externSymbol.UdonType.SystemType);
}

Expand Down Expand Up @@ -348,7 +348,7 @@ internal static string GetUdonMethodName(ExternMethodSymbol methodSymbol, Abstra

foreach (IParameterSymbol parameter in parameters)
{
paramStr += $"_{GetUdonTypeName(context.GetTypeSymbol(parameter.Type))}";
paramStr += $"_{GetUdonTypeName(context.GetTypeSymbolWithoutRedirect(parameter.Type))}";
if (parameter.RefKind != RefKind.None)
paramStr += "Ref";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: GenericsTest
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 3a6f059baa1b7af43966bc39afc1b73f,
serializedUdonProgramAsset: {fileID: 11400000, guid: 24a3704bc2443a041abc75adb3025726,
type: 2}
udonAssembly:
assemblyError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@ public void ExecuteTests()

tester.TestAssertion("Generic variant 3", objects.Length == 3 &&
objects[0] == gameObject && objects[1] == transform && objects[2] == this);

CallUdonGenericMethod();
}

void CallUdonGenericMethod()
{
//float[] floatArray;
int[] intArray;
UnityEngine.Object[] unityEngineObjectArray;

//floatArray = new float[] { 1f, 2f };
//while (floatArray[0] == 1f)
// VRC.SDKBase.Utilities.ShuffleArray(floatArray);
//tester.TestAssertion("Call Udon generic method 1", floatArray[0] == 2f);

intArray = new int[] { 1, 2 };
while (intArray[0] == 1)
VRC.SDKBase.Utilities.ShuffleArray(intArray);
tester.TestAssertion("Call Udon generic method 2", intArray[0] == 2);

unityEngineObjectArray = new UnityEngine.Object[] { gameObject, transform };
while (unityEngineObjectArray[0].Equals(gameObject))
VRC.SDKBase.Utilities.ShuffleArray(unityEngineObjectArray);
tester.TestAssertion("Call Udon generic method 3", unityEngineObjectArray[0].Equals(transform));
}
}

Expand Down