Commit Graph

3 Commits

Author SHA1 Message Date
Valentin Shergin b3b72bbdcf Fabric: Using types `EventTarget`, `EventHandler` & co. instead of `void *` everywhere
Summary:
Nothing actually changed besides type names... which actually helps me found an issue in FabricUIManager!
Now there is no a single `void *` in Fabric/C++ and JavaScript bindings. Yay!

Reviewed By: fkgozali

Differential Revision: D8191420

fbshipit-source-id: b1eb60b6bc34dd25ab200aab854ffbd7ccf5b15d
2018-05-29 15:03:57 -07:00
Valentin Shergin 957ef606b9 Adding `Wrapper` suffix to `EventHandler` and `EventHandler` type names
Summary:
It's maybe not so important/crucial, but this thing bothers me a lot.
We use raw opaque `EventTarget`, `InstanceHandle` and `EventHandler` pointers in application layer quite a lot and we don't have any kind of type-safety here. I believe all those opaque types should be represented as named scalar types which compiler at least can differentiate at compile time.
So I propose introducing named aliases for them which will point to particular empty `struct`s. This will allow us to tag types properly in all functions and methods and ensure that we pass right values as right arguments.
Again, they are *just aliases*, which are effectively still `void *`, no any additional logic or names are involved.

Unfortunately, those nice type names are already taken by `JSIFabricUIManager` local anonymous namespace (even if they are inside anonymous namespace we cannot use them https://stackoverflow.com/questions/3673353/anonymous-namespace-ambiguity).  I think it's fair to rename them because... it's local. And we already use `Wrapper` suffix for them anyways.

Reviewed By: fkgozali

Differential Revision: D8181151

fbshipit-source-id: 9b55b43fb671a56b32a862ac54f78d528e1188ce
2018-05-29 11:41:49 -07:00
Valentin Shergin 2a3025da97 Fabric: Application layer of events infrastructure
Summary: This implements `EventHandlers` abstract class (aka "Events Guy") which encapsulates `eventDispatcher` and `instanceHandle` (and ownership of future `eventTarget`), all of this as part of existing {ShadowNode + Props + LayoutMetrics + LocalData + Descriptor + (and now) EventHandlers} infra. (We don't plan to add anything else to this model. Ever.)

Reviewed By: fkgozali

Differential Revision: D8053351

fbshipit-source-id: 1dd9ccbcbe5a2eb284b59ea351dc8beca645e8bf
2018-05-22 16:31:58 -07:00