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

WIP: Visitor pattern implementation for serialization #1456

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

garrett-is-a-swann
Copy link
Contributor

Reworks/merges the JSON/Script serialization functions to use a single entity-component "graph" traversal mechanism. This mechanism can also be used by user code in order to perform arbitrary serializations, and/or as a map/reduce mechanism.

distr/flecs.h Outdated Show resolved Hide resolved
@SanderMertens
Copy link
Owner

I like the idea of a visitor that understands the reflection data and provides a simpler user-facing API. The current reflection API is complex, and is also not documented very well.

However, I think such a visitor API would be a better fit for C++ as there the compiler is able to optimize out virtual calls if it knows the type of the visitor. In C having this many callbacks hurts performance since they can't be inlined. Both the JSON serializer and flecs script are performance critical, so I don't think this PR is moving things in the right direction.

Some thoughts on improving the usability of the reflection API:

  • A reflection manual is sorely needed
  • Examples that show how to iterate the TypeSerializer
  • I'd like to explore whether the flecs::cursor API can be extended to provide easier iteration of members/elements
  • A C++ visitor-based approach could start out as an external repository
  • If extending existing APIs proves too cumbersome, the visitor could get upstreamed to flecs

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

Successfully merging this pull request may close these issues.

3 participants