cross-language-cpp / djinni-generator

Command-line tool that generates gluecode from a djinni-IDL file

Home Page:https://djinni.xlcpp.dev/djinni-generator/setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to declare a callable type in IDL and add it to an arg of an interface method?

DominicCabral opened this issue · comments

My use case is that I'm trying to pass a callback as a an argument of a method within my interface, something like:

InitializeCallback = function {
    state: MyState;
    error: MyError;
}

my_interface = interface +c {
    initialize(callback: InitializeCallback);
}

If not, is there a plan to support it?

Your sample is not clear to me, except, it looks very java script like but that is a different domain.

You can already pass classes as callbacks today, and people do that.

Let me try a better explanation. My C++ header that I'm trying to replicate via IDL has methods that require function callbacks as so:

    void initialize(const std::function<void(const MyState*, MyError)>& handler);

Is that a little more clear?

Please read this comment from @artwyman in the former dropbox repo , since I could not explain it better.
dropbox/djinni#425 (comment)
This has not changed, and very likely will not change in reasonable time (or ever if no one implements it)
Does this answer your question?

It does, again, thanks for your quick response @a4z!