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

Conversation

@Headline
Copy link
Member

Headline commented Jul 24, 2018

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 Jul 24, 2018
@KyleSanderson

This comment has been minimized.

Copy link
Member

KyleSanderson commented Jul 25, 2018

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

@Headline

This comment has been minimized.

Copy link
Member Author

Headline commented Jul 25, 2018

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

This comment has been minimized.

Copy link
Member

KyleSanderson commented Jul 25, 2018

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

@Headline

This comment has been minimized.

Copy link
Member Author

Headline commented Jul 25, 2018

@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
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@Headline Headline deleted the native-ret-any branch Jul 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.