Skip to content

Design proposal for new API#1

Draft
naritanara wants to merge 7 commits into
mainfrom
api_redesign
Draft

Design proposal for new API#1
naritanara wants to merge 7 commits into
mainfrom
api_redesign

Conversation

@naritanara

@naritanara naritanara commented Aug 25, 2025

Copy link
Copy Markdown
Member

The new api is under a new namespace to make it easier to review, when approved it will be moved to the current API location. Having this PR allows me to receive feedback and slowly adjust the API until we find a set of headers that we are happy to commit to.

Summary:

  • Two public APIs:
    • Visualizer API: Optimized for space and traversal speed
    • Parser API: Optimized for fast insertion
  • libizumi translates between these two APIs
  • New supported features:
    • async parsing
    • dynamically loaded parsers
    • full kanata compatibility

@naritanara naritanara added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Aug 25, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this new API, I understand that the instruction table array stores multiple traces, instead of a single trace divided into different instruction tables. Is that correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just fixed the signatures for what I was intending. The expected flow is:

  1. izumi_prepare() to init the parser and get a handle
  2. izumi_parse() to add a table to the array (a size hint is provided to achieve asyncronous parsing)
  3. izumi_done() to invalidate the handle and free all parsing resources, except the table array, which will probably outlive the parser.

If multiple traces are open, multiple izumi_handles are needed.

@naritanara

Copy link
Copy Markdown
Member Author

How to parser:

  1. In the prepare method, try to start loading the file or error. If returning an okay value, the callee must save the handle and use it to further refer to the ongoing parse process.
  2. In the parse method, the only modification allowed is to add another node to the instruction table. The initial node and any node already given in a previous parse call should not be modified. This allows the parser to exist in a separate thread, with the parse method causing this thread to start working on another table and link the current one to the last one provided to libizumi (this is optional, it can all happen synchronously in a single thread).
  3. In the done method, all resources should be freed, except the tables which are owned by libizumi.

@theOfficeCat

Copy link
Copy Markdown
Member

This seems good, I will start porting the previous version of the library to the new API and see if there is something missing that would be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants