Open mathiasi opened 5 years ago
Thanks! Implementing interfaces is definitely in the pipeline, but right now you can use already supported std::function<> parameters to implement callbacks to client languages.
Good to hear! Yea I found the way to do callbacks but that doesn't fully meet my needs. I need entire interfaces to be implemented in the client language and have it passed to C++. I'll keep an eye out for updates :)
@Boris-Rasin do I understand correctly that using c++ interfaces in client languages is impossible now?
For instance, I have an interface Foo, it's implementation and the factory Bar that produces Foo. I get a SIGABRT on creating Foo object in JNI.
Bar.h
#include <memory>
#include <scapix/bridge/object.h>
#include "Foo.h"
class Bar : public scapix::bridge::object<Bar> {
public:
std::shared_ptr<Foo> getFoo() {
return std::static_pointer_cast<Foo>(std::make_shared<FooImpl>());
}
};
Foo.h
#include <scapix/bridge/object.h>
class Foo : public scapix::bridge::object<Foo> {
public:
virtual ~Foo() = default;
virtual void baz() = 0;
};
class FooImpl : public Foo {
public:
void baz() override {}
};
client's code
val bar = Bar()
val foo = bar.getFoo() // SIGABRT here
foo.baz()
dmalukov, this issue is about support for interfaces as callbacks from C++ (in addition to std::function support). Your example is supposed to work. I will take a look. Can you open a different issue for it?
Interfaces as callbacks from C++ (overriding C++ virtual functions in bridged languages) are supported in the latest version of Scapix, currently for Python bridge only.
Support for other languages coming soon, stay tuned!
Added support for overriding C++ virtual functions in JavaScript bridge (now supported in Python and JavaScript bridges).
First for all: very interesting project! I was testing it for a new project but I need the ability to implement a C++ interface in the "client" languages. I could see from https://github.com/scapix-com/example1/blob/a0a0b5a27e4c68c1e2f6bb210901206ff378b213/source/chat/contact.h there is some traces of something along those lines (scapix::bridge::interface). What is the current status of this? Was it scratched or is it coming in the pipelines?