1

The article https://www.dartlang.org/articles/server/native-extensions describes how to use functions written in C/C++ in dart modules. Both the synchronous and asynchronous way of calling C/C++ functions work, and that's very well. However, there is a question: is it possible to transfer a pointer to a function written in dart into module written in C/C++ and use this pointer as a callback function? I.e. to call this function from a module in C/C++ and pass some parameters to it as these parameters changes. Create, suppose a listener in the C/C++ module and subscribe to it in dart? Is there a similar method of communication in dart? Maybe there are some other ways to communicate and transfer data between dart and C/C++? Maybe something completely exotic like EventBus?

Michael Kanzieper
  • 709
  • 1
  • 10
  • 20
  • 1
    You want to *embed* the Dart VM into your C++ code. How to do that (or even if it is possible) is a different question – Basile Starynkevitch Mar 04 '19 at 06:45
  • 1
    @BasileStarynkevitch - I don't think he's trying to invoke Dart from a C++ program. Rather, he's got a Dart program that invokes a native extension. And he wants the native extension in C++ to call back into the Dart program. – selbie Mar 04 '19 at 06:49
  • 1
    @selbie - Your clarification is correct. I really mean how to call the dart function from the extension. – Michael Kanzieper Mar 04 '19 at 07:18

0 Answers0