Hey guys

I have a question about whether we can use embind to invoke polymorphic 
functions on derived classes (when the derived class type definitions may 
not be known). For example, say I have a class Foo which derives from a 
pure virtual class IFoo. However, we don't publicly expose the class Foo, 
but rather expose a factory function that creates an IFoo pointer for you.

// Exposed publicly
class IFoo
{
public:
    IFoo() = default();
    virtual ~IFoo()=default();
    virtual void Bar() = 0;
};


// Not exposed publicly 
class Foo
{
public:
   Foo() = default();
   virtual ~Foo() = default();
   virtual void Bar() override;
};

// Exposed publicly 
std::shared_ptr<IFoo> MakeFoo()
{
    return std::shared_ptr<IFoo>(new Foo());
}


My question is; I want to create an emscripten binding so that non ASM JS 
code can invoke Bar on an IFoo pointer obtained via MakeFoo. Is that even 
possible with embind currently? The confusion I have is that embind needs 
to be told the code address of the function to be invoked. The only code 
address I could theoretically bind it to would be IFoo::Bar. But would we 
polymorphically transition to Foo::Bar (the way you would with normal C++) 
when invoking Bar on a JS object created with a call to Module.MakeFoo()?


Thanks in advance!
-Arnab


-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to