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

Accessing argument metadata from tclass_field #11823

Open
Aidan63 opened this issue Nov 13, 2024 · 2 comments
Open

Accessing argument metadata from tclass_field #11823

Aidan63 opened this issue Nov 13, 2024 · 2 comments

Comments

@Aidan63
Copy link
Contributor

Aidan63 commented Nov 13, 2024

Currently there doesn't seem to be a way to access argument metadata on an extern function.

extern class Foo {
    extern function bar(@:cpp.Marshal(c_string) s:String):Void;
}

In the above case there is no way to access the @:cpp.Marshal metadata from a tclass_field. In non extern functions you can inspect the cf_expr TFunction but for externs there is no expression.

I think I've found the place in typeloadFields which types functions but I'm not sure what a good approach is, append the arguments meta to cf_meta and key it by argument name somehow? Add a new cf_argument_meta field?

End goal of this to to have the compiler generate glue code for converting to and from common haxe and c++ types by annotating arguments, it would greatly simplify things being able to look at all extern classes up front as opposed to accumulating a list of all found functions while iterating over the ast.

@Simn
Copy link
Member

Simn commented Nov 18, 2024

Extern functions have been quite annoying in this regard. An adjacent problem is argument default values, which are also part of the expression and required a workaround for externs.

I'd be happy to redesign this, but I'm not sure how. The cleanest approach would probably be to merge cf_kind and cf_expr, but that would cause a rather large amount of friction and I don't know if this is worth it for the potential gains.

I don't think something like cf_argument_meta would be that great because then we have redundant information for non-externs.

@Aidan63
Copy link
Contributor Author

Aidan63 commented Nov 20, 2024

ah, right, I remember coming across the @:value meta for abstract functions with default values, that would be another benefit of any change.

My initial thought was to just re-use or do something very similar to that, but that does just feel like piling on the bodges.

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

No branches or pull requests

2 participants