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

Allow any returns in native callbacks #857

Merged
merged 1 commit into from
Jul 26, 2018
Merged

Allow any returns in native callbacks #857

merged 1 commit into from
Jul 26, 2018

Conversation

Headline
Copy link
Member

Native callbacks currently require plugin authors to retag their returns to an int, but by adding any as another acceptable prototype we allow them to return without needing to retag.

public any Native_Something(Handle plugin, int numParams)
{
    float val =5.0;
    return val; // no tag mismatch
}

Thanks asherkin for bringing this change to light

@Headline Headline requested a review from asherkin July 24, 2018 21:04
@KyleSanderson
Copy link
Member

I guess we still need int in there for old code? is this correct?

@Headline
Copy link
Member Author

The typeset has the older int prototype, this shouldn’t break anything older. Many of our built-in plugins still use the int counterpart and they compile

@KyleSanderson
Copy link
Member

Why not just change it to any then? Does this give some micro-optimization?

@Headline
Copy link
Member Author

@KyleSanderson if we changed int to any and kept the typedef, then every callback would have to be rewritten. While int, float, char can coherse to any, they're still different types and the compiler errors out w/ prototype mismatch. We need that typeset(funcenum) for this change to be possible.

@Headline Headline merged commit 11abe77 into master Jul 26, 2018
@Headline Headline deleted the native-ret-any branch July 26, 2018 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants