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

Qt support #25

Open
haxscramper opened this issue Oct 23, 2021 · 1 comment
Open

Qt support #25

haxscramper opened this issue Oct 23, 2021 · 1 comment
Labels
open for design discussion question Further information is requested

Comments

@haxscramper
Copy link
Owner

haxscramper commented Oct 23, 2021

I don't think it makes sense to try and provide an overly generalized solution that might be further extended in order to work with Qt. Instead, support should be built-in, especially considering this is a non-trivial thing to do even in this mode.

Without accounting for some basic interop problems, like extreme difficulty of inheritance #2 , wrapping methods #1 and other things that are most likely yet to be discovered, there are some Qt-specific problems, that make it harder to provide meaningful wrappers. Specifically - signal and slot mechanism, dynamic properties. Latter one is not as fundamental as slots, so it can be addressed sometimes later. Slots on the other hand are the most important feature, and I really need to consider how to approach them.

  • Generating list of existing signals and slots.
    • Proof Of Concept: Re-implementing Qt moc using libclang provides an implementation of a tool that can read and analyze C++ source code while keeping track of the signal/slot mechanism. The problem with implementation - despite the article name, it uses libtooling API, which is quite hard to wrap, and will require a lot more stability than just Qt libtooling wrappers #19.
    • The alternative solution is to rely on boost::wave capabilities once again, in order to keep track of all macros that have been expanded. Considering Qt is split into lots of very clean headers (one per class), running tree-sitter&boost::wave pipeline would be a lot faster.
      • It is possible to fork and modify tree-sitter grammar for C++, to allow for signals/slots to be included in the access_specifier rule pattern.

Related

@haxscramper haxscramper added open for design discussion question Further information is requested labels Oct 23, 2021
haxscramper added a commit that referenced this issue Nov 2, 2021
- ADDED ::
  - Support for reading Qt signals, slots
  - General C++ method, constructor handling
- NEXT ::
  - Make a simplified test for Qt wrapper generator before going into
    wrapping whole Qt library.
  - #25
haxscramper added a commit that referenced this issue Nov 12, 2021
- ADDED ::
  - Support for `__attribute__((annotate("qt_signal")))` annotation
    detection for the libclang-based frontend.
  - Get parent translation unit from any cursor
- REMOVED ::
  - `.unit` field fron `WrapConf` value - when needed it can be retrieved
    using `getParentTranslationUnit()`
- RELATED ::
  - #25
@haxscramper
Copy link
Owner Author

After reading https://woboq.com/blog/verdigris-qt-without-moc.html I think it would be possible to use https://github.com/woboq/verdigris approach, either directly or via additional codegen. I would need to generate c++ classes at some point anyway, so it makes sense to extend on that approach. Although, generated header files could be processed my mic as well, but it would require separate build step after every class has been generated. Is it possible run nim compiler in steps? Generate cxx code, and then compile things separately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open for design discussion question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant