This is more or less what i'm trying to achieve:

foo.h:
    
    
    struct Foo {
        virtual ~Foo() = default;
        
        virtual void bar() {}
    };
    
    inline void processFoos(Foo* foo)
    {
        foo->bar();
    }
    
    
    Run

test.nim:
    
    
    type
      Foo {.importcpp: "Foo", header: "<foo.h>", inheritable, pure.} = object
      Xyz = object of Foo
        bar: proc()
    
    proc processFoos(foo: ptr Foo) {.importcpp: "processFoos(@)".}
    
    proc main() =
      var xyz = Xyz()
      xyz.bar = proc() = echo "123"
      
      processFoos(addr(xyz))
    
    when isMainModule:
      main()
    
    
    Run

But as of today achieve something like this is not possible with current c++ 
codegen, at least i cannot think of a way to use the exportcpp pragma you 
mentioned.

Reply via email to