-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
[flash] native property support rework #8241
Conversation
This is technically a breaking change, but I think it's fine, because with normal field usage nothing should change and inheritance was already kind of broken anyway :-) |
Can't speak for the implementation, but design wise it seems neat :) The breaking part would be the loader creating the externs with different access and |
one edge-case found in our code base that I still have to deal with: e.g. interface I {
var x(get,set):Float;
}
class C extends Sprite implements I {
// haxe thinks that get_x/set_x is present because that's how we load Sprite extern,
// but these methods are not real, so we have to detect that and generate
// `function get_x() return super.x` so the method becomes "real"
} |
So, in the current state, no metadata is used/required: we just treat non-physical properties as native. That means two things:
I think the only thing that this can break is that the non-physical property will now appear in reflection results, but I hope that's acceptable, given that we already have some |
Is anyone interested in reviewing this? This is kind of important for us so I'd like to have it merged soon. (also I just realized that I have to adapt genas3 for the new flash externs, so some refactorings will come) |
I have no knowledge about abc, but I can review for the generic logic errors. |
Also, what will happen with an existing Haxe code which uses |
I think that will work but it won't generate UPD: fixed |
There's a distinct chance that this'll mess up haxe serialization in subtle ways (e.g. serializes non-physical field, that when unserialized on another static platform causes runtime crash, or when unserialized on flash calls the setter before the object is ready). Probably not relevant for your use case or in fact anybody anymore ever. Still, it feels like the kind of thing that nobody runs into, except for the one guy who will have to spend half a week figuring out what's wrong. Why did you abandon the metadata after all? |
It was more annoying to deal with it than not :) Mostly because of interface property implementation (we gotta check that if the interface requires flash property, the implementation provides it). But I could add back it, I guess, it doesn't matter too much for us. Will look into it. |
68a8bce
to
c936f3f
Compare
should be good enough
This is a PR that reworks native property support for the Flash target. We need this at @innogames, because the current situation is rather sad:
Currently the extern loader loads native properties as they were normal var fields, which causes a lot of issues when inheritance and interface implementation is involved:
@:getter
/@:setter
methods and it gets worse when you want to also compile to e.g. JS with HTML5, where the properties are actually implemented in Haxe, so you have to write something like:get/set
property in the implementation.This PR reworks it so the loader loads native properties as actual Haxe
get/set
properties and also generates fakeget_
/set_
methods that an user can override/implement. Then the generator takes care about them as well: it rewrites externget_x()/set_x()
method access into property access and it generates native getters and setters for non-extern overrides/implementations. Currently this requires marking the properties with@:flash.property
(one can also use this for generating native properties for non-extern classes).