-
-
Notifications
You must be signed in to change notification settings - Fork 658
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
[cpp] Support type parameters on extern classes #10415
[cpp] Support type parameters on extern classes #10415
Conversation
Hmm, was hoping the failing cppia test was something being flakey, but seems I have broken something (and the mac ci seems stuck running as well) |
There we are, all green now. That's what I get for changing code I thought I understood. |
…nition on struct classes in case of extern class type parameter
Had an issue where if you tried to use another extern class for the T parameter, passing an object of that type into an extern function would cause it be casted to dynamic and refuse to compile. The issue seemed to be when a function call is retyped it uses the types of the TFun which in the case of generics will be something like I worked around this by using the types of the arguments being passed in instead of the argument types of the function definition when retyping the function for Also, these two new CI failures seem unrelated. |
Hello,
I've added support for type parameters / generic extern classes for cpp. Main change is that
TCppInst
now carries a list oftcpp
type parameters around with it which are used if the class is extern. This allows you to write externs like in the following example, where previously you'd need to write externs for each type of the native templated type (or do stuff like have a generic extern but then extern it with another extern specifying the type).which generates cpp code looking like this.
One thing you can't do with generic externs is something like
@:native('::cpp::Struct<std::vector>')
for templated classes like you can with non templated classes as the parameters are simply appened to the end (maybe we need a new meta like@:structWrap
to auto wrap the type in acpp.Struct
?).