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

General implementation roadmap #5

Closed
5 of 16 tasks
haxscramper opened this issue Aug 29, 2021 · 1 comment
Closed
5 of 16 tasks

General implementation roadmap #5

haxscramper opened this issue Aug 29, 2021 · 1 comment
Labels

Comments

@haxscramper
Copy link
Owner

haxscramper commented Aug 29, 2021

  • Libclang-based implementation
    • Remove old implementation of the source code processing, use CxxT IR instead
  • Tree-sitter based implementation
    • Figure out how to use boost wave in general, make a POC implementation for preprocessor wrapper
    • Wrap boost wave in a shared library that provides a simple C callback-based API, in order to be able to use it from nim on all backends. Boost wave is heavily templated, so it would be very inconvenient to interface with it anyway (from nim). Partially done, see src/boost_wave
    • Implement tree-sitter based C/C++ converter that uses selectively preprocessed C code from previous step. Partially done, see src/hc_tsreader
    • C and C++ code translation. Partially done, right now mostly works with plain C code. See src/hc_tsconvert
  • General
    • Finalize implementation of the source-agnostic (from tree-sitter or libclang) intermediate representation, base all further transformations on it. Partially done, see src/hc_save

    • Reimplement type graph construction and convenience override generation using CxxT IR

    • Automatically generate boilerplate code that makes wrappers easier to use #10

      • Convert ‘out’ arguments for C functions to nim tuple[] returns :: Need to know which parameters are in, which are out. Sometimes this is mentioned in documentation, but in general this is a "dark knowledge", not formally noted down anywhere.
      • Wrap ‘raw’ C procedures that return exit codes to raising ones :: Specify list of allowed values, and relations between regular int return and some enum definition.
      • Convert ‘macro enum groups’ into full nim enums (#define PAPI_OK 0, #define PAPI_EINVAL -1) :: It is possible to infer macro enum boundaries to some degree (if they follow certain naming pattern), but grouping based on "enum begin" and "enum end" seems less error-prone.
    • CLI tool for generating wrappers

  • Helper macros :: Sometimes it is easier to write a small file with couple classes/procs rather than installing and running external wrapper generator. This is also needed for interfacing with C++ classes - I need to generate a C++ class and then .importcpp. it back. Not reusing main codegen implementation would be a waste.
@haxscramper haxscramper changed the title hcparse todo General implementation roadmap Sep 19, 2021
@haxscramper
Copy link
Owner Author

Split into smaller issues, partially added into Alpha version project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant