Kakadu / lablqml

Interfacing Qt/QML with OCaml. Formely known as lablqt
http://kakadu.github.io/lablqml
GNU Lesser General Public License v2.1
159 stars 17 forks source link

Registering metatypes declared in OCaml #42

Open Kakadu opened 7 years ago

Kakadu commented 7 years ago

It should allow declaring types in OCaml

class MyMegaItem = object ... end
let () = registerMetaType_MyMegaItem ()

ad use them in QML

Item {
  MyMetaItem { ... }
}
ghost commented 7 years ago

This is a good direction to go, given that QML is not meant to be bound to, but the other way around (QML encapsulating C++).

Could this approach benefit from @mrvn's work?

Kakadu commented 7 years ago

I'm not sure yet. This week is over busy. The guy came from England and giving lectures about some crazy math(denotational semantics).

On Wed, Feb 1, 2017 at 12:09 AM, orbifx notifications@github.com wrote:

This is a good direction to go, given that QML is not meant to be bound to, but the other way around (QML encapsulating C++).

Could this approach benefit from @mrvn https://github.com/mrvn's work?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Kakadu/lablqt/issues/42#issuecomment-276477218, or mute the thread https://github.com/notifications/unsubscribe-auth/AAav0nwYju8WPkei73r6_LIHbGf3muSTks5rX5TogaJpZM4LxzIY .

Kakadu commented 7 years ago

Writing the status down in case I will not return back to this task.

I did some hacking in the branch declareMetaType. Good thing is that I simplified code generation a bit by using ppx_tools.metaquot ocamlfind package. Another good thing is that we are able to register generated class type in QML engine and use it without error.

The bad thing that is not yet usable in general. It is expected that we define good, useful, non-virtual ocaml class and allow C++ side to use methods from it. But at the moment everything is implemented in another way: ocaml object creates C++ object to use it. Need some more time to investigate it. Not sure when.

ghost commented 7 years ago

What is the output of your approach? Some generated C++ files?

Kakadu commented 7 years ago

Yeah, the same as before.

Kakadu commented 7 years ago

I have moves towards it in branch https://github.com/Kakadu/lablqml/tree/declareMetaType There is a demo: https://github.com/Kakadu/lablqml/tree/declareMetaType/demos/declMetaType1

@orbifx , RFC