Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Convert Il2Cpp Delegates to System Delegates in Method Signatures #195

Open
ds5678 opened this issue Dec 22, 2024 · 0 comments
Open

Convert Il2Cpp Delegates to System Delegates in Method Signatures #195

ds5678 opened this issue Dec 22, 2024 · 0 comments
Labels
generation Related to assembly generation

Comments

@ds5678
Copy link
Collaborator

ds5678 commented Dec 22, 2024

In theory, all Il2Cpp Action and Func delegates in method signatures could be converted to their System counterparts. This would be emitted as a separate overload, rather than a direct substitution. It synergizes well with #148 and allows more system interfaces to be implemented, such as INotifyCompletion (which was the incentive for #133).

public Il2CppSystem.Action Method(Il2CppSystem.Action normalParam, in Il2CppSystem.Action inParam, out Il2CppSystem.Action outParam);

public System.Action Method(System.Action normalParam, in System.Action inParam, out System.Action outParam)
{
    // Conversions are shown explicitly here for clarity, even though they're actually implicit
    var normalParamIl2Cpp = (Il2CppSystem.Action)normalParam;
    var inParamIl2Cpp = (Il2CppSystem.Action)inParam;
    Il2CppSystem.Action result = Method(normalParamIl2Cpp, in inParamIl2Cpp, out Il2CppSystem.Action outParamIl2Cpp);
    outParam = (System.Action)outParamIl2Cpp;
    return (System.Action)result;
}

In theory, ref parameters could also be supported.

public void Method(ref Il2CppSystem.Action param);

public void Method(ref System.Action param)
{
    // Conversions are shown explicitly here for clarity, even though they're actually implicit
    var paramIl2Cpp = (Il2CppSystem.Action)param;
    Method(ref paramIl2Cpp);
    param = (System.Action)paramIl2Cpp;
}

Property accessors and conversion operators should be excluded. Converting event methods might enable #163 to become a reality.

Discussed briefly here: #133 (comment)

@ds5678 ds5678 added the generation Related to assembly generation label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generation Related to assembly generation
Projects
None yet
Development

No branches or pull requests

1 participant