dotherside
dotherside copied to clipboard
Add support for QQuickItem
it would be cool to being able to create QQuickItem instances from a binded language. This woud allow custom QQuickItems. For sure this is going to be a big task
I'm curious won't it be simpler to interface to C++ directly from dlang?
What do you mean? :)
Il 16 apr 2017 22:31, "drug007" [email protected] ha scritto:
I'm curious won't it be simpler to interface to C++ directly from dlang?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/filcuc/DOtherSide/issues/44#issuecomment-294372541, or mute the thread https://github.com/notifications/unsubscribe-auth/AG07ozr-9ANT3BQnuZVwntRVHQVXBPzNks5rwnqKgaJpZM4Ju_ov .
I mean do not use intermediate c layer but link against c++ code directly using extern(C++) (plus some wrapper of course for special members)
Maybe, but it's not the goal of this library. This c layer exists for not reimplementing the c layer in every language (like go-qml and others). This c bindings are already used by 3 languages D, Nim and Rust. All languages profit from the progress of this library. That said even if D has some interfacing machinery in place for talking with C++ in the end you will need to create some support library...So here it is :)
Il 16 apr 2017 22:39, "drug007" [email protected] ha scritto:
I mean do not use intermediate c layer but link against c++ code directly using extern(C++) (plus some wrapper of course for special members)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/filcuc/DOtherSide/issues/44#issuecomment-294372998, or mute the thread https://github.com/notifications/unsubscribe-auth/AG07o5HsUHnYK6kmjLWKYvgp4K8kcMYdks5rwnyagaJpZM4Ju_ov .
I see, but may be dlang can be used to automate binding? But of course it's offtopic of this issue.
A possible alternative is prototyping a generator with clang api in order to parse the C++ Qt headers and than generate our code. If it was me i would start with a python script given that is super simple and already gas clang bindings.
Could you provide some example of the script to look for evaluation? have no experience with neither python nor clang, but some years ago I intended to write a plugin for clang, so I have some understanding.
Something like http://eli.thegreenplace.net/2011/07/03/parsing-c-in-python-with-clang
Il 17 apr 2017 08:38, "drug007" [email protected] ha scritto:
Could you provide some example of the script to look for evaluation? have no experience with neither python nor clang, but some years ago I intended to write a plugin for clang, so I have some understanding.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/filcuc/DOtherSide/issues/44#issuecomment-294416651, or mute the thread https://github.com/notifications/unsubscribe-auth/AG07o4BDMnAEeEkrk-JsHjFy79DeTHp8ks5rwwjugaJpZM4Ju_ov .
At First the script should extract the class name and its list of function plus virtual functions and their parameters.
Il 17 apr 2017 08:49, "Filippo Cucchetto" [email protected] ha scritto:
Something like http://eli.thegreenplace.net/2011/07/03/parsing-c-in- python-with-clang
Il 17 apr 2017 08:38, "drug007" [email protected] ha scritto:
Could you provide some example of the script to look for evaluation? have no experience with neither python nor clang, but some years ago I intended to write a plugin for clang, so I have some understanding.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/filcuc/DOtherSide/issues/44#issuecomment-294416651, or mute the thread https://github.com/notifications/unsubscribe-auth/AG07o4BDMnAEeEkrk-JsHjFy79DeTHp8ks5rwwjugaJpZM4Ju_ov .
I managed to get the class name and list of methods and their args. Dirty output, but nevertheless. I forked dstep
and made some addition to translate c++ code, you can check here. To build just type dub build
, to translate QQuickItem
use :
bin/dstep -I/usr/include/x86_64-linux-gnu/qt5/ -x c++ /usr/include/x86_64-linux-gnu/qt5/QtQuick/qquickitem.h -fPIC -o qquickitem.d
The problems now are (don't work):
- enum translation
- nested structs
- some args of method
- ctor/dtor aren't handled at all
Enum I guess need to be translated, not sure about nested structs, also don't know what to do with expanded Q_QBJECT
like oid* qt_metacast (const(char)*);
etc - they are translated, but should be?
Now I try to make bindings to QPoint and already have some question like what's the best way to interface with c++ operators like div, mul etc - should they be just reimplemented in binding language?
Also because I'm intrested in dlang bindings I'll try to make its directly using dlang abilities just to research the sitiation to realize what to do. Afterwards it'll be possible to make bindings in "standard" way through C interface.
@drug007 ok but honestly i'd go with a tool that uses clang and not some other techs. Using clang is the way to imho but this doesn't mean you can't do or research other ways. But i'm saying that just to be honest 😄 . Connected to this (since i mantain also DQml) i would not like to make it independent from DOtherSide or better: i would like to make it independent 'if and only if' we develop an automatic generation of bindings that is pluggable in order to be used also by rust and nim. Sorry for being straight but i prefear to be clear in my views on DOtherSide, DQml, NimQml and Rust bindings
I totally understand your position about DOtherSide, I am agreed and will help with it if I can. Despite dlang abilities to link to c++ directly they aren't enought to avoid intermediate layer like DOtherSide.
What about clang - dstep uses libclang underhood and I'm sure that it is appropriate tool to base off, don't you think so?