geode-sdk / bindings

Addresses & function signatures for Geometry Dash
46 stars 109 forks source link

keyword/attribute to indicate function shouldnt be hooked #99

Open matcool opened 10 months ago

matcool commented 10 months ago

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.

HJfod commented 10 months ago

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 commented 10 months ago

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