Re: Implicit casting issues when binding to C++

  • From: Mike Pall <mike-1207@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 11 Jul 2012 18:23:59 +0200

Janis Britals wrote:
> Mike Pall wrote:
> > You can manage such a conversion matrix as part of each base 
> > type and fill it in when creating the derived types.
> 
> It could be done the way you describe here, of course. Reason why I would
> like to do it in "C" is to avoid the extra metacall to VM and associated
> "trace_abort". The downcasting to base type happens way more often than
> conversions via implicit constructor calls, and it's practically
> unavoidable, whereas you always can call the implicit constructor explicitly
> to avoid the breaking of trace recording. And since the static_cast is
> really nothing more than a small delta added to the resulting pointer I
> think this warrants a special treatment in the conversion algorithm.

Oh well ... I can see the problem, but I don't like the solution.

I'd rather implement proper handling for derived classes (well,
structs in C parser mode) including the vtable issue. That would
also allow declaring and calling regular, static or virtual methods.
Automatic conversions to a base class (with pointer offsets) would
work, too. Multiple inheritance should be doable, but I hope you
don't need virtual base classes?

I'm tempted to invest a couple hours into this and see how far
I get. No promises -- I really don't know if this works out.

--Mike

Other related posts: