Skip to content

Inheritance problem with mixed C++ OCaml object model

Kakadu edited this page Jan 6, 2012 · 2 revisions

A problem arose, out of the kind that are somewhat hard to deal with. At the moment, it is not possible to inherit from some abstract Qt/C++ classes, due to pure virtual methods which aren't transportable easily to the OCaml runtime, which essentially forbids the use of such classes in OCaml and ruins the binding's transparency.

Exempli gratia, there is such an abstract class Foo that it contains a method with the following signature:

class Foo {
  void bar(QModelIndex&) = 0;
}

The problem lies in the absence of possibility to create a wrapping OCaml `twin' class around this C++ one, which is the approach used in the current version of lablQt (that is, a pointer to a C++ object is received from the C++ runtime, wrapped around with an OCaml class and juggled inside the OCaml runtime as needed), seeing as the compiler barfs at the twin class being abstract. I. e. we know of no way to transfer a value from the C++ stack to the OCaml runtime, this denies the possibility of inheriting such classes from OCaml ones.

Any helpful feedback on the problem is very much welcome.

Something went wrong with that request. Please try again.