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

keyword/attribute to indicate function shouldnt be hooked #99

Open
matcool opened this issue Jan 10, 2024 · 2 comments
Open

keyword/attribute to indicate function shouldnt be hooked #99

matcool opened this issue Jan 10, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@matcool
Copy link
Member

matcool commented Jan 10, 2024

sometimes functions are inlined in a lot of places, or are merged with other functions, which makes hooking a problem, even though itd still be nice to give them an address instead of having to reimplement the whole thing.

@matcool matcool added the enhancement New feature or request label Jan 10, 2024
@HJfod
Copy link
Member

HJfod commented Jan 10, 2024

I'd recommend an attribute:

[[warnhook(inlined)]]
static GameManager* sharedState();

[[warnhook(merged)]]
virtual void draw();

This way tooling could provide a more descriptive warning for why the function shouldn't be hooked. On Broma's side this should just be implemented as an attribute that stores a generic string for the reason, and then in Bindings we should check that the string matches one of a known enum like inlined, merged.

We could also just take in an arbitary string literal:

[[warnhook("Inlined sometimes on Windows")]]
static GameManager* sharedState();

[[warnhook("Merged with StatsCell::draw, CommentCell::draw")]]
virtual void draw();

This would make adding new error cases as easy as writing them, but it could make error messages disjointed and inconsistent.

Alternatively we could just introduce two new keywords, inlined and merged:

inlined static GameManager* sharedState();

merged {
    StatsCell::draw,
    CommentCell::draw,
}
virtual void draw();

This would make syntax for specifying which functions the function is merged with clearer, as doing so with attributes would lead to [[docs]] mess imo:

[[warnhook(merged {
    StatsCell::draw,
    CommentCell::draw,
})]]
virtual void draw();

@matcool
Copy link
Member Author

matcool commented Jan 10, 2024

i think specifying which functions its merged with exactly is a little overkill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants